• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2013 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.
4
5import logging
6import urlparse
7
8import linksyse2100_ap_configurator
9
10
11class LinksysWRT160APConfigurator(linksyse2100_ap_configurator.
12                                   Linksyse2100APConfigurator):
13    """Derived class to control Linksys WRT160Nv3 router."""
14
15    def navigate_to_page(self, page_number):
16        if page_number == 1:
17            page_url = urlparse.urljoin(self.admin_interface_url,
18                                        'Wireless_Basic.asp')
19            self.get_url(page_url, page_title='Settngs')
20        elif page_number == 2:
21            page_url = urlparse.urljoin(self.admin_interface_url,
22                                        'WL_WPATable.asp')
23            self.get_url(page_url, page_title='Security')
24        else:
25            raise RuntimeError('Invalid page number passed. Number of pages '
26                               '%d, page value sent was %d' %
27                               (self.get_number_of_pages(), page_number))
28
29
30    def _set_channel(self, channel):
31        position = self._get_channel_popup_position(channel)
32        xpath = '//select[@name="wl_schannel"]'
33        channels = ['Auto', '1', '2', '3', '4', '5', '6', '7', '8',
34                    '9', '10', '11']
35        self.select_item_from_popup_by_xpath(channels[position], xpath)
36
37
38    def _set_channel_width(self, channel_wid):
39        channel_width_choice = ['Auto (20 MHz or 40 MHz)', '20MHz only']
40        xpath = '//select[@name="_wl_nbw"]'
41        self.select_item_from_popup_by_xpath(channel_width_choice[channel_wid],
42                                             xpath)
43
44
45    def _set_security_wpapsk(self, security, shared_key, update_interval=3600):
46        if update_interval not in range(600, 7201):
47           logging.info('The update interval should be between 600 and 7200.'
48                       'Setting the interval to default (3600)')
49           update_interval = 3600
50        super(LinksysWRT160APConfigurator, self)._set_security_wpapsk(security,
51                                          shared_key, update_interval)
52        text = '//input[@name="wl_wpa_gtk_rekey"]'
53        self.set_content_of_text_field_by_xpath(update_interval, text,
54                                                abort_check=True)
55