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/bind.h" | 5 #include "base/bind.h" |
6 #include "base/callback.h" | 6 #include "base/callback.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/chromeos/login/users/user.h" | 10 #include "chrome/browser/chromeos/login/users/user.h" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 }; | 131 }; |
132 #endif // defined(OS_CHROMEOS) | 132 #endif // defined(OS_CHROMEOS) |
133 | 133 |
134 class ExtensionNetworkingPrivateApiTest | 134 class ExtensionNetworkingPrivateApiTest |
135 : public ExtensionApiTest, | 135 : public ExtensionApiTest, |
136 public testing::WithParamInterface<bool> { | 136 public testing::WithParamInterface<bool> { |
137 public: | 137 public: |
138 ExtensionNetworkingPrivateApiTest() | 138 ExtensionNetworkingPrivateApiTest() |
139 #if defined(OS_CHROMEOS) | 139 #if defined(OS_CHROMEOS) |
140 : detector_(NULL), | 140 : detector_(NULL), |
141 service_test_(NULL) | 141 service_test_(NULL), |
| 142 manager_test_(NULL) |
142 #endif | 143 #endif |
143 { | 144 { |
144 } | 145 } |
145 | 146 |
146 bool RunNetworkingSubtest(const std::string& subtest) { | 147 bool RunNetworkingSubtest(const std::string& subtest) { |
147 return RunExtensionSubtest( | 148 return RunExtensionSubtest( |
148 "networking", "main.html?" + subtest, | 149 "networking", "main.html?" + subtest, |
149 kFlagEnableFileAccess | kFlagLoadAsComponent); | 150 kFlagEnableFileAccess | kFlagLoadAsComponent); |
150 } | 151 } |
151 | 152 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 virtual void SetUpOnMainThread() OVERRIDE { | 215 virtual void SetUpOnMainThread() OVERRIDE { |
215 detector_ = new NetworkPortalDetectorTestImpl(); | 216 detector_ = new NetworkPortalDetectorTestImpl(); |
216 NetworkPortalDetector::InitializeForTesting(detector_); | 217 NetworkPortalDetector::InitializeForTesting(detector_); |
217 | 218 |
218 ExtensionApiTest::SetUpOnMainThread(); | 219 ExtensionApiTest::SetUpOnMainThread(); |
219 content::RunAllPendingInMessageLoop(); | 220 content::RunAllPendingInMessageLoop(); |
220 | 221 |
221 InitializeSanitizedUsername(); | 222 InitializeSanitizedUsername(); |
222 | 223 |
223 DBusThreadManager* dbus_manager = DBusThreadManager::Get(); | 224 DBusThreadManager* dbus_manager = DBusThreadManager::Get(); |
224 ShillManagerClient::TestInterface* manager_test = | 225 manager_test_ = dbus_manager->GetShillManagerClient()->GetTestInterface(); |
225 dbus_manager->GetShillManagerClient()->GetTestInterface(); | 226 service_test_ = dbus_manager->GetShillServiceClient()->GetTestInterface(); |
| 227 |
226 ShillIPConfigClient::TestInterface* ip_config_test = | 228 ShillIPConfigClient::TestInterface* ip_config_test = |
227 dbus_manager->GetShillIPConfigClient()->GetTestInterface(); | 229 dbus_manager->GetShillIPConfigClient()->GetTestInterface(); |
228 ShillDeviceClient::TestInterface* device_test = | 230 ShillDeviceClient::TestInterface* device_test = |
229 dbus_manager->GetShillDeviceClient()->GetTestInterface(); | 231 dbus_manager->GetShillDeviceClient()->GetTestInterface(); |
230 ShillProfileClient::TestInterface* profile_test = | 232 ShillProfileClient::TestInterface* profile_test = |
231 dbus_manager->GetShillProfileClient()->GetTestInterface(); | 233 dbus_manager->GetShillProfileClient()->GetTestInterface(); |
232 | 234 |
233 service_test_ = dbus_manager->GetShillServiceClient()->GetTestInterface(); | |
234 | |
235 device_test->ClearDevices(); | 235 device_test->ClearDevices(); |
236 service_test_->ClearServices(); | 236 service_test_->ClearServices(); |
237 | 237 |
238 // Sends a notification about the added profile. | 238 // Sends a notification about the added profile. |
239 profile_test->AddProfile(kUser1ProfilePath, userhash_); | 239 profile_test->AddProfile(kUser1ProfilePath, userhash_); |
240 | 240 |
241 // Add IPConfigs | 241 // Add IPConfigs |
242 base::DictionaryValue ipconfig; | 242 base::DictionaryValue ipconfig; |
243 ipconfig.SetStringWithoutPathExpansion(shill::kAddressProperty, "0.0.0.0"); | 243 ipconfig.SetStringWithoutPathExpansion(shill::kAddressProperty, "0.0.0.0"); |
244 ipconfig.SetStringWithoutPathExpansion(shill::kGatewayProperty, "0.0.0.1"); | 244 ipconfig.SetStringWithoutPathExpansion(shill::kGatewayProperty, "0.0.0.1"); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 service_test_->SetServiceProperty("stub_wifi2", | 316 service_test_->SetServiceProperty("stub_wifi2", |
317 shill::kWifiFrequency, | 317 shill::kWifiFrequency, |
318 base::FundamentalValue(5000)); | 318 base::FundamentalValue(5000)); |
319 service_test_->SetServiceProperty("stub_wifi2", | 319 service_test_->SetServiceProperty("stub_wifi2", |
320 shill::kProfileProperty, | 320 shill::kProfileProperty, |
321 base::StringValue(kUser1ProfilePath)); | 321 base::StringValue(kUser1ProfilePath)); |
322 profile_test->AddService(kUser1ProfilePath, "stub_wifi2"); | 322 profile_test->AddService(kUser1ProfilePath, "stub_wifi2"); |
323 | 323 |
324 AddService("stub_vpn1", "vpn1", shill::kTypeVPN, shill::kStateOnline); | 324 AddService("stub_vpn1", "vpn1", shill::kTypeVPN, shill::kStateOnline); |
325 | 325 |
326 manager_test->SortManagerServices(); | 326 manager_test_->SortManagerServices(); |
327 | 327 |
328 content::RunAllPendingInMessageLoop(); | 328 content::RunAllPendingInMessageLoop(); |
329 } | 329 } |
330 #else // !defined(OS_CHROMEOS) | 330 #else // !defined(OS_CHROMEOS) |
331 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 331 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
332 ExtensionApiTest::SetUpCommandLine(command_line); | 332 ExtensionApiTest::SetUpCommandLine(command_line); |
333 // Whitelist the extension ID of the test extension. | 333 // Whitelist the extension ID of the test extension. |
334 command_line->AppendSwitchASCII( | 334 command_line->AppendSwitchASCII( |
335 extensions::switches::kWhitelistedExtensionID, | 335 extensions::switches::kWhitelistedExtensionID, |
336 "epcifkihnkjgphfkloaaleeakhpmgdmn"); | 336 "epcifkihnkjgphfkloaaleeakhpmgdmn"); |
(...skipping 14 matching lines...) Expand all Loading... |
351 } | 351 } |
352 | 352 |
353 #endif // OS_CHROMEOS | 353 #endif // OS_CHROMEOS |
354 | 354 |
355 protected: | 355 protected: |
356 #if defined(OS_CHROMEOS) | 356 #if defined(OS_CHROMEOS) |
357 NetworkPortalDetectorTestImpl* detector() { return detector_; } | 357 NetworkPortalDetectorTestImpl* detector() { return detector_; } |
358 | 358 |
359 NetworkPortalDetectorTestImpl* detector_; | 359 NetworkPortalDetectorTestImpl* detector_; |
360 ShillServiceClient::TestInterface* service_test_; | 360 ShillServiceClient::TestInterface* service_test_; |
| 361 ShillManagerClient::TestInterface* manager_test_; |
361 policy::MockConfigurationPolicyProvider provider_; | 362 policy::MockConfigurationPolicyProvider provider_; |
362 std::string userhash_; | 363 std::string userhash_; |
363 #endif | 364 #endif |
364 }; | 365 }; |
365 | 366 |
366 // Place each subtest into a separate browser test so that the stub networking | 367 // Place each subtest into a separate browser test so that the stub networking |
367 // library state is reset for each subtest run. This way they won't affect each | 368 // library state is reset for each subtest run. This way they won't affect each |
368 // other. | 369 // other. |
369 | 370 |
370 IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest, StartConnect) { | 371 IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest, StartConnect) { |
(...skipping 14 matching lines...) Expand all Loading... |
385 EXPECT_TRUE(RunNetworkingSubtest("startDisconnectNonexistent")) << message_; | 386 EXPECT_TRUE(RunNetworkingSubtest("startDisconnectNonexistent")) << message_; |
386 } | 387 } |
387 | 388 |
388 IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest, | 389 IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest, |
389 StartGetPropertiesNonexistent) { | 390 StartGetPropertiesNonexistent) { |
390 EXPECT_TRUE(RunNetworkingSubtest("startGetPropertiesNonexistent")) | 391 EXPECT_TRUE(RunNetworkingSubtest("startGetPropertiesNonexistent")) |
391 << message_; | 392 << message_; |
392 } | 393 } |
393 | 394 |
394 #if defined(OS_CHROMEOS) | 395 #if defined(OS_CHROMEOS) |
395 // Non-Chrome OS only supports wifi currently. | 396 // TODO(stevenjb/mef): Fix these on non-Chrome OS, crbug.com/371442. |
| 397 IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest, GetNetworks) { |
| 398 // Remove "stub_wifi2" from the visible list. |
| 399 manager_test_->RemoveManagerService("stub_wifi2", false); |
| 400 // Add a couple of additional networks that are not configured (saved). |
| 401 AddService("stub_wifi3", "wifi3", shill::kTypeWifi, shill::kStateIdle); |
| 402 AddService("stub_wifi4", "wifi4", shill::kTypeWifi, shill::kStateIdle); |
| 403 EXPECT_TRUE(RunNetworkingSubtest("getNetworks")) << message_; |
| 404 } |
| 405 |
396 IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest, GetVisibleNetworks) { | 406 IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest, GetVisibleNetworks) { |
397 EXPECT_TRUE(RunNetworkingSubtest("getVisibleNetworks")) << message_; | 407 EXPECT_TRUE(RunNetworkingSubtest("getVisibleNetworks")) << message_; |
398 } | 408 } |
399 #endif | 409 #endif |
400 | 410 |
401 IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest, | 411 IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest, |
402 GetVisibleNetworksWifi) { | 412 GetVisibleNetworksWifi) { |
403 EXPECT_TRUE(RunNetworkingSubtest("getVisibleNetworksWifi")) << message_; | 413 EXPECT_TRUE(RunNetworkingSubtest("getVisibleNetworksWifi")) << message_; |
404 } | 414 } |
405 | 415 |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 base::Unretained(detector()))); | 597 base::Unretained(detector()))); |
588 EXPECT_TRUE(RunNetworkingSubtest("captivePortalNotification")) << message_; | 598 EXPECT_TRUE(RunNetworkingSubtest("captivePortalNotification")) << message_; |
589 } | 599 } |
590 #endif // defined(OS_CHROMEOS) | 600 #endif // defined(OS_CHROMEOS) |
591 | 601 |
592 INSTANTIATE_TEST_CASE_P(ExtensionNetworkingPrivateApiTestInstantiation, | 602 INSTANTIATE_TEST_CASE_P(ExtensionNetworkingPrivateApiTestInstantiation, |
593 ExtensionNetworkingPrivateApiTest, | 603 ExtensionNetworkingPrivateApiTest, |
594 testing::Bool()); | 604 testing::Bool()); |
595 | 605 |
596 } // namespace | 606 } // namespace |
OLD | NEW |