harpreet | 2cc4d11 | 2016-05-19 17:03:19 -0700 | [diff] [blame] | 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 | |
| 5 | import datetime, logging, time |
| 6 | |
| 7 | from autotest_lib.client.bin import test |
| 8 | from autotest_lib.client.common_lib import error |
| 9 | from autotest_lib.client.common_lib.cros import chrome, cfm_util |
| 10 | |
harpreet | 32731c7 | 2016-06-15 14:03:13 -0700 | [diff] [blame^] | 11 | LONG_TIMEOUT = 7 |
harpreet | 2cc4d11 | 2016-05-19 17:03:19 -0700 | [diff] [blame] | 12 | SHORT_TIMEOUT = 2 |
| 13 | EXT_ID = 'ikfcpmgefdpheiiomgmhlmmkihchmdlj' |
| 14 | |
| 15 | |
| 16 | class enterprise_CFM_SessionStress(test.test): |
| 17 | """Stress tests the device in CFM kiosk mode by initiating a new hangout |
| 18 | session multiple times. |
| 19 | """ |
| 20 | version = 1 |
| 21 | |
| 22 | |
| 23 | def _run_hangout_session(self, webview_context): |
| 24 | """Start a hangout session and do some checks before ending the session. |
| 25 | |
| 26 | @param webview_context: Context for hangouts webview. |
| 27 | @raises error.TestFail if any of the checks fail. |
| 28 | """ |
| 29 | current_time = datetime.datetime.now().strftime("%Y%m%d-%H%M%S") |
| 30 | hangout_name = 'auto-hangout-' + current_time |
| 31 | logging.info('Session name: %s', hangout_name) |
| 32 | |
harpreet | 2cc4d11 | 2016-05-19 17:03:19 -0700 | [diff] [blame] | 33 | cfm_util.start_new_hangout_session(webview_context, hangout_name) |
harpreet | 2cc4d11 | 2016-05-19 17:03:19 -0700 | [diff] [blame] | 34 | time.sleep(LONG_TIMEOUT) |
| 35 | cfm_util.end_hangout_session(webview_context) |
| 36 | |
harpreet | 2cc4d11 | 2016-05-19 17:03:19 -0700 | [diff] [blame] | 37 | |
| 38 | def run_once(self, repeat): |
| 39 | """Runs the test.""" |
| 40 | with chrome.Chrome(clear_enterprise_policy=False, |
| 41 | dont_override_profile=True, |
| 42 | disable_gaia_services=False, |
| 43 | disable_default_apps=False, |
| 44 | auto_login=False) as cr: |
| 45 | cfm_webview_context = cfm_util.get_cfm_webview_context( |
| 46 | cr.browser, EXT_ID) |
| 47 | |
| 48 | cfm_util.wait_for_telemetry_commands(cfm_webview_context) |
| 49 | cfm_util.wait_for_oobe_start_page(cfm_webview_context) |
| 50 | |
| 51 | if not cfm_util.is_oobe_start_page(cfm_webview_context): |
| 52 | raise error.TestFail('CFM did not reach oobe screen.') |
| 53 | |
| 54 | cfm_util.skip_oobe_screen(cfm_webview_context) |
| 55 | |
| 56 | while repeat: |
| 57 | self._run_hangout_session(cfm_webview_context) |
| 58 | time.sleep(SHORT_TIMEOUT) |
| 59 | repeat -= 1 |
| 60 | |