OLD | NEW |
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 15 matching lines...) Expand all Loading... |
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 std::unique_ptr<base::DictionaryValue> dict(new DictionaryValue()); |
36 dict->Set("hostSuffix", new base::StringValue(host_suffix)); | 36 dict->Set("hostSuffix", new base::Value(host_suffix)); |
37 return std::unique_ptr<base::Value>(dict.release()); | 37 return std::unique_ptr<base::Value>(dict.release()); |
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 std::unique_ptr<base::ListValue> result(new base::ListValue()); |
43 result->Append(std::move(value)); | 43 result->Append(std::move(value)); |
44 return result; | 44 return result; |
45 } | 45 } |
46 | 46 |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 std::unique_ptr<EventMatcher> matcher(MatcherFromURLFilterList( | 258 std::unique_ptr<EventMatcher> matcher(MatcherFromURLFilterList( |
259 ValueAsList(std::unique_ptr<Value>(new DictionaryValue())))); | 259 ValueAsList(std::unique_ptr<Value>(new DictionaryValue())))); |
260 int id = event_filter_.AddEventMatcher("event1", std::move(matcher)); | 260 int id = event_filter_.AddEventMatcher("event1", std::move(matcher)); |
261 std::set<int> matches = event_filter_.MatchEvent( | 261 std::set<int> matches = event_filter_.MatchEvent( |
262 "event1", empty_url_event_, MSG_ROUTING_NONE); | 262 "event1", empty_url_event_, MSG_ROUTING_NONE); |
263 ASSERT_EQ(1u, matches.size()); | 263 ASSERT_EQ(1u, matches.size()); |
264 ASSERT_EQ(1u, matches.count(id)); | 264 ASSERT_EQ(1u, matches.count(id)); |
265 } | 265 } |
266 | 266 |
267 } // namespace extensions | 267 } // namespace extensions |
OLD | NEW |