1# Copyright (c) 2013 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 gobject 6from dbus.mainloop.glib import DBusGMainLoop 7 8from autotest_lib.client.bin import test 9from autotest_lib.client.common_lib.cros import chrome, session_manager 10from autotest_lib.client.cros import asan 11 12 13class login_LoginSuccess(test.test): 14 """Sign in using Telemetry and validate system state.""" 15 version = 1 16 17 _SESSION_START_TIMEOUT = 10 18 _SESSION_STOP_TIMEOUT = 60 19 # TODO(afakhry): Remove this timeout increase for asan bots once we figure 20 # out why logging out is taking so long. See crbug.com/488291 21 if asan.running_on_asan(): 22 _SESSION_STOP_TIMEOUT *= 2 23 24 25 def initialize(self): 26 super(login_LoginSuccess, self).initialize() 27 28 bus_loop = DBusGMainLoop(set_as_default=True) 29 self._session_manager = session_manager.connect(bus_loop) 30 self._listener = session_manager.SessionSignalListener( 31 gobject.MainLoop()) 32 33 34 def run_once(self, stress_run=False): 35 # For stress runs, we are extending timeout to find other problems 36 if stress_run: 37 self._SESSION_STOP_TIMEOUT *= 2 38 self._listener.listen_for_session_state_change('started') 39 with chrome.Chrome(): 40 self._listener.wait_for_signals(desc='Session started.', 41 timeout=self._SESSION_START_TIMEOUT) 42 # To enable use as a 'helper test'. 43 self.job.set_state('client_success', True) 44 45 # Start listening to stop signal before logging out. 46 self._listener.listen_for_session_state_change('stopped') 47 48 self._listener.wait_for_signals(desc='Session stopped.', 49 timeout=self._SESSION_STOP_TIMEOUT) 50