summaryrefslogtreecommitdiff
path: root/tests/GuiBaseTest.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/GuiBaseTest.py')
-rw-r--r--tests/GuiBaseTest.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/tests/GuiBaseTest.py b/tests/GuiBaseTest.py
index 2f340396..3e82769a 100644
--- a/tests/GuiBaseTest.py
+++ b/tests/GuiBaseTest.py
@@ -14,6 +14,7 @@ from onionshare.web import Web
from onionshare_gui import Application, OnionShare, OnionShareGui
from onionshare_gui.mode.share_mode import ShareMode
from onionshare_gui.mode.receive_mode import ReceiveMode
+from onionshare_gui.mode.website_mode import WebsiteMode
class GuiBaseTest(object):
@@ -103,6 +104,9 @@ class GuiBaseTest(object):
if type(mode) == ShareMode:
QtTest.QTest.mouseClick(self.gui.share_mode_button, QtCore.Qt.LeftButton)
self.assertTrue(self.gui.mode, self.gui.MODE_SHARE)
+ if type(mode) == WebsiteMode:
+ QtTest.QTest.mouseClick(self.gui.website_mode_button, QtCore.Qt.LeftButton)
+ self.assertTrue(self.gui.mode, self.gui.MODE_WEBSITE)
def click_toggle_history(self, mode):
@@ -112,7 +116,7 @@ class GuiBaseTest(object):
self.assertEqual(mode.history.isVisible(), not currently_visible)
- def history_indicator(self, mode, public_mode):
+ def history_indicator(self, mode, public_mode, indicator_count="1"):
'''Test that we can make sure the history is toggled off, do an action, and the indiciator works'''
# Make sure history is toggled off
if mode.history.isVisible():
@@ -143,7 +147,7 @@ class GuiBaseTest(object):
# Indicator should be visible, have a value of "1"
self.assertTrue(mode.toggle_history.indicator_label.isVisible())
- self.assertEqual(mode.toggle_history.indicator_label.text(), "1")
+ self.assertEqual(mode.toggle_history.indicator_label.text(), indicator_count)
# Toggle history back on, indicator should be hidden again
QtTest.QTest.mouseClick(mode.toggle_history, QtCore.Qt.LeftButton)
@@ -166,6 +170,9 @@ class GuiBaseTest(object):
QtTest.QTest.mouseClick(mode.server_status.server_button, QtCore.Qt.LeftButton)
self.assertEqual(mode.server_status.status, 1)
+ def toggle_indicator_is_reset(self, mode):
+ self.assertEqual(mode.toggle_history.indicator_count, 0)
+ self.assertFalse(mode.toggle_history.indicator_label.isVisible())
def server_status_indicator_says_starting(self, mode):
'''Test that the Server Status indicator shows we are Starting'''
@@ -198,6 +205,9 @@ class GuiBaseTest(object):
else:
self.assertIsNone(mode.server_status.web.password, r'(\w+)-(\w+)')
+ def add_button_visible(self, mode):
+ '''Test that the add button should be visible'''
+ self.assertTrue(mode.server_status.file_selection.add_button.isVisible())
def url_description_shown(self, mode):
'''Test that the URL label is showing'''
@@ -249,7 +259,7 @@ class GuiBaseTest(object):
def server_is_stopped(self, mode, stay_open):
'''Test that the server stops when we click Stop'''
- if type(mode) == ReceiveMode or (type(mode) == ShareMode and stay_open):
+ if type(mode) == ReceiveMode or (type(mode) == ShareMode and stay_open) or (type(mode) == WebsiteMode):
QtTest.QTest.mouseClick(mode.server_status.server_button, QtCore.Qt.LeftButton)
self.assertEqual(mode.server_status.status, 0)
@@ -275,6 +285,10 @@ class GuiBaseTest(object):
else:
self.assertEqual(self.gui.share_mode.server_status_label.text(), strings._('closing_automatically'))
+ def clear_all_history_items(self, mode, count):
+ if count == 0:
+ QtTest.QTest.mouseClick(mode.history.clear_button, QtCore.Qt.LeftButton)
+ self.assertEquals(len(mode.history.item_list.items.keys()), count)
# Auto-stop timer tests
def set_timeout(self, mode, timeout):