OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/event_listener_map.h" | 5 #include "extensions/browser/event_listener_map.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
11 #include "content/public/test/mock_render_process_host.h" | 11 #include "content/public/test/mock_render_process_host.h" |
12 #include "content/public/test/test_browser_context.h" | 12 #include "content/public/test/test_browser_context.h" |
13 #include "extensions/browser/event_router.h" | 13 #include "extensions/browser/event_router.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 #include "url/gurl.h" | 15 #include "url/gurl.h" |
16 | 16 |
17 using base::DictionaryValue; | 17 using base::DictionaryValue; |
18 using base::ListValue; | 18 using base::ListValue; |
19 using base::StringValue; | 19 using base::Value; |
20 | 20 |
21 namespace extensions { | 21 namespace extensions { |
22 | 22 |
23 namespace { | 23 namespace { |
24 | 24 |
25 const char kExt1Id[] = "extension_1"; | 25 const char kExt1Id[] = "extension_1"; |
26 const char kExt2Id[] = "extension_2"; | 26 const char kExt2Id[] = "extension_2"; |
27 const char kEvent1Name[] = "event1"; | 27 const char kEvent1Name[] = "event1"; |
28 const char kEvent2Name[] = "event2"; | 28 const char kEvent2Name[] = "event2"; |
29 const char kURL[] = "https://google.com/some/url"; | 29 const char kURL[] = "https://google.com/some/url"; |
(...skipping 17 matching lines...) Expand all Loading... |
47 listeners_(new EventListenerMap(delegate_.get())), | 47 listeners_(new EventListenerMap(delegate_.get())), |
48 browser_context_(new content::TestBrowserContext), | 48 browser_context_(new content::TestBrowserContext), |
49 process_(new content::MockRenderProcessHost(browser_context_.get())) {} | 49 process_(new content::MockRenderProcessHost(browser_context_.get())) {} |
50 | 50 |
51 std::unique_ptr<DictionaryValue> CreateHostSuffixFilter( | 51 std::unique_ptr<DictionaryValue> CreateHostSuffixFilter( |
52 const std::string& suffix) { | 52 const std::string& suffix) { |
53 std::unique_ptr<DictionaryValue> filter(new DictionaryValue); | 53 std::unique_ptr<DictionaryValue> filter(new DictionaryValue); |
54 std::unique_ptr<ListValue> filter_list(new ListValue); | 54 std::unique_ptr<ListValue> filter_list(new ListValue); |
55 std::unique_ptr<DictionaryValue> filter_dict(new DictionaryValue); | 55 std::unique_ptr<DictionaryValue> filter_dict(new DictionaryValue); |
56 | 56 |
57 filter_dict->Set("hostSuffix", new StringValue(suffix)); | 57 filter_dict->Set("hostSuffix", new Value(suffix)); |
58 | 58 |
59 filter_list->Append(std::move(filter_dict)); | 59 filter_list->Append(std::move(filter_dict)); |
60 filter->Set("url", filter_list.release()); | 60 filter->Set("url", filter_list.release()); |
61 return filter; | 61 return filter; |
62 } | 62 } |
63 | 63 |
64 std::unique_ptr<Event> CreateNamedEvent(const std::string& event_name) { | 64 std::unique_ptr<Event> CreateNamedEvent(const std::string& event_name) { |
65 return CreateEvent(event_name, GURL()); | 65 return CreateEvent(event_name, GURL()); |
66 } | 66 } |
67 | 67 |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 | 388 |
389 std::unique_ptr<Event> event( | 389 std::unique_ptr<Event> event( |
390 CreateEvent(kEvent1Name, GURL("http://www.google.com"))); | 390 CreateEvent(kEvent1Name, GURL("http://www.google.com"))); |
391 std::set<const EventListener*> targets(listeners_->GetEventListeners(*event)); | 391 std::set<const EventListener*> targets(listeners_->GetEventListeners(*event)); |
392 ASSERT_EQ(0u, targets.size()); | 392 ASSERT_EQ(0u, targets.size()); |
393 } | 393 } |
394 | 394 |
395 } // namespace | 395 } // namespace |
396 | 396 |
397 } // namespace extensions | 397 } // namespace extensions |
OLD | NEW |