2018-09-22 02:50:39 -04:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import unittest
|
|
|
|
import pytest
|
|
|
|
import json
|
|
|
|
|
2018-09-23 20:41:48 -04:00
|
|
|
from PyQt5 import QtWidgets
|
2018-09-22 02:50:39 -04:00
|
|
|
|
|
|
|
from onionshare.common import Common
|
|
|
|
from onionshare.web import Web
|
|
|
|
from onionshare import onion, strings
|
|
|
|
from onionshare_gui import *
|
|
|
|
|
2018-09-23 20:41:48 -04:00
|
|
|
from .commontests import CommonTests
|
|
|
|
|
2018-09-22 02:50:39 -04:00
|
|
|
class OnionShareGuiTest(unittest.TestCase):
|
|
|
|
@classmethod
|
|
|
|
def setUpClass(cls):
|
|
|
|
test_settings = {
|
|
|
|
"public_mode": False,
|
2018-09-30 21:32:18 -04:00
|
|
|
"receive_allow_receiver_shutdown": True
|
2018-09-22 02:50:39 -04:00
|
|
|
}
|
2018-09-30 21:32:18 -04:00
|
|
|
cls.gui = CommonTests.set_up(test_settings)
|
2018-09-27 20:34:46 -04:00
|
|
|
|
2018-09-22 02:50:39 -04:00
|
|
|
@classmethod
|
|
|
|
def tearDownClass(cls):
|
2018-09-30 21:32:18 -04:00
|
|
|
CommonTests.tear_down()
|
2018-09-22 02:50:39 -04:00
|
|
|
|
|
|
|
@pytest.mark.run(order=1)
|
2018-09-23 20:41:48 -04:00
|
|
|
def test_gui_loaded(self):
|
|
|
|
CommonTests.test_gui_loaded(self)
|
2018-09-22 02:50:39 -04:00
|
|
|
|
|
|
|
@pytest.mark.run(order=2)
|
|
|
|
def test_windowTitle_seen(self):
|
2018-09-23 20:41:48 -04:00
|
|
|
CommonTests.test_windowTitle_seen(self)
|
2018-09-22 02:50:39 -04:00
|
|
|
|
|
|
|
@pytest.mark.run(order=3)
|
|
|
|
def test_settings_button_is_visible(self):
|
2018-09-23 20:41:48 -04:00
|
|
|
CommonTests.test_settings_button_is_visible(self)
|
2018-09-22 02:50:39 -04:00
|
|
|
|
|
|
|
@pytest.mark.run(order=4)
|
|
|
|
def test_server_status_bar_is_visible(self):
|
2018-09-23 20:41:48 -04:00
|
|
|
CommonTests.test_server_status_bar_is_visible(self)
|
2018-09-22 02:50:39 -04:00
|
|
|
|
|
|
|
@pytest.mark.run(order=6)
|
2018-09-23 20:41:48 -04:00
|
|
|
def test_click_mode(self):
|
2018-10-07 23:37:54 -04:00
|
|
|
CommonTests.test_click_mode(self, self.gui.receive_mode)
|
2018-09-22 02:50:39 -04:00
|
|
|
|
2018-09-29 21:24:11 -04:00
|
|
|
@pytest.mark.run(order=6)
|
|
|
|
def test_history_is_not_visible(self):
|
2018-10-07 23:37:54 -04:00
|
|
|
CommonTests.test_history_is_not_visible(self, self.gui.receive_mode)
|
2018-09-22 02:50:39 -04:00
|
|
|
|
|
|
|
@pytest.mark.run(order=7)
|
2018-09-29 21:24:11 -04:00
|
|
|
def test_click_toggle_history(self):
|
2018-10-07 23:37:54 -04:00
|
|
|
CommonTests.test_click_toggle_history(self, self.gui.receive_mode)
|
2018-09-29 21:24:11 -04:00
|
|
|
|
|
|
|
@pytest.mark.run(order=8)
|
2018-09-23 20:41:48 -04:00
|
|
|
def test_history_is_visible(self):
|
2018-10-07 23:37:54 -04:00
|
|
|
CommonTests.test_history_is_visible(self, self.gui.receive_mode)
|
2018-09-22 02:50:39 -04:00
|
|
|
|
|
|
|
@pytest.mark.run(order=8)
|
|
|
|
def test_server_working_on_start_button_pressed(self):
|
2018-10-07 23:37:54 -04:00
|
|
|
CommonTests.test_server_working_on_start_button_pressed(self, self.gui.receive_mode)
|
2018-09-22 02:50:39 -04:00
|
|
|
|
|
|
|
@pytest.mark.run(order=9)
|
|
|
|
def test_server_status_indicator_says_starting(self):
|
2018-10-07 23:37:54 -04:00
|
|
|
CommonTests.test_server_status_indicator_says_starting(self, self.gui.receive_mode)
|
2018-09-22 02:50:39 -04:00
|
|
|
|
|
|
|
@pytest.mark.run(order=10)
|
|
|
|
def test_settings_button_is_hidden(self):
|
2018-09-23 20:41:48 -04:00
|
|
|
CommonTests.test_settings_button_is_hidden(self)
|
2018-09-22 02:50:39 -04:00
|
|
|
|
|
|
|
@pytest.mark.run(order=11)
|
|
|
|
def test_a_server_is_started(self):
|
2018-10-07 23:37:54 -04:00
|
|
|
CommonTests.test_a_server_is_started(self, self.gui.receive_mode)
|
2018-09-22 02:50:39 -04:00
|
|
|
|
|
|
|
@pytest.mark.run(order=12)
|
|
|
|
def test_a_web_server_is_running(self):
|
2018-09-23 20:41:48 -04:00
|
|
|
CommonTests.test_a_web_server_is_running(self)
|
2018-09-22 02:50:39 -04:00
|
|
|
|
|
|
|
@pytest.mark.run(order=14)
|
|
|
|
def test_have_a_slug(self):
|
2018-10-07 23:37:54 -04:00
|
|
|
CommonTests.test_have_a_slug(self, self.gui.receive_mode, False)
|
2018-09-22 02:50:39 -04:00
|
|
|
|
|
|
|
@pytest.mark.run(order=15)
|
|
|
|
def test_url_description_shown(self):
|
2018-10-07 23:37:54 -04:00
|
|
|
CommonTests.test_url_description_shown(self, self.gui.receive_mode)
|
2018-09-22 02:50:39 -04:00
|
|
|
|
|
|
|
@pytest.mark.run(order=16)
|
|
|
|
def test_have_copy_url_button(self):
|
2018-10-07 23:37:54 -04:00
|
|
|
CommonTests.test_have_copy_url_button(self, self.gui.receive_mode)
|
2018-09-22 02:50:39 -04:00
|
|
|
|
|
|
|
@pytest.mark.run(order=17)
|
2018-09-23 20:41:48 -04:00
|
|
|
def test_server_status_indicator_says_started(self):
|
2018-10-07 23:37:54 -04:00
|
|
|
CommonTests.test_server_status_indicator_says_started(self, self.gui.receive_mode)
|
2018-09-22 02:50:39 -04:00
|
|
|
|
|
|
|
@pytest.mark.run(order=18)
|
|
|
|
def test_web_page(self):
|
2018-10-07 23:37:54 -04:00
|
|
|
CommonTests.test_web_page(self, self.gui.receive_mode, 'Select the files you want to send, then click', False)
|
2018-09-22 02:50:39 -04:00
|
|
|
|
|
|
|
@pytest.mark.run(order=19)
|
|
|
|
def test_upload_file(self):
|
2018-09-23 20:41:48 -04:00
|
|
|
CommonTests.test_upload_file(self, False, '/tmp/OnionShare/test.txt')
|
2018-09-22 02:50:39 -04:00
|
|
|
|
|
|
|
@pytest.mark.run(order=20)
|
2018-09-23 20:41:48 -04:00
|
|
|
def test_history_widgets_present(self):
|
2018-10-07 23:37:54 -04:00
|
|
|
CommonTests.test_history_widgets_present(self, self.gui.receive_mode)
|
2018-09-22 02:50:39 -04:00
|
|
|
|
|
|
|
@pytest.mark.run(order=21)
|
2018-09-23 20:41:48 -04:00
|
|
|
def test_counter_incremented(self):
|
2018-10-07 23:37:54 -04:00
|
|
|
CommonTests.test_counter_incremented(self, self.gui.receive_mode, 1)
|
2018-09-22 02:50:39 -04:00
|
|
|
|
|
|
|
@pytest.mark.run(order=22)
|
|
|
|
def test_upload_same_file_is_renamed(self):
|
2018-09-23 20:41:48 -04:00
|
|
|
CommonTests.test_upload_file(self, False, '/tmp/OnionShare/test-2.txt')
|
2018-09-22 02:50:39 -04:00
|
|
|
|
|
|
|
@pytest.mark.run(order=23)
|
|
|
|
def test_upload_count_incremented_again(self):
|
2018-10-07 23:37:54 -04:00
|
|
|
CommonTests.test_counter_incremented(self, self.gui.receive_mode, 2)
|
2018-09-22 02:50:39 -04:00
|
|
|
|
|
|
|
@pytest.mark.run(order=24)
|
2018-09-30 14:41:07 -04:00
|
|
|
def test_history_indicator(self):
|
2018-10-07 23:37:54 -04:00
|
|
|
CommonTests.test_history_indicator(self, self.gui.receive_mode, False)
|
2018-09-22 02:50:39 -04:00
|
|
|
|
|
|
|
@pytest.mark.run(order=25)
|
|
|
|
def test_server_is_stopped(self):
|
2018-10-07 23:37:54 -04:00
|
|
|
CommonTests.test_server_is_stopped(self, self.gui.receive_mode, False)
|
2018-09-22 02:50:39 -04:00
|
|
|
|
2018-09-30 14:41:07 -04:00
|
|
|
@pytest.mark.run(order=26)
|
2018-09-22 02:50:39 -04:00
|
|
|
def test_web_service_is_stopped(self):
|
2018-09-23 20:41:48 -04:00
|
|
|
CommonTests.test_web_service_is_stopped(self)
|
2018-09-22 02:50:39 -04:00
|
|
|
|
2018-09-30 14:41:07 -04:00
|
|
|
@pytest.mark.run(order=27)
|
2018-09-22 02:50:39 -04:00
|
|
|
def test_server_status_indicator_says_closed(self):
|
2018-10-07 23:37:54 -04:00
|
|
|
CommonTests.test_server_status_indicator_says_closed(self, self.gui.receive_mode, False)
|
2018-09-22 02:50:39 -04:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
unittest.main()
|