| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "chrome/browser/extensions/api/mdns/mdns_api.h" | 6 #include "chrome/browser/extensions/api/mdns/mdns_api.h" |
| 7 #include "chrome/browser/extensions/extension_apitest.h" | 7 #include "chrome/browser/extensions/extension_apitest.h" |
| 8 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
| 9 #include "chrome/common/extensions/api/mdns.h" | 9 #include "chrome/common/extensions/api/mdns.h" |
| 10 #include "extensions/common/switches.h" | 10 #include "extensions/common/switches.h" |
| 11 #include "extensions/test/result_catcher.h" |
| 11 #include "testing/gmock/include/gmock/gmock.h" | 12 #include "testing/gmock/include/gmock/gmock.h" |
| 12 | 13 |
| 13 using extensions::DnsSdRegistry; | 14 using extensions::DnsSdRegistry; |
| 14 using ::testing::A; | 15 using ::testing::A; |
| 15 using ::testing::_; | 16 using ::testing::_; |
| 16 | 17 |
| 17 namespace api = extensions::api; | 18 namespace api = extensions::api; |
| 18 | 19 |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 .Times(1); | 79 .Times(1); |
| 79 EXPECT_CALL(*dns_sd_registry_, UnregisterDnsSdListener(service_type)) | 80 EXPECT_CALL(*dns_sd_registry_, UnregisterDnsSdListener(service_type)) |
| 80 .Times(1); | 81 .Times(1); |
| 81 EXPECT_CALL(*dns_sd_registry_, | 82 EXPECT_CALL(*dns_sd_registry_, |
| 82 RemoveObserver(A<extensions::DnsSdRegistry::DnsSdObserver*>())) | 83 RemoveObserver(A<extensions::DnsSdRegistry::DnsSdObserver*>())) |
| 83 .Times(1); | 84 .Times(1); |
| 84 | 85 |
| 85 EXPECT_TRUE(RunExtensionSubtest("mdns/api", "register_listener.html")) | 86 EXPECT_TRUE(RunExtensionSubtest("mdns/api", "register_listener.html")) |
| 86 << message_; | 87 << message_; |
| 87 | 88 |
| 88 ResultCatcher catcher; | 89 extensions::ResultCatcher catcher; |
| 89 // Dispatch 3 events, one of which should not be sent to the test extension. | 90 // Dispatch 3 events, one of which should not be sent to the test extension. |
| 90 DnsSdRegistry::DnsSdServiceList services; | 91 DnsSdRegistry::DnsSdServiceList services; |
| 91 | 92 |
| 92 extensions::DnsSdService service; | 93 extensions::DnsSdService service; |
| 93 service.service_name = service_type; | 94 service.service_name = service_type; |
| 94 services.push_back(service); | 95 services.push_back(service); |
| 95 | 96 |
| 96 dns_sd_registry_->DispatchMDnsEvent(service_type, services); | 97 dns_sd_registry_->DispatchMDnsEvent(service_type, services); |
| 97 dns_sd_registry_->DispatchMDnsEvent("_uninteresting._tcp.local", services); | 98 dns_sd_registry_->DispatchMDnsEvent("_uninteresting._tcp.local", services); |
| 98 dns_sd_registry_->DispatchMDnsEvent(service_type, services); | 99 dns_sd_registry_->DispatchMDnsEvent(service_type, services); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 121 EXPECT_CALL(*dns_sd_registry_, UnregisterDnsSdListener(test_service_type)) | 122 EXPECT_CALL(*dns_sd_registry_, UnregisterDnsSdListener(test_service_type)) |
| 122 .Times(1); | 123 .Times(1); |
| 123 EXPECT_CALL(*dns_sd_registry_, | 124 EXPECT_CALL(*dns_sd_registry_, |
| 124 RemoveObserver(A<extensions::DnsSdRegistry::DnsSdObserver*>())) | 125 RemoveObserver(A<extensions::DnsSdRegistry::DnsSdObserver*>())) |
| 125 .Times(1); | 126 .Times(1); |
| 126 | 127 |
| 127 EXPECT_TRUE(RunExtensionSubtest("mdns/api", | 128 EXPECT_TRUE(RunExtensionSubtest("mdns/api", |
| 128 "register_multiple_listeners.html")) | 129 "register_multiple_listeners.html")) |
| 129 << message_; | 130 << message_; |
| 130 | 131 |
| 131 ResultCatcher catcher; | 132 extensions::ResultCatcher catcher; |
| 132 DnsSdRegistry::DnsSdServiceList services; | 133 DnsSdRegistry::DnsSdServiceList services; |
| 133 | 134 |
| 134 extensions::DnsSdService service; | 135 extensions::DnsSdService service; |
| 135 service.service_name = service_type; | 136 service.service_name = service_type; |
| 136 services.push_back(service); | 137 services.push_back(service); |
| 137 | 138 |
| 138 dns_sd_registry_->DispatchMDnsEvent(service_type, services); | 139 dns_sd_registry_->DispatchMDnsEvent(service_type, services); |
| 139 dns_sd_registry_->DispatchMDnsEvent(test_service_type, services); | 140 dns_sd_registry_->DispatchMDnsEvent(test_service_type, services); |
| 140 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 141 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 141 } | 142 } |
| OLD | NEW |