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

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 re
stanleyw 2011/10/18 01:24:47 re does not appear to be used so I think we can re
deepakg 2011/10/20 23:20:57 Done.
7 import subprocess as sub
8
9 import pyauto_functional # Must be imported before pyauto
10 import pyauto
11
12
13 class ChromeosGSMCompliance(pyauto.PyUITest):
14 """Tests for ChromeOS GSM compliance.
15
16 Fakes connection to a network and verifies that the network name is correct.
17 """
18
19 _ethernet = None
20
21 def _GetEthernet(self):
22 """Get the ethernet to which the device is connected."""
23 process = sub.Popen('ifconfig | cut -d\' \' -f 1 | grep eth',
24 stdout=sub.PIPE, shell=True).communicate()
25 self.assertNotEqual(process[0], '', msg='Not connected to Ethernet.')
26 self._ethernet = process[0].rstrip()
27
28 def setUp(self):
29 pyauto.PyUITest.setUp(self)
30 sub.call(['sudo', 'stop', 'cromo'])
31 _ethernet = self._GetEthernet()
stanleyw 2011/10/18 01:24:47 GetEthernet returns nothing. You don't need _ether
deepakg 2011/10/20 23:20:57 Done.
32 if self._ethernet:
33 sub.call(['sudo', '/bin/sh', '/usr/local/lib/flimflam/test/backchannel',
34 'setup', self._ethernet, 'pseudo-modem0'])
35 else:
36 # If there is no eth check if we have pseudo-modem0.
37 process = sub.Popen('ifconfig | cut -d\' \' -f 1 | grep pseudo',
38 stdout=sub.PIPE, shell=True).communicate()
39 self.assertNotEqual(process[0].rstrip(), 'pseudo-modem0',
40 msg='Could not setup a pseudo-modem')
41
42 def tearDown(self):
43 if self._ethernet:
44 sub.call(['sudo', '/bin/sh', '/usr/local/lib/flimflam/test/backchannel',
45 'teardown', self._ethernet, 'pseudo-modem0'])
46 pyauto.PyUITest.tearDown(self)
47
48 def _CheckFakeGSM(self):
49 """Check if fake-gsm-modem is running."""
50 ps = sub.Popen('ps -ef | grep fake-gsm-modem | grep -v grep',
51 shell=True, stdout=sub.PIPE).stdout.read()
52 if len(ps.split('fake-gsm-modem')) > 0:
53 return True
54 return False
55
56 def _VerifyBasicCarrierCompliance(self, carrier_name, cellular_name):
57 """Faking the specified carrier and checking the name.
58
59 Args:
60 carrier_name: The name of the carrier.
61 cellular_name: The name in the icon of the cellular network.
62 """
63 fake_gsm = sub.Popen(['sudo', '/usr/bin/python',
64 '/usr/local/lib/flimflam/test/fake-gsm-modem',
65 '-c', carrier_name])
66 result = False
67 try:
68 for counter in range(10): # Wait for the fake GSM to connect.
stanleyw 2011/10/18 01:24:47 We have a subroutine for this in pyauto.py. It's
deepakg 2011/10/20 23:20:57 Done.
69 if self._CheckFakeGSM():
70 for network in self.NetworkScan().keys():
71 if network == 'cellular_networks':
72 network_info = self.NetworkScan()[network]
73 for key in network_info.keys():
74 if network_info[key]['name'] == cellular_name:
75 result = True
76 raise StopIteration()
77 except StopIteration:
78 pass
79
80 self.assertTrue(self._CheckFakeGSM(), msg='Fake GSM is not running.')
81 fake_gsm.terminate()
82 self.assertTrue(result, msg='Did not connect to cellular network %s.'
83 % cellular_name)
84
85 def testConnectThree(self):
86 """Testing connection to Three."""
87 self._VerifyBasicCarrierCompliance('three', '3')
88
89 def testConnectSFR(self):
90 """Testing connection to SFR."""
91 self._VerifyBasicCarrierCompliance('SFR', 'SFR')
92
93 def testConnectKPN(self):
94 """Testing connection to KPN."""
95 self._VerifyBasicCarrierCompliance('KPN', 'KPN NL')
96
97 def testConnectSimyo(self):
98 """Testing connection to Simyo."""
99 self._VerifyBasicCarrierCompliance('Simyo', 'E-Plus')
100
101 def testConnectMovistar(self):
102 """Testing connection to Movistar."""
103 self._VerifyBasicCarrierCompliance('Movistar', 'Movistar')
104
105 def testConnectThreeita(self):
106 """Testing connection to threeita."""
107 self._VerifyBasicCarrierCompliance('threeita', '3ITA')
108
109 def testConnectAtt(self):
110 """Testing connection to att."""
111 self._VerifyBasicCarrierCompliance('att', 'AT&T')
112
113 def testConnectTmobile(self):
114 """Testing connection to Tmobile."""
115 self._VerifyBasicCarrierCompliance('Tmobile', 'T-Mobile')
116
117
118 if __name__ == '__main__':
119 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