• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2014 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 logging, os, sys, time
6
7from autotest_lib.client.bin import test
8from autotest_lib.client.common_lib.cros import chrome
9
10
11class desktopui_SimpleLogin(test.test):
12    """Login and wait until exit flag file is seen."""
13    version = 2
14
15
16    def run_once(self, start_url=None, exit_without_logout=False):
17        """
18        Entrance point for test.
19
20        @param exit_without_logout: True if exit without logout
21                                    False otherwise
22        """
23        terminate_path = '/tmp/simple_login_exit'
24        if os.path.isfile(terminate_path):
25            os.remove(terminate_path)
26
27        cr = chrome.Chrome()
28        if start_url is not None:
29            tab = cr.browser.tabs[0]
30            try:
31                tab.Navigate(start_url)
32            except Exception as e:
33                logging.debug(e)
34                pass
35        if exit_without_logout is True:
36            sys.exit(0)
37        while True:
38            time.sleep(1)
39            if os.path.isfile(terminate_path):
40                logging.info('Exit flag detected; exiting.')
41                cr.browser.Close()
42                return
43
44
45