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

Side by Side Diff: functional/chromeos_gsm_compliance.py

Issue 8198024: Tests for GSM compliance. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome/test/
Patch Set: '' Created 9 years, 2 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 | 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
(Empty)
1 #!/usr/bin/python
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
4 # found in the LICENSE file.
5
6 import subprocess as sub
7
8 import pyauto_functional # Must be imported before pyauto
9 import pyauto
10
11
12 class ChromeosGSMCompliance(pyauto.PyUITest):
13 """Tests for ChromeOS GSM compliance.
14
15 Fakes connection to a network and verifies that the network name is correct.
16 """
17
18 _ethernet = None
19
20 def _GetEthernet(self):
21 """Get the ethernet to which the device is connected."""
22 process = sub.Popen('ifconfig | cut -d\' \' -f 1 | grep eth',
dennis_jeffrey 2011/10/20 23:49:14 nit: maybe change the variable name "process" to s
deepakg 2011/10/21 00:31:55 Done.
23 stdout=sub.PIPE, shell=True).communicate()
24 self.assertNotEqual(process[0], '', msg='Not connected to Ethernet.')
25 self._ethernet = process[0].rstrip()
26
27 def setUp(self):
28 pyauto.PyUITest.setUp(self)
29 sub.call(['sudo', 'stop', 'cromo'])
30 self._GetEthernet()
31 if self._ethernet:
32 sub.call(['sudo', '/bin/sh', '/usr/local/lib/flimflam/test/backchannel',
33 'setup', self._ethernet, 'pseudo-modem0'])
34 else:
dennis_jeffrey 2011/10/20 23:49:14 Will we ever enter the "else" case? Because at li
deepakg 2011/10/21 00:31:55 Done.
35 # If there is no eth check if we have pseudo-modem0.
dennis_jeffrey 2011/10/20 23:49:14 nit: 'eth' --> 'ethernet'
deepakg 2011/10/21 00:31:55 This part is removed.
36 process = sub.Popen('ifconfig | cut -d\' \' -f 1 | grep pseudo',
dennis_jeffrey 2011/10/20 23:49:14 Similar comment as line 22 above.
deepakg 2011/10/21 00:31:55 This part is removed.
37 stdout=sub.PIPE, shell=True).communicate()
38 self.assertNotEqual(process[0].rstrip(), 'pseudo-modem0',
39 msg='Could not setup a pseudo-modem')
40
41 def tearDown(self):
42 if self._ethernet:
43 sub.call(['sudo', '/bin/sh', '/usr/local/lib/flimflam/test/backchannel',
44 'teardown', self._ethernet, 'pseudo-modem0'])
45 pyauto.PyUITest.tearDown(self)
46
47 def _CheckFakeGSM(self):
dennis_jeffrey 2011/10/20 23:49:14 Maybe this function name is more descriptive: _Is
deepakg 2011/10/21 00:31:55 Done.
48 """Check if fake-gsm-modem is running."""
dennis_jeffrey 2011/10/20 23:49:14 Add a "Returns:" section to this docstring, since
deepakg 2011/10/21 00:31:55 Done.
49 ps = sub.Popen('ps -ef | grep fake-gsm-modem | grep -v grep',
dennis_jeffrey 2011/10/20 23:49:14 change to call?
deepakg 2011/10/21 00:31:55 Done.
50 shell=True, stdout=sub.PIPE).stdout.read()
dennis_jeffrey 2011/10/20 23:49:14 Does calling ".stdout.read()" here ensure that the
deepakg 2011/10/21 00:31:55 Done.
51 if len(ps.split('fake-gsm-modem')) > 0:
52 return True
53 return False
dennis_jeffrey 2011/10/20 23:49:14 I think it'll be have the same if we replace lines
deepakg 2011/10/21 00:31:55 Done.
54
55 def _VerifyBasicCarrierCompliance(self, carrier_name, cellular_name):
56 """Faking the specified carrier and checking the name.
57
58 Args:
59 carrier_name: The name of the carrier.
60 cellular_name: The name in the icon of the cellular network.
61 """
62 fake_gsm = sub.Popen(['sudo', '/usr/bin/python',
63 '/usr/local/lib/flimflam/test/fake-gsm-modem',
64 '-c', carrier_name])
65 result = False
66 # Wait for the fake GSM to connect.
67 cellular = 'cellular_networks'
68 self.WaitUntil(lambda:cellular in self.NetworkScan().keys(),
dennis_jeffrey 2011/10/20 23:49:14 nit: add a space right after the ':'
dennis_jeffrey 2011/10/20 23:49:14 The WaitUntil function will return False if the th
deepakg 2011/10/21 00:31:55 Done.
69 timeout=10, retry_sleep=1)
70 network_info = self.NetworkScan()[cellular]
71 for key in network_info.keys():
72 if network_info[key]['name'] == cellular_name:
73 result = True
74 break
dennis_jeffrey 2011/10/20 23:49:14 I think can replace lines 71-74 with this: result
deepakg 2011/10/21 00:31:55 Done. Thanks, I didn't know about any().
75
76 self.assertTrue(self._CheckFakeGSM(), msg='Fake GSM is not running.')
77 fake_gsm.terminate()
78 self.assertTrue(result, msg='Did not connect to cellular network %s.'
79 % cellular_name)
80
81 def testConnectThree(self):
82 """Testing connection to Three."""
83 self._VerifyBasicCarrierCompliance('three', '3')
84
85 def testConnectSFR(self):
86 """Testing connection to SFR."""
87 self._VerifyBasicCarrierCompliance('SFR', 'SFR')
88
89 def testConnectKPN(self):
90 """Testing connection to KPN."""
91 self._VerifyBasicCarrierCompliance('KPN', 'KPN NL')
92
93 def testConnectSimyo(self):
94 """Testing connection to Simyo."""
95 self._VerifyBasicCarrierCompliance('Simyo', 'E-Plus')
96
97 def testConnectMovistar(self):
98 """Testing connection to Movistar."""
99 self._VerifyBasicCarrierCompliance('Movistar', 'Movistar')
100
101 def testConnectThreeita(self):
102 """Testing connection to threeita."""
103 self._VerifyBasicCarrierCompliance('threeita', '3ITA')
104
105 def testConnectAtt(self):
106 """Testing connection to att."""
107 self._VerifyBasicCarrierCompliance('att', 'AT&T')
108
109 def testConnectTmobile(self):
110 """Testing connection to Tmobile."""
111 self._VerifyBasicCarrierCompliance('Tmobile', 'T-Mobile')
112
113
114 if __name__ == '__main__':
115 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