This repository has been archived by the owner on Aug 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1480612: Test Register Application Restart more thoroughly. r=whi…
…mboo
- Loading branch information
Showing
2 changed files
with
120 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 69 additions & 45 deletions
114
...g/firefox-ui/tests/functional/sessionstore/test_restore_windows_after_windows_shutdown.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,69 @@ | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
# add this directory to the path | ||
import sys | ||
import os | ||
sys.path.append(os.path.dirname(__file__)) | ||
|
||
from session_store_test_case import SessionStoreTestCase | ||
|
||
|
||
class TestSessionStoreWindowsShutdown(SessionStoreTestCase): | ||
|
||
def setUp(self): | ||
super(TestSessionStoreWindowsShutdown, self).setUp(startup_page=3, no_auto_updates=False) | ||
|
||
def test_with_variety(self): | ||
""" Test restoring a set of windows across Windows shutdown. | ||
Opens a set of windows, both standard and private, with | ||
some number of tabs in them. Once the tabs have loaded, shuts down | ||
the browser with the Windows Restart Manager, restarts the browser, | ||
and then ensures that the standard tabs have been restored, | ||
and that the private ones have not. | ||
This specifically exercises the Windows synchronous shutdown | ||
mechanism, which terminates the process in response to the | ||
Restart Manager's WM_ENDSESSION message. | ||
""" | ||
|
||
current_windows_set = self.convert_open_windows_to_set() | ||
self.assertEqual(current_windows_set, self.all_windows, | ||
msg='Not all requested windows have been opened. Expected {}, got {}.' | ||
.format(self.all_windows, current_windows_set)) | ||
|
||
self.marionette.quit(in_app=True, callback=lambda: self.simulate_os_shutdown()) | ||
self.marionette.start_session() | ||
self.marionette.set_context('chrome') | ||
|
||
current_windows_set = self.convert_open_windows_to_set() | ||
self.assertEqual(current_windows_set, self.test_windows, | ||
msg="""Non private browsing windows should have | ||
been restored. Expected {}, got {}. | ||
""".format(self.test_windows, current_windows_set)) | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
# add this directory to the path | ||
import sys | ||
import os | ||
sys.path.append(os.path.dirname(__file__)) | ||
|
||
from session_store_test_case import SessionStoreTestCase | ||
|
||
# We test the following combinations with simulated Windows shutdown: | ||
# - Start page = restore session (expect restore in all cases) | ||
# - RAR (toolkit.winRegisterApplicationRestart) disabled | ||
# - RAR enabled, restarted manually | ||
# | ||
# - Start page = home | ||
# - RAR disabled (no restore) | ||
# - RAR enabled: | ||
# - restarted by OS (restore) | ||
# - restarted manually (no restore) | ||
|
||
|
||
class TestWindowsShutdown(SessionStoreTestCase): | ||
def setUp(self): | ||
super(TestWindowsShutdown, self).setUp( | ||
startup_page=3, | ||
no_auto_updates=False) | ||
|
||
def test_with_variety(self): | ||
"""Test session restore selected by user.""" | ||
self.windows_shutdown_with_variety(restart_by_os=False, expect_restore=True) | ||
|
||
|
||
class TestWindowsShutdownRegisterRestart(SessionStoreTestCase): | ||
def setUp(self): | ||
super(TestWindowsShutdownRegisterRestart, self).setUp( | ||
startup_page=3, | ||
no_auto_updates=False, | ||
win_register_restart=True) | ||
|
||
def test_manual_restart(self): | ||
"""Test that restore tabs works in case of register restart failure.""" | ||
self.windows_shutdown_with_variety(restart_by_os=False, expect_restore=True) | ||
|
||
|
||
class TestWindowsShutdownNormal(SessionStoreTestCase): | ||
def setUp(self): | ||
super(TestWindowsShutdownNormal, self).setUp( | ||
no_auto_updates=False) | ||
|
||
def test_with_variety(self): | ||
"""Test that windows are not restored on a normal restart.""" | ||
self.windows_shutdown_with_variety(restart_by_os=False, expect_restore=False) | ||
|
||
|
||
class TestWindowsShutdownForcedSessionRestore(SessionStoreTestCase): | ||
def setUp(self): | ||
super(TestWindowsShutdownForcedSessionRestore, self).setUp( | ||
no_auto_updates=False, | ||
win_register_restart=True) | ||
|
||
def test_os_restart(self): | ||
"""Test that register application restart restores the session.""" | ||
self.windows_shutdown_with_variety(restart_by_os=True, expect_restore=True) | ||
|
||
def test_manual_restart(self): | ||
"""Test that OS shutdown is ignored on manual start.""" | ||
self.windows_shutdown_with_variety(restart_by_os=False, expect_restore=False) |