mirror of
https://github.com/onionshare/onionshare.git
synced 2025-02-24 08:29:52 -05:00
Add test_autostart_and_autostop_timer_mismatch, and make it pass
This commit is contained in:
parent
3f04ffb69e
commit
6c89ce2f28
@ -72,12 +72,7 @@ class ModeSettingsWidget(QtWidgets.QWidget):
|
|||||||
# The autostart timer widget
|
# The autostart timer widget
|
||||||
self.autostart_timer_widget = QtWidgets.QDateTimeEdit()
|
self.autostart_timer_widget = QtWidgets.QDateTimeEdit()
|
||||||
self.autostart_timer_widget.setDisplayFormat("hh:mm A MMM d, yy")
|
self.autostart_timer_widget.setDisplayFormat("hh:mm A MMM d, yy")
|
||||||
self.autostart_timer_widget.setDateTime(
|
self.autostart_timer_reset()
|
||||||
QtCore.QDateTime.currentDateTime().addSecs(300) # 5 minutes in the future
|
|
||||||
)
|
|
||||||
self.autostart_timer_widget.setMinimumDateTime(
|
|
||||||
QtCore.QDateTime.currentDateTime().addSecs(60)
|
|
||||||
)
|
|
||||||
self.autostart_timer_widget.setCurrentSection(
|
self.autostart_timer_widget.setCurrentSection(
|
||||||
QtWidgets.QDateTimeEdit.MinuteSection
|
QtWidgets.QDateTimeEdit.MinuteSection
|
||||||
)
|
)
|
||||||
@ -105,12 +100,7 @@ class ModeSettingsWidget(QtWidgets.QWidget):
|
|||||||
# The autostop timer widget
|
# The autostop timer widget
|
||||||
self.autostop_timer_widget = QtWidgets.QDateTimeEdit()
|
self.autostop_timer_widget = QtWidgets.QDateTimeEdit()
|
||||||
self.autostop_timer_widget.setDisplayFormat("hh:mm A MMM d, yy")
|
self.autostop_timer_widget.setDisplayFormat("hh:mm A MMM d, yy")
|
||||||
self.autostop_timer_widget.setDateTime(
|
self.autostop_timer_reset()
|
||||||
QtCore.QDateTime.currentDateTime().addSecs(300)
|
|
||||||
)
|
|
||||||
self.autostop_timer_widget.setMinimumDateTime(
|
|
||||||
QtCore.QDateTime.currentDateTime().addSecs(60)
|
|
||||||
)
|
|
||||||
self.autostop_timer_widget.setCurrentSection(
|
self.autostop_timer_widget.setCurrentSection(
|
||||||
QtWidgets.QDateTimeEdit.MinuteSection
|
QtWidgets.QDateTimeEdit.MinuteSection
|
||||||
)
|
)
|
||||||
@ -249,20 +239,40 @@ class ModeSettingsWidget(QtWidgets.QWidget):
|
|||||||
"""
|
"""
|
||||||
Reset the auto-start timer in the UI after stopping a share
|
Reset the auto-start timer in the UI after stopping a share
|
||||||
"""
|
"""
|
||||||
self.autostart_timer_widget.setDateTime(
|
if self.common.gui.local_only:
|
||||||
QtCore.QDateTime.currentDateTime().addSecs(300)
|
# For testing
|
||||||
)
|
self.autostart_timer_widget.setDateTime(
|
||||||
self.autostart_timer_widget.setMinimumDateTime(
|
QtCore.QDateTime.currentDateTime().addSecs(15)
|
||||||
QtCore.QDateTime.currentDateTime().addSecs(60)
|
)
|
||||||
)
|
self.autostart_timer_widget.setMinimumDateTime(
|
||||||
|
QtCore.QDateTime.currentDateTime()
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
self.autostart_timer_widget.setDateTime(
|
||||||
|
QtCore.QDateTime.currentDateTime().addSecs(
|
||||||
|
300
|
||||||
|
) # 5 minutes in the future
|
||||||
|
)
|
||||||
|
self.autostart_timer_widget.setMinimumDateTime(
|
||||||
|
QtCore.QDateTime.currentDateTime().addSecs(60)
|
||||||
|
)
|
||||||
|
|
||||||
def autostop_timer_reset(self):
|
def autostop_timer_reset(self):
|
||||||
"""
|
"""
|
||||||
Reset the auto-stop timer in the UI after stopping a share
|
Reset the auto-stop timer in the UI after stopping a share
|
||||||
"""
|
"""
|
||||||
self.autostop_timer_widget.setDateTime(
|
if self.common.gui.local_only:
|
||||||
QtCore.QDateTime.currentDateTime().addSecs(300)
|
# For testing
|
||||||
)
|
self.autostop_timer_widget.setDateTime(
|
||||||
self.autostop_timer_widget.setMinimumDateTime(
|
QtCore.QDateTime.currentDateTime().addSecs(15)
|
||||||
QtCore.QDateTime.currentDateTime().addSecs(60)
|
)
|
||||||
)
|
self.autostop_timer_widget.setMinimumDateTime(
|
||||||
|
QtCore.QDateTime.currentDateTime()
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
self.autostop_timer_widget.setDateTime(
|
||||||
|
QtCore.QDateTime.currentDateTime().addSecs(300)
|
||||||
|
)
|
||||||
|
self.autostop_timer_widget.setMinimumDateTime(
|
||||||
|
QtCore.QDateTime.currentDateTime().addSecs(60)
|
||||||
|
)
|
||||||
|
@ -359,15 +359,15 @@ class GuiBaseTest(unittest.TestCase):
|
|||||||
def set_timeout(self, tab, timeout):
|
def set_timeout(self, tab, timeout):
|
||||||
"""Test that the timeout can be set"""
|
"""Test that the timeout can be set"""
|
||||||
timer = QtCore.QDateTime.currentDateTime().addSecs(timeout)
|
timer = QtCore.QDateTime.currentDateTime().addSecs(timeout)
|
||||||
tab.get_mode().server_status.autostop_timer_widget.setDateTime(timer)
|
tab.get_mode().mode_settings_widget.autostop_timer_widget.setDateTime(timer)
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
tab.get_mode().server_status.autostop_timer_widget.dateTime(), timer
|
tab.get_mode().mode_settings_widget.autostop_timer_widget.dateTime(), timer
|
||||||
)
|
)
|
||||||
|
|
||||||
def autostop_timer_widget_hidden(self, tab):
|
def autostop_timer_widget_hidden(self, tab):
|
||||||
"""Test that the auto-stop timer widget is hidden when share has started"""
|
"""Test that the auto-stop timer widget is hidden when share has started"""
|
||||||
self.assertFalse(
|
self.assertFalse(
|
||||||
tab.get_mode().server_status.autostop_timer_container.isVisible()
|
tab.get_mode().mode_settings_widget.autostop_timer_container.isVisible()
|
||||||
)
|
)
|
||||||
|
|
||||||
def server_timed_out(self, tab, wait):
|
def server_timed_out(self, tab, wait):
|
||||||
|
@ -191,21 +191,26 @@ class TestShare(GuiBaseTest):
|
|||||||
|
|
||||||
# Auto-start timer tests
|
# Auto-start timer tests
|
||||||
|
|
||||||
def set_autostart_timer(self, tab, mode, timer):
|
def set_autostart_timer(self, tab, timer):
|
||||||
"""Test that the timer can be set"""
|
"""Test that the timer can be set"""
|
||||||
schedule = QtCore.QDateTime.currentDateTime().addSecs(timer)
|
schedule = QtCore.QDateTime.currentDateTime().addSecs(timer)
|
||||||
mode.server_status.autostart_timer_widget.setDateTime(schedule)
|
tab.get_mode().mode_settings_widget.autostart_timer_widget.setDateTime(schedule)
|
||||||
self.assertTrue(mode.server_status.autostart_timer_widget.dateTime(), schedule)
|
self.assertTrue(
|
||||||
|
tab.get_mode().mode_settings_widget.autostart_timer_widget.dateTime(),
|
||||||
|
schedule,
|
||||||
|
)
|
||||||
|
|
||||||
def autostart_timer_widget_hidden(self, tab, mode):
|
def autostart_timer_widget_hidden(self, tab, mode):
|
||||||
"""Test that the auto-start timer widget is hidden when share has started"""
|
"""Test that the auto-start timer widget is hidden when share has started"""
|
||||||
self.assertFalse(mode.server_status.autostart_timer_container.isVisible())
|
self.assertFalse(
|
||||||
|
tab.get_mode().mode_settings_widget.autostart_timer_widget.isVisible()
|
||||||
|
)
|
||||||
|
|
||||||
def scheduled_service_started(self, tab, mode, wait):
|
def scheduled_service_started(self, tab, mode, wait):
|
||||||
"""Test that the server has timed out after the timer ran out"""
|
"""Test that the server has timed out after the timer ran out"""
|
||||||
QtTest.QTest.qWait(wait)
|
QtTest.QTest.qWait(wait)
|
||||||
# We should have started now
|
# We should have started now
|
||||||
self.assertEqual(mode.server_status.status, 2)
|
self.assertEqual(tab.get_mode().server_status.status, 2)
|
||||||
|
|
||||||
def cancel_the_share(self, tab, mode):
|
def cancel_the_share(self, tab, mode):
|
||||||
"""Test that we can cancel a share before it's started up """
|
"""Test that we can cancel a share before it's started up """
|
||||||
@ -214,12 +219,14 @@ class TestShare(GuiBaseTest):
|
|||||||
self.add_delete_buttons_hidden(tab)
|
self.add_delete_buttons_hidden(tab)
|
||||||
self.mode_settings_widget_is_hidden(tab)
|
self.mode_settings_widget_is_hidden(tab)
|
||||||
self.set_autostart_timer(tab, 10)
|
self.set_autostart_timer(tab, 10)
|
||||||
QtTest.QTest.mousePress(mode.server_status.server_button, QtCore.Qt.LeftButton)
|
QtTest.QTest.mousePress(
|
||||||
|
tab.get_mode().server_status.server_button, QtCore.Qt.LeftButton
|
||||||
|
)
|
||||||
QtTest.QTest.qWait(2000)
|
QtTest.QTest.qWait(2000)
|
||||||
QtTest.QTest.mouseRelease(
|
QtTest.QTest.mouseRelease(
|
||||||
mode.server_status.server_button, QtCore.Qt.LeftButton
|
tab.get_mode().server_status.server_button, QtCore.Qt.LeftButton
|
||||||
)
|
)
|
||||||
self.assertEqual(mode.server_status.status, 0)
|
self.assertEqual(tab.get_mode().server_status.status, 0)
|
||||||
self.server_is_stopped(tab)
|
self.server_is_stopped(tab)
|
||||||
self.web_server_is_stopped(tab)
|
self.web_server_is_stopped(tab)
|
||||||
|
|
||||||
@ -340,17 +347,6 @@ class TestShare(GuiBaseTest):
|
|||||||
self.scheduled_service_started(tab, 7000)
|
self.scheduled_service_started(tab, 7000)
|
||||||
self.web_server_is_running(tab)
|
self.web_server_is_running(tab)
|
||||||
|
|
||||||
def run_all_share_mode_autostop_autostart_mismatch_tests(self, tab):
|
|
||||||
"""Auto-stop timer tests in share mode"""
|
|
||||||
self.run_all_share_mode_setup_tests(tab)
|
|
||||||
self.set_autostart_timer(tab, 15)
|
|
||||||
self.set_timeout(tab, 5)
|
|
||||||
QtCore.QTimer.singleShot(4000, self.accept_dialog)
|
|
||||||
QtTest.QTest.mouseClick(
|
|
||||||
tab.get_mode().server_status.server_button, QtCore.Qt.LeftButton
|
|
||||||
)
|
|
||||||
self.server_is_stopped(tab, False)
|
|
||||||
|
|
||||||
def run_all_share_mode_unreadable_file_tests(self, tab):
|
def run_all_share_mode_unreadable_file_tests(self, tab):
|
||||||
"""Attempt to share an unreadable file"""
|
"""Attempt to share an unreadable file"""
|
||||||
self.run_all_share_mode_setup_tests(tab)
|
self.run_all_share_mode_setup_tests(tab)
|
||||||
@ -363,19 +359,23 @@ class TestShare(GuiBaseTest):
|
|||||||
# Tests
|
# Tests
|
||||||
|
|
||||||
@pytest.mark.gui
|
@pytest.mark.gui
|
||||||
def test_tmp(self):
|
def test_autostart_and_autostop_timer_mismatch(self):
|
||||||
tab = self.new_share_tab()
|
tab = self.new_share_tab()
|
||||||
self.run_all_share_mode_setup_tests(tab)
|
|
||||||
self.run_all_share_mode_started_tests(tab)
|
|
||||||
self.run_all_share_mode_download_tests(tab)
|
|
||||||
self.run_all_share_mode_individual_file_download_tests(tab)
|
|
||||||
self.run_all_share_mode_tests(tab)
|
|
||||||
self.run_all_clear_all_button_tests(tab)
|
|
||||||
self.run_all_share_mode_individual_file_tests(tab)
|
|
||||||
self.run_all_large_file_tests(tab)
|
|
||||||
self.run_all_share_mode_persistent_tests(tab)
|
|
||||||
self.run_all_share_mode_timer_tests(tab)
|
|
||||||
self.run_all_share_mode_autostart_timer_tests(tab)
|
|
||||||
self.run_all_share_mode_autostop_autostart_mismatch_tests(tab)
|
|
||||||
self.run_all_share_mode_unreadable_file_tests(tab)
|
|
||||||
|
|
||||||
|
def accept_dialog():
|
||||||
|
window = tab.common.gui.qtapp.activeWindow()
|
||||||
|
if window:
|
||||||
|
window.close()
|
||||||
|
|
||||||
|
tab.get_mode().mode_settings_widget.toggle_advanced_button.click()
|
||||||
|
tab.get_mode().mode_settings_widget.autostart_timer_checkbox.click()
|
||||||
|
tab.get_mode().mode_settings_widget.autostop_timer_checkbox.click()
|
||||||
|
|
||||||
|
self.run_all_common_setup_tests()
|
||||||
|
|
||||||
|
self.run_all_share_mode_setup_tests(tab)
|
||||||
|
self.set_autostart_timer(tab, 15)
|
||||||
|
self.set_timeout(tab, 5)
|
||||||
|
QtCore.QTimer.singleShot(200, accept_dialog)
|
||||||
|
tab.get_mode().server_status.server_button.click()
|
||||||
|
self.server_is_stopped(tab)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user