blob: 558c7a0097079e7d779fa4dad139df61aee6e41a [file] [log] [blame]
# Copyright 2014 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import logging, os
from autotest_lib.client.bin import test, utils
from autotest_lib.client.common_lib import error
from autotest_lib.client.common_lib.cros import chrome, enrollment
class enterprise_RemoraRequisition(test.test):
"""Enroll as a Remora device."""
version = 1
_HANGOUTS_EXT_ID = 'acdafoiapclbpdkhnighhilgampkglpc'
def _WaitForHangouts(self, browser):
def _HangoutExtContexts():
try:
ext_contexts = browser.extensions.GetByExtensionId(
self._HANGOUTS_EXT_ID)
if len(ext_contexts) > 1:
return ext_contexts
except KeyError:
pass
return []
return utils.poll_for_condition(
_HangoutExtContexts,
exception=error.TestFail('Hangouts app failed to launch'),
timeout=30,
sleep_interval=1)
def _CheckHangoutsExtensionContexts(self, browser):
ext_contexts = self._WaitForHangouts(browser)
ext_urls = set([context.EvaluateJavaScript('location.href;')
for context in ext_contexts])
expected_urls = set(
['chrome-extension://' + self._HANGOUTS_EXT_ID + '/' + path
for path in ['hangoutswindow.html?windowid=0',
'_generated_background_page.html']])
if expected_urls != ext_urls:
raise error.TestFail(
'Unexpected extension context urls, expected %s, got %s'
% (expected_urls, ext_urls))
def run_once(self):
user_id, password = utils.get_signin_credentials(os.path.join(
os.path.dirname(os.path.realpath(__file__)), 'credentials.txt'))
if not (user_id and password):
logging.warn('No credentials found - exiting test.')
return
with chrome.Chrome(auto_login=False) as cr:
enrollment.RemoraEnrollment(cr.browser, user_id, password)
self._CheckHangoutsExtensionContexts(cr.browser)