| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "extensions/common/event_filter.h" | 9 #include "extensions/common/event_filter.h" |
| 10 #include "extensions/common/event_filtering_info.h" | 10 #include "extensions/common/event_filtering_info.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 EventFilterUnittest() { | 23 EventFilterUnittest() { |
| 24 google_event_.SetURL(GURL("http://google.com")); | 24 google_event_.SetURL(GURL("http://google.com")); |
| 25 yahoo_event_.SetURL(GURL("http://yahoo.com")); | 25 yahoo_event_.SetURL(GURL("http://yahoo.com")); |
| 26 random_url_event_.SetURL(GURL("http://www.something-else.com")); | 26 random_url_event_.SetURL(GURL("http://www.something-else.com")); |
| 27 empty_url_event_.SetURL(GURL()); | 27 empty_url_event_.SetURL(GURL()); |
| 28 } | 28 } |
| 29 | 29 |
| 30 protected: | 30 protected: |
| 31 scoped_ptr<base::Value> HostSuffixDict(const std::string& host_suffix) { | 31 scoped_ptr<base::Value> HostSuffixDict(const std::string& host_suffix) { |
| 32 scoped_ptr<base::DictionaryValue> dict(new DictionaryValue()); | 32 scoped_ptr<base::DictionaryValue> dict(new DictionaryValue()); |
| 33 dict->Set("hostSuffix", base::Value::CreateStringValue(host_suffix)); | 33 dict->Set("hostSuffix", new base::StringValue(host_suffix)); |
| 34 return scoped_ptr<base::Value>(dict.release()); | 34 return scoped_ptr<base::Value>(dict.release()); |
| 35 } | 35 } |
| 36 | 36 |
| 37 scoped_ptr<base::ListValue> ValueAsList(scoped_ptr<base::Value> value) { | 37 scoped_ptr<base::ListValue> ValueAsList(scoped_ptr<base::Value> value) { |
| 38 scoped_ptr<base::ListValue> result(new base::ListValue()); | 38 scoped_ptr<base::ListValue> result(new base::ListValue()); |
| 39 result->Append(value.release()); | 39 result->Append(value.release()); |
| 40 return result.Pass(); | 40 return result.Pass(); |
| 41 } | 41 } |
| 42 | 42 |
| 43 scoped_ptr<EventMatcher> AllURLs() { | 43 scoped_ptr<EventMatcher> AllURLs() { |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 scoped_ptr<EventMatcher> matcher(MatcherFromURLFilterList(ValueAsList( | 250 scoped_ptr<EventMatcher> matcher(MatcherFromURLFilterList(ValueAsList( |
| 251 scoped_ptr<Value>(new DictionaryValue())))); | 251 scoped_ptr<Value>(new DictionaryValue())))); |
| 252 int id = event_filter_.AddEventMatcher("event1", matcher.Pass()); | 252 int id = event_filter_.AddEventMatcher("event1", matcher.Pass()); |
| 253 std::set<int> matches = event_filter_.MatchEvent( | 253 std::set<int> matches = event_filter_.MatchEvent( |
| 254 "event1", empty_url_event_, MSG_ROUTING_NONE); | 254 "event1", empty_url_event_, MSG_ROUTING_NONE); |
| 255 ASSERT_EQ(1u, matches.size()); | 255 ASSERT_EQ(1u, matches.size()); |
| 256 ASSERT_EQ(1u, matches.count(id)); | 256 ASSERT_EQ(1u, matches.count(id)); |
| 257 } | 257 } |
| 258 | 258 |
| 259 } // namespace extensions | 259 } // namespace extensions |
| OLD | NEW |