blob: 147324b78674a7c053ee5cd6149c857c4648b104 [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 gobject, logging
from dbus.exceptions import DBusException
from dbus.mainloop.glib import DBusGMainLoop
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, session_manager
from autotest_lib.client.cros import constants
class desktopui_ExitOnSupervisedUserCrash_P(test.test):
"""Sign in, indicate that a supervised user is being created, then crash."""
version = 1
def initialize(self):
super(desktopui_ExitOnSupervisedUserCrash, self).initialize()
def run_once(self, arc_mode=None):
listener = session_manager.SessionSignalListener(gobject.MainLoop())
with chrome.Chrome(arc_mode=arc_mode):
sm = session_manager.connect(DBusGMainLoop(set_as_default=True))
# Tell session_manager that we're going all the way through
# creating a supervised user.
# Crashing the browser should not end the session, as creating the
# user is finished.
# We should still be able to talk to the session_manager,
# and it should indicate that we're still inside a user session.
state = sm.RetrieveSessionState()
except DBusException as e:
raise error.TestError('Failed to retrieve session state: ', e)
if state != 'started':
raise error.TestFail('Session should not have ended: ', state)
# Start listening to stop signal before the session gets killed.
# Tell session_manager that a supervised user is being set up,
# and kill it in the middle. Session should die.
nuke_browser_error = None
except error.AutoservPidAlreadyDeadError as e:
nuke_browser_error = e
logging.warning('Browser may have crashed untimely: ', e)
listener.wait_for_signals(desc='Session stopped.',
except utils.TimeoutError as actual_problem:
if nuke_browser_error is not None:
actual_problem = nuke_browser_error
raise error.TestFail(actual_problem)