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

Side by Side Diff: extensions/common/event_filter_unittest.cc

Issue 2899743002: Remove raw base::DictionaryValue::Set in //extensions (Closed)
Patch Set: Addressed nit Created 3 years, 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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/common/event_filter.h" 5 #include "extensions/common/event_filter.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 14 matching lines...) Expand all
25 public: 25 public:
26 EventFilterUnittest() { 26 EventFilterUnittest() {
27 google_event_.SetURL(GURL("http://google.com")); 27 google_event_.SetURL(GURL("http://google.com"));
28 yahoo_event_.SetURL(GURL("http://yahoo.com")); 28 yahoo_event_.SetURL(GURL("http://yahoo.com"));
29 random_url_event_.SetURL(GURL("http://www.something-else.com")); 29 random_url_event_.SetURL(GURL("http://www.something-else.com"));
30 empty_url_event_.SetURL(GURL()); 30 empty_url_event_.SetURL(GURL());
31 } 31 }
32 32
33 protected: 33 protected:
34 std::unique_ptr<base::Value> HostSuffixDict(const std::string& host_suffix) { 34 std::unique_ptr<base::Value> HostSuffixDict(const std::string& host_suffix) {
35 std::unique_ptr<base::DictionaryValue> dict(new DictionaryValue()); 35 auto dict = base::MakeUnique<DictionaryValue>();
36 dict->Set("hostSuffix", new base::Value(host_suffix)); 36 dict->SetString("hostSuffix", host_suffix);
37 return std::unique_ptr<base::Value>(dict.release()); 37 return std::move(dict);
38 } 38 }
39 39
40 std::unique_ptr<base::ListValue> ValueAsList( 40 std::unique_ptr<base::ListValue> ValueAsList(
41 std::unique_ptr<base::Value> value) { 41 std::unique_ptr<base::Value> value) {
42 std::unique_ptr<base::ListValue> result(new base::ListValue()); 42 auto result = base::MakeUnique<base::ListValue>();
43 result->Append(std::move(value)); 43 result->Append(std::move(value));
44 return result; 44 return result;
45 } 45 }
46 46
47 std::unique_ptr<EventMatcher> AllURLs() { 47 std::unique_ptr<EventMatcher> AllURLs() {
48 return std::unique_ptr<EventMatcher>( 48 return base::MakeUnique<EventMatcher>(
49 new EventMatcher(std::unique_ptr<DictionaryValue>(new DictionaryValue), 49 base::MakeUnique<base::DictionaryValue>(), MSG_ROUTING_NONE);
50 MSG_ROUTING_NONE));
51 } 50 }
52 51
53 std::unique_ptr<EventMatcher> HostSuffixMatcher( 52 std::unique_ptr<EventMatcher> HostSuffixMatcher(
54 const std::string& host_suffix) { 53 const std::string& host_suffix) {
55 return MatcherFromURLFilterList(ValueAsList(HostSuffixDict(host_suffix))); 54 return MatcherFromURLFilterList(ValueAsList(HostSuffixDict(host_suffix)));
56 } 55 }
57 56
58 std::unique_ptr<EventMatcher> MatcherFromURLFilterList( 57 std::unique_ptr<EventMatcher> MatcherFromURLFilterList(
59 std::unique_ptr<ListValue> url_filter_list) { 58 std::unique_ptr<ListValue> url_filter_list) {
60 std::unique_ptr<DictionaryValue> filter_dict(new DictionaryValue); 59 auto filter_dict = base::MakeUnique<DictionaryValue>();
61 filter_dict->Set("url", url_filter_list.release()); 60 filter_dict->Set("url", std::move(url_filter_list));
62 return std::unique_ptr<EventMatcher>( 61 return std::unique_ptr<EventMatcher>(
63 new EventMatcher(std::move(filter_dict), MSG_ROUTING_NONE)); 62 new EventMatcher(std::move(filter_dict), MSG_ROUTING_NONE));
64 } 63 }
65 64
66 EventFilter event_filter_; 65 EventFilter event_filter_;
67 EventFilteringInfo empty_event_; 66 EventFilteringInfo empty_event_;
68 EventFilteringInfo google_event_; 67 EventFilteringInfo google_event_;
69 EventFilteringInfo yahoo_event_; 68 EventFilteringInfo yahoo_event_;
70 EventFilteringInfo random_url_event_; 69 EventFilteringInfo random_url_event_;
71 EventFilteringInfo empty_url_event_; 70 EventFilteringInfo empty_url_event_;
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 std::unique_ptr<EventMatcher> matcher(MatcherFromURLFilterList( 257 std::unique_ptr<EventMatcher> matcher(MatcherFromURLFilterList(
259 ValueAsList(std::unique_ptr<Value>(new DictionaryValue())))); 258 ValueAsList(std::unique_ptr<Value>(new DictionaryValue()))));
260 int id = event_filter_.AddEventMatcher("event1", std::move(matcher)); 259 int id = event_filter_.AddEventMatcher("event1", std::move(matcher));
261 std::set<int> matches = event_filter_.MatchEvent( 260 std::set<int> matches = event_filter_.MatchEvent(
262 "event1", empty_url_event_, MSG_ROUTING_NONE); 261 "event1", empty_url_event_, MSG_ROUTING_NONE);
263 ASSERT_EQ(1u, matches.size()); 262 ASSERT_EQ(1u, matches.size());
264 ASSERT_EQ(1u, matches.count(id)); 263 ASSERT_EQ(1u, matches.count(id));
265 } 264 }
266 265
267 } // namespace extensions 266 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/value_store/value_store_change.cc ('k') | extensions/common/extension_l10n_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698