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

Side by Side Diff: functional/chromeos_wifi_functional.py

Issue 8586013: Added 4 new pyauto tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome/test/
Patch Set: '' Created 9 years, 1 month 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import os 6 import os
7 7
8 import pyauto_functional 8 import pyauto_functional
9 import chromeos_network # pyauto_functional must come before chromeos_network 9 import chromeos_network # pyauto_functional must come before chromeos_network
10 import pyauto_utils 10 import pyauto_utils
11 11
12 12
13 class ChromeosWifiFunctional(chromeos_network.PyNetworkUITest): 13 class ChromeosWifiFunctional(chromeos_network.PyNetworkUITest):
14 """Tests for ChromeOS wifi functionality. 14 """Tests for ChromeOS wifi functionality.
15 15
16 These tests should be run within vacinity of the power strip where the wifi 16 These tests should be run within vacinity of the power strip where the wifi
17 routers are attached. 17 routers are attached.
18 """ 18 """
19 19
20 def _LoginDevice(self): 20 def _LoginDevice(self, test_account='test_google_account'):
21 """Logs into the device and cleans up flimflam profile.""" 21 """Logs into the device and cleans up flimflam profile.
22
23 Args:
24 test_account: The account used to login to the device.
25 """
22 if not self.GetLoginInfo()['is_logged_in']: 26 if not self.GetLoginInfo()['is_logged_in']:
23 credentials = self.GetPrivateInfo()['test_google_account'] 27 credentials = self.GetPrivateInfo()[test_account]
24 self.Login(credentials['username'], credentials['password']) 28 self.Login(credentials['username'], credentials['password'])
25 login_info = self.GetLoginInfo() 29 login_info = self.GetLoginInfo()
26 self.assertTrue(login_info['is_logged_in'], msg='Login failed.') 30 self.assertTrue(login_info['is_logged_in'], msg='Login failed.')
27 31
28 ff_dir = '/home/chronos/user/flimflam' 32 ff_dir = '/home/chronos/user/flimflam'
29 self.assertTrue(os.path.isdir(ff_dir), 'User is logged in but user ' 33 self.assertTrue(os.path.isdir(ff_dir), 'User is logged in but user '
30 'flimflam profile is not present.') 34 'flimflam profile is not present.')
31 35
32 # Clean up the items in the flimflam profile directory. 36 # Clean up the items in the flimflam profile directory.
33 for item in os.listdir(ff_dir): 37 for item in os.listdir(ff_dir):
(...skipping 17 matching lines...) Expand all
51 self.InitWifiPowerStrip() 55 self.InitWifiPowerStrip()
52 router = self.GetRouterConfig(router_name) 56 router = self.GetRouterConfig(router_name)
53 self.RouterPower(router_name, True) 57 self.RouterPower(router_name, True)
54 58
55 # When we connect to a wifi service, it should be added to the 59 # When we connect to a wifi service, it should be added to the
56 # remembered_wifi list. 60 # remembered_wifi list.
57 self.WaitUntilWifiNetworkAvailable(router['ssid'], 61 self.WaitUntilWifiNetworkAvailable(router['ssid'],
58 is_hidden=router.get('hidden')) 62 is_hidden=router.get('hidden'))
59 return router 63 return router
60 64
65 def _VerifyIfConnectedToNetwork(self, network_ssid, status='Online state'):
66 """Verify if we are connected to the network.
67
68 The test calling this function will fail for one of these three reasons:
69 1. The server path for the SSID is not found.
70 2. If we are not connected to the network.
71 3. If we did not find the network in the wifi_networks list.
72
73 Args:
74 newtork_ssid: The network to which we are supposed to be connected to.
75 status: The status that we expect the network to have, by default it
76 would be 'Online state'.
77 """
78 service_path = self.GetServicePath(network_ssid)
79 self.assertTrue(service_path is not None,
80 msg='Could not find a service path for the given ssid %s.' %
81 network_ssid)
82 wifi_network = self.NetworkScan()['wifi_networks']
83 for path in wifi_network:
84 if path == service_path:
85 self.assertTrue(
86 wifi_network[path]['status'] == status,
87 msg='Unexpected network status %s, Network %s should have'
dennis_jeffrey 2011/11/22 01:52:35 add a space right after 'have' near the end of thi
88 'status %s.' % (wifi_network[path]['status'],
89 network_ssid, status))
90 break;
91 else:
92 self.fail(msg='Did not find the network %s in the '
93 'wifi_networks list.' % network_ssid)
94
61 def testConnectShareEncryptedNetwork(self): 95 def testConnectShareEncryptedNetwork(self):
62 """A shared encrypted network can connect and is remembered. 96 """A shared encrypted network can connect and is remembered.
63 97
64 Note: This test does not verify that the network is added to the public 98 Note: This test does not verify that the network is added to the public
65 profile 99 profile
66 """ 100 """
67 router_name = 'D-Link_N150' 101 router_name = 'D-Link_N150'
68 self._LoginDevice() 102 self._LoginDevice()
69 router = self._SetupRouter(router_name) 103 router = self._SetupRouter(router_name)
70 error = self.ConnectToWifiRouter(router_name, shared=True) 104 error = self.ConnectToWifiRouter(router_name, shared=True)
(...skipping 18 matching lines...) Expand all
89 error = self.ConnectToWifiRouter(router_name, shared=False) 123 error = self.ConnectToWifiRouter(router_name, shared=False)
90 self.assertFalse(error, 'Failed to connect to wifi network %s. ' 124 self.assertFalse(error, 'Failed to connect to wifi network %s. '
91 'Reason: %s.' % (router['ssid'], error)) 125 'Reason: %s.' % (router['ssid'], error))
92 service_path = self.GetServicePath(router['ssid']) 126 service_path = self.GetServicePath(router['ssid'])
93 self.assertTrue(service_path in self.GetNetworkInfo()['remembered_wifi'], 127 self.assertTrue(service_path in self.GetNetworkInfo()['remembered_wifi'],
94 'Connected wifi was not added to the remembered list.') 128 'Connected wifi was not added to the remembered list.')
95 self.ForgetWifiNetwork(service_path) 129 self.ForgetWifiNetwork(service_path)
96 self.assertFalse(service_path in self.GetNetworkInfo()['remembered_wifi'], 130 self.assertFalse(service_path in self.GetNetworkInfo()['remembered_wifi'],
97 'Connected wifi was not removed from the remembered list.') 131 'Connected wifi was not removed from the remembered list.')
98 132
133 def testConnectToSharedOpenNetwork(self):
134 """Can connect to a shared open network.
135
136 Verify that the connected network is in the remembered network list
137 for all the users.
138 """
139 router_name = 'Trendnet_639gr_4'
140 self._LoginDevice()
141 router = self._SetupRouter(router_name)
142 error = self.ConnectToWifiRouter(router_name)
143 self.assertFalse(error, msg='Failed to connect to wifi network %s. '
144 'Reason: %s.' % (router['ssid'], error))
145 service_path = self.GetServicePath(router['ssid'])
146 self.assertTrue(service_path in self.GetNetworkInfo()['remembered_wifi'],
147 msg='Open wifi is not remembered for the current user.')
148 self.Logout()
149 self._LoginDevice(test_account='test_google_account_2')
150 self.assertTrue(service_path in self.NetworkScan()['remembered_wifi'],
151 msg='Open network is not shared with other users.')
152
153 def testConnectToSharedHiddenNetwork(self):
154 """Can connect to shared hidden network and verify that it's shared."""
155 router_name = 'Netgear_WGR614'
156 self._LoginDevice()
157 router = self._SetupRouter(router_name)
158 error = self.ConnectToWifiRouter(router_name)
159 self.assertFalse(error, msg='Failed to connect to hidden network %s. '
160 'Reason: %s.' % (router['ssid'], error))
161 service_path = self.GetServicePath(router['ssid'])
162 self.assertTrue(service_path in self.NetworkScan()['remembered_wifi'],
163 msg='Hidden network is not added to the remembered list.')
164 self.Logout()
165 self._LoginDevice(test_account='test_google_account_2')
166 self.assertTrue(service_path in self.NetworkScan()['remembered_wifi'],
167 msg='Shared hidden network is not in other user\'s '
168 'remembered list.')
169
170 def testConnectToNonSharedHiddenNetwork(self):
171 """Can connect to a non-shared hidden network.
172
173 Verify that it is not shared with other users.
174 """
175 router_name = 'Linksys_WRT54GL'
176 self._LoginDevice()
177 router = self._SetupRouter(router_name)
178 error = self.ConnectToWifiRouter(router_name, shared=False)
179 self.assertFalse(error, msg='Failed to connect to hidden network %s. '
180 'Reason: %s.' % (router['ssid'], error))
181 service_path = self.GetServicePath(router['ssid'])
182 self.assertTrue(service_path in self.NetworkScan()['remembered_wifi'],
183 msg='Hidden network is not added to the remembered list.')
184 self.Logout()
185 self._LoginDevice(test_account='test_google_account_2')
186 self.assertFalse(service_path in self.NetworkScan()['remembered_wifi'],
187 msg='Non-shared hidden network %s is shared.'
188 % router['ssid'])
189
190 def testConnectToEncryptedNetworkInLoginScreen(self):
191 """Can connect to encrypted network in login screen.
192
193 Verify that this network is in the remembered list after login.
194 """
195 router_name = 'Belkin_G'
196 if self.GetLoginInfo()['is_logged_in']:
197 self.Logout()
198 router = self._SetupRouter(router_name)
199 error = self.ConnectToWifiRouter(router_name)
200 self.assertFalse(error, 'Failed to connect to wifi network %s. '
201 'Reason: %s.' % (router['ssid'], error))
202 service_path = self.GetServicePath(router['ssid'])
203 self._VerifyIfConnectedToNetwork(router['ssid'], 'Connected')
204 self._LoginDevice()
205 self.assertTrue(service_path in self.NetworkScan()['remembered_wifi'],
206 msg='Network is not added to the remembered list.')
207
99 208
100 if __name__ == '__main__': 209 if __name__ == '__main__':
101 pyauto_functional.Main() 210 pyauto_functional.Main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698