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 = 1
14
15
16    def run_once(self, 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 exit_without_logout is True:
29            sys.exit(0)
30        while True:
31            time.sleep(1)
32            if os.path.isfile(terminate_path):
33                logging.info('Exit flag detected; exiting.')
34                cr.browser.Close()
35                return
36
37
38