Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: chrome/browser/extensions/api/networking_private/networking_private_apitest.cc

Issue 267433005: Provide IPConfigs in networkingPrivate.GetProperties (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/networking/test.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "chrome/browser/chromeos/login/user_manager.h" 11 #include "chrome/browser/chromeos/login/user_manager.h"
12 #include "chrome/browser/extensions/extension_apitest.h" 12 #include "chrome/browser/extensions/extension_apitest.h"
13 #include "chrome/common/chrome_switches.h" 13 #include "chrome/common/chrome_switches.h"
14 #include "chrome/test/base/ui_test_utils.h" 14 #include "chrome/test/base/ui_test_utils.h"
15 #include "extensions/common/switches.h" 15 #include "extensions/common/switches.h"
16 #include "testing/gmock/include/gmock/gmock.h" 16 #include "testing/gmock/include/gmock/gmock.h"
17 17
18 #if defined(OS_CHROMEOS) 18 #if defined(OS_CHROMEOS)
19 #include "chrome/browser/chrome_notification_types.h" 19 #include "chrome/browser/chrome_notification_types.h"
20 #include "chrome/browser/chromeos/net/network_portal_detector.h" 20 #include "chrome/browser/chromeos/net/network_portal_detector.h"
21 #include "chrome/browser/chromeos/net/network_portal_detector_test_impl.h" 21 #include "chrome/browser/chromeos/net/network_portal_detector_test_impl.h"
22 #include "chromeos/chromeos_switches.h" 22 #include "chromeos/chromeos_switches.h"
23 #include "chromeos/dbus/cryptohome_client.h" 23 #include "chromeos/dbus/cryptohome_client.h"
24 #include "chromeos/dbus/dbus_thread_manager.h" 24 #include "chromeos/dbus/dbus_thread_manager.h"
25 #include "chromeos/dbus/shill_device_client.h" 25 #include "chromeos/dbus/shill_device_client.h"
26 #include "chromeos/dbus/shill_ipconfig_client.h"
26 #include "chromeos/dbus/shill_manager_client.h" 27 #include "chromeos/dbus/shill_manager_client.h"
27 #include "chromeos/dbus/shill_profile_client.h" 28 #include "chromeos/dbus/shill_profile_client.h"
28 #include "chromeos/dbus/shill_service_client.h" 29 #include "chromeos/dbus/shill_service_client.h"
29 #include "chromeos/network/onc/onc_utils.h" 30 #include "chromeos/network/onc/onc_utils.h"
30 #include "components/onc/onc_constants.h" 31 #include "components/onc/onc_constants.h"
31 #include "components/policy/core/browser/browser_policy_connector.h" 32 #include "components/policy/core/browser/browser_policy_connector.h"
32 #include "components/policy/core/common/external_data_fetcher.h" 33 #include "components/policy/core/common/external_data_fetcher.h"
33 #include "components/policy/core/common/mock_configuration_policy_provider.h" 34 #include "components/policy/core/common/mock_configuration_policy_provider.h"
34 #include "components/policy/core/common/policy_map.h" 35 #include "components/policy/core/common/policy_map.h"
35 #include "components/policy/core/common/policy_types.h" 36 #include "components/policy/core/common/policy_types.h"
36 #include "content/public/browser/notification_observer.h" 37 #include "content/public/browser/notification_observer.h"
37 #include "content/public/browser/notification_registrar.h" 38 #include "content/public/browser/notification_registrar.h"
38 #include "content/public/browser/notification_service.h" 39 #include "content/public/browser/notification_service.h"
39 #include "content/public/browser/notification_source.h" 40 #include "content/public/browser/notification_source.h"
40 #include "policy/policy_constants.h" 41 #include "policy/policy_constants.h"
41 #include "third_party/cros_system_api/dbus/service_constants.h" 42 #include "third_party/cros_system_api/dbus/service_constants.h"
42 #else // !defined(OS_CHROMEOS) 43 #else // !defined(OS_CHROMEOS)
43 #include "chrome/browser/extensions/api/networking_private/networking_private_cr edentials_getter.h" 44 #include "chrome/browser/extensions/api/networking_private/networking_private_cr edentials_getter.h"
44 #include "chrome/browser/extensions/api/networking_private/networking_private_se rvice_client.h" 45 #include "chrome/browser/extensions/api/networking_private/networking_private_se rvice_client.h"
45 #include "chrome/browser/extensions/api/networking_private/networking_private_se rvice_client_factory.h" 46 #include "chrome/browser/extensions/api/networking_private/networking_private_se rvice_client_factory.h"
46 #include "components/wifi/fake_wifi_service.h" 47 #include "components/wifi/fake_wifi_service.h"
47 #endif // defined(OS_CHROMEOS) 48 #endif // defined(OS_CHROMEOS)
48 49
50 // TODO(stevenjb/mef): Clean these tests up. crbug.com/371442
51
49 using testing::Return; 52 using testing::Return;
50 using testing::_; 53 using testing::_;
51 54
52 #if defined(OS_CHROMEOS) 55 #if defined(OS_CHROMEOS)
53 using chromeos::CryptohomeClient; 56 using chromeos::CryptohomeClient;
54 using chromeos::DBUS_METHOD_CALL_SUCCESS; 57 using chromeos::DBUS_METHOD_CALL_SUCCESS;
55 using chromeos::DBusMethodCallStatus; 58 using chromeos::DBusMethodCallStatus;
56 using chromeos::DBusThreadManager; 59 using chromeos::DBusThreadManager;
57 using chromeos::NetworkPortalDetector; 60 using chromeos::NetworkPortalDetector;
58 using chromeos::NetworkPortalDetectorTestImpl; 61 using chromeos::NetworkPortalDetectorTestImpl;
59 using chromeos::ShillDeviceClient; 62 using chromeos::ShillDeviceClient;
63 using chromeos::ShillIPConfigClient;
60 using chromeos::ShillManagerClient; 64 using chromeos::ShillManagerClient;
61 using chromeos::ShillProfileClient; 65 using chromeos::ShillProfileClient;
62 using chromeos::ShillServiceClient; 66 using chromeos::ShillServiceClient;
63 #else // !defined(OS_CHROMEOS) 67 #else // !defined(OS_CHROMEOS)
64 using extensions::NetworkingPrivateServiceClientFactory; 68 using extensions::NetworkingPrivateServiceClientFactory;
65 #endif // defined(OS_CHROMEOS) 69 #endif // defined(OS_CHROMEOS)
66 70
67 namespace { 71 namespace {
68 72
69 #if defined(OS_CHROMEOS) 73 #if defined(OS_CHROMEOS)
70 const char kUser1ProfilePath[] = "/profile/user1/shill"; 74 const char kUser1ProfilePath[] = "/profile/user1/shill";
75 const char kWifiDevicePath[] = "/device/stub_wifi_device1";
76 const char kCellularDevicePath[] = "/device/stub_cellular_device1";
77 const char kIPConfigPath[] = "/ipconfig/ipconfig1";
71 78
72 class TestListener : public content::NotificationObserver { 79 class TestListener : public content::NotificationObserver {
73 public: 80 public:
74 TestListener(const std::string& message, const base::Closure& callback) 81 TestListener(const std::string& message, const base::Closure& callback)
75 : message_(message), callback_(callback) { 82 : message_(message), callback_(callback) {
76 registrar_.Add(this, 83 registrar_.Add(this,
77 chrome::NOTIFICATION_EXTENSION_TEST_MESSAGE, 84 chrome::NOTIFICATION_EXTENSION_TEST_MESSAGE,
78 content::NotificationService::AllSources()); 85 content::NotificationService::AllSources());
79 } 86 }
80 87
(...skipping 24 matching lines...) Expand all
105 : public extensions::NetworkingPrivateServiceClient::CryptoVerify { 112 : public extensions::NetworkingPrivateServiceClient::CryptoVerify {
106 virtual void VerifyDestination(scoped_ptr<base::ListValue> args, 113 virtual void VerifyDestination(scoped_ptr<base::ListValue> args,
107 bool* verified, 114 bool* verified,
108 std::string* error) OVERRIDE { 115 std::string* error) OVERRIDE {
109 *verified = true; 116 *verified = true;
110 } 117 }
111 118
112 virtual void VerifyAndEncryptCredentials( 119 virtual void VerifyAndEncryptCredentials(
113 scoped_ptr<base::ListValue> args, 120 scoped_ptr<base::ListValue> args,
114 const extensions::NetworkingPrivateServiceClient::CryptoVerify:: 121 const extensions::NetworkingPrivateServiceClient::CryptoVerify::
115 VerifyAndEncryptCredentialsCallback& callback) OVERRIDE { 122 VerifyAndEncryptCredentialsCallback& callback) OVERRIDE {
116 callback.Run("encrypted_credentials", ""); 123 callback.Run("encrypted_credentials", "");
117 } 124 }
118 125
119 virtual void VerifyAndEncryptData(scoped_ptr<base::ListValue> args, 126 virtual void VerifyAndEncryptData(scoped_ptr<base::ListValue> args,
120 std::string* encoded_data, 127 std::string* encoded_data,
121 std::string* error) OVERRIDE { 128 std::string* error) OVERRIDE {
122 *encoded_data = "encrypted_data"; 129 *encoded_data = "encrypted_data";
123 } 130 }
124 }; 131 };
125 #endif // defined(OS_CHROMEOS) 132 #endif // defined(OS_CHROMEOS)
126 133
127 class ExtensionNetworkingPrivateApiTest 134 class ExtensionNetworkingPrivateApiTest
128 : public ExtensionApiTest, 135 : public ExtensionApiTest,
129 public testing::WithParamInterface<bool> { 136 public testing::WithParamInterface<bool> {
130 public: 137 public:
131 ExtensionNetworkingPrivateApiTest() 138 ExtensionNetworkingPrivateApiTest()
132 #if defined(OS_CHROMEOS) 139 #if defined(OS_CHROMEOS)
133 : detector_(NULL) 140 : detector_(NULL),
141 service_test_(NULL)
134 #endif 142 #endif
135 { 143 {
136 } 144 }
137 145
138 bool RunNetworkingSubtest(const std::string& subtest) { 146 bool RunNetworkingSubtest(const std::string& subtest) {
139 return RunExtensionSubtest( 147 return RunExtensionSubtest(
140 "networking", "main.html?" + subtest, 148 "networking", "main.html?" + subtest,
141 kFlagEnableFileAccess | kFlagLoadAsComponent); 149 kFlagEnableFileAccess | kFlagLoadAsComponent);
142 } 150 }
143 151
144 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { 152 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
145 #if defined(OS_CHROMEOS) 153 #if defined(OS_CHROMEOS)
146 EXPECT_CALL(provider_, IsInitializationComplete(_)) 154 EXPECT_CALL(provider_, IsInitializationComplete(_))
147 .WillRepeatedly(Return(true)); 155 .WillRepeatedly(Return(true));
148 policy::BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_); 156 policy::BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_);
149 #endif 157 #endif
150 158
151 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); 159 ExtensionApiTest::SetUpInProcessBrowserTestFixture();
152 } 160 }
153 161
154 #if defined(OS_CHROMEOS) 162 #if defined(OS_CHROMEOS)
155 static void AssignString(std::string* out, 163 static void AssignString(std::string* out,
156 DBusMethodCallStatus call_status, 164 DBusMethodCallStatus call_status,
157 const std::string& result) { 165 const std::string& result) {
158 CHECK_EQ(call_status, DBUS_METHOD_CALL_SUCCESS); 166 CHECK_EQ(call_status, DBUS_METHOD_CALL_SUCCESS);
159 *out = result; 167 *out = result;
160 } 168 }
161 169
162 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 170 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
163 ExtensionApiTest::SetUpCommandLine(command_line); 171 ExtensionApiTest::SetUpCommandLine(command_line);
164 // Whitelist the extension ID of the test extension. 172 // Whitelist the extension ID of the test extension.
165 command_line->AppendSwitchASCII( 173 command_line->AppendSwitchASCII(
166 extensions::switches::kWhitelistedExtensionID, 174 extensions::switches::kWhitelistedExtensionID,
167 "epcifkihnkjgphfkloaaleeakhpmgdmn"); 175 "epcifkihnkjgphfkloaaleeakhpmgdmn");
(...skipping 24 matching lines...) Expand all
192 200
193 virtual void SetUpOnMainThread() OVERRIDE { 201 virtual void SetUpOnMainThread() OVERRIDE {
194 detector_ = new NetworkPortalDetectorTestImpl(); 202 detector_ = new NetworkPortalDetectorTestImpl();
195 NetworkPortalDetector::InitializeForTesting(detector_); 203 NetworkPortalDetector::InitializeForTesting(detector_);
196 204
197 ExtensionApiTest::SetUpOnMainThread(); 205 ExtensionApiTest::SetUpOnMainThread();
198 content::RunAllPendingInMessageLoop(); 206 content::RunAllPendingInMessageLoop();
199 207
200 InitializeSanitizedUsername(); 208 InitializeSanitizedUsername();
201 209
210 DBusThreadManager* dbus_manager = DBusThreadManager::Get();
202 ShillManagerClient::TestInterface* manager_test = 211 ShillManagerClient::TestInterface* manager_test =
203 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface(); 212 dbus_manager->GetShillManagerClient()->GetTestInterface();
213 ShillIPConfigClient::TestInterface* ip_config_test =
214 dbus_manager->GetShillIPConfigClient()->GetTestInterface();
204 ShillDeviceClient::TestInterface* device_test = 215 ShillDeviceClient::TestInterface* device_test =
205 DBusThreadManager::Get()->GetShillDeviceClient()->GetTestInterface(); 216 dbus_manager->GetShillDeviceClient()->GetTestInterface();
206 ShillProfileClient::TestInterface* profile_test = 217 ShillProfileClient::TestInterface* profile_test =
207 DBusThreadManager::Get()->GetShillProfileClient()->GetTestInterface(); 218 dbus_manager->GetShillProfileClient()->GetTestInterface();
208 ShillServiceClient::TestInterface* service_test = 219
209 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface(); 220 service_test_ = dbus_manager->GetShillServiceClient()->GetTestInterface();
210 221
211 device_test->ClearDevices(); 222 device_test->ClearDevices();
212 service_test->ClearServices(); 223 service_test_->ClearServices();
213 224
214 // Sends a notification about the added profile. 225 // Sends a notification about the added profile.
215 profile_test->AddProfile(kUser1ProfilePath, userhash_); 226 profile_test->AddProfile(kUser1ProfilePath, userhash_);
216 227
217 device_test->AddDevice("/device/stub_wifi_device1", 228 // Add IPConfigs
218 shill::kTypeWifi, "stub_wifi_device1"); 229 base::DictionaryValue ipconfig;
219 device_test->AddDevice("/device/stub_cellular_device1", 230 ipconfig.SetStringWithoutPathExpansion(shill::kAddressProperty, "0.0.0.0");
220 shill::kTypeCellular, "stub_cellular_device1"); 231 ipconfig.SetStringWithoutPathExpansion(shill::kGatewayProperty, "0.0.0.1");
232 ipconfig.SetIntegerWithoutPathExpansion(shill::kPrefixlenProperty, 0);
233 ipconfig.SetStringWithoutPathExpansion(
234 shill::kMethodProperty, shill::kTypeIPv4);
235 ip_config_test->AddIPConfig(kIPConfigPath, ipconfig);
221 236
237 // Add Devices
238 device_test->AddDevice(
239 kWifiDevicePath, shill::kTypeWifi, "stub_wifi_device1");
240 base::ListValue wifi_ip_configs;
241 wifi_ip_configs.AppendString(kIPConfigPath);
242 device_test->SetDeviceProperty(
243 kWifiDevicePath, shill::kIPConfigsProperty, wifi_ip_configs);
244 device_test->AddDevice(
245 kCellularDevicePath, shill::kTypeCellular, "stub_cellular_device1");
246
247 // Add Services
222 const bool add_to_watchlist = true; 248 const bool add_to_watchlist = true;
223 const bool add_to_visible = true; 249 const bool add_to_visible = true;
224 service_test->AddService("stub_ethernet", "eth0", 250 service_test_->AddService("stub_ethernet", "eth0",
225 shill::kTypeEthernet, shill::kStateOnline, 251 shill::kTypeEthernet, shill::kStateOnline,
226 add_to_visible, add_to_watchlist); 252 add_to_visible, add_to_watchlist);
227 service_test->SetServiceProperty( 253 service_test_->SetServiceProperty(
228 "stub_ethernet", 254 "stub_ethernet",
229 shill::kProfileProperty, 255 shill::kProfileProperty,
230 base::StringValue(ShillProfileClient::GetSharedProfilePath())); 256 base::StringValue(ShillProfileClient::GetSharedProfilePath()));
231 profile_test->AddService(ShillProfileClient::GetSharedProfilePath(), 257 profile_test->AddService(ShillProfileClient::GetSharedProfilePath(),
232 "stub_ethernet"); 258 "stub_ethernet");
233 259
234 service_test->AddService("stub_wifi1", "wifi1", 260 service_test_->AddService("stub_wifi1", "wifi1",
235 shill::kTypeWifi, shill::kStateOnline, 261 shill::kTypeWifi, shill::kStateOnline,
236 add_to_visible, add_to_watchlist); 262 add_to_visible, add_to_watchlist);
237 service_test->SetServiceProperty("stub_wifi1", 263 service_test_->SetServiceProperty("stub_wifi1",
238 shill::kSecurityProperty, 264 shill::kSecurityProperty,
239 base::StringValue(shill::kSecurityWep)); 265 base::StringValue(shill::kSecurityWep));
240 service_test->SetServiceProperty("stub_wifi1", 266 service_test_->SetServiceProperty("stub_wifi1",
241 shill::kProfileProperty, 267 shill::kSignalStrengthProperty,
242 base::StringValue(kUser1ProfilePath)); 268 base::FundamentalValue(40));
269 service_test_->SetServiceProperty("stub_wifi1",
270 shill::kProfileProperty,
271 base::StringValue(kUser1ProfilePath));
272 service_test_->SetServiceProperty("stub_wifi1",
273 shill::kConnectableProperty,
274 base::FundamentalValue(true));
275 service_test_->SetServiceProperty("stub_wifi1",
276 shill::kDeviceProperty,
277 base::StringValue(kWifiDevicePath));
243 profile_test->AddService(kUser1ProfilePath, "stub_wifi1"); 278 profile_test->AddService(kUser1ProfilePath, "stub_wifi1");
244 base::ListValue frequencies1; 279 base::ListValue frequencies1;
245 frequencies1.AppendInteger(2400); 280 frequencies1.AppendInteger(2400);
246 service_test->SetServiceProperty("stub_wifi1", 281 service_test_->SetServiceProperty("stub_wifi1",
247 shill::kWifiFrequencyListProperty, 282 shill::kWifiFrequencyListProperty,
248 frequencies1); 283 frequencies1);
249 service_test->SetServiceProperty("stub_wifi1", 284 service_test_->SetServiceProperty("stub_wifi1",
250 shill::kWifiFrequency, 285 shill::kWifiFrequency,
251 base::FundamentalValue(2400)); 286 base::FundamentalValue(2400));
252 287
253 service_test->AddService("stub_wifi2", "wifi2_PSK", 288 service_test_->AddService("stub_wifi2", "wifi2_PSK",
254 shill::kTypeWifi, shill::kStateIdle, 289 shill::kTypeWifi, shill::kStateIdle,
255 add_to_visible, add_to_watchlist); 290 add_to_visible, add_to_watchlist);
256 service_test->SetServiceProperty("stub_wifi2", 291 service_test_->SetServiceProperty("stub_wifi2",
257 shill::kGuidProperty, 292 shill::kGuidProperty,
258 base::StringValue("stub_wifi2")); 293 base::StringValue("stub_wifi2"));
259 service_test->SetServiceProperty("stub_wifi2", 294 service_test_->SetServiceProperty("stub_wifi2",
260 shill::kSecurityProperty, 295 shill::kSecurityProperty,
261 base::StringValue(shill::kSecurityPsk)); 296 base::StringValue(shill::kSecurityPsk));
262 service_test->SetServiceProperty("stub_wifi2", 297 service_test_->SetServiceProperty("stub_wifi2",
263 shill::kSignalStrengthProperty, 298 shill::kSignalStrengthProperty,
264 base::FundamentalValue(80)); 299 base::FundamentalValue(80));
265 service_test->SetServiceProperty("stub_wifi2", 300 service_test_->SetServiceProperty("stub_wifi2",
266 shill::kConnectableProperty, 301 shill::kConnectableProperty,
267 base::FundamentalValue(true)); 302 base::FundamentalValue(true));
268 303
269 base::ListValue frequencies2; 304 base::ListValue frequencies2;
270 frequencies2.AppendInteger(2400); 305 frequencies2.AppendInteger(2400);
271 frequencies2.AppendInteger(5000); 306 frequencies2.AppendInteger(5000);
272 service_test->SetServiceProperty("stub_wifi2", 307 service_test_->SetServiceProperty("stub_wifi2",
273 shill::kWifiFrequencyListProperty, 308 shill::kWifiFrequencyListProperty,
274 frequencies2); 309 frequencies2);
275 service_test->SetServiceProperty("stub_wifi2", 310 service_test_->SetServiceProperty("stub_wifi2",
276 shill::kWifiFrequency, 311 shill::kWifiFrequency,
277 base::FundamentalValue(5000)); 312 base::FundamentalValue(5000));
278 service_test->SetServiceProperty("stub_wifi2", 313 service_test_->SetServiceProperty("stub_wifi2",
279 shill::kProfileProperty, 314 shill::kProfileProperty,
280 base::StringValue(kUser1ProfilePath)); 315 base::StringValue(kUser1ProfilePath));
281 profile_test->AddService(kUser1ProfilePath, "stub_wifi2"); 316 profile_test->AddService(kUser1ProfilePath, "stub_wifi2");
282 317
283 service_test->AddService("stub_cellular1", "cellular1", 318 service_test_->AddService("stub_vpn1", "vpn1",
284 shill::kTypeCellular, shill::kStateIdle, 319 shill::kTypeVPN,
285 add_to_visible, add_to_watchlist); 320 shill::kStateOnline,
286 service_test->SetServiceProperty( 321 add_to_visible, add_to_watchlist);
287 "stub_cellular1",
288 shill::kNetworkTechnologyProperty,
289 base::StringValue(shill::kNetworkTechnologyGsm));
290 service_test->SetServiceProperty(
291 "stub_cellular1",
292 shill::kActivationStateProperty,
293 base::StringValue(shill::kActivationStateNotActivated));
294 service_test->SetServiceProperty(
295 "stub_cellular1",
296 shill::kRoamingStateProperty,
297 base::StringValue(shill::kRoamingStateHome));
298
299 service_test->AddService("stub_vpn1", "vpn1",
300 shill::kTypeVPN,
301 shill::kStateOnline,
302 add_to_visible, add_to_watchlist);
303 322
304 manager_test->SortManagerServices(); 323 manager_test->SortManagerServices();
305 324
306 content::RunAllPendingInMessageLoop(); 325 content::RunAllPendingInMessageLoop();
307 } 326 }
308 #else // !defined(OS_CHROMEOS) 327 #else // !defined(OS_CHROMEOS)
309 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 328 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
310 ExtensionApiTest::SetUpCommandLine(command_line); 329 ExtensionApiTest::SetUpCommandLine(command_line);
311 // Whitelist the extension ID of the test extension. 330 // Whitelist the extension ID of the test extension.
312 command_line->AppendSwitchASCII( 331 command_line->AppendSwitchASCII(
(...skipping 15 matching lines...) Expand all
328 &CreateNetworkingPrivateServiceClient); 347 &CreateNetworkingPrivateServiceClient);
329 } 348 }
330 349
331 #endif // OS_CHROMEOS 350 #endif // OS_CHROMEOS
332 351
333 protected: 352 protected:
334 #if defined(OS_CHROMEOS) 353 #if defined(OS_CHROMEOS)
335 NetworkPortalDetectorTestImpl* detector() { return detector_; } 354 NetworkPortalDetectorTestImpl* detector() { return detector_; }
336 355
337 NetworkPortalDetectorTestImpl* detector_; 356 NetworkPortalDetectorTestImpl* detector_;
357 ShillServiceClient::TestInterface* service_test_;
338 policy::MockConfigurationPolicyProvider provider_; 358 policy::MockConfigurationPolicyProvider provider_;
339 std::string userhash_; 359 std::string userhash_;
340 #endif 360 #endif
341 }; 361 };
342 362
343 // Place each subtest into a separate browser test so that the stub networking 363 // Place each subtest into a separate browser test so that the stub networking
344 // library state is reset for each subtest run. This way they won't affect each 364 // library state is reset for each subtest run. This way they won't affect each
345 // other. 365 // other.
346 366
347 IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest, StartConnect) { 367 IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest, StartConnect) {
(...skipping 13 matching lines...) Expand all
361 StartDisconnectNonexistent) { 381 StartDisconnectNonexistent) {
362 EXPECT_TRUE(RunNetworkingSubtest("startDisconnectNonexistent")) << message_; 382 EXPECT_TRUE(RunNetworkingSubtest("startDisconnectNonexistent")) << message_;
363 } 383 }
364 384
365 IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest, 385 IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest,
366 StartGetPropertiesNonexistent) { 386 StartGetPropertiesNonexistent) {
367 EXPECT_TRUE(RunNetworkingSubtest("startGetPropertiesNonexistent")) 387 EXPECT_TRUE(RunNetworkingSubtest("startGetPropertiesNonexistent"))
368 << message_; 388 << message_;
369 } 389 }
370 390
391 #if defined(OS_CHROMEOS)
392 // Non-Chrome OS only supports wifi currently.
371 IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest, GetVisibleNetworks) { 393 IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest, GetVisibleNetworks) {
372 EXPECT_TRUE(RunNetworkingSubtest("getVisibleNetworks")) << message_; 394 EXPECT_TRUE(RunNetworkingSubtest("getVisibleNetworks")) << message_;
373 } 395 }
396 #endif
374 397
375 IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest, 398 IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest,
376 GetVisibleNetworksWifi) { 399 GetVisibleNetworksWifi) {
377 EXPECT_TRUE(RunNetworkingSubtest("getVisibleNetworksWifi")) << message_; 400 EXPECT_TRUE(RunNetworkingSubtest("getVisibleNetworksWifi")) << message_;
378 } 401 }
379 402
403 #if defined(OS_CHROMEOS)
404 // TODO(stevenjb/mef): Fix this on non-Chrome OS, crbug.com/371442.
380 IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest, RequestNetworkScan) { 405 IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest, RequestNetworkScan) {
381 EXPECT_TRUE(RunNetworkingSubtest("requestNetworkScan")) << message_; 406 EXPECT_TRUE(RunNetworkingSubtest("requestNetworkScan")) << message_;
382 } 407 }
408 #endif
383 409
384 // Properties are filtered and translated through 410 // Properties are filtered and translated through
385 // ShillToONCTranslator::TranslateWiFiWithState 411 // ShillToONCTranslator::TranslateWiFiWithState
386 IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest, GetProperties) { 412 IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest, GetProperties) {
387 EXPECT_TRUE(RunNetworkingSubtest("getProperties")) << message_; 413 EXPECT_TRUE(RunNetworkingSubtest("getProperties")) << message_;
388 } 414 }
389 415
390 IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest, GetState) { 416 IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest, GetState) {
391 EXPECT_TRUE(RunNetworkingSubtest("getState")) << message_; 417 EXPECT_TRUE(RunNetworkingSubtest("getState")) << message_;
392 } 418 }
393 419
394 IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest, GetStateNonExistent) { 420 IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest, GetStateNonExistent) {
395 EXPECT_TRUE(RunNetworkingSubtest("getStateNonExistent")) << message_; 421 EXPECT_TRUE(RunNetworkingSubtest("getStateNonExistent")) << message_;
396 } 422 }
397 423
398 IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest, SetProperties) { 424 IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest, SetProperties) {
399 EXPECT_TRUE(RunNetworkingSubtest("setProperties")) << message_; 425 EXPECT_TRUE(RunNetworkingSubtest("setProperties")) << message_;
400 } 426 }
401 427
402 IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest, CreateNetwork) { 428 IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest, CreateNetwork) {
403 EXPECT_TRUE(RunNetworkingSubtest("createNetwork")) << message_; 429 EXPECT_TRUE(RunNetworkingSubtest("createNetwork")) << message_;
404 } 430 }
405 431
432 #if defined(OS_CHROMEOS)
433 // TODO(stevenjb/mef): Find a maintainable way to support this on win/mac and
434 // a better way to set this up on Chrome OS.
406 IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest, 435 IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest,
407 GetManagedProperties) { 436 GetManagedProperties) {
408 #if defined(OS_CHROMEOS)
409 // TODO(mef): Move this to ChromeOS-specific helper or SetUpOnMainThread.
410 ShillServiceClient::TestInterface* service_test =
411 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface();
412 const std::string uidata_blob = 437 const std::string uidata_blob =
413 "{ \"user_settings\": {" 438 "{ \"user_settings\": {"
414 " \"WiFi\": {" 439 " \"WiFi\": {"
415 " \"Passphrase\": \"FAKE_CREDENTIAL_VPaJDV9x\" }" 440 " \"Passphrase\": \"FAKE_CREDENTIAL_VPaJDV9x\" }"
416 " }" 441 " }"
417 "}"; 442 "}";
418 service_test->SetServiceProperty("stub_wifi2", 443 service_test_->SetServiceProperty("stub_wifi2",
419 shill::kUIDataProperty, 444 shill::kUIDataProperty,
420 base::StringValue(uidata_blob)); 445 base::StringValue(uidata_blob));
421 service_test->SetServiceProperty("stub_wifi2", 446 service_test_->SetServiceProperty("stub_wifi2",
422 shill::kAutoConnectProperty, 447 shill::kAutoConnectProperty,
423 base::FundamentalValue(false)); 448 base::FundamentalValue(false));
424 449
425 ShillProfileClient::TestInterface* profile_test = 450 ShillProfileClient::TestInterface* profile_test =
426 DBusThreadManager::Get()->GetShillProfileClient()->GetTestInterface(); 451 DBusThreadManager::Get()->GetShillProfileClient()->GetTestInterface();
427 // Update the profile entry. 452 // Update the profile entry.
428 profile_test->AddService(kUser1ProfilePath, "stub_wifi2"); 453 profile_test->AddService(kUser1ProfilePath, "stub_wifi2");
429 454
430 content::RunAllPendingInMessageLoop(); 455 content::RunAllPendingInMessageLoop();
431 456
432 const std::string user_policy_blob = 457 const std::string user_policy_blob =
433 "{ \"NetworkConfigurations\": [" 458 "{ \"NetworkConfigurations\": ["
(...skipping 13 matching lines...) Expand all
447 472
448 policy::PolicyMap policy; 473 policy::PolicyMap policy;
449 policy.Set(policy::key::kOpenNetworkConfiguration, 474 policy.Set(policy::key::kOpenNetworkConfiguration,
450 policy::POLICY_LEVEL_MANDATORY, 475 policy::POLICY_LEVEL_MANDATORY,
451 policy::POLICY_SCOPE_USER, 476 policy::POLICY_SCOPE_USER,
452 new base::StringValue(user_policy_blob), 477 new base::StringValue(user_policy_blob),
453 NULL); 478 NULL);
454 provider_.UpdateChromePolicy(policy); 479 provider_.UpdateChromePolicy(policy);
455 480
456 content::RunAllPendingInMessageLoop(); 481 content::RunAllPendingInMessageLoop();
457 #endif // OS_CHROMEOS
458 482
459 EXPECT_TRUE(RunNetworkingSubtest("getManagedProperties")) << message_; 483 EXPECT_TRUE(RunNetworkingSubtest("getManagedProperties")) << message_;
460 } 484 }
485 #endif // OS_CHROMEOS
461 486
462 IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest, 487 IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest,
463 OnNetworksChangedEventConnect) { 488 OnNetworksChangedEventConnect) {
464 EXPECT_TRUE(RunNetworkingSubtest("onNetworksChangedEventConnect")) 489 EXPECT_TRUE(RunNetworkingSubtest("onNetworksChangedEventConnect"))
465 << message_; 490 << message_;
466 } 491 }
467 492
468 IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest, 493 IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest,
469 OnNetworksChangedEventDisconnect) { 494 OnNetworksChangedEventDisconnect) {
470 EXPECT_TRUE(RunNetworkingSubtest("onNetworksChangedEventDisconnect")) 495 EXPECT_TRUE(RunNetworkingSubtest("onNetworksChangedEventDisconnect"))
471 << message_; 496 << message_;
472 } 497 }
473 498
499 #if defined(OS_CHROMEOS)
500 // TODO(stevenjb/mef): Fix this on non-Chrome OS, crbug.com/371442.
474 IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest, 501 IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest,
475 OnNetworkListChangedEvent) { 502 OnNetworkListChangedEvent) {
476 EXPECT_TRUE(RunNetworkingSubtest("onNetworkListChangedEvent")) << message_; 503 EXPECT_TRUE(RunNetworkingSubtest("onNetworkListChangedEvent")) << message_;
477 } 504 }
505 #endif // OS_CHROMEOS
478 506
479 IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest, 507 IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest,
480 VerifyDestination) { 508 VerifyDestination) {
481 EXPECT_TRUE(RunNetworkingSubtest("verifyDestination")) << message_; 509 EXPECT_TRUE(RunNetworkingSubtest("verifyDestination")) << message_;
482 } 510 }
483 511
484 IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest, 512 IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest,
485 VerifyAndEncryptCredentials) { 513 VerifyAndEncryptCredentials) {
486 EXPECT_TRUE(RunNetworkingSubtest("verifyAndEncryptCredentials")) << message_; 514 EXPECT_TRUE(RunNetworkingSubtest("verifyAndEncryptCredentials")) << message_;
487 } 515 }
(...skipping 13 matching lines...) Expand all
501 IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest, 529 IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest,
502 GetWifiTDLSStatus) { 530 GetWifiTDLSStatus) {
503 EXPECT_TRUE(RunNetworkingSubtest("getWifiTDLSStatus")) << message_; 531 EXPECT_TRUE(RunNetworkingSubtest("getWifiTDLSStatus")) << message_;
504 } 532 }
505 #endif 533 #endif
506 534
507 // NetworkPortalDetector is only enabled for Chrome OS. 535 // NetworkPortalDetector is only enabled for Chrome OS.
508 #if defined(OS_CHROMEOS) 536 #if defined(OS_CHROMEOS)
509 IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest, 537 IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest,
510 GetCaptivePortalStatus) { 538 GetCaptivePortalStatus) {
539 service_test_->AddService("stub_cellular1", "cellular1",
540 shill::kTypeCellular, shill::kStateIdle,
541 true /* add_to_visible */,
542 true /* add_to_watchlist */);
543 service_test_->SetServiceProperty(
544 "stub_cellular1",
545 shill::kNetworkTechnologyProperty,
546 base::StringValue(shill::kNetworkTechnologyGsm));
547 service_test_->SetServiceProperty(
548 "stub_cellular1",
549 shill::kActivationStateProperty,
550 base::StringValue(shill::kActivationStateNotActivated));
551 service_test_->SetServiceProperty(
552 "stub_cellular1",
553 shill::kRoamingStateProperty,
554 base::StringValue(shill::kRoamingStateHome));
555 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()->
556 SortManagerServices();
557 content::RunAllPendingInMessageLoop();
558
511 NetworkPortalDetector::CaptivePortalState state; 559 NetworkPortalDetector::CaptivePortalState state;
512 state.status = NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE; 560 state.status = NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE;
513 detector()->SetDetectionResultsForTesting("stub_ethernet", state); 561 detector()->SetDetectionResultsForTesting("stub_ethernet", state);
514 562
515 state.status = NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_OFFLINE; 563 state.status = NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_OFFLINE;
516 detector()->SetDetectionResultsForTesting("stub_wifi1", state); 564 detector()->SetDetectionResultsForTesting("stub_wifi1", state);
517 565
518 state.status = NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL; 566 state.status = NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL;
519 detector()->SetDetectionResultsForTesting("stub_wifi2", state); 567 detector()->SetDetectionResultsForTesting("stub_wifi2", state);
520 568
(...skipping 17 matching lines...) Expand all
538 base::Unretained(detector()))); 586 base::Unretained(detector())));
539 EXPECT_TRUE(RunNetworkingSubtest("captivePortalNotification")) << message_; 587 EXPECT_TRUE(RunNetworkingSubtest("captivePortalNotification")) << message_;
540 } 588 }
541 #endif // defined(OS_CHROMEOS) 589 #endif // defined(OS_CHROMEOS)
542 590
543 INSTANTIATE_TEST_CASE_P(ExtensionNetworkingPrivateApiTestInstantiation, 591 INSTANTIATE_TEST_CASE_P(ExtensionNetworkingPrivateApiTestInstantiation,
544 ExtensionNetworkingPrivateApiTest, 592 ExtensionNetworkingPrivateApiTest,
545 testing::Bool()); 593 testing::Bool());
546 594
547 } // namespace 595 } // namespace
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/networking/test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698