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/chrome_switches.h" | |
10 #include "chrome/common/extensions/api/mdns.h" | 9 #include "chrome/common/extensions/api/mdns.h" |
| 10 #include "extensions/common/switches.h" |
11 #include "testing/gmock/include/gmock/gmock.h" | 11 #include "testing/gmock/include/gmock/gmock.h" |
12 | 12 |
13 using extensions::DnsSdRegistry; | 13 using extensions::DnsSdRegistry; |
14 using ::testing::A; | 14 using ::testing::A; |
15 using ::testing::_; | 15 using ::testing::_; |
16 | 16 |
17 namespace api = extensions::api; | 17 namespace api = extensions::api; |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
(...skipping 16 matching lines...) Expand all Loading... |
37 extensions::DnsSdRegistry::DnsSdObserver* api_; | 37 extensions::DnsSdRegistry::DnsSdObserver* api_; |
38 }; | 38 }; |
39 | 39 |
40 class MDnsAPITest : public ExtensionApiTest { | 40 class MDnsAPITest : public ExtensionApiTest { |
41 public: | 41 public: |
42 MDnsAPITest() {} | 42 MDnsAPITest() {} |
43 | 43 |
44 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 44 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
45 ExtensionApiTest::SetUpCommandLine(command_line); | 45 ExtensionApiTest::SetUpCommandLine(command_line); |
46 command_line->AppendSwitchASCII( | 46 command_line->AppendSwitchASCII( |
47 switches::kWhitelistedExtensionID, "ddchlicdkolnonkihahngkmmmjnjlkkf"); | 47 extensions::switches::kWhitelistedExtensionID, |
| 48 "ddchlicdkolnonkihahngkmmmjnjlkkf"); |
48 } | 49 } |
49 | 50 |
50 void SetUpTestDnsSdRegistry() { | 51 void SetUpTestDnsSdRegistry() { |
51 extensions::MDnsAPI* api = extensions::MDnsAPI::Get(profile()); | 52 extensions::MDnsAPI* api = extensions::MDnsAPI::Get(profile()); |
52 dns_sd_registry_ = new MockDnsSdRegistry(api); | 53 dns_sd_registry_ = new MockDnsSdRegistry(api); |
53 // Transfers ownership of the registry instance. | 54 // Transfers ownership of the registry instance. |
54 api->SetDnsSdRegistryForTesting( | 55 api->SetDnsSdRegistryForTesting( |
55 make_scoped_ptr<DnsSdRegistry>(dns_sd_registry_).Pass()); | 56 make_scoped_ptr<DnsSdRegistry>(dns_sd_registry_).Pass()); |
56 } | 57 } |
57 | 58 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 DnsSdRegistry::DnsSdServiceList services; | 132 DnsSdRegistry::DnsSdServiceList services; |
132 | 133 |
133 extensions::DnsSdService service; | 134 extensions::DnsSdService service; |
134 service.service_name = service_type; | 135 service.service_name = service_type; |
135 services.push_back(service); | 136 services.push_back(service); |
136 | 137 |
137 dns_sd_registry_->DispatchMDnsEvent(service_type, services); | 138 dns_sd_registry_->DispatchMDnsEvent(service_type, services); |
138 dns_sd_registry_->DispatchMDnsEvent(test_service_type, services); | 139 dns_sd_registry_->DispatchMDnsEvent(test_service_type, services); |
139 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 140 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
140 } | 141 } |
OLD | NEW |