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

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
stanleyw 2011/11/21 19:32:45 What do the function arguments mean?
deepakg 2011/11/21 23:49:44 Done.
68 The test calling this function will fail for one of these three reasons:
stanleyw 2011/11/21 19:32:45 extra space between will and fail
deepakg 2011/11/21 23:49:44 Done.
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 service_path = self.GetServicePath(network_ssid)
74 self.assertTrue(service_path is not None,
75 msg='Could not find a service path for the given ssid %s.' %
76 network_ssid)
77 network_available = False
78 for path in self.NetworkScan()['wifi_networks']:
79 if path == service_path:
80 network_available = True
stanleyw 2011/11/21 19:32:45 We can get rid of the network_available variable i
deepakg 2011/11/21 23:49:44 Thanks, didn't know this was possible.
81 self.assertTrue(
82 self.NetworkScan()['wifi_networks'][path]['status'] == status,
83 msg='Not connected to the network %s.' % network_ssid)
84 break;
85 self.assertTrue(network_available,
86 msg='Did not find the network %s in the wifi_networks'
87 ' list.' % network_ssid)
88
61 def testConnectShareEncryptedNetwork(self): 89 def testConnectShareEncryptedNetwork(self):
62 """A shared encrypted network can connect and is remembered. 90 """A shared encrypted network can connect and is remembered.
63 91
64 Note: This test does not verify that the network is added to the public 92 Note: This test does not verify that the network is added to the public
65 profile 93 profile
66 """ 94 """
67 router_name = 'D-Link_N150' 95 router_name = 'D-Link_N150'
68 self._LoginDevice() 96 self._LoginDevice()
69 router = self._SetupRouter(router_name) 97 router = self._SetupRouter(router_name)
70 error = self.ConnectToWifiRouter(router_name, shared=True) 98 error = self.ConnectToWifiRouter(router_name, shared=True)
(...skipping 18 matching lines...) Expand all
89 error = self.ConnectToWifiRouter(router_name, shared=False) 117 error = self.ConnectToWifiRouter(router_name, shared=False)
90 self.assertFalse(error, 'Failed to connect to wifi network %s. ' 118 self.assertFalse(error, 'Failed to connect to wifi network %s. '
91 'Reason: %s.' % (router['ssid'], error)) 119 'Reason: %s.' % (router['ssid'], error))
92 service_path = self.GetServicePath(router['ssid']) 120 service_path = self.GetServicePath(router['ssid'])
93 self.assertTrue(service_path in self.GetNetworkInfo()['remembered_wifi'], 121 self.assertTrue(service_path in self.GetNetworkInfo()['remembered_wifi'],
94 'Connected wifi was not added to the remembered list.') 122 'Connected wifi was not added to the remembered list.')
95 self.ForgetWifiNetwork(service_path) 123 self.ForgetWifiNetwork(service_path)
96 self.assertFalse(service_path in self.GetNetworkInfo()['remembered_wifi'], 124 self.assertFalse(service_path in self.GetNetworkInfo()['remembered_wifi'],
97 'Connected wifi was not removed from the remembered list.') 125 'Connected wifi was not removed from the remembered list.')
98 126
127 def testConnectToSharedOpenNetwork(self):
128 """Can connect to a shared open network.
129
130 Verify that the connected network is in the remembered network list
131 for all the users.
132 """
133 router_name = 'Trendnet_639gr_4'
134 self._LoginDevice()
135 router = self._SetupRouter(router_name)
136 error = self.ConnectToWifiRouter(router_name)
137 self.assertFalse(error, msg='Failed to connect to wifi network %s. '
138 'Reason: %s.' % (router['ssid'], error))
139 service_path = self.GetServicePath(router['ssid'])
140 self.assertTrue(service_path in self.GetNetworkInfo()['remembered_wifi'],
141 msg='Open wifi is not remembered for the current user.')
142 self.Logout()
143 self._LoginDevice(test_account='test_google_account_2')
144 self.assertTrue(service_path in self.NetworkScan()['remembered_wifi'],
145 msg='Open network is not shared with other users.')
146
147 def testConnectToSharedHiddenNetwork(self):
148 """Can connect to shared hidden network and verify that it's shared."""
149 router_name = "Netgear_WGR614"
150 self._LoginDevice()
151 router = self._SetupRouter(router_name)
152 error = self.ConnectToWifiRouter(router_name)
153 self.assertFalse(error, msg='Failed to connect to hidden network %s. '
154 'Reason: %s.' % (router['ssid'], error))
155 service_path = self.GetServicePath(router['ssid'])
156 self.assertTrue(service_path in self.NetworkScan()['remembered_wifi'],
157 msg='Hidden network is not added to the remembered list.')
158 self.Logout()
159 self._LoginDevice(test_account='test_google_account_2')
160 self.assertTrue(service_path in self.NetworkScan()['remembered_wifi'],
161 msg='Shared hidden network is not in other user\'s '
162 'remembered list.')
163
164 def testConnectToNonSharedHiddenNetwork(self):
165 """Can connect to a non-shared hidden network.
166
167 Verify that it is not shared with other users.
168 """
169 router_name = "Linksys_WRT54GL"
170 self._LoginDevice()
171 router = self._SetupRouter(router_name)
172 error = self.ConnectToWifiRouter(router_name, shared=False)
173 self.assertFalse(error, msg='Failed to connect to hidden network %s. '
174 'Reason: %s.' % (router['ssid'], error))
175 service_path = self.GetServicePath(router['ssid'])
176 self.assertTrue(service_path in self.NetworkScan()['remembered_wifi'],
177 msg='Hidden network is not added to the remembered list.')
178 self.Logout()
179 self._LoginDevice(test_account='test_google_account_2')
180 self.assertFalse(service_path in self.NetworkScan()['remembered_wifi'],
181 msg='Non-shared hidden network %s is shared.'
182 % router['ssid'])
183
184 def testConnectToEncryptedNetworkInLoginScreen(self):
185 """Can connect to encrypted network in login screen.
186
187 Verify that this network is in the remembered list after login.
188 """
189 router_name = 'Belkin_G'
stanleyw 2011/11/21 19:32:45 We should probably check that if we're logged in,
deepakg 2011/11/21 23:49:44 Done.
190 router = self._SetupRouter(router_name)
191 error = self.ConnectToWifiRouter(router_name)
192 self.assertFalse(error, 'Failed to connect to wifi network %s. '
193 'Reason: %s.' % (router['ssid'], error))
194 service_path = self.GetServicePath(router['ssid'])
195 self._VerifyIfConnectedToNetwork(router['ssid'], 'Connected')
196 self._LoginDevice()
197 self.assertTrue(service_path in self.NetworkScan()['remembered_wifi'],
198 msg='Network is not added to the remembered list.')
199
99 200
100 if __name__ == '__main__': 201 if __name__ == '__main__':
101 pyauto_functional.Main() 202 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