Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 result = sub.Popen('ifconfig | cut -d\' \' -f 1 | grep eth', | |
| 23 stdout=sub.PIPE, shell=True).communicate() | |
| 24 self.assertNotEqual(result[0], '', msg='Not connected to Ethernet.') | |
| 25 self._ethernet = result[0].rstrip() | |
| 26 | |
| 27 def setUp(self): | |
| 28 pyauto.PyUITest.setUp(self) | |
| 29 sub.call(['sudo', 'stop', 'cromo']) | |
| 30 self._GetEthernet() | |
| 31 sub.call(['sudo', '/bin/sh', '/usr/local/lib/flimflam/test/backchannel', | |
| 32 'setup', self._ethernet, 'pseudo-modem0']) | |
| 33 | |
| 34 def tearDown(self): | |
| 35 if self._ethernet: | |
| 36 sub.call(['sudo', '/bin/sh', '/usr/local/lib/flimflam/test/backchannel', | |
| 37 'teardown', self._ethernet, 'pseudo-modem0']) | |
| 38 pyauto.PyUITest.tearDown(self) | |
| 39 | |
| 40 def _IsFakeGSMRunning(self): | |
| 41 """Check if fake-gsm-modem is running. | |
| 42 | |
| 43 Returns: | |
| 44 True if fake-gsm-modem process is running and False if not. | |
|
dennis_jeffrey
2011/10/21 01:02:16
nit: indent this line by 1 fewer space (should onl
deepakg
2011/10/21 01:06:43
Done.
| |
| 45 """ | |
| 46 call = sub.Popen('ps -ef | grep fake-gsm-modem | grep -v grep', | |
|
dennis_jeffrey
2011/10/21 01:02:16
sorry, my previous comment where I said "change to
deepakg
2011/10/21 01:06:43
Done.
| |
| 47 shell=True, stdout=sub.PIPE).communicate() | |
| 48 return len(call[0].split('fake-gsm-modem')) > 0 | |
| 49 | |
| 50 def _VerifyBasicCarrierCompliance(self, carrier_name, cellular_name): | |
| 51 """Faking the specified carrier and checking the name. | |
| 52 | |
| 53 Args: | |
| 54 carrier_name: The name of the carrier. | |
| 55 cellular_name: The name in the icon of the cellular network. | |
|
dennis_jeffrey
2011/10/21 01:02:16
nit: indent the above 2 lines by 1 fewer space eac
deepakg
2011/10/21 01:06:43
Done.
| |
| 56 """ | |
| 57 fake_gsm = sub.Popen(['sudo', '/usr/bin/python', | |
| 58 '/usr/local/lib/flimflam/test/fake-gsm-modem', | |
| 59 '-c', carrier_name]) | |
| 60 # Wait for the fake GSM to connect. | |
| 61 cellular = 'cellular_networks' | |
| 62 self.assertTrue(self.WaitUntil(lambda: cellular in | |
| 63 self.NetworkScan().keys(), timeout=10, retry_sleep=1), | |
| 64 msg='Did not connect to any cellular network') | |
|
stanleyw
2011/10/21 01:21:16
"No cellular networks appeared on scan.". No conn
deepakg
2011/10/21 22:40:42
Done.
| |
| 65 network_info = self.NetworkScan()[cellular] | |
| 66 result = any([network_info[key]['name'] == cellular_name | |
| 67 for key in network_info.keys()]) | |
| 68 self.assertTrue(self._IsFakeGSMRunning(), msg='Fake GSM is not running.') | |
|
stanleyw
2011/10/21 01:21:16
This assertion should probably happen before we pe
deepakg
2011/10/21 22:40:42
Done.
| |
| 69 fake_gsm.terminate() | |
| 70 self.assertTrue(result, msg='Did not connect to cellular network %s.' | |
|
stanleyw
2011/10/21 01:21:16
We're testing if name displayed in the menu matche
deepakg
2011/10/21 22:40:42
Done.
| |
| 71 % cellular_name) | |
| 72 | |
| 73 def testConnectThree(self): | |
| 74 """Testing connection to Three.""" | |
| 75 self._VerifyBasicCarrierCompliance('three', '3') | |
| 76 | |
| 77 def testConnectSFR(self): | |
| 78 """Testing connection to SFR.""" | |
| 79 self._VerifyBasicCarrierCompliance('SFR', 'SFR') | |
| 80 | |
| 81 def testConnectKPN(self): | |
| 82 """Testing connection to KPN.""" | |
| 83 self._VerifyBasicCarrierCompliance('KPN', 'KPN NL') | |
| 84 | |
| 85 def testConnectSimyo(self): | |
| 86 """Testing connection to Simyo.""" | |
| 87 self._VerifyBasicCarrierCompliance('Simyo', 'E-Plus') | |
| 88 | |
| 89 def testConnectMovistar(self): | |
| 90 """Testing connection to Movistar.""" | |
| 91 self._VerifyBasicCarrierCompliance('Movistar', 'Movistar') | |
| 92 | |
| 93 def testConnectThreeita(self): | |
| 94 """Testing connection to threeita.""" | |
| 95 self._VerifyBasicCarrierCompliance('threeita', '3ITA') | |
| 96 | |
| 97 def testConnectAtt(self): | |
| 98 """Testing connection to att.""" | |
| 99 self._VerifyBasicCarrierCompliance('att', 'AT&T') | |
| 100 | |
| 101 def testConnectTmobile(self): | |
| 102 """Testing connection to Tmobile.""" | |
| 103 self._VerifyBasicCarrierCompliance('Tmobile', 'T-Mobile') | |
| 104 | |
| 105 | |
| 106 if __name__ == '__main__': | |
| 107 pyauto_functional.Main() | |
| OLD | NEW |