diff --git a/tests_gui_local/commontests.py b/tests_gui_local/commontests.py index 870c2dbe..21e8cfad 100644 --- a/tests_gui_local/commontests.py +++ b/tests_gui_local/commontests.py @@ -52,6 +52,59 @@ class CommonTests(object): QtTest.QTest.mouseClick(self.gui.share_mode.info.toggle_button, QtCore.Qt.LeftButton) self.assertEqual(self.gui.share_mode.downloads.isVisible(), not currently_visible) + def test_history_indicator(self, mode, public_mode): + '''Test that we can make sure the history is toggled off, do an action, and the indiciator works''' + if mode == 'receive': + # Make sure history is toggled off + if self.gui.receive_mode.uploads.isVisible(): + QtTest.QTest.mouseClick(self.gui.receive_mode.info.toggle_button, QtCore.Qt.LeftButton) + self.assertFalse(self.gui.receive_mode.uploads.isVisible()) + + # Indicator should not be visible yet + self.assertFalse(self.gui.receive_mode.info.indicator_label.isVisible()) + + # Upload a file + files = {'file[]': open('/tmp/test.txt', 'rb')} + if not public_mode: + path = 'http://127.0.0.1:{}/{}/upload'.format(self.gui.app.port, self.gui.receive_mode.web.slug) + else: + path = 'http://127.0.0.1:{}/upload'.format(self.gui.app.port) + response = requests.post(path, files=files) + QtTest.QTest.qWait(2000) + + # Indicator should be visible, have a value of "1" + self.assertTrue(self.gui.receive_mode.info.indicator_label.isVisible()) + self.assertEqual(self.gui.receive_mode.info.indicator_label.text(), "1") + + # Toggle history back on, indicator should be hidden again + QtTest.QTest.mouseClick(self.gui.receive_mode.info.toggle_button, QtCore.Qt.LeftButton) + self.assertFalse(self.gui.receive_mode.info.indicator_label.isVisible()) + + if mode == 'share': + # Make sure history is toggled off + if self.gui.share_mode.downloads.isVisible(): + QtTest.QTest.mouseClick(self.gui.share_mode.info.toggle_button, QtCore.Qt.LeftButton) + self.assertFalse(self.gui.share_mode.downloads.isVisible()) + + # Indicator should not be visible yet + self.assertFalse(self.gui.share_mode.info.indicator_label.isVisible()) + + # Download files + if public_mode: + url = "http://127.0.0.1:{}/download".format(self.gui.app.port) + else: + url = "http://127.0.0.1:{}/{}/download".format(self.gui.app.port, self.gui.share_mode.web.slug) + r = requests.get(url) + QtTest.QTest.qWait(2000) + + # Indicator should be visible, have a value of "1" + self.assertTrue(self.gui.share_mode.info.indicator_label.isVisible()) + self.assertEqual(self.gui.share_mode.info.indicator_label.text(), "1") + + # Toggle history back on, indicator should be hidden again + QtTest.QTest.mouseClick(self.gui.share_mode.info.toggle_button, QtCore.Qt.LeftButton) + self.assertFalse(self.gui.share_mode.info.indicator_label.isVisible()) + def test_history_is_not_visible(self, mode): '''Test that the History section is not visible''' if mode == 'receive': diff --git a/tests_gui_local/onionshare_receive_mode_upload_test.py b/tests_gui_local/onionshare_receive_mode_upload_test.py index b53d5c06..19674aa3 100644 --- a/tests_gui_local/onionshare_receive_mode_upload_test.py +++ b/tests_gui_local/onionshare_receive_mode_upload_test.py @@ -171,14 +171,18 @@ class OnionShareGuiTest(unittest.TestCase): CommonTests.test_counter_incremented(self, 'receive', 2) @pytest.mark.run(order=24) + def test_history_indicator(self): + CommonTests.test_history_indicator(self, 'receive', False) + + @pytest.mark.run(order=25) def test_server_is_stopped(self): CommonTests.test_server_is_stopped(self, 'receive', False) - @pytest.mark.run(order=25) + @pytest.mark.run(order=26) def test_web_service_is_stopped(self): CommonTests.test_web_service_is_stopped(self) - @pytest.mark.run(order=26) + @pytest.mark.run(order=27) def test_server_status_indicator_says_closed(self): CommonTests.test_server_status_indicator_says_closed(self, 'receive', False) diff --git a/tests_gui_local/onionshare_receive_mode_upload_test_public_mode.py b/tests_gui_local/onionshare_receive_mode_upload_test_public_mode.py index 5e5a6b77..e3f85731 100644 --- a/tests_gui_local/onionshare_receive_mode_upload_test_public_mode.py +++ b/tests_gui_local/onionshare_receive_mode_upload_test_public_mode.py @@ -171,14 +171,18 @@ class OnionShareGuiTest(unittest.TestCase): CommonTests.test_counter_incremented(self, 'receive', 2) @pytest.mark.run(order=24) + def test_history_indicator(self): + CommonTests.test_history_indicator(self, 'receive', True) + + @pytest.mark.run(order=25) def test_server_is_stopped(self): CommonTests.test_server_is_stopped(self, 'receive', False) - @pytest.mark.run(order=25) + @pytest.mark.run(order=26) def test_web_service_is_stopped(self): CommonTests.test_web_service_is_stopped(self) - @pytest.mark.run(order=26) + @pytest.mark.run(order=27) def test_server_status_indicator_says_closed(self): CommonTests.test_server_status_indicator_says_closed(self, 'receive', False) diff --git a/tests_gui_local/onionshare_share_mode_download_test.py b/tests_gui_local/onionshare_share_mode_download_test.py index 40df6d98..c4a60101 100644 --- a/tests_gui_local/onionshare_share_mode_download_test.py +++ b/tests_gui_local/onionshare_share_mode_download_test.py @@ -192,6 +192,12 @@ class OnionShareGuiTest(unittest.TestCase): def test_add_button_visible(self): CommonTests.test_add_button_visible(self) + @pytest.mark.run(order=30) + def test_history_indicator(self): + CommonTests.test_server_working_on_start_button_pressed(self, 'share') + CommonTests.test_a_server_is_started(self, 'share') + CommonTests.test_history_indicator(self, 'share', False) + if __name__ == "__main__": unittest.main() diff --git a/tests_gui_local/onionshare_share_mode_download_test_public_mode.py b/tests_gui_local/onionshare_share_mode_download_test_public_mode.py index 73d4c999..a10ee4c2 100644 --- a/tests_gui_local/onionshare_share_mode_download_test_public_mode.py +++ b/tests_gui_local/onionshare_share_mode_download_test_public_mode.py @@ -192,6 +192,12 @@ class OnionShareGuiTest(unittest.TestCase): def test_add_button_visible(self): CommonTests.test_add_button_visible(self) + @pytest.mark.run(order=30) + def test_history_indicator(self): + CommonTests.test_server_working_on_start_button_pressed(self, 'share') + CommonTests.test_a_server_is_started(self, 'share') + CommonTests.test_history_indicator(self, 'share', True) + if __name__ == "__main__": unittest.main() diff --git a/tests_gui_local/onionshare_share_mode_download_test_stay_open.py b/tests_gui_local/onionshare_share_mode_download_test_stay_open.py index e849d224..8426c264 100644 --- a/tests_gui_local/onionshare_share_mode_download_test_stay_open.py +++ b/tests_gui_local/onionshare_share_mode_download_test_stay_open.py @@ -204,6 +204,12 @@ class OnionShareGuiTest(unittest.TestCase): def test_add_button_visible(self): CommonTests.test_add_button_visible(self) + @pytest.mark.run(order=33) + def test_history_indicator(self): + CommonTests.test_server_working_on_start_button_pressed(self, 'share') + CommonTests.test_a_server_is_started(self, 'share') + CommonTests.test_history_indicator(self, 'share', True) + if __name__ == "__main__": unittest.main() diff --git a/tests_gui_local/onionshare_slug_persistent_test.py b/tests_gui_local/onionshare_slug_persistent_test.py index 5b53f7e0..9fb623dd 100644 --- a/tests_gui_local/onionshare_slug_persistent_test.py +++ b/tests_gui_local/onionshare_slug_persistent_test.py @@ -168,6 +168,12 @@ class OnionShareGuiTest(unittest.TestCase): CommonTests.test_server_is_stopped(self, 'share', True) CommonTests.test_web_service_is_stopped(self) + @pytest.mark.run(order=23) + def test_history_indicator(self): + CommonTests.test_server_working_on_start_button_pressed(self, 'share') + CommonTests.test_a_server_is_started(self, 'share') + CommonTests.test_history_indicator(self, 'share', False) + if __name__ == "__main__": unittest.main()