summaryrefslogtreecommitdiffstats
path: root/chrome/test/functional/chromeos_wifi_compliance.py
blob: edeb629ed7c412eed45a977937afa3f65e654236 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/usr/bin/python
# Copyright (c) 2011 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import pyauto_functional
import chromeos_network  # pyauto_functional must come before chromeos_network


class ChromeosWifiCompliance(chromeos_network.PyNetworkUITest):
  """Tests for ChromeOS wifi complaince.

  These tests should be run within vacinity of the power strip where the wifi
  routers are attached.
  """

  def _BasicConnectRouterCompliance(self, router_name):
    """Generic basic test routine for connecting to a router.

    Args:
      router_name: The name of the router.
    """
    self.InitWifiPowerStrip()
    router = self.GetRouterConfig(router_name)
    self.RouterPower(router_name, True)

    # If the wifi network is expected to be invisible, the following
    # line should timeout which is expected.
    wifi_visible = self.WaitUntilWifiNetworkAvailable(router['ssid'],
                                                 is_hidden=router.get('hidden'))

    # Note, we expect wifi_visible and 'hidden' status to be opposites.
    # The test fails if the network visibility is not as expected.
    if wifi_visible == router.get('hidden', False):
      self.fail('We expected wifi network "%s" to be %s, but it was not.' %
                (router['ssid'],
                 {True: 'hidden', False: 'visible'}[router.get('hidden',
                 False)]))

    # Verify connect did not have any errors.
    error = self.ConnectToWifiRouter(router_name)
    self.assertFalse(error, 'Failed to connect to wifi network %s. '
                            'Reason: %s.' % (router['ssid'], error))

    # Verify the network we connected to.
    ssid = self.GetConnectedWifi()
    self.assertEqual(ssid, router['ssid'],
                     'Did not successfully connect to wifi network %s.' % ssid)

    self.DisconnectFromWifiNetwork()

  def testConnectBelkinG(self):
    """Test connecting to the Belkin G router."""
    self._BasicConnectRouterCompliance('Belkin_G')

  def testConnectBelkinNPlus(self):
    """Test connecting to the Belkin N+ router."""
    self._BasicConnectRouterCompliance('Belkin_N+')

  def testConnectDLinkN150(self):
    """Test connecting to the D-Link N150 router."""
    self._BasicConnectRouterCompliance('D-Link_N150')

  def testConnectLinksysE3000(self):
    """Test connecting to the Linksys E3000 router.

    The LinksysE3000 supports broadcasting of up to 2 SSID's.
    This test will try connecting to each of them one at a time.
    """
    self._BasicConnectRouterCompliance('LinksysE3000')
    self._BasicConnectRouterCompliance('LinksysE3000_2')

  def testConnectLinksysWRT54G2(self):
    """Test connecting to the Linksys WRT54G2 router."""
    self._BasicConnectRouterCompliance('Linksys_WRT54G2')

  def testConnectLinksysWRT54GL(self):
    """Test connecting to the LinksysWRT54GL router."""
    self._BasicConnectRouterCompliance('Linksys_WRT54GL')

  def testConnectNetgearN300(self):
    """Test connecting to the Netgear N300 router."""
    self._BasicConnectRouterCompliance('Netgear_N300')

  def testConnectNetgearWGR614(self):
    """Test connecting to the Netgear WGR 614 router."""
    self._BasicConnectRouterCompliance('Netgear_WGR614')

  def testConnectNfiniti(self):
    """Test connecting to the Nfiniti router."""
    self._BasicConnectRouterCompliance('Nfiniti')

  def testConnectSMCWBR145(self):
    """Test connecting to the SMC WBR 145 router."""
    self._BasicConnectRouterCompliance('SMC_WBR145')

  def testConnectTrendnet_639gr(self):
    """Test connecting to the Trendnet 639gr router.

    The LinksysE3000 supports broadcasting of up to 4 SSID's.
    This test will try connecting to each of them one at a time.
    """
    self._BasicConnectRouterCompliance('Trendnet_639gr')
    self._BasicConnectRouterCompliance('Trendnet_639gr_2')
    self._BasicConnectRouterCompliance('Trendnet_639gr_3')
    self._BasicConnectRouterCompliance('Trendnet_639gr_4')


if __name__ == '__main__':
  pyauto_functional.Main()