| 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/user.h" | 10 #include "chrome/browser/chromeos/login/user.h" |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 chromeos::User* user = user_manager->GetActiveUser(); | 191 chromeos::User* user = user_manager->GetActiveUser(); |
| 192 CHECK(user); | 192 CHECK(user); |
| 193 std::string userhash; | 193 std::string userhash; |
| 194 DBusThreadManager::Get()->GetCryptohomeClient()->GetSanitizedUsername( | 194 DBusThreadManager::Get()->GetCryptohomeClient()->GetSanitizedUsername( |
| 195 user->email(), | 195 user->email(), |
| 196 base::Bind(&AssignString, &userhash_)); | 196 base::Bind(&AssignString, &userhash_)); |
| 197 content::RunAllPendingInMessageLoop(); | 197 content::RunAllPendingInMessageLoop(); |
| 198 CHECK(!userhash_.empty()); | 198 CHECK(!userhash_.empty()); |
| 199 } | 199 } |
| 200 | 200 |
| 201 void AddService(const std::string& service_path, |
| 202 const std::string& name, |
| 203 const std::string& type, |
| 204 const std::string& state) { |
| 205 const bool add_to_watchlist = true; |
| 206 const bool add_to_visible = true; |
| 207 // Tests need a known GUID, so use 'service_path'. |
| 208 service_test_->AddServiceWithIPConfig( |
| 209 service_path, service_path /* guid */, name, |
| 210 type, state, "" /* ipconfig_path */, |
| 211 add_to_visible, add_to_watchlist); |
| 212 } |
| 213 |
| 201 virtual void SetUpOnMainThread() OVERRIDE { | 214 virtual void SetUpOnMainThread() OVERRIDE { |
| 202 detector_ = new NetworkPortalDetectorTestImpl(); | 215 detector_ = new NetworkPortalDetectorTestImpl(); |
| 203 NetworkPortalDetector::InitializeForTesting(detector_); | 216 NetworkPortalDetector::InitializeForTesting(detector_); |
| 204 | 217 |
| 205 ExtensionApiTest::SetUpOnMainThread(); | 218 ExtensionApiTest::SetUpOnMainThread(); |
| 206 content::RunAllPendingInMessageLoop(); | 219 content::RunAllPendingInMessageLoop(); |
| 207 | 220 |
| 208 InitializeSanitizedUsername(); | 221 InitializeSanitizedUsername(); |
| 209 | 222 |
| 210 DBusThreadManager* dbus_manager = DBusThreadManager::Get(); | 223 DBusThreadManager* dbus_manager = DBusThreadManager::Get(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 238 device_test->AddDevice( | 251 device_test->AddDevice( |
| 239 kWifiDevicePath, shill::kTypeWifi, "stub_wifi_device1"); | 252 kWifiDevicePath, shill::kTypeWifi, "stub_wifi_device1"); |
| 240 base::ListValue wifi_ip_configs; | 253 base::ListValue wifi_ip_configs; |
| 241 wifi_ip_configs.AppendString(kIPConfigPath); | 254 wifi_ip_configs.AppendString(kIPConfigPath); |
| 242 device_test->SetDeviceProperty( | 255 device_test->SetDeviceProperty( |
| 243 kWifiDevicePath, shill::kIPConfigsProperty, wifi_ip_configs); | 256 kWifiDevicePath, shill::kIPConfigsProperty, wifi_ip_configs); |
| 244 device_test->AddDevice( | 257 device_test->AddDevice( |
| 245 kCellularDevicePath, shill::kTypeCellular, "stub_cellular_device1"); | 258 kCellularDevicePath, shill::kTypeCellular, "stub_cellular_device1"); |
| 246 | 259 |
| 247 // Add Services | 260 // Add Services |
| 248 const bool add_to_watchlist = true; | 261 AddService("stub_ethernet", "eth0", |
| 249 const bool add_to_visible = true; | 262 shill::kTypeEthernet, shill::kStateOnline); |
| 250 service_test_->AddService("stub_ethernet", "eth0", | |
| 251 shill::kTypeEthernet, shill::kStateOnline, | |
| 252 add_to_visible, add_to_watchlist); | |
| 253 service_test_->SetServiceProperty( | 263 service_test_->SetServiceProperty( |
| 254 "stub_ethernet", | 264 "stub_ethernet", |
| 255 shill::kProfileProperty, | 265 shill::kProfileProperty, |
| 256 base::StringValue(ShillProfileClient::GetSharedProfilePath())); | 266 base::StringValue(ShillProfileClient::GetSharedProfilePath())); |
| 257 profile_test->AddService(ShillProfileClient::GetSharedProfilePath(), | 267 profile_test->AddService(ShillProfileClient::GetSharedProfilePath(), |
| 258 "stub_ethernet"); | 268 "stub_ethernet"); |
| 259 | 269 |
| 260 service_test_->AddService("stub_wifi1", "wifi1", | 270 AddService("stub_wifi1", "wifi1", shill::kTypeWifi, shill::kStateOnline); |
| 261 shill::kTypeWifi, shill::kStateOnline, | |
| 262 add_to_visible, add_to_watchlist); | |
| 263 service_test_->SetServiceProperty("stub_wifi1", | 271 service_test_->SetServiceProperty("stub_wifi1", |
| 264 shill::kSecurityProperty, | 272 shill::kSecurityProperty, |
| 265 base::StringValue(shill::kSecurityWep)); | 273 base::StringValue(shill::kSecurityWep)); |
| 266 service_test_->SetServiceProperty("stub_wifi1", | 274 service_test_->SetServiceProperty("stub_wifi1", |
| 267 shill::kSignalStrengthProperty, | 275 shill::kSignalStrengthProperty, |
| 268 base::FundamentalValue(40)); | 276 base::FundamentalValue(40)); |
| 269 service_test_->SetServiceProperty("stub_wifi1", | 277 service_test_->SetServiceProperty("stub_wifi1", |
| 270 shill::kProfileProperty, | 278 shill::kProfileProperty, |
| 271 base::StringValue(kUser1ProfilePath)); | 279 base::StringValue(kUser1ProfilePath)); |
| 272 service_test_->SetServiceProperty("stub_wifi1", | 280 service_test_->SetServiceProperty("stub_wifi1", |
| 273 shill::kConnectableProperty, | 281 shill::kConnectableProperty, |
| 274 base::FundamentalValue(true)); | 282 base::FundamentalValue(true)); |
| 275 service_test_->SetServiceProperty("stub_wifi1", | 283 service_test_->SetServiceProperty("stub_wifi1", |
| 276 shill::kDeviceProperty, | 284 shill::kDeviceProperty, |
| 277 base::StringValue(kWifiDevicePath)); | 285 base::StringValue(kWifiDevicePath)); |
| 278 profile_test->AddService(kUser1ProfilePath, "stub_wifi1"); | 286 profile_test->AddService(kUser1ProfilePath, "stub_wifi1"); |
| 279 base::ListValue frequencies1; | 287 base::ListValue frequencies1; |
| 280 frequencies1.AppendInteger(2400); | 288 frequencies1.AppendInteger(2400); |
| 281 service_test_->SetServiceProperty("stub_wifi1", | 289 service_test_->SetServiceProperty("stub_wifi1", |
| 282 shill::kWifiFrequencyListProperty, | 290 shill::kWifiFrequencyListProperty, |
| 283 frequencies1); | 291 frequencies1); |
| 284 service_test_->SetServiceProperty("stub_wifi1", | 292 service_test_->SetServiceProperty("stub_wifi1", |
| 285 shill::kWifiFrequency, | 293 shill::kWifiFrequency, |
| 286 base::FundamentalValue(2400)); | 294 base::FundamentalValue(2400)); |
| 287 | 295 |
| 288 service_test_->AddService("stub_wifi2", "wifi2_PSK", | 296 AddService("stub_wifi2", "wifi2_PSK", shill::kTypeWifi, shill::kStateIdle); |
| 289 shill::kTypeWifi, shill::kStateIdle, | |
| 290 add_to_visible, add_to_watchlist); | |
| 291 service_test_->SetServiceProperty("stub_wifi2", | 297 service_test_->SetServiceProperty("stub_wifi2", |
| 292 shill::kGuidProperty, | 298 shill::kGuidProperty, |
| 293 base::StringValue("stub_wifi2")); | 299 base::StringValue("stub_wifi2")); |
| 294 service_test_->SetServiceProperty("stub_wifi2", | 300 service_test_->SetServiceProperty("stub_wifi2", |
| 295 shill::kSecurityProperty, | 301 shill::kSecurityProperty, |
| 296 base::StringValue(shill::kSecurityPsk)); | 302 base::StringValue(shill::kSecurityPsk)); |
| 297 service_test_->SetServiceProperty("stub_wifi2", | 303 service_test_->SetServiceProperty("stub_wifi2", |
| 298 shill::kSignalStrengthProperty, | 304 shill::kSignalStrengthProperty, |
| 299 base::FundamentalValue(80)); | 305 base::FundamentalValue(80)); |
| 300 service_test_->SetServiceProperty("stub_wifi2", | 306 service_test_->SetServiceProperty("stub_wifi2", |
| 301 shill::kConnectableProperty, | 307 shill::kConnectableProperty, |
| 302 base::FundamentalValue(true)); | 308 base::FundamentalValue(true)); |
| 303 | 309 |
| 304 base::ListValue frequencies2; | 310 base::ListValue frequencies2; |
| 305 frequencies2.AppendInteger(2400); | 311 frequencies2.AppendInteger(2400); |
| 306 frequencies2.AppendInteger(5000); | 312 frequencies2.AppendInteger(5000); |
| 307 service_test_->SetServiceProperty("stub_wifi2", | 313 service_test_->SetServiceProperty("stub_wifi2", |
| 308 shill::kWifiFrequencyListProperty, | 314 shill::kWifiFrequencyListProperty, |
| 309 frequencies2); | 315 frequencies2); |
| 310 service_test_->SetServiceProperty("stub_wifi2", | 316 service_test_->SetServiceProperty("stub_wifi2", |
| 311 shill::kWifiFrequency, | 317 shill::kWifiFrequency, |
| 312 base::FundamentalValue(5000)); | 318 base::FundamentalValue(5000)); |
| 313 service_test_->SetServiceProperty("stub_wifi2", | 319 service_test_->SetServiceProperty("stub_wifi2", |
| 314 shill::kProfileProperty, | 320 shill::kProfileProperty, |
| 315 base::StringValue(kUser1ProfilePath)); | 321 base::StringValue(kUser1ProfilePath)); |
| 316 profile_test->AddService(kUser1ProfilePath, "stub_wifi2"); | 322 profile_test->AddService(kUser1ProfilePath, "stub_wifi2"); |
| 317 | 323 |
| 318 service_test_->AddService("stub_vpn1", "vpn1", | 324 AddService("stub_vpn1", "vpn1", shill::kTypeVPN, shill::kStateOnline); |
| 319 shill::kTypeVPN, | |
| 320 shill::kStateOnline, | |
| 321 add_to_visible, add_to_watchlist); | |
| 322 | 325 |
| 323 manager_test->SortManagerServices(); | 326 manager_test->SortManagerServices(); |
| 324 | 327 |
| 325 content::RunAllPendingInMessageLoop(); | 328 content::RunAllPendingInMessageLoop(); |
| 326 } | 329 } |
| 327 #else // !defined(OS_CHROMEOS) | 330 #else // !defined(OS_CHROMEOS) |
| 328 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 331 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 329 ExtensionApiTest::SetUpCommandLine(command_line); | 332 ExtensionApiTest::SetUpCommandLine(command_line); |
| 330 // Whitelist the extension ID of the test extension. | 333 // Whitelist the extension ID of the test extension. |
| 331 command_line->AppendSwitchASCII( | 334 command_line->AppendSwitchASCII( |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest, | 532 IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest, |
| 530 GetWifiTDLSStatus) { | 533 GetWifiTDLSStatus) { |
| 531 EXPECT_TRUE(RunNetworkingSubtest("getWifiTDLSStatus")) << message_; | 534 EXPECT_TRUE(RunNetworkingSubtest("getWifiTDLSStatus")) << message_; |
| 532 } | 535 } |
| 533 #endif | 536 #endif |
| 534 | 537 |
| 535 // NetworkPortalDetector is only enabled for Chrome OS. | 538 // NetworkPortalDetector is only enabled for Chrome OS. |
| 536 #if defined(OS_CHROMEOS) | 539 #if defined(OS_CHROMEOS) |
| 537 IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest, | 540 IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest, |
| 538 GetCaptivePortalStatus) { | 541 GetCaptivePortalStatus) { |
| 539 service_test_->AddService("stub_cellular1", "cellular1", | 542 AddService("stub_cellular1", "cellular1", |
| 540 shill::kTypeCellular, shill::kStateIdle, | 543 shill::kTypeCellular, shill::kStateIdle); |
| 541 true /* add_to_visible */, | |
| 542 true /* add_to_watchlist */); | |
| 543 service_test_->SetServiceProperty( | 544 service_test_->SetServiceProperty( |
| 544 "stub_cellular1", | 545 "stub_cellular1", |
| 545 shill::kNetworkTechnologyProperty, | 546 shill::kNetworkTechnologyProperty, |
| 546 base::StringValue(shill::kNetworkTechnologyGsm)); | 547 base::StringValue(shill::kNetworkTechnologyGsm)); |
| 547 service_test_->SetServiceProperty( | 548 service_test_->SetServiceProperty( |
| 548 "stub_cellular1", | 549 "stub_cellular1", |
| 549 shill::kActivationStateProperty, | 550 shill::kActivationStateProperty, |
| 550 base::StringValue(shill::kActivationStateNotActivated)); | 551 base::StringValue(shill::kActivationStateNotActivated)); |
| 551 service_test_->SetServiceProperty( | 552 service_test_->SetServiceProperty( |
| 552 "stub_cellular1", | 553 "stub_cellular1", |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 base::Unretained(detector()))); | 587 base::Unretained(detector()))); |
| 587 EXPECT_TRUE(RunNetworkingSubtest("captivePortalNotification")) << message_; | 588 EXPECT_TRUE(RunNetworkingSubtest("captivePortalNotification")) << message_; |
| 588 } | 589 } |
| 589 #endif // defined(OS_CHROMEOS) | 590 #endif // defined(OS_CHROMEOS) |
| 590 | 591 |
| 591 INSTANTIATE_TEST_CASE_P(ExtensionNetworkingPrivateApiTestInstantiation, | 592 INSTANTIATE_TEST_CASE_P(ExtensionNetworkingPrivateApiTestInstantiation, |
| 592 ExtensionNetworkingPrivateApiTest, | 593 ExtensionNetworkingPrivateApiTest, |
| 593 testing::Bool()); | 594 testing::Bool()); |
| 594 | 595 |
| 595 } // namespace | 596 } // namespace |
| OLD | NEW |