Test the history indicator widget, in local GUI tests

This commit is contained in:
Micah Lee 2018-09-30 11:41:07 -07:00
parent f5c7acf8f2
commit 3fd7581995
No known key found for this signature in database
GPG key ID: 403C2657CD994F73
7 changed files with 89 additions and 4 deletions

View file

@ -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':

View file

@ -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)

View file

@ -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)

View file

@ -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()

View file

@ -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()

View file

@ -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()

View file

@ -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()