• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2014 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 ap_spec
6import edimax_ap_configurator
7
8
9class Edimax6475ndAPConfigurator(
10        edimax_ap_configurator.EdimaxAPConfigurator):
11    """Derived class to control the Edimax BR-6475ND AP."""
12
13
14    def navigate_to_page(self, page_number):
15        """Navigate to the required page.
16
17        @param page_number: The page number to navigate to.
18
19        """
20        if page_number != 1 and page_number != 2:
21            raise RuntimeError('Invalid page number passed.  Number of pages is'
22                               '%d, page value sent was %d' %
23                               (self.get_number_of_pages(), page_number))
24        page_url = self.admin_interface_url
25        self.get_url(page_url, page_title='EDIMAX Technology')
26        frame = self.driver.find_element_by_xpath('//frame[@name="mainFrame"]')
27        self.driver.switch_to_frame(frame)
28        main_tabs = self.driver.find_elements_by_css_selector('div')
29        main_tabs[2].click()
30        sub_tabs = self.driver.find_elements_by_xpath(
31                                                     '//span[@class="style11"]')
32        if self.current_band == ap_spec.BAND_2GHZ:
33            sub_tabs[2].click()
34        else:
35            sub_tabs[3].click()
36        if page_number == 1:
37            # Open the general settings page.
38            self.click_button_by_xpath('//input[@onclick="c_fun(0)" and '
39                                       '@name="sys"]')
40            self.wait_for_object_by_xpath('//select[@name="band"]')
41        else:
42            # Open the security settings page.
43            self.click_button_by_xpath('//input[@onclick="c_fun(1)" and '
44                                       '@name="sys"]')
45            self.wait_for_object_by_xpath('//select[@name="method"]')
46
47
48    def get_supported_bands(self):
49        return [{'band': ap_spec.BAND_2GHZ, 'channels': range(1, 11)},
50                {'band': ap_spec.BAND_5GHZ,
51                 'channels': [36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108,
52                              136, 140, 149, 153, 157, 161, 165]}]
53
54
55    def set_band(self, band):
56        if band == ap_spec.BAND_5GHZ:
57            self.current_band = ap_spec.BAND_5GHZ
58        elif band == ap_spec.BAND_2GHZ:
59            self.current_band = ap_spec.BAND_2GHZ
60        else:
61            raise RuntimeError('Invalid band sent %s' % band)
62
63
64    def get_supported_modes(self):
65        return [{'band': ap_spec.BAND_2GHZ,
66                 'modes': [ap_spec.MODE_B,
67                           ap_spec.MODE_G,
68                           ap_spec.MODE_N,
69                           ap_spec.MODE_B | ap_spec.MODE_G,
70                           ap_spec.MODE_B | ap_spec.MODE_G | ap_spec.MODE_N]},
71                {'band': ap_spec.BAND_5GHZ,
72                 'modes': [ap_spec.MODE_A,
73                           ap_spec.MODE_N,
74                           ap_spec.MODE_A | ap_spec.MODE_N]}]
75
76
77    def _set_mode(self, mode, band=None):
78        # Create the mode to popup item mapping
79        mode_mapping_2ghz = {ap_spec.MODE_B | ap_spec.MODE_G | ap_spec.MODE_N:
80                             '2.4 GHz (B+G+N)',
81                             ap_spec.MODE_N: '2.4 GHz (N)',
82                             ap_spec.MODE_B: '2.4 GHz (B)',
83                             ap_spec.MODE_G: '2.4 GHz (G)',
84                             ap_spec.MODE_B | ap_spec.MODE_G: '2.4 GHz (B+G)'}
85        mode_mapping_5ghz = {ap_spec.MODE_A: '5 GHz (A)',
86                             ap_spec.MODE_N: '5 GHz (N)',
87                             ap_spec.MODE_A | ap_spec.MODE_N: '5 GHz (A+N)'}
88        mode_name = ''
89        if mode in mode_mapping_2ghz.keys() or mode in mode_mapping_5ghz.keys():
90            if self.current_band == ap_spec.BAND_2GHZ:
91                mode_name = mode_mapping_2ghz[mode]
92            else:
93                mode_name = mode_mapping_5ghz[mode]
94        else:
95            raise RuntimeError('The mode selected %d is not supported by router'
96                               ' %s.', hex(mode), self.name)
97        xpath = '//select[@name="band"]'
98        self.select_item_from_popup_by_xpath(mode_name, xpath)
99
100
101    def _set_channel(self, channel):
102        position = self._get_channel_popup_position(channel)
103        channel_choices_2ghz = ['1', '2', '3', '4', '5',
104                                '6', '7', '8', '9', '10', '11']
105        channel_choices_5ghz = [ '36', '40', '44', '48', '52', '56', '60',
106                                 '64', '100', '104', '108', '136', '140',
107                                 '149', '153', '157', '161', '165']
108        if self.current_band == ap_spec.BAND_2GHZ:
109            self.select_item_from_popup_by_xpath(channel_choices_2ghz[position],
110                                                 '//select[@name="chan"]')
111        else:
112            self.select_item_from_popup_by_xpath(channel_choices_5ghz[position],
113                                                 '//select[@name="chan"]')
114