• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2016 The Chromium OS 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 time
6
7from telemetry.core import exceptions
8from autotest_lib.client.common_lib import error
9from autotest_lib.client.common_lib.cros import cfm_util
10
11DEFAULT_TIMEOUT = 30
12SHORT_TIMEOUT = 5
13
14def config_riseplayer(browser, ext_id, app_config_id):
15    """
16    Configure Rise Player app with a specific display id.
17
18    Step through the configuration screen of the Rise Player app
19    which is launched within the browser and enter a display id
20    within the configuration frame to initiate media display.
21
22    @param browser: browser instance containing the Rise Player kiosk app.
23    @param ext_id: extension id of the Rise Player Kiosk App.
24    @param app_config_id: display id for the Rise Player app .
25
26    """
27    if not app_config_id:
28        raise error.TestFail(
29                'Error in configuring Rise Player: app_config_id is None')
30    config_js = """
31                var frameId = 'btn btn-primary display-register-button'
32                document.getElementsByClassName(frameId)[0].click();
33                $( "input:text" ).val("%s");
34                document.getElementsByClassName(frameId)[4].click();
35                """ % app_config_id
36
37    kiosk_webview_context = cfm_util.get_cfm_webview_context(
38            browser, ext_id)
39    # Wait for the configuration frame to load.
40    time.sleep(SHORT_TIMEOUT)
41    kiosk_webview_context.ExecuteJavaScript(config_js)
42    # TODO (krishnargv): Find a way to verify that content is playing
43    #                    within the RisePlayer app.
44    verify_app_config_id = """
45            /rvashow.*.display&id=%s.*/.test(location.href)
46            """ % app_config_id
47    #Verify that Risepplayer successfully validates the display id.
48    try:
49        kiosk_webview_context.WaitForJavaScriptCondition(
50                verify_app_config_id,
51                timeout=DEFAULT_TIMEOUT)
52    except exceptions.TimeoutException:
53        raise error.TestFail('Error in configuring Rise Player with id: %s'
54                             % app_config_id)
55