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

Side by Side Diff: chrome/test/functional/chromeos_vpn.py

Issue 23359003: Eliminate unused PYAUTO tests and TestingAutomationProvider methods (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 3 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
OLDNEW
(Empty)
1 #!/usr/bin/env 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 os
7 import subprocess
8
9 import pyauto_functional
10 import pyauto
11 import chromeos_network
12
13
14 class PrivateNetworkTest(chromeos_network.PyNetworkUITest):
15 """Tests for VPN.
16
17 Expected to be run with access to the lab setup as defined in
18 vpn_testbed_config.
19 """
20
21 def _PingTest(self, hostname, timeout=10):
22 """Attempt to ping a remote host.
23
24 Returns:
25 True if the ping succeeds.
26 False otherwise.
27 """
28 return subprocess.call(['ping', '-c', '1', '-W',
29 str(timeout), hostname]) == 0
30
31 def testCanAddNetwork(self):
32 """Test to add a VPN network, connect and disconnect."""
33 # Load VPN config data from file.
34 vpn_info_file = os.path.join(pyauto.PyUITest.DataDir(),
35 'pyauto_private/chromeos/network',
36 'vpn_testbed_config')
37 self.assertTrue(os.path.exists(vpn_info_file))
38 vpn = self.EvalDataFrom(vpn_info_file)
39
40 # Connect to wifi.
41 self.NetworkScan()
42 self.WaitUntilWifiNetworkAvailable(vpn['wifi'])
43 wifi_vpn = self.GetServicePath(vpn['wifi'])
44 self.assertTrue(wifi_vpn)
45 self.assertTrue(self.ConnectToWifiNetwork(wifi_vpn) is None)
46 self.assertFalse(self._PingTest(vpn['ping']),
47 msg='VPN ping succeeded when not connected.')
48
49 # Connect to the VPN.
50 self.AddPrivateNetwork(hostname=vpn['hostname'],
51 service_name=vpn['service_name'],
52 provider_type=vpn['provider_type'],
53 username=vpn['username'],
54 password=vpn['password'],
55 key=vpn['key'])
56
57 # Get private network info.
58 result = self.GetPrivateNetworkInfo()
59 self.assertTrue('connected' in result, msg='Could not connect to VPN')
60 connected = result['connected']
61 self.assertTrue(self._PingTest(vpn['ping']), msg='VPN ping failed.')
62 self.DisconnectFromPrivateNetwork()
63 self.assertFalse(self._PingTest(vpn['ping']),
64 msg='VPN ping succeeded when not connected.')
65 # Connect to the remembered private network.
66 self.ConnectToPrivateNetwork(connected)
67 self.assertTrue(self._PingTest(vpn['ping']), msg='VPN ping failed.')
68 self.DisconnectFromPrivateNetwork()
69 self.assertFalse(self._PingTest(vpn['ping']),
70 msg='VPN ping succeeded when not connected.')
71
72
73 if __name__ == '__main__':
74 pyauto_functional.Main()
OLDNEW
« no previous file with comments | « chrome/test/functional/chromeos_txt_msg_functional.py ('k') | chrome/test/functional/chromeos_wifi_compliance.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698