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