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.
6 import pyauto_functional
7 import chromeos_network
# pyauto_functional must come before chromeos_network
10 class ChromeosWifiCompliance(chromeos_network
.PyNetworkUITest
):
11 """Tests for ChromeOS wifi complaince.
13 These tests should be run within vacinity of the power strip where the wifi
17 def _BasicConnectRouterCompliance(self
, router_name
):
18 """Generic basic test routine for connecting to a router.
21 router_name: The name of the router.
23 self
.InitWifiPowerStrip()
24 router
= self
.GetRouterConfig(router_name
)
25 self
.RouterPower(router_name
, True)
27 # If the wifi network is expected to be invisible, the following
28 # line should timeout which is expected.
29 wifi_visible
= self
.WaitUntilWifiNetworkAvailable(router
['ssid'],
30 is_hidden
=router
.get('hidden'))
32 # Note, we expect wifi_visible and 'hidden' status to be opposites.
33 # The test fails if the network visibility is not as expected.
34 if wifi_visible
== router
.get('hidden', False):
35 self
.fail('We expected wifi network "%s" to be %s, but it was not.' %
37 {True: 'hidden', False: 'visible'}[router
.get('hidden',
40 # Verify connect did not have any errors.
41 error
= self
.ConnectToWifiRouter(router_name
)
42 self
.assertFalse(error
, 'Failed to connect to wifi network %s. '
43 'Reason: %s.' % (router
['ssid'], error
))
45 # Verify the network we connected to.
46 ssid
= self
.GetConnectedWifi()
47 self
.assertEqual(ssid
, router
['ssid'],
48 'Did not successfully connect to wifi network %s.' % ssid
)
50 self
.DisconnectFromWifiNetwork()
52 def testConnectBelkinG(self
):
53 """Test connecting to the Belkin G router."""
54 self
._BasicConnectRouterCompliance
('Belkin_G')
56 def testConnectBelkinNPlus(self
):
57 """Test connecting to the Belkin N+ router."""
58 self
._BasicConnectRouterCompliance
('Belkin_N+')
60 def testConnectDLinkN150(self
):
61 """Test connecting to the D-Link N150 router."""
62 self
._BasicConnectRouterCompliance
('D-Link_N150')
64 def testConnectLinksysE3000(self
):
65 """Test connecting to the Linksys E3000 router.
67 The LinksysE3000 supports broadcasting of up to 2 SSID's.
68 This test will try connecting to each of them one at a time.
70 self
._BasicConnectRouterCompliance
('LinksysE3000')
71 self
._BasicConnectRouterCompliance
('LinksysE3000_2')
73 def testConnectLinksysWRT54G2(self
):
74 """Test connecting to the Linksys WRT54G2 router."""
75 self
._BasicConnectRouterCompliance
('Linksys_WRT54G2')
77 def testConnectLinksysWRT54GL(self
):
78 """Test connecting to the LinksysWRT54GL router."""
79 self
._BasicConnectRouterCompliance
('Linksys_WRT54GL')
81 def testConnectNetgearN300(self
):
82 """Test connecting to the Netgear N300 router."""
83 self
._BasicConnectRouterCompliance
('Netgear_N300')
85 def testConnectNetgearWGR614(self
):
86 """Test connecting to the Netgear WGR 614 router."""
87 self
._BasicConnectRouterCompliance
('Netgear_WGR614')
89 def testConnectNfiniti(self
):
90 """Test connecting to the Nfiniti router."""
91 self
._BasicConnectRouterCompliance
('Nfiniti')
93 def testConnectSMCWBR145(self
):
94 """Test connecting to the SMC WBR 145 router."""
95 self
._BasicConnectRouterCompliance
('SMC_WBR145')
97 def testConnectTrendnet_639gr(self
):
98 """Test connecting to the Trendnet 639gr router.
100 The LinksysE3000 supports broadcasting of up to 4 SSID's.
101 This test will try connecting to each of them one at a time.
103 self
._BasicConnectRouterCompliance
('Trendnet_639gr')
104 self
._BasicConnectRouterCompliance
('Trendnet_639gr_2')
105 self
._BasicConnectRouterCompliance
('Trendnet_639gr_3')
106 self
._BasicConnectRouterCompliance
('Trendnet_639gr_4')
109 if __name__
== '__main__':
110 pyauto_functional
.Main()