OLD | NEW |
| (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 re | |
7 | |
8 import pyauto_functional | |
9 import chromeos_network # pyauto_functional must come before chromeos_network | |
10 | |
11 | |
12 class WifiNotification(chromeos_network.PyNetworkUITest): | |
13 """Test for ChromeOS wifi Network Disconnected Notification. | |
14 | |
15 These tests will be testing Network Disconnected Notification on | |
16 various network encryptions (WEP,RSN, WPA) and various password lengths. | |
17 """ | |
18 | |
19 password1 = 'wrongpasswor' | |
20 password5 = 'tente' | |
21 password10 = 'tententent' | |
22 password13 = 'thirteenthirt' | |
23 password26 = 'twentysixtwentysixtwentysi' | |
24 password64 = \ | |
25 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl' | |
26 | |
27 def _WifiNotification(self, router_name, password): | |
28 """Basic test for wifi notification. | |
29 | |
30 Args: | |
31 router_name: The name of the router. | |
32 password: invalid password. | |
33 """ | |
34 self.InitWifiPowerStrip() | |
35 router_config = self.GetRouterConfig(router_name) | |
36 self.RouterPower(router_name, True) | |
37 | |
38 self.assertTrue(self.WaitUntilWifiNetworkAvailable(router_config['ssid']), | |
39 'Wifi network %s never showed up.' % router_config['ssid']) | |
40 | |
41 service_path = self.GetServicePath(router_config['ssid']) | |
42 self.ConnectToWifiNetwork(service_path, password=password) | |
43 self.WaitForNotificationCount(1) | |
44 | |
45 notification_result = self.GetActiveNotifications()[0]['content_url'] | |
46 result_error = re.search('Error|Failed', notification_result) | |
47 self.assertTrue(result_error, 'Expected to find Error/Failed in ' | |
48 'notification, not found as expected.') | |
49 result_ssid = re.search(router_config['ssid'], notification_result) | |
50 self.assertTrue(result_ssid, | |
51 'SSID is not found. Notification text is: "%s"' | |
52 % notification_result) | |
53 | |
54 def testWifiNotificationWEP_Linksys_WRT54G2_wrongpassword(self): | |
55 """wifi disconnect notification-Linksys_WRT54G2.(WEP)-invalid password""" | |
56 self._WifiNotification('Linksys_WRT54G2', WifiNotification.password1) | |
57 | |
58 def testWifiNotificationWEP_Linksys_WRT54G2_five_char(self): | |
59 """wifi disconnect notification for Linksys_WRT54G2.(WEP)-5 password """ | |
60 self._WifiNotification('Linksys_WRT54G2', WifiNotification.password5) | |
61 | |
62 def testWifiNotificationWEP_Linksys_WRT54G2_ten_char(self): | |
63 """wifi disconnect notification for Linksys_WRT54G2.(WEP)-10 password""" | |
64 self._WifiNotification('Linksys_WRT54G2', WifiNotification.password10) | |
65 | |
66 def testWifiNotificationWEP_Linksys_WRT54G2_thirteen_char(self): | |
67 """wifi disconnect notification for Linksys_WRT54G2.(WEP)-13 password""" | |
68 self._WifiNotification('Linksys_WRT54G2', WifiNotification.password13) | |
69 | |
70 def testWifiNotificationWEP_Linksys_WRT54G2_twentysix_char(self): | |
71 """wifi disconnect notification for Linksys_WRT54G2.(WEP)-26 password""" | |
72 self._WifiNotification('Linksys_WRT54G2', WifiNotification.password26) | |
73 | |
74 def testWifiNotificationRSN_Belkin_G_wrongpassword(self): | |
75 """wifi disconnect notification for Belkin_G (rsn)-wrong password""" | |
76 self._WifiNotification('Belkin_G', WifiNotification.password1) | |
77 | |
78 def testWifiNotificationWPA_Trendnet_639gr_wrongpassword(self): | |
79 """wifi disconnect notification for Trendnet_639gr (WPA)-wrong password""" | |
80 self._WifiNotification('Trendnet_639gr', WifiNotification.password1) | |
81 | |
82 def testWifiNotificationWPA_Trendnet_639gr_five_char(self): | |
83 """wifi disconnect notification for Trendnet_639gr (WPA)-5 password""" | |
84 self._WifiNotification('Trendnet_639gr', WifiNotification.password5) | |
85 | |
86 def testWifiNotificationWPA_Trendnet_639gr_sixtyfour_char(self): | |
87 """wifi disconnect notification for Trendnet_639gr (WPA)-64 password""" | |
88 self._WifiNotification('Trendnet_639gr', WifiNotification.password64) | |
89 | |
90 | |
91 if __name__ == '__main__': | |
92 pyauto_functional.Main() | |
OLD | NEW |