Test closing window

This commit is contained in:
Micah Lee 2019-11-08 15:40:37 +08:00
parent 786ff5d5bf
commit cef0d7711b
No known key found for this signature in database
GPG key ID: 403C2657CD994F73
2 changed files with 49 additions and 13 deletions

View file

@ -337,6 +337,38 @@ class TestTabs(unittest.TestCase):
tab = self.new_website_tab()
self.close_persistent_tab(tab)
@pytest.mark.gui
def test_016_quit_with_server_started_should_warn(self):
"""Quitting OnionShare with any active servers should show a warning"""
tab = self.new_share_tab()
# Start the server
self.assertEqual(
tab.get_mode().server_status.status,
tab.get_mode().server_status.STATUS_STOPPED,
)
QtTest.QTest.mouseClick(
tab.get_mode().server_status.server_button, QtCore.Qt.LeftButton
)
self.assertEqual(
tab.get_mode().server_status.status,
tab.get_mode().server_status.STATUS_WORKING,
)
QtTest.QTest.qWait(1000)
self.assertEqual(
tab.get_mode().server_status.status,
tab.get_mode().server_status.STATUS_STARTED,
)
# Prepare to reject the dialog
QtCore.QTimer.singleShot(1000, self.gui.close_dialog.reject_button.click)
# Close the window
self.gui.close()
# The window should still be open
self.assertTrue(self.gui.isVisible())
if __name__ == "__main__":
unittest.main()