Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(309)

Side by Side Diff: extensions/browser/value_store/value_store_unittest.cc

Issue 2294653002: Some linked_ptr -> unique_ptr conversion in extensions/browser. (Closed)
Patch Set: address comments Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « extensions/browser/updater/request_queue.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 (const ValueStoreChange& change : expected)
93 it != expected.end(); ++it) { 93 expected_as_map[change.key()] = base::MakeUnique<ValueStoreChange>(change);
94 expected_as_map[it->key()] =
95 linked_ptr<ValueStoreChange>(new ValueStoreChange(*it));
96 }
97 94
98 std::set<std::string> keys_seen; 95 std::set<std::string> keys_seen;
99 96
100 for (ValueStoreChangeList::const_iterator it = actual.begin(); 97 for (ValueStoreChangeList::const_iterator it = actual.begin();
101 it != actual.end(); ++it) { 98 it != actual.end(); ++it) {
102 if (keys_seen.count(it->key())) { 99 if (keys_seen.count(it->key())) {
103 return testing::AssertionFailure() << 100 return testing::AssertionFailure() <<
104 "Multiple changes seen for key: " << it->key(); 101 "Multiple changes seen for key: " << it->key();
105 } 102 }
106 keys_seen.insert(it->key()); 103 keys_seen.insert(it->key());
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 { 491 {
495 ValueStoreChangeList changes; 492 ValueStoreChangeList changes;
496 changes.push_back( 493 changes.push_back(
497 ValueStoreChange(key3_, val3_->CreateDeepCopy(), nullptr)); 494 ValueStoreChange(key3_, val3_->CreateDeepCopy(), nullptr));
498 changes.push_back( 495 changes.push_back(
499 ValueStoreChange("qwerty", val3_->CreateDeepCopy(), nullptr)); 496 ValueStoreChange("qwerty", val3_->CreateDeepCopy(), nullptr));
500 EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Clear()); 497 EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Clear());
501 EXPECT_PRED_FORMAT2(ChangesEq, ValueStoreChangeList(), storage_->Clear()); 498 EXPECT_PRED_FORMAT2(ChangesEq, ValueStoreChangeList(), storage_->Clear());
502 } 499 }
503 } 500 }
OLDNEW
« no previous file with comments | « extensions/browser/updater/request_queue.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698