1# Lint as: python2, python3 2# Copyright (c) 2014 The Chromium OS Authors. All rights reserved. 3# Use of this source code is governed by a BSD-style license that can be 4# found in the LICENSE file. 5 6import logging, os, sys, time 7 8from autotest_lib.client.bin import test 9from autotest_lib.client.common_lib.cros import chrome 10 11 12class desktopui_SimpleLogin(test.test): 13 """Login and wait until exit flag file is seen.""" 14 version = 2 15 16 17 def run_once(self, start_url=None, exit_without_logout=False): 18 """ 19 Entrance point for test. 20 21 @param exit_without_logout: True if exit without logout 22 False otherwise 23 """ 24 terminate_path = '/tmp/simple_login_exit' 25 if os.path.isfile(terminate_path): 26 os.remove(terminate_path) 27 28 cr = chrome.Chrome() 29 if start_url is not None: 30 tab = cr.browser.tabs[0] 31 try: 32 tab.Navigate(start_url) 33 except Exception as e: 34 logging.debug(e) 35 pass 36 if exit_without_logout is True: 37 sys.exit(0) 38 while True: 39 time.sleep(1) 40 if os.path.isfile(terminate_path): 41 logging.info('Exit flag detected; exiting.') 42 cr.browser.Close() 43 return 44 45 46