OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "extensions/browser/value_store/value_store_unittest.h" | 5 #include "extensions/browser/value_store/value_store_unittest.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 : key1_("foo"), | 126 : key1_("foo"), |
127 key2_("bar"), | 127 key2_("bar"), |
128 key3_("baz"), | 128 key3_("baz"), |
129 empty_dict_(new base::DictionaryValue()), | 129 empty_dict_(new base::DictionaryValue()), |
130 dict1_(new base::DictionaryValue()), | 130 dict1_(new base::DictionaryValue()), |
131 dict3_(new base::DictionaryValue()), | 131 dict3_(new base::DictionaryValue()), |
132 dict12_(new base::DictionaryValue()), | 132 dict12_(new base::DictionaryValue()), |
133 dict123_(new base::DictionaryValue()), | 133 dict123_(new base::DictionaryValue()), |
134 ui_thread_(BrowserThread::UI, base::MessageLoop::current()), | 134 ui_thread_(BrowserThread::UI, base::MessageLoop::current()), |
135 file_thread_(BrowserThread::FILE, base::MessageLoop::current()) { | 135 file_thread_(BrowserThread::FILE, base::MessageLoop::current()) { |
136 val1_.reset(new base::StringValue(key1_ + "Value")); | 136 val1_.reset(new base::Value(key1_ + "Value")); |
137 val2_.reset(new base::StringValue(key2_ + "Value")); | 137 val2_.reset(new base::Value(key2_ + "Value")); |
138 val3_.reset(new base::StringValue(key3_ + "Value")); | 138 val3_.reset(new base::Value(key3_ + "Value")); |
139 | 139 |
140 list1_.push_back(key1_); | 140 list1_.push_back(key1_); |
141 list2_.push_back(key2_); | 141 list2_.push_back(key2_); |
142 list3_.push_back(key3_); | 142 list3_.push_back(key3_); |
143 list12_.push_back(key1_); | 143 list12_.push_back(key1_); |
144 list12_.push_back(key2_); | 144 list12_.push_back(key2_); |
145 list13_.push_back(key1_); | 145 list13_.push_back(key1_); |
146 list13_.push_back(key3_); | 146 list13_.push_back(key3_); |
147 list123_.push_back(key1_); | 147 list123_.push_back(key1_); |
148 list123_.push_back(key2_); | 148 list123_.push_back(key2_); |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 EXPECT_PRED_FORMAT2(SettingsEq, *empty_dict_, storage_->Get(key1_)); | 323 EXPECT_PRED_FORMAT2(SettingsEq, *empty_dict_, storage_->Get(key1_)); |
324 EXPECT_PRED_FORMAT2(SettingsEq, *empty_dict_, storage_->Get(empty_list_)); | 324 EXPECT_PRED_FORMAT2(SettingsEq, *empty_dict_, storage_->Get(empty_list_)); |
325 EXPECT_PRED_FORMAT2(SettingsEq, *empty_dict_, storage_->Get(list123_)); | 325 EXPECT_PRED_FORMAT2(SettingsEq, *empty_dict_, storage_->Get(list123_)); |
326 EXPECT_PRED_FORMAT2(SettingsEq, *empty_dict_, storage_->Get()); | 326 EXPECT_PRED_FORMAT2(SettingsEq, *empty_dict_, storage_->Get()); |
327 } | 327 } |
328 | 328 |
329 // Dots should be allowed in key names; they shouldn't be interpreted as | 329 // Dots should be allowed in key names; they shouldn't be interpreted as |
330 // indexing into a dictionary. | 330 // indexing into a dictionary. |
331 TEST_P(ValueStoreTest, DotsInKeyNames) { | 331 TEST_P(ValueStoreTest, DotsInKeyNames) { |
332 std::string dot_key("foo.bar"); | 332 std::string dot_key("foo.bar"); |
333 base::StringValue dot_value("baz.qux"); | 333 base::Value dot_value("baz.qux"); |
334 std::vector<std::string> dot_list; | 334 std::vector<std::string> dot_list; |
335 dot_list.push_back(dot_key); | 335 dot_list.push_back(dot_key); |
336 base::DictionaryValue dot_dict; | 336 base::DictionaryValue dot_dict; |
337 dot_dict.SetWithoutPathExpansion(dot_key, dot_value.CreateDeepCopy()); | 337 dot_dict.SetWithoutPathExpansion(dot_key, dot_value.CreateDeepCopy()); |
338 | 338 |
339 EXPECT_PRED_FORMAT2(SettingsEq, *empty_dict_, storage_->Get(dot_key)); | 339 EXPECT_PRED_FORMAT2(SettingsEq, *empty_dict_, storage_->Get(dot_key)); |
340 | 340 |
341 { | 341 { |
342 ValueStoreChangeList changes; | 342 ValueStoreChangeList changes; |
343 changes.push_back( | 343 changes.push_back( |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 { | 491 { |
492 ValueStoreChangeList changes; | 492 ValueStoreChangeList changes; |
493 changes.push_back( | 493 changes.push_back( |
494 ValueStoreChange(key3_, val3_->CreateDeepCopy(), nullptr)); | 494 ValueStoreChange(key3_, val3_->CreateDeepCopy(), nullptr)); |
495 changes.push_back( | 495 changes.push_back( |
496 ValueStoreChange("qwerty", val3_->CreateDeepCopy(), nullptr)); | 496 ValueStoreChange("qwerty", val3_->CreateDeepCopy(), nullptr)); |
497 EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Clear()); | 497 EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Clear()); |
498 EXPECT_PRED_FORMAT2(ChangesEq, ValueStoreChangeList(), storage_->Clear()); | 498 EXPECT_PRED_FORMAT2(ChangesEq, ValueStoreChangeList(), storage_->Clear()); |
499 } | 499 } |
500 } | 500 } |
OLD | NEW |