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 ap_spec
6import trendnet_ap_configurator
7
8
9class Trendnet691grAPConfigurator(trendnet_ap_configurator.
10                                  TrendnetAPConfigurator):
11    """Derived class to control the Trendnet TEW-691GR."""
12
13
14    def save_page(self, page_number):
15        super(Trendnet691grAPConfigurator, self).save_page(page_number)
16        # Reboot the device.
17        reboot_button = '//input[@value="Reboot the Device"]'
18        if self.object_by_xpath_exist(reboot_button):
19            self.click_button_by_xpath(reboot_button)
20            self.wait_for_progress_bar()
21
22
23    def _set_security_wpapsk(self, security, shared_key, update_interval=1800):
24        self.wait_for_object_by_id('security_mode')
25        if security == ap_spec.SECURITY_TYPE_WPAPSK:
26            wpa_item = 'WPA-PSK'
27        else:
28            wpa_item = 'WPA2-PSK'
29        self.select_item_from_popup_by_id(wpa_item, 'security_mode',
30                                          wait_for_xpath='id("passphrase")')
31        self.set_content_of_text_field_by_id(shared_key, 'passphrase')
32        self.set_content_of_text_field_by_id(update_interval,
33                                             'keyRenewalInterval')
34