1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_VALUE_STORE_VALUE_STORE_UNITTEST_H_ 6 #define CHROME_BROWSER_VALUE_STORE_VALUE_STORE_UNITTEST_H_ 7 8 #include "testing/gtest/include/gtest/gtest.h" 9 10 #include "base/files/scoped_temp_dir.h" 11 #include "base/memory/ref_counted.h" 12 #include "base/memory/scoped_ptr.h" 13 #include "base/message_loop/message_loop.h" 14 #include "chrome/browser/value_store/value_store.h" 15 #include "chrome/test/base/testing_profile.h" 16 #include "content/public/test/test_browser_thread.h" 17 18 // Parameter type for the value-parameterized tests. 19 typedef ValueStore* (*ValueStoreTestParam)(const base::FilePath& file_path); 20 21 // Test fixture for ValueStore tests. Tests are defined in 22 // settings_storage_unittest.cc with configurations for both cached 23 // and non-cached leveldb storage, and cached no-op storage. 24 class ValueStoreTest : public testing::TestWithParam<ValueStoreTestParam> { 25 public: 26 ValueStoreTest(); 27 virtual ~ValueStoreTest(); 28 29 virtual void SetUp() OVERRIDE; 30 virtual void TearDown() OVERRIDE; 31 32 protected: 33 scoped_ptr<ValueStore> storage_; 34 35 std::string key1_; 36 std::string key2_; 37 std::string key3_; 38 39 scoped_ptr<Value> val1_; 40 scoped_ptr<Value> val2_; 41 scoped_ptr<Value> val3_; 42 43 std::vector<std::string> empty_list_; 44 std::vector<std::string> list1_; 45 std::vector<std::string> list2_; 46 std::vector<std::string> list3_; 47 std::vector<std::string> list12_; 48 std::vector<std::string> list13_; 49 std::vector<std::string> list123_; 50 51 std::set<std::string> empty_set_; 52 std::set<std::string> set1_; 53 std::set<std::string> set2_; 54 std::set<std::string> set3_; 55 std::set<std::string> set12_; 56 std::set<std::string> set13_; 57 std::set<std::string> set123_; 58 59 scoped_ptr<DictionaryValue> empty_dict_; 60 scoped_ptr<DictionaryValue> dict1_; 61 scoped_ptr<DictionaryValue> dict3_; 62 scoped_ptr<DictionaryValue> dict12_; 63 scoped_ptr<DictionaryValue> dict123_; 64 65 private: 66 base::ScopedTempDir temp_dir_; 67 68 // Need these so that the DCHECKs for running on FILE or UI threads pass. 69 base::MessageLoop message_loop_; 70 content::TestBrowserThread ui_thread_; 71 content::TestBrowserThread file_thread_; 72 }; 73 74 #endif // CHROME_BROWSER_VALUE_STORE_VALUE_STORE_UNITTEST_H_ 75