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/linked_ptr.h" | 10 #include "base/memory/ptr_util.h" |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 | 12 |
13 using content::BrowserThread; | 13 using content::BrowserThread; |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 // To save typing ValueStore::DEFAULTS everywhere. | 17 // To save typing ValueStore::DEFAULTS everywhere. |
18 const ValueStore::WriteOptions DEFAULTS = ValueStore::DEFAULTS; | 18 const ValueStore::WriteOptions DEFAULTS = ValueStore::DEFAULTS; |
19 | 19 |
20 // Gets the pretty-printed JSON for a value. | 20 // Gets the pretty-printed JSON for a value. |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
81 << actual_result->status().message; | 81 << actual_result->status().message; |
82 } | 82 } |
83 | 83 |
84 const ValueStoreChangeList& actual = actual_result->changes(); | 84 const ValueStoreChangeList& actual = actual_result->changes(); |
85 if (expected.size() != actual.size()) { | 85 if (expected.size() != actual.size()) { |
86 return testing::AssertionFailure() << | 86 return testing::AssertionFailure() << |
87 "Actual has wrong size, expecting " << expected.size() << | 87 "Actual has wrong size, expecting " << expected.size() << |
88 " but was " << actual.size(); | 88 " but was " << actual.size(); |
89 } | 89 } |
90 | 90 |
91 std::map<std::string, linked_ptr<ValueStoreChange> > expected_as_map; | 91 std::map<std::string, std::unique_ptr<ValueStoreChange>> expected_as_map; |
92 for (ValueStoreChangeList::const_iterator it = expected.begin(); | 92 for (ValueStoreChangeList::const_iterator it = expected.begin(); |
93 it != expected.end(); ++it) { | 93 it != expected.end(); ++it) { |
94 expected_as_map[it->key()] = | 94 std::unique_ptr<ValueStoreChange> change(new ValueStoreChange(*it)); |
95 linked_ptr<ValueStoreChange>(new ValueStoreChange(*it)); | 95 expected_as_map[it->key()] = std::move(change); |
Devlin
2016/08/30 19:21:54
base::MakeUnique
lazyboy
2016/08/30 20:30:56
Done.
| |
96 } | 96 } |
97 | 97 |
98 std::set<std::string> keys_seen; | 98 std::set<std::string> keys_seen; |
99 | 99 |
100 for (ValueStoreChangeList::const_iterator it = actual.begin(); | 100 for (ValueStoreChangeList::const_iterator it = actual.begin(); |
101 it != actual.end(); ++it) { | 101 it != actual.end(); ++it) { |
102 if (keys_seen.count(it->key())) { | 102 if (keys_seen.count(it->key())) { |
103 return testing::AssertionFailure() << | 103 return testing::AssertionFailure() << |
104 "Multiple changes seen for key: " << it->key(); | 104 "Multiple changes seen for key: " << it->key(); |
105 } | 105 } |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
494 { | 494 { |
495 ValueStoreChangeList changes; | 495 ValueStoreChangeList changes; |
496 changes.push_back( | 496 changes.push_back( |
497 ValueStoreChange(key3_, val3_->CreateDeepCopy(), nullptr)); | 497 ValueStoreChange(key3_, val3_->CreateDeepCopy(), nullptr)); |
498 changes.push_back( | 498 changes.push_back( |
499 ValueStoreChange("qwerty", val3_->CreateDeepCopy(), nullptr)); | 499 ValueStoreChange("qwerty", val3_->CreateDeepCopy(), nullptr)); |
500 EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Clear()); | 500 EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Clear()); |
501 EXPECT_PRED_FORMAT2(ChangesEq, ValueStoreChangeList(), storage_->Clear()); | 501 EXPECT_PRED_FORMAT2(ChangesEq, ValueStoreChangeList(), storage_->Clear()); |
502 } | 502 } |
503 } | 503 } |
OLD | NEW |