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