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

Side by Side Diff: chrome/browser/chromeos/extensions/networking_private_apitest.cc

Issue 12387065: Convert TrayVPN to use new NetworkState code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix browser_tests Created 7 years, 9 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 <stdio.h> 5 #include <stdio.h>
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "chrome/browser/extensions/extension_apitest.h" 8 #include "chrome/browser/extensions/extension_apitest.h"
9 #include "chrome/common/chrome_switches.h" 9 #include "chrome/common/chrome_switches.h"
10 #include "chrome/test/base/ui_test_utils.h" 10 #include "chrome/test/base/ui_test_utils.h"
11 #include "chromeos/dbus/dbus_thread_manager.h"
12 #include "chromeos/dbus/shill_device_client.h"
13 #include "chromeos/dbus/shill_service_client.h"
14 #include "third_party/cros_system_api/dbus/service_constants.h"
11 15
12 namespace chromeos { 16 namespace chromeos {
13 17
14 class ExtensionNetworkingPrivateApiTest : public ExtensionApiTest { 18 class ExtensionNetworkingPrivateApiTest : public ExtensionApiTest {
15 public: 19 public:
16 // Whitelist the extension ID of the test extension. 20 // Whitelist the extension ID of the test extension.
17 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 21 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
18 ExtensionApiTest::SetUpCommandLine(command_line); 22 ExtensionApiTest::SetUpCommandLine(command_line);
19 command_line->AppendSwitchASCII( 23 command_line->AppendSwitchASCII(
20 switches::kWhitelistedExtensionID, "epcifkihnkjgphfkloaaleeakhpmgdmn"); 24 switches::kWhitelistedExtensionID, "epcifkihnkjgphfkloaaleeakhpmgdmn");
21 } 25 }
22 26
23 bool RunNetworkingSubtest(const std::string& subtest) { 27 bool RunNetworkingSubtest(const std::string& subtest) {
24 return RunExtensionSubtest( 28 return RunExtensionSubtest(
25 "networking", "main.html?" + subtest, 29 "networking", "main.html?" + subtest,
26 kFlagEnableFileAccess | kFlagLoadAsComponent); 30 kFlagEnableFileAccess | kFlagLoadAsComponent);
27 } 31 }
32
33 virtual void SetUpOnMainThread() OVERRIDE {
34 ExtensionApiTest::SetUpOnMainThread();
35 content::RunAllPendingInMessageLoop();
36
37 ShillDeviceClient::TestInterface* device_test =
38 DBusThreadManager::Get()->GetShillDeviceClient()->GetTestInterface();
39 device_test->ClearDevices();
40 device_test->AddDevice("/device/stub_wifi_device1",
41 flimflam::kTypeWifi, "stub_wifi_device1");
42 device_test->AddDevice("/device/stub_cellular_device1",
43 flimflam::kTypeCellular, "stub_cellular_device1");
44
45 ShillServiceClient::TestInterface* service_test =
46 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface();
47 service_test->ClearServices();
48 const bool add_to_watchlist = true;
49 service_test->AddService("stub_ethernet",
50 "eth0",
51 flimflam::kTypeEthernet, flimflam::kStateOnline,
52 add_to_watchlist);
53 service_test->AddService("stub_wifi1",
54 "wifi1",
55 flimflam::kTypeWifi, flimflam::kStateOnline,
56 add_to_watchlist);
57 service_test->AddService("stub_wifi2",
58 "wifi2_PSK",
59 flimflam::kTypeWifi, flimflam::kStateIdle,
60 add_to_watchlist);
61 base::StringValue psk_value(flimflam::kSecurityPsk);
62 service_test->SetServiceProperty("stub_wifi2",
63 flimflam::kSecurityProperty,
64 psk_value);
65 base::FundamentalValue strength_value(80);
66 service_test->SetServiceProperty("stub_wifi2",
67 flimflam::kSignalStrengthProperty,
68 strength_value);
69 service_test->AddService("stub_cellular1",
70 "cellular1",
71 flimflam::kTypeCellular, flimflam::kStateIdle,
72 add_to_watchlist);
73 }
74
28 }; 75 };
29 76
30 // Place each subtest into a separate browser test so that the stub networking 77 // Place each subtest into a separate browser test so that the stub networking
31 // library state is reset for each subtest run. This way they won't affect each 78 // library state is reset for each subtest run. This way they won't affect each
32 // other. 79 // other.
33 80
34 IN_PROC_BROWSER_TEST_F(ExtensionNetworkingPrivateApiTest, StartConnect) { 81 IN_PROC_BROWSER_TEST_F(ExtensionNetworkingPrivateApiTest, StartConnect) {
35 EXPECT_TRUE(RunNetworkingSubtest("startConnect")) << message_; 82 EXPECT_TRUE(RunNetworkingSubtest("startConnect")) << message_;
36 } 83 }
37 84
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 EXPECT_TRUE(RunNetworkingSubtest("verifyAndEncryptCredentials")) << message_; 124 EXPECT_TRUE(RunNetworkingSubtest("verifyAndEncryptCredentials")) << message_;
78 } 125 }
79 126
80 IN_PROC_BROWSER_TEST_F(ExtensionNetworkingPrivateApiTest, 127 IN_PROC_BROWSER_TEST_F(ExtensionNetworkingPrivateApiTest,
81 VerifyAndEncryptData) { 128 VerifyAndEncryptData) {
82 EXPECT_TRUE(RunNetworkingSubtest("verifyAndEncryptData")) << message_; 129 EXPECT_TRUE(RunNetworkingSubtest("verifyAndEncryptData")) << message_;
83 } 130 }
84 131
85 132
86 } // namespace chromeos 133 } // namespace chromeos
OLDNEW
« no previous file with comments | « ash/system/chromeos/network/tray_vpn.cc ('k') | chrome/test/data/extensions/api_test/networking/test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698