1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
7 import ap_configurator_factory
8 import dlink_ap_configurator
9 import linksys_ap_configurator
11 import pyauto_ap_configurator # must preceed pyauto
15 class ConfiguratorTest(pyauto.PyUITest):
16 """This test needs to be run against the UI interface.
18 The purpose of this test is to act as a basic acceptance test when developing
19 a new AP configurator class. Use this to make sure all core functionality is
22 This test does not verify that everything works.
27 pyauto.PyUITest.setUp(self)
28 factory = ap_configurator_factory.APConfiguratorFactory(self)
29 # Set self.ap to the one you want to test against.
30 self.ap = factory.GetAPConfiguratorByShortName('DAP-1522')
32 def testMakeNoChanges(self):
33 """Test saving with no changes doesn't throw an error."""
34 # Set to a known state.
35 self.ap.SetRadio(True)
36 self.ap.ApplySettings()
37 # Set the same setting again.
38 self.ap.SetRadio(True)
39 self.ap.ApplySettings()
42 """Test we can adjust the radio setting."""
43 self.ap.SetRadio(True)
44 self.ap.ApplySettings()
45 self.ap.SetRadio(False)
46 self.ap.ApplySettings()
48 def testChannel(self):
49 """Test adjusting the channel."""
51 self.ap.ApplySettings()
53 def testVisibility(self):
54 """Test adjusting the visibility."""
55 self.ap.SetVisibility(False)
56 self.ap.ApplySettings()
57 self.ap.SetVisibility(True)
58 self.ap.ApplySettings()
61 """Test setting the SSID."""
62 self.ap.SetSSID('AP-automated-ssid')
63 self.ap.ApplySettings()
65 def testSecurityWEP(self):
66 """Test configuring WEP security."""
67 self.ap.SetSecurityWEP('45678', self.ap.wep_authentication_open)
68 self.ap.ApplySettings()
69 self.ap.SetSecurityWEP('90123', self.ap.wep_authentication_shared)
70 self.ap.ApplySettings()
72 def testPrioritySets(self):
73 """Test that commands are run in the right priority."""
74 self.ap.SetRadio(False)
75 self.ap.SetVisibility(True)
76 self.ap.SetSSID('priority_test')
77 self.ap.ApplySettings()
79 def testSecurityAndGeneralSettings(self):
80 """Test updating settings that are general and security related."""
81 self.ap.SetRadio(False)
82 self.ap.SetVisibility(True)
83 self.ap.SetSecurityWEP('88888', self.ap.wep_authentication_open)
84 self.ap.SetSSID('sec&gen_test')
85 self.ap.ApplySettings()
88 """Tests switching modes."""
89 modes_info = self.ap.GetSupportedModes()
90 self.assertFalse(not modes_info,
91 msg='Returned an invalid mode list. Is this method'
93 for band_modes in modes_info:
94 for mode in band_modes['modes']:
96 self.ap.ApplySettings()
98 def testModesWithBand(self):
99 """Tests switching modes that support adjusting the band."""
100 # Check if we support self.kModeN across multiple bands
101 modes_info = self.ap.GetSupportedModes()
103 for band_modes in modes_info:
104 if self.ap.mode_n in band_modes['modes']:
105 n_bands.append(band_modes['band'])
107 for n_band in n_bands:
108 self.ap.SetMode(self.ap.mode_n, band=n_band)
109 self.ap.ApplySettings()
111 def testFastCycleSecurity(self):
112 """Mini stress for changing security settings rapidly."""
113 self.ap.SetRadio(True)
114 self.ap.SetSecurityWEP('77777', self.ap.wep_authentication_open)
115 self.ap.SetSecurityDisabled()
116 self.ap.SetSecurityWPAPSK('qwertyuiolkjhgfsdfg')
117 self.ap.ApplySettings()
119 def testCycleSecurity(self):
120 """Test switching between different security settings."""
121 self.ap.SetRadio(True)
122 self.ap.SetSecurityWEP('77777', self.ap.wep_authentication_open)
123 self.ap.ApplySettings()
124 self.ap.SetSecurityDisabled()
125 self.ap.ApplySettings()
126 self.ap.SetSecurityWPAPSK('qwertyuiolkjhgfsdfg')
127 self.ap.ApplySettings()
129 def testActionsWhenRadioDisabled(self):
130 """Test making changes when the radio is diabled."""
131 self.ap.SetRadio(False)
132 self.ap.ApplySettings()
133 self.ap.SetSecurityWEP('77777', self.ap.wep_authentication_open)
134 self.ap.SetRadio(False)
135 self.ap.ApplySettings()
138 if __name__ == '__main__':
139 pyauto_ap_configurator.Main()