Fix tests

This commit is contained in:
Micah Lee 2020-06-28 13:01:23 -07:00
parent 55e95d527b
commit f6ea6e4a1d
No known key found for this signature in database
GPG Key ID: 403C2657CD994F73
7 changed files with 70 additions and 60 deletions

View File

@ -338,8 +338,8 @@ class FileSelection(QtWidgets.QVBoxLayout):
else:
self.add_button = QtWidgets.QPushButton(strings._("gui_add"))
self.add_button.clicked.connect(self.add)
self.delete_button = QtWidgets.QPushButton(strings._("gui_delete"))
self.delete_button.clicked.connect(self.delete)
self.remove_button = QtWidgets.QPushButton(strings._("gui_remove"))
self.remove_button.clicked.connect(self.delete)
button_layout = QtWidgets.QHBoxLayout()
button_layout.addStretch()
if self.common.platform == "Darwin":
@ -347,7 +347,7 @@ class FileSelection(QtWidgets.QVBoxLayout):
button_layout.addWidget(self.add_folder_button)
else:
button_layout.addWidget(self.add_button)
button_layout.addWidget(self.delete_button)
button_layout.addWidget(self.remove_button)
# Add the widgets
self.addWidget(self.file_list)
@ -366,7 +366,7 @@ class FileSelection(QtWidgets.QVBoxLayout):
self.add_folder_button.hide()
else:
self.add_button.hide()
self.delete_button.hide()
self.remove_button.hide()
else:
if self.common.platform == "Darwin":
self.add_files_button.show()
@ -376,9 +376,9 @@ class FileSelection(QtWidgets.QVBoxLayout):
# Delete button should be hidden if item isn't selected
if len(self.file_list.selectedItems()) == 0:
self.delete_button.hide()
self.remove_button.hide()
else:
self.delete_button.show()
self.remove_button.show()
# Update the file list
self.file_list.update()

View File

@ -112,11 +112,15 @@ class ShareMode(Mode):
self.info_label.hide()
# Delete all files button
self.delete_all_button = QtWidgets.QPushButton(strings._("gui_file_selection_delete_all"))
self.delete_all_button.setFlat(True)
self.delete_all_button.setStyleSheet(self.common.gui.css["share_delete_all_files_button"])
self.delete_all_button.clicked.connect(self.delete_all)
self.delete_all_button.hide()
self.remove_all_button = QtWidgets.QPushButton(
strings._("gui_file_selection_remove_all")
)
self.remove_all_button.setFlat(True)
self.remove_all_button.setStyleSheet(
self.common.gui.css["share_delete_all_files_button"]
)
self.remove_all_button.clicked.connect(self.delete_all)
self.remove_all_button.hide()
# Toggle history
self.toggle_history = ToggleHistory(
@ -133,7 +137,7 @@ class ShareMode(Mode):
top_bar_layout = QtWidgets.QHBoxLayout()
top_bar_layout.addWidget(self.info_label)
top_bar_layout.addStretch()
top_bar_layout.addWidget(self.delete_all_button)
top_bar_layout.addWidget(self.remove_all_button)
top_bar_layout.addWidget(self.toggle_history)
# Primary action layout
@ -206,7 +210,7 @@ class ShareMode(Mode):
# Hide and reset the downloads if we have previously shared
self.reset_info_counters()
self.delete_all_button.hide()
self.remove_all_button.hide()
def start_server_step2_custom(self):
"""
@ -267,7 +271,7 @@ class ShareMode(Mode):
self.history.update_in_progress()
self.file_selection.file_list.adjustSize()
self.delete_all_button.show()
self.remove_all_button.show()
def cancel_server_custom(self):
"""
@ -355,7 +359,7 @@ class ShareMode(Mode):
if self.server_status.file_selection.get_num_files() > 0:
self.primary_action.show()
self.info_label.show()
self.delete_all_button.show()
self.remove_all_button.show()
def update_primary_action(self):
self.common.log("ShareMode", "update_primary_action")
@ -365,7 +369,7 @@ class ShareMode(Mode):
if file_count > 0:
self.primary_action.show()
self.info_label.show()
self.delete_all_button.show()
self.remove_all_button.show()
# Update the file count in the info label
total_size_bytes = 0
@ -388,7 +392,7 @@ class ShareMode(Mode):
else:
self.primary_action.hide()
self.info_label.hide()
self.delete_all_button.hide()
self.remove_all_button.hide()
def reset_info_counters(self):
"""

View File

@ -115,11 +115,15 @@ class WebsiteMode(Mode):
self.info_label.hide()
# Delete all files button
self.delete_all_button = QtWidgets.QPushButton(strings._("gui_file_selection_delete_all"))
self.delete_all_button.setFlat(True)
self.delete_all_button.setStyleSheet(self.common.gui.css["share_delete_all_files_button"])
self.delete_all_button.clicked.connect(self.delete_all)
self.delete_all_button.hide()
self.remove_all_button = QtWidgets.QPushButton(
strings._("gui_file_selection_remove_all")
)
self.remove_all_button.setFlat(True)
self.remove_all_button.setStyleSheet(
self.common.gui.css["share_delete_all_files_button"]
)
self.remove_all_button.clicked.connect(self.delete_all)
self.remove_all_button.hide()
# Toggle history
self.toggle_history = ToggleHistory(
@ -136,7 +140,7 @@ class WebsiteMode(Mode):
top_bar_layout = QtWidgets.QHBoxLayout()
top_bar_layout.addWidget(self.info_label)
top_bar_layout.addStretch()
top_bar_layout.addWidget(self.delete_all_button)
top_bar_layout.addWidget(self.remove_all_button)
top_bar_layout.addWidget(self.toggle_history)
# Primary action layout
@ -199,7 +203,7 @@ class WebsiteMode(Mode):
# Hide and reset the downloads if we have previously shared
self.reset_info_counters()
self.delete_all_button.hide()
self.remove_all_button.hide()
def start_server_step2_custom(self):
"""
@ -238,7 +242,7 @@ class WebsiteMode(Mode):
self.history.completed_count = 0
self.file_selection.file_list.adjustSize()
self.delete_all_button.show()
self.remove_all_button.show()
def cancel_server_custom(self):
"""
@ -260,7 +264,7 @@ class WebsiteMode(Mode):
if self.server_status.file_selection.get_num_files() > 0:
self.primary_action.show()
self.info_label.show()
self.delete_all_button.show()
self.remove_all_button.show()
def update_primary_action(self):
self.common.log("WebsiteMode", "update_primary_action")
@ -270,7 +274,7 @@ class WebsiteMode(Mode):
if file_count > 0:
self.primary_action.show()
self.info_label.show()
self.delete_all_button.show()
self.remove_all_button.show()
# Update the file count in the info label
total_size_bytes = 0
@ -293,7 +297,7 @@ class WebsiteMode(Mode):
else:
self.primary_action.hide()
self.info_label.hide()
self.delete_all_button.hide()
self.remove_all_button.hide()
def reset_info_counters(self):
"""

View File

@ -11,8 +11,8 @@
"gui_add": "Add",
"gui_add_files": "Add Files",
"gui_add_folder": "Add Folder",
"gui_delete": "Delete",
"gui_file_selection_delete_all": "Delete All",
"gui_remove": "Remove",
"gui_file_selection_remove_all": "Remove All",
"gui_choose_items": "Choose",
"gui_share_start_server": "Start sharing",
"gui_share_stop_server": "Stop sharing",
@ -206,4 +206,4 @@
"mode_settings_receive_data_dir_label": "Save files to",
"mode_settings_receive_data_dir_browse_button": "Browse",
"mode_settings_website_disable_csp_checkbox": "Disable Content Security Policy header (allows your website to use third-party resources)"
}
}

View File

@ -388,13 +388,13 @@ class GuiBaseTest(unittest.TestCase):
tab.get_mode().server_status.file_selection.get_num_files(), num
)
def add_delete_buttons_hidden(self, tab):
"""Test that the add and delete buttons are hidden when the server starts"""
def add_remove_buttons_hidden(self, tab):
"""Test that the add and remove buttons are hidden when the server starts"""
self.assertFalse(
tab.get_mode().server_status.file_selection.add_button.isVisible()
)
self.assertFalse(
tab.get_mode().server_status.file_selection.delete_button.isVisible()
tab.get_mode().server_status.file_selection.remove_button.isVisible()
)
# Auto-stop timer tests

View File

@ -12,8 +12,8 @@ from .gui_base_test import GuiBaseTest
class TestShare(GuiBaseTest):
# Shared test methods
def deleting_all_files_hides_delete_button(self, tab):
"""Test that clicking on the file item shows the delete button. Test that deleting the only item in the list hides the delete button"""
def removing_all_files_hides_remove_button(self, tab):
"""Test that clicking on the file item shows the remove button. Test that removing the only item in the list hides the remove button"""
rect = tab.get_mode().server_status.file_selection.file_list.visualItemRect(
tab.get_mode().server_status.file_selection.file_list.item(0)
)
@ -22,12 +22,12 @@ class TestShare(GuiBaseTest):
QtCore.Qt.LeftButton,
pos=rect.center(),
)
# Delete button should be visible
# Remove button should be visible
self.assertTrue(
tab.get_mode().server_status.file_selection.delete_button.isVisible()
tab.get_mode().server_status.file_selection.remove_button.isVisible()
)
# Click delete, delete button should still be visible since we have one more file
tab.get_mode().server_status.file_selection.delete_button.click()
# Click remove, remove button should still be visible since we have one more file
tab.get_mode().server_status.file_selection.remove_button.click()
rect = tab.get_mode().server_status.file_selection.file_list.visualItemRect(
tab.get_mode().server_status.file_selection.file_list.item(0)
)
@ -37,17 +37,17 @@ class TestShare(GuiBaseTest):
pos=rect.center(),
)
self.assertTrue(
tab.get_mode().server_status.file_selection.delete_button.isVisible()
tab.get_mode().server_status.file_selection.remove_button.isVisible()
)
tab.get_mode().server_status.file_selection.delete_button.click()
tab.get_mode().server_status.file_selection.remove_button.click()
# No more files, the delete button should be hidden
# No more files, the remove button should be hidden
self.assertFalse(
tab.get_mode().server_status.file_selection.delete_button.isVisible()
tab.get_mode().server_status.file_selection.remove_button.isVisible()
)
def add_a_file_and_delete_using_its_delete_widget(self, tab):
"""Test that we can also delete a file by clicking on its [X] widget"""
def add_a_file_and_remove_using_its_remove_widget(self, tab):
"""Test that we can also remove a file by clicking on its [X] widget"""
num_files = tab.get_mode().server_status.file_selection.get_num_files()
tab.get_mode().server_status.file_selection.file_list.add_file(self.tmpfiles[0])
tab.get_mode().server_status.file_selection.file_list.item(
@ -55,11 +55,11 @@ class TestShare(GuiBaseTest):
).item_button.click()
self.file_selection_widget_has_files(tab, num_files)
def add_a_file_and_delete_using_delete_all_widget(self, tab):
"""Test that we can also delete all files by clicking on the Delete All widget"""
def add_a_file_and_remove_using_remove_all_widget(self, tab):
"""Test that we can also remove all files by clicking on the Remove All widget"""
tab.get_mode().server_status.file_selection.file_list.add_file(self.tmpfiles[0])
tab.get_mode().server_status.file_selection.file_list.add_file(self.tmpfiles[1])
tab.get_mode().delete_all_button.click()
tab.get_mode().remove_all_button.click()
# Should be no files after clearing all
self.file_selection_widget_has_files(tab, 0)
@ -197,7 +197,7 @@ class TestShare(GuiBaseTest):
"""Test that we can cancel a share before it's started up """
self.server_working_on_start_button_pressed(tab)
self.server_status_indicator_says_scheduled(tab)
self.add_delete_buttons_hidden(tab)
self.add_remove_buttons_hidden(tab)
self.mode_settings_widget_is_hidden(tab)
self.set_autostart_timer(tab, 10)
QtTest.QTest.mousePress(
@ -224,15 +224,15 @@ class TestShare(GuiBaseTest):
self.history_is_not_visible(tab)
self.click_toggle_history(tab)
self.history_is_visible(tab)
self.deleting_all_files_hides_delete_button(tab)
self.add_a_file_and_delete_using_its_delete_widget(tab)
self.removing_all_files_hides_remove_button(tab)
self.add_a_file_and_remove_using_its_remove_widget(tab)
self.file_selection_widget_read_files(tab)
def run_all_share_mode_started_tests(self, tab, startup_time=2000):
"""Tests in share mode after starting a share"""
self.server_working_on_start_button_pressed(tab)
self.server_status_indicator_says_starting(tab)
self.add_delete_buttons_hidden(tab)
self.add_remove_buttons_hidden(tab)
self.mode_settings_widget_is_hidden(tab)
self.server_is_started(tab, startup_time)
self.web_server_is_running(tab)
@ -287,10 +287,10 @@ class TestShare(GuiBaseTest):
self.individual_file_is_viewable_or_not(tab)
self.clear_all_history_items(tab, 2)
def run_all_delete_all_file_selection_button_tests(self, tab):
"""Test the Delete All File Selection button"""
def run_all_remove_all_file_selection_button_tests(self, tab):
"""Test the Remove All File Selection button"""
self.run_all_share_mode_setup_tests(tab)
self.add_a_file_and_delete_using_delete_all_widget(tab)
self.add_a_file_and_remove_using_remove_all_widget(tab)
def run_all_share_mode_individual_file_tests(self, tab):
"""Tests in share mode when viewing an individual file"""
@ -401,14 +401,14 @@ class TestShare(GuiBaseTest):
self.close_all_tabs()
@pytest.mark.gui
def test_delete_all_file_selection_button(self):
def test_remove_all_file_selection_button(self):
"""
Test delete all file items at once
Test remove all file items at once
"""
tab = self.new_share_tab()
self.run_all_common_setup_tests()
self.run_all_delete_all_file_selection_button_tests(tab)
self.run_all_remove_all_file_selection_button_tests(tab)
self.close_all_tabs()
@ -586,6 +586,7 @@ class TestShare(GuiBaseTest):
Rate limit should be triggered
"""
tab = self.new_share_tab()
def accept_dialog():
window = tab.common.gui.qtapp.activeWindow()
if window:
@ -605,6 +606,7 @@ class TestShare(GuiBaseTest):
Public mode should skip the rate limit
"""
tab = self.new_share_tab()
def accept_dialog():
window = tab.common.gui.qtapp.activeWindow()
if window:

View File

@ -64,7 +64,7 @@ class TestWebsite(GuiBaseTest):
"""Tests in website mode after starting a share"""
self.server_working_on_start_button_pressed(tab)
self.server_status_indicator_says_starting(tab)
self.add_delete_buttons_hidden(tab)
self.add_remove_buttons_hidden(tab)
self.server_is_started(tab, startup_time)
self.web_server_is_running(tab)
self.have_a_password(tab)