Ejemplo n.º 1
0
    def test_proxy_widget_save_manual_settings(self, settings_patcher,
                                               proxy_widget_load_patcher):
        """
        Test that the settings are saved correctly
        """
        # GIVEN: A Mocked and instance of the proxy widget with some known values set
        settings_instance = MagicMock()
        settings_patcher.return_value = settings_instance
        proxy_widget = ProxyWidget()
        proxy_widget.manual_proxy_radio.setChecked(True)
        proxy_widget.http_edit.setText('http_proxy_server:port')
        proxy_widget.https_edit.setText('https_proxy_server:port')
        proxy_widget.username_edit.setText('username')
        proxy_widget.password_edit.setText('password')

        # WHEN: Calling save
        proxy_widget.save()

        # THEN: The settings should be set as expected
        settings_instance.setValue.assert_has_calls([
            call('advanced/proxy mode', ProxyMode.MANUAL_PROXY),
            call('advanced/proxy http', 'http_proxy_server:port'),
            call('advanced/proxy https', 'https_proxy_server:port'),
            call('advanced/proxy username', 'username'),
            call('advanced/proxy password', 'password')
        ])
Ejemplo n.º 2
0
    def test_proxy_widget_load_default_settings(self):
        """
        Test that the default settings are loaded from the config correctly
        """
        # GIVEN: And instance of the widget with default settings
        proxy_widget = ProxyWidget()

        # WHEN: Calling the `load` method
        proxy_widget.load()

        # THEN: The widget should be in its default state
        assert proxy_widget.use_sysem_proxy_radio.isChecked() is True
        assert proxy_widget.http_edit.text() == ''
        assert proxy_widget.https_edit.text() == ''
        assert proxy_widget.username_edit.text() == ''
        assert proxy_widget.password_edit.text() == ''
Ejemplo n.º 3
0
    def test_radio_button_exclusivity_manual_proxy(self):
        """
        Test that only one radio button can be checked at a time, and that the line edits are only enabled when the
        `manual_proxy_radio` is checked
        """
        # GIVEN: An instance of the `openlp.core.common.widgets.widgets.ProxyWidget` with a radio already checked
        proxy_widget = ProxyWidget()
        proxy_widget.no_proxy_radio.setChecked(True)

        # WHEN: 'Checking' the `manual_proxy_radio` button
        proxy_widget.manual_proxy_radio.setChecked(True)

        # THEN: The other radio buttons should not be checked and the line edits should be enabled
        assert proxy_widget.no_proxy_radio.isChecked() is False
        assert proxy_widget.use_sysem_proxy_radio.isChecked() is False
        assert proxy_widget.http_edit.isEnabled() is True
        assert proxy_widget.https_edit.isEnabled() is True
        assert proxy_widget.username_edit.isEnabled() is True
        assert proxy_widget.password_edit.isEnabled() is True
Ejemplo n.º 4
0
 def setup_ui(self):
     """
     Configure the UI elements for the tab.
     """
     self.setObjectName('AdvancedTab')
     super(AdvancedTab, self).setup_ui()
     self.ui_group_box = QtWidgets.QGroupBox(self.left_column)
     self.ui_group_box.setObjectName('ui_group_box')
     self.ui_layout = QtWidgets.QFormLayout(self.ui_group_box)
     self.ui_layout.setObjectName('ui_layout')
     self.recent_label = QtWidgets.QLabel(self.ui_group_box)
     self.recent_label.setObjectName('recent_label')
     self.recent_spin_box = QtWidgets.QSpinBox(self.ui_group_box)
     self.recent_spin_box.setObjectName('recent_spin_box')
     self.recent_spin_box.setMinimum(0)
     self.ui_layout.addRow(self.recent_label, self.recent_spin_box)
     self.media_plugin_check_box = QtWidgets.QCheckBox(self.ui_group_box)
     self.media_plugin_check_box.setObjectName('media_plugin_check_box')
     self.ui_layout.addRow(self.media_plugin_check_box)
     self.hide_mouse_check_box = QtWidgets.QCheckBox(self.ui_group_box)
     self.hide_mouse_check_box.setObjectName('hide_mouse_check_box')
     self.ui_layout.addRow(self.hide_mouse_check_box)
     self.double_click_live_check_box = QtWidgets.QCheckBox(
         self.ui_group_box)
     self.double_click_live_check_box.setObjectName(
         'double_click_live_check_box')
     self.ui_layout.addRow(self.double_click_live_check_box)
     self.single_click_preview_check_box = QtWidgets.QCheckBox(
         self.ui_group_box)
     self.single_click_preview_check_box.setObjectName(
         'single_click_preview_check_box')
     self.ui_layout.addRow(self.single_click_preview_check_box)
     self.single_click_service_preview_check_box = QtWidgets.QCheckBox(
         self.ui_group_box)
     self.single_click_service_preview_check_box.setObjectName(
         'single_click_service_preview_check_box')
     self.ui_layout.addRow(self.single_click_service_preview_check_box)
     self.expand_service_item_check_box = QtWidgets.QCheckBox(
         self.ui_group_box)
     self.expand_service_item_check_box.setObjectName(
         'expand_service_item_check_box')
     self.ui_layout.addRow(self.expand_service_item_check_box)
     self.slide_max_height_label = QtWidgets.QLabel(self.ui_group_box)
     self.slide_max_height_label.setObjectName('slide_max_height_label')
     self.slide_max_height_combo_box = QtWidgets.QComboBox(
         self.ui_group_box)
     self.slide_max_height_combo_box.addItem('', userData=0)
     self.slide_max_height_combo_box.addItem('', userData=-4)
     # Generate numeric values for combo box dynamically
     for px in range(60, 801, 5):
         self.slide_max_height_combo_box.addItem(str(px) + 'px',
                                                 userData=px)
     self.slide_max_height_combo_box.setObjectName(
         'slide_max_height_combo_box')
     self.ui_layout.addRow(self.slide_max_height_label,
                           self.slide_max_height_combo_box)
     self.autoscroll_label = QtWidgets.QLabel(self.ui_group_box)
     self.autoscroll_label.setObjectName('autoscroll_label')
     self.autoscroll_combo_box = QtWidgets.QComboBox(self.ui_group_box)
     self.autoscroll_combo_box.addItems(
         ['', '', '', '', '', '', '', '', '', '', '', ''])
     self.autoscroll_combo_box.setObjectName('autoscroll_combo_box')
     self.ui_layout.addRow(self.autoscroll_label)
     self.ui_layout.addRow(self.autoscroll_combo_box)
     self.search_as_type_check_box = QtWidgets.QCheckBox(self.ui_group_box)
     self.search_as_type_check_box.setObjectName('SearchAsType_check_box')
     self.ui_layout.addRow(self.search_as_type_check_box)
     self.enable_auto_close_check_box = QtWidgets.QCheckBox(
         self.ui_group_box)
     self.enable_auto_close_check_box.setObjectName(
         'enable_auto_close_check_box')
     self.ui_layout.addRow(self.enable_auto_close_check_box)
     self.experimental_check_box = QtWidgets.QCheckBox(self.ui_group_box)
     self.experimental_check_box.setObjectName('experimental_check_box')
     self.ui_layout.addRow(self.experimental_check_box)
     self.left_layout.addWidget(self.ui_group_box)
     if HAS_DARK_STYLE:
         self.use_dark_style_checkbox = QtWidgets.QCheckBox(
             self.ui_group_box)
         self.use_dark_style_checkbox.setObjectName(
             'use_dark_style_checkbox')
         self.ui_layout.addRow(self.use_dark_style_checkbox)
     # Service Item Slide Limits
     self.slide_group_box = QtWidgets.QGroupBox(self.left_column)
     self.slide_group_box.setObjectName('slide_group_box')
     self.slide_layout = QtWidgets.QVBoxLayout(self.slide_group_box)
     self.slide_layout.setObjectName('slide_layout')
     self.slide_label = QtWidgets.QLabel(self.slide_group_box)
     self.slide_label.setWordWrap(True)
     self.slide_layout.addWidget(self.slide_label)
     self.end_slide_radio_button = QtWidgets.QRadioButton(
         self.slide_group_box)
     self.end_slide_radio_button.setObjectName('end_slide_radio_button')
     self.slide_layout.addWidget(self.end_slide_radio_button)
     self.wrap_slide_radio_button = QtWidgets.QRadioButton(
         self.slide_group_box)
     self.wrap_slide_radio_button.setObjectName('wrap_slide_radio_button')
     self.slide_layout.addWidget(self.wrap_slide_radio_button)
     self.next_item_radio_button = QtWidgets.QRadioButton(
         self.slide_group_box)
     self.next_item_radio_button.setObjectName('next_item_radio_button')
     self.slide_layout.addWidget(self.next_item_radio_button)
     self.left_layout.addWidget(self.slide_group_box)
     # Data Directory
     self.data_directory_group_box = QtWidgets.QGroupBox(self.left_column)
     self.data_directory_group_box.setObjectName('data_directory_group_box')
     self.data_directory_layout = QtWidgets.QFormLayout(
         self.data_directory_group_box)
     self.data_directory_layout.setObjectName('data_directory_layout')
     self.data_directory_new_label = QtWidgets.QLabel(
         self.data_directory_group_box)
     self.data_directory_new_label.setObjectName(
         'data_directory_current_label')
     self.data_directory_path_edit = PathEdit(
         self.data_directory_group_box,
         path_type=PathEditType.Directories,
         default_path=AppLocation.get_directory(AppLocation.DataDir))
     self.data_directory_layout.addRow(self.data_directory_new_label,
                                       self.data_directory_path_edit)
     self.new_data_directory_has_files_label = QtWidgets.QLabel(
         self.data_directory_group_box)
     self.new_data_directory_has_files_label.setObjectName(
         'new_data_directory_has_files_label')
     self.new_data_directory_has_files_label.setWordWrap(True)
     self.data_directory_cancel_button = QtWidgets.QToolButton(
         self.data_directory_group_box)
     self.data_directory_cancel_button.setObjectName(
         'data_directory_cancel_button')
     self.data_directory_cancel_button.setIcon(UiIcons().delete)
     self.data_directory_copy_check_layout = QtWidgets.QHBoxLayout()
     self.data_directory_copy_check_layout.setObjectName(
         'data_directory_copy_check_layout')
     self.data_directory_copy_check_box = QtWidgets.QCheckBox(
         self.data_directory_group_box)
     self.data_directory_copy_check_box.setObjectName(
         'data_directory_copy_check_box')
     self.data_directory_copy_check_layout.addWidget(
         self.data_directory_copy_check_box)
     self.data_directory_copy_check_layout.addStretch()
     self.data_directory_copy_check_layout.addWidget(
         self.data_directory_cancel_button)
     self.data_directory_layout.addRow(
         self.data_directory_copy_check_layout)
     self.data_directory_layout.addRow(
         self.new_data_directory_has_files_label)
     self.left_layout.addWidget(self.data_directory_group_box)
     # Display Workarounds
     self.display_workaround_group_box = QtWidgets.QGroupBox(
         self.right_column)
     self.display_workaround_group_box.setObjectName(
         'display_workaround_group_box')
     self.display_workaround_layout = QtWidgets.QVBoxLayout(
         self.display_workaround_group_box)
     self.display_workaround_layout.setObjectName(
         'display_workaround_layout')
     self.ignore_aspect_ratio_check_box = QtWidgets.QCheckBox(
         self.display_workaround_group_box)
     self.ignore_aspect_ratio_check_box.setObjectName(
         'ignore_aspect_ratio_check_box')
     self.display_workaround_layout.addWidget(
         self.ignore_aspect_ratio_check_box)
     self.x11_bypass_check_box = QtWidgets.QCheckBox(
         self.display_workaround_group_box)
     self.x11_bypass_check_box.setObjectName('x11_bypass_check_box')
     self.display_workaround_layout.addWidget(self.x11_bypass_check_box)
     self.alternate_rows_check_box = QtWidgets.QCheckBox(
         self.display_workaround_group_box)
     self.alternate_rows_check_box.setObjectName('alternate_rows_check_box')
     self.display_workaround_layout.addWidget(self.alternate_rows_check_box)
     self.right_layout.addWidget(self.display_workaround_group_box)
     # Default service name
     self.service_name_group_box = QtWidgets.QGroupBox(self.right_column)
     self.service_name_group_box.setObjectName('service_name_group_box')
     self.service_name_layout = QtWidgets.QFormLayout(
         self.service_name_group_box)
     self.service_name_check_box = QtWidgets.QCheckBox(
         self.service_name_group_box)
     self.service_name_check_box.setObjectName('service_name_check_box')
     self.service_name_layout.setObjectName('service_name_layout')
     self.service_name_layout.addRow(self.service_name_check_box)
     self.service_name_time_label = QtWidgets.QLabel(
         self.service_name_group_box)
     self.service_name_time_label.setObjectName('service_name_time_label')
     self.service_name_day = QtWidgets.QComboBox(
         self.service_name_group_box)
     self.service_name_day.addItems(['', '', '', '', '', '', '', ''])
     self.service_name_day.setObjectName('service_name_day')
     self.service_name_time = QtWidgets.QTimeEdit(
         self.service_name_group_box)
     self.service_name_time.setObjectName('service_name_time')
     self.service_name_time_layout = QtWidgets.QHBoxLayout()
     self.service_name_time_layout.setObjectName('service_name_time_layout')
     self.service_name_time_layout.addWidget(self.service_name_day)
     self.service_name_time_layout.addWidget(self.service_name_time)
     self.service_name_layout.addRow(self.service_name_time_label,
                                     self.service_name_time_layout)
     self.service_name_label = QtWidgets.QLabel(self.service_name_group_box)
     self.service_name_label.setObjectName('service_name_label')
     self.service_name_edit = QtWidgets.QLineEdit(
         self.service_name_group_box)
     self.service_name_edit.setObjectName('service_name_edit')
     self.service_name_edit.setValidator(
         QtGui.QRegExpValidator(QtCore.QRegExp(r'[^/\\?*|<>\[\]":+]+'),
                                self))
     self.service_name_revert_button = QtWidgets.QToolButton(
         self.service_name_group_box)
     self.service_name_revert_button.setObjectName(
         'service_name_revert_button')
     self.service_name_revert_button.setIcon(UiIcons().undo)
     self.service_name_button_layout = QtWidgets.QHBoxLayout()
     self.service_name_button_layout.setObjectName(
         'service_name_button_layout')
     self.service_name_button_layout.addWidget(self.service_name_edit)
     self.service_name_button_layout.addWidget(
         self.service_name_revert_button)
     self.service_name_layout.addRow(self.service_name_label,
                                     self.service_name_button_layout)
     self.service_name_example_label = QtWidgets.QLabel(
         self.service_name_group_box)
     self.service_name_example_label.setObjectName(
         'service_name_example_label')
     self.service_name_example = QtWidgets.QLabel(
         self.service_name_group_box)
     self.service_name_example.setObjectName('service_name_example')
     self.service_name_layout.addRow(self.service_name_example_label,
                                     self.service_name_example)
     self.right_layout.addWidget(self.service_name_group_box)
     # Proxies
     self.proxy_widget = ProxyWidget(self.right_column)
     self.right_layout.addWidget(self.proxy_widget)
     # After the last item on each side, add some spacing
     self.left_layout.addStretch()
     self.right_layout.addStretch()
     # Set up all the connections and things
     self.should_update_service_name_example = False
     self.service_name_check_box.toggled.connect(
         self.service_name_check_box_toggled)
     self.service_name_day.currentIndexChanged.connect(
         self.on_service_name_day_changed)
     self.service_name_time.timeChanged.connect(
         self.update_service_name_example)
     self.service_name_edit.textChanged.connect(
         self.update_service_name_example)
     self.service_name_revert_button.clicked.connect(
         self.on_service_name_revert_button_clicked)
     self.alternate_rows_check_box.toggled.connect(
         self.on_alternate_rows_check_box_toggled)
     self.data_directory_path_edit.pathChanged.connect(
         self.on_data_directory_path_edit_path_changed)
     self.data_directory_cancel_button.clicked.connect(
         self.on_data_directory_cancel_button_clicked)
     self.data_directory_copy_check_box.toggled.connect(
         self.on_data_directory_copy_check_box_toggled)
     self.end_slide_radio_button.clicked.connect(
         self.on_end_slide_button_clicked)
     self.wrap_slide_radio_button.clicked.connect(
         self.on_wrap_slide_button_clicked)
     self.next_item_radio_button.clicked.connect(
         self.on_next_item_button_clicked)
     self.search_as_type_check_box.stateChanged.connect(
         self.on_search_as_type_check_box_changed)