Exemple #1
0
async def test_show_dialog_for_prime3_layout(skip_qtbot, mocker,
                                             corruption_game_description):
    mock_execute_dialog = mocker.patch(
        "randovania.gui.lib.async_dialog.execute_dialog",
        new_callable=AsyncMock)
    mock_clipboard: MagicMock = mocker.patch(
        "PySide2.QtWidgets.QApplication.clipboard")

    window = SeedDetailsWindow(None, MagicMock())
    window.player_index_combo.addItem("Current", 0)
    skip_qtbot.addWidget(window)

    collections.namedtuple("MockPickup", ["name"])
    target = MagicMock()
    target.pickup.name = "Boost Ball"

    patches = corruption_game_description.create_game_patches()
    for i in range(100):
        patches.pickup_assignment[PickupIndex(i)] = target

    window.layout_description = MagicMock()
    window.layout_description.all_patches = {0: patches}

    # Run
    await window._show_dialog_for_prime3_layout()

    # Assert
    mock_execute_dialog.assert_awaited_once()
    mock_clipboard.return_value.setText.assert_called_once()
Exemple #2
0
def test_update_layout_description_no_spoiler(skip_qtbot, mocker):
    # Setup
    mock_describer = mocker.patch(
        "randovania.gui.lib.preset_describer.describe",
        return_value=["a", "b", "c", "d"])
    mock_merge = mocker.patch(
        "randovania.gui.lib.preset_describer.merge_categories",
        return_value="<description>")

    options = MagicMock()
    description = MagicMock()
    description.permalink.player_count = 1
    description.permalink.as_base64_str = "<permalink>"
    description.permalink.spoiler = False

    window = SeedDetailsWindow(None, options)
    skip_qtbot.addWidget(window)

    # Run
    window.update_layout_description(description)

    # Assert
    mock_describer.assert_called_once_with(
        description.permalink.get_preset.return_value)
    mock_merge.assert_has_calls([
        call(["a", "c"]),
        call(["b", "d"]),
    ])
    def _open_existing_seed_details(self):
        json_path = prompt_user_for_seed_log(self)
        if json_path is None:
            return

        self._seed_details = SeedDetailsWindow(json_path)
        self._seed_details.show()
Exemple #4
0
def show_game_details(app: QApplication, options, game: Path):
    from randovania.layout.layout_description import LayoutDescription
    from randovania.gui.seed_details_window import SeedDetailsWindow

    layout = LayoutDescription.from_file(game)
    details_window = SeedDetailsWindow(None, options)
    details_window.update_layout_description(layout)
    details_window.show()
    app.details_window = details_window
Exemple #5
0
    def __init__(self, options: Options, preset_manager: PresetManager, preview: bool):
        super().__init__()
        self.setupUi(self)
        self.setWindowTitle("Randovania {}".format(VERSION))
        self.is_preview_mode = preview
        self.setAcceptDrops(True)
        common_qt_lib.set_default_window_icon(self)

        self.intro_label.setText(self.intro_label.text().format(version=VERSION))

        self._preset_manager = preset_manager

        if preview:
            debug.set_level(2)

        # Signals
        self.newer_version_signal.connect(self.display_new_version)
        self.background_tasks_button_lock_signal.connect(self.enable_buttons_with_background_tasks)
        self.progress_update_signal.connect(self.update_progress)
        self.stop_background_process_button.clicked.connect(self.stop_background_process)
        self.options_changed_signal.connect(self.on_options_changed)

        self.intro_play_now_button.clicked.connect(lambda: self.welcome_tab_widget.setCurrentWidget(self.tab_play))
        self.open_faq_button.clicked.connect(self._open_faq)
        self.open_database_viewer_button.clicked.connect(self._open_data_visualizer)

        self.import_permalink_button.clicked.connect(self._import_permalink)
        self.create_new_seed_button.clicked.connect(
            lambda: self.welcome_tab_widget.setCurrentWidget(self.tab_create_seed))

        # Menu Bar
        self.menu_action_data_visualizer.triggered.connect(self._open_data_visualizer)
        self.menu_action_item_tracker.triggered.connect(self._open_item_tracker)
        self.menu_action_edit_new_database.triggered.connect(self._open_data_editor_default)
        self.menu_action_edit_existing_database.triggered.connect(self._open_data_editor_prompt)
        self.menu_action_validate_seed_after.triggered.connect(self._on_validate_seed_change)
        self.menu_action_timeout_generation_after_a_time_limit.triggered.connect(self._on_generate_time_limit_change)

        self.generate_seed_tab = GenerateSeedTab(self, self, self, options)
        self.generate_seed_tab.setup_ui()
        self._details_window = SeedDetailsWindow(self, self, options)
        self._details_window.added_to_tab = False

        # Needs the GenerateSeedTab
        self._create_open_map_tracker_actions()

        # Setting this event only now, so all options changed trigger only once
        options.on_options_changed = self.options_changed_signal.emit
        self._options = options
        with options:
            self.on_options_changed()

        self.main_tab_widget.setCurrentIndex(0)

        # Update hints text
        self._update_hints_text()
Exemple #6
0
def test_update_layout_description_actual_seed(skip_qtbot, test_files_dir):
    description = LayoutDescription.from_file(
        test_files_dir.joinpath("log_files", "seed_a.rdvgame"))

    # Run
    window = SeedDetailsWindow(None, MagicMock())
    skip_qtbot.addWidget(window)
    window.update_layout_description(description)

    # Assert
    assert len(window.pickup_spoiler_buttons) == 119
    assert window.pickup_spoiler_show_all_button.text() == "Show All"
    skip_qtbot.mouseClick(window.pickup_spoiler_show_all_button,
                          QtCore.Qt.LeftButton)
    assert window.pickup_spoiler_show_all_button.text() == "Hide All"
Exemple #7
0
async def test_export_iso(skip_qtbot, mocker):
    # Setup
    mock_execute_dialog = mocker.patch(
        "randovania.gui.lib.async_dialog.execute_dialog",
        new_callable=AsyncMock,
        return_value=QtWidgets.QDialog.Accepted)

    options = MagicMock()
    options.output_directory = None

    window = SeedDetailsWindow(None, options)
    window.layout_description = MagicMock()
    window._player_names = {}
    window.run_in_background_async = AsyncMock()

    # Run
    await window._export_iso()

    # Assert
    mock_execute_dialog.assert_awaited_once()
    window.run_in_background_async.assert_awaited_once()
async def test_export_iso(skip_qtbot, mocker):
    # Setup
    mock_input_dialog = mocker.patch(
        "randovania.gui.seed_details_window.GameInputDialog")
    mock_execute_dialog = mocker.patch(
        "randovania.gui.lib.async_dialog.execute_dialog",
        new_callable=AsyncMock,
        return_value=QtWidgets.QDialog.Accepted)

    options = MagicMock()
    options.output_directory = None

    window_manager = MagicMock()
    patcher_provider = window_manager.patcher_provider
    patcher = patcher_provider.patcher_for_game.return_value
    patcher.is_busy = False

    window = SeedDetailsWindow(window_manager, options)
    window.layout_description = MagicMock()
    window._player_names = {}

    players_config = PlayersConfiguration(
        player_index=window.current_player_index,
        player_names=window._player_names,
    )

    # Run
    await window._export_iso()

    # Assert
    mock_execute_dialog.assert_awaited_once()
    patcher.create_patch_data.assert_called_once_with(
        window.layout_description, players_config, options.cosmetic_patches)
    patcher.patch_game.assert_called_once_with(
        mock_input_dialog.return_value.input_file,
        mock_input_dialog.return_value.output_file,
        patcher.create_patch_data.return_value,
        window._options.game_files_path,
        progress_update=ANY,
    )
 def _open_game_details(self, layout: LayoutDescription):
     from randovania.gui.seed_details_window import SeedDetailsWindow
     details_window = SeedDetailsWindow(self, self._options)
     details_window.update_layout_description(layout)
     details_window.show()
     self.track_window(details_window)