mirror of
https://github.com/LorenEteval/Furious.git
synced 2026-10-02 03:48:03 +03:00
refactor: simplify download speed menu
Expose a single Test Download Speed action backed by the multithreaded scheduler while retaining and documenting the single-threaded API for programmatic callers. Remove the obsolete translation and cover the menu label, shortcut, and dispatch behavior. Signed-off-by: Loren Eteval <loren.eteval@proton.me>
This commit is contained in:
Vendored
-8
@@ -549,14 +549,6 @@ TRANSLATION = {
|
||||
"ZH": "测试下行速度",
|
||||
"isReviewed": "True"
|
||||
},
|
||||
"Test Download Speed (Multithreaded)": {
|
||||
"source": [
|
||||
"Furious.Widget.ServerTableView"
|
||||
],
|
||||
"RU": "Измерить скорость загрузки (многопоточная)",
|
||||
"ZH": "测试下行速度(多线程)",
|
||||
"isReviewed": "True"
|
||||
},
|
||||
"Clear Test Results": {
|
||||
"source": [
|
||||
"Furious.Widget.ServerTableView"
|
||||
|
||||
@@ -1472,22 +1472,17 @@ class ServerTableView(
|
||||
QtCore.Qt.Key.Key_O,
|
||||
),
|
||||
),
|
||||
# The context menu intentionally exposes only the multithreaded test.
|
||||
# Keep the single-threaded methods as a programmatic API for callers
|
||||
# that need that scheduler explicitly.
|
||||
AppQAction(
|
||||
_('Test Download Speed (Multithreaded)'),
|
||||
_('Test Download Speed'),
|
||||
callback=lambda: self.testSelectedItemDownloadSpeedMulti(),
|
||||
shortcut=QtCore.QKeyCombination(
|
||||
QtCore.Qt.KeyboardModifier.ControlModifier,
|
||||
QtCore.Qt.Key.Key_M,
|
||||
),
|
||||
),
|
||||
AppQAction(
|
||||
_('Test Download Speed'),
|
||||
callback=lambda: self.testSelectedItemDownloadSpeed(),
|
||||
shortcut=QtCore.QKeyCombination(
|
||||
QtCore.Qt.KeyboardModifier.ControlModifier,
|
||||
QtCore.Qt.Key.Key_T,
|
||||
),
|
||||
),
|
||||
AppQAction(
|
||||
_('Clear Test Results'),
|
||||
callback=lambda: self.clearSelectedItemTestResult(),
|
||||
@@ -2511,7 +2506,11 @@ class ServerTableView(
|
||||
)
|
||||
|
||||
def testSelectedItemDownloadSpeed(self):
|
||||
"""Handle test selected item download speed for the user servers Qt table view."""
|
||||
"""Run the retained single-threaded download-test API for selected rows.
|
||||
|
||||
The Home context menu uses the multithreaded variant; this method remains
|
||||
available for programmatic callers that explicitly need serial scheduling.
|
||||
"""
|
||||
self.testSelectedItemDownloadSpeedWithTimeout(5000)
|
||||
|
||||
def testSelectedItemDownloadSpeedMulti(self):
|
||||
|
||||
@@ -35,7 +35,7 @@ from Furious.Window.SettingsPage import (
|
||||
)
|
||||
from Furious.Window.SubscriptionPage import _SubscriptionEditorDialog
|
||||
|
||||
from PySide6 import QtCore
|
||||
from PySide6 import QtCore, QtGui
|
||||
from PySide6.QtTest import QTest
|
||||
from PySide6.QtWidgets import QLineEdit, QVBoxLayout, QWidget
|
||||
|
||||
@@ -361,6 +361,48 @@ class ServerTableQtInteractionTest(unittest.TestCase):
|
||||
window.close()
|
||||
window.deleteLater()
|
||||
|
||||
def testContextMenuUsesOnlyMultithreadedDownloadSpeedAction(self):
|
||||
"""Expose one download command backed by the multithreaded scheduler."""
|
||||
with isolatedSettings():
|
||||
table = self._table(('one',))
|
||||
|
||||
try:
|
||||
actions = tuple(
|
||||
action
|
||||
for action in table.contextMenu.actions()
|
||||
if not action.isSeparator()
|
||||
and action.textEnglish == 'Test Download Speed'
|
||||
)
|
||||
|
||||
self.assertEqual(len(actions), 1)
|
||||
self.assertEqual(
|
||||
actions[0].shortcut(),
|
||||
QtGui.QKeySequence(
|
||||
QtCore.QKeyCombination(
|
||||
QtCore.Qt.KeyboardModifier.ControlModifier,
|
||||
QtCore.Qt.Key.Key_M,
|
||||
)
|
||||
),
|
||||
)
|
||||
|
||||
with (
|
||||
mock.patch.object(
|
||||
table,
|
||||
'testSelectedItemDownloadSpeedMulti',
|
||||
) as multithreaded,
|
||||
mock.patch.object(
|
||||
table,
|
||||
'testSelectedItemDownloadSpeed',
|
||||
) as singleThreaded,
|
||||
):
|
||||
actions[0].trigger()
|
||||
processQtEvents()
|
||||
|
||||
multithreaded.assert_called_once_with()
|
||||
singleThreaded.assert_not_called()
|
||||
finally:
|
||||
self._destroyTable(table)
|
||||
|
||||
def testHeaderSortPreservesSelectionCurrentAndActiveIdentity(self):
|
||||
"""Remap Qt persistent indexes when a real header click sorts rows."""
|
||||
with isolatedSettings():
|
||||
|
||||
Reference in New Issue
Block a user