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