| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chrome/browser/extensions/api/mdns/mdns_api.h" | 5 #include "chrome/browser/extensions/api/mdns/mdns_api.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 MOCK_CONST_METHOD2(IsMDnsAllowed, | 66 MOCK_CONST_METHOD2(IsMDnsAllowed, |
| 67 bool(const std::string& extension_id, | 67 bool(const std::string& extension_id, |
| 68 const std::string& service_type)); | 68 const std::string& service_type)); |
| 69 | 69 |
| 70 MOCK_METHOD0(GetEventListeners, | 70 MOCK_METHOD0(GetEventListeners, |
| 71 const extensions::EventListenerMap::ListenerList&()); | 71 const extensions::EventListenerMap::ListenerList&()); |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 std::unique_ptr<KeyedService> MockedMDnsAPITestingFactoryFunction( | 74 std::unique_ptr<KeyedService> MockedMDnsAPITestingFactoryFunction( |
| 75 content::BrowserContext* context) { | 75 content::BrowserContext* context) { |
| 76 return base::WrapUnique(new MockedMDnsAPI(context)); | 76 return base::MakeUnique<MockedMDnsAPI>(context); |
| 77 } | 77 } |
| 78 | 78 |
| 79 std::unique_ptr<KeyedService> MDnsAPITestingFactoryFunction( | 79 std::unique_ptr<KeyedService> MDnsAPITestingFactoryFunction( |
| 80 content::BrowserContext* context) { | 80 content::BrowserContext* context) { |
| 81 return base::WrapUnique(new MDnsAPI(context)); | 81 return base::MakeUnique<MDnsAPI>(context); |
| 82 } | 82 } |
| 83 | 83 |
| 84 std::unique_ptr<KeyedService> BuildEventRouter( | 84 std::unique_ptr<KeyedService> BuildEventRouter( |
| 85 content::BrowserContext* context) { | 85 content::BrowserContext* context) { |
| 86 return base::WrapUnique( | 86 return base::MakeUnique<extensions::EventRouter>( |
| 87 new extensions::EventRouter(context, ExtensionPrefs::Get(context))); | 87 context, ExtensionPrefs::Get(context)); |
| 88 } | 88 } |
| 89 | 89 |
| 90 // For ExtensionService interface when it requires a path that is not used. | 90 // For ExtensionService interface when it requires a path that is not used. |
| 91 base::FilePath bogus_file_pathname(const std::string& name) { | 91 base::FilePath bogus_file_pathname(const std::string& name) { |
| 92 return base::FilePath(FILE_PATH_LITERAL("//foobar_nonexistent")) | 92 return base::FilePath(FILE_PATH_LITERAL("//foobar_nonexistent")) |
| 93 .AppendASCII(name); | 93 .AppendASCII(name); |
| 94 } | 94 } |
| 95 | 95 |
| 96 class MockDnsSdRegistry : public DnsSdRegistry { | 96 class MockDnsSdRegistry : public DnsSdRegistry { |
| 97 public: | 97 public: |
| (...skipping 24 matching lines...) Expand all Loading... |
| 122 virtual ~MockEventRouter() {} | 122 virtual ~MockEventRouter() {} |
| 123 | 123 |
| 124 virtual void BroadcastEvent(std::unique_ptr<Event> event) { | 124 virtual void BroadcastEvent(std::unique_ptr<Event> event) { |
| 125 BroadcastEventPtr(event.get()); | 125 BroadcastEventPtr(event.get()); |
| 126 } | 126 } |
| 127 MOCK_METHOD1(BroadcastEventPtr, void(Event* event)); | 127 MOCK_METHOD1(BroadcastEventPtr, void(Event* event)); |
| 128 }; | 128 }; |
| 129 | 129 |
| 130 std::unique_ptr<KeyedService> MockEventRouterFactoryFunction( | 130 std::unique_ptr<KeyedService> MockEventRouterFactoryFunction( |
| 131 content::BrowserContext* context) { | 131 content::BrowserContext* context) { |
| 132 return base::WrapUnique( | 132 return base::MakeUnique<MockEventRouter>(context, |
| 133 new MockEventRouter(context, ExtensionPrefs::Get(context))); | 133 ExtensionPrefs::Get(context)); |
| 134 } | 134 } |
| 135 | 135 |
| 136 class EventServiceListSizeMatcher | 136 class EventServiceListSizeMatcher |
| 137 : public testing::MatcherInterface<const Event&> { | 137 : public testing::MatcherInterface<const Event&> { |
| 138 public: | 138 public: |
| 139 explicit EventServiceListSizeMatcher(size_t expected_size) | 139 explicit EventServiceListSizeMatcher(size_t expected_size) |
| 140 : expected_size_(expected_size) {} | 140 : expected_size_(expected_size) {} |
| 141 | 141 |
| 142 virtual bool MatchAndExplain(const Event& e, | 142 virtual bool MatchAndExplain(const Event& e, |
| 143 testing::MatchResultListener* listener) const { | 143 testing::MatchResultListener* listener) const { |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 render_process_host(), kExtId, filter, false); | 439 render_process_host(), kExtId, filter, false); |
| 440 | 440 |
| 441 EXPECT_CALL(*dns_sd_registry(), UnregisterDnsSdListener("_trex._tcp.local")); | 441 EXPECT_CALL(*dns_sd_registry(), UnregisterDnsSdListener("_trex._tcp.local")); |
| 442 EventRouter::Get(browser_context()) | 442 EventRouter::Get(browser_context()) |
| 443 ->RemoveFilteredEventListener(api::mdns::OnServiceList::kEventName, | 443 ->RemoveFilteredEventListener(api::mdns::OnServiceList::kEventName, |
| 444 render_process_host(), kExtId, filter, | 444 render_process_host(), kExtId, filter, |
| 445 false); | 445 false); |
| 446 } | 446 } |
| 447 | 447 |
| 448 } // namespace extensions | 448 } // namespace extensions |
| OLD | NEW |