T-573 修复封面画廊候选图宽度

This commit is contained in:
chengma
2026-07-09 15:51:48 +08:00
parent 065ad349de
commit c3c79b63d4
3 changed files with 109 additions and 12 deletions
+54
View File
@@ -2277,6 +2277,60 @@ class GuiTests(TempDirMixin, unittest.TestCase):
self.assert_removed(temp_dir)
def test_cover_gallery_candidate_content_width_fits_multiple_candidates(self):
with self.make_temp_dir() as temp_dir:
cfg, account, tasks, canonicals, _archives = self._cover_gallery_task_set(temp_dir, count=1)
prefix = os.path.splitext(canonicals[0])[0]
self.write_test_image(f"{prefix}_20260709101100.jpg")
self.write_test_image(f"{prefix}_20260709101200.jpg")
dialog = CoverGalleryDialog(tasks[0], cfg["image_dir"], cfg["db_path"], account=account)
self.addCleanup(dialog.close)
self.assertGreaterEqual(len(dialog.candidates), 4)
expected_width = (
len(dialog.candidates) * (dialog.THUMBNAIL_SIZE + 16)
+ (len(dialog.candidates) - 1) * dialog.candidate_layout.spacing()
)
self.assertIs(dialog.candidate_scroll.widget(), dialog.candidate_content)
self.assertGreaterEqual(dialog.candidate_content.minimumWidth(), expected_width)
self.assertGreaterEqual(dialog.candidate_content.width(), expected_width)
self.assert_removed(temp_dir)
def test_cover_gallery_switch_task_resyncs_candidate_content_width(self):
with self.make_temp_dir() as temp_dir:
cfg, account, tasks, canonicals, archives = self._cover_gallery_task_set(temp_dir, count=2)
os.remove(archives[0])
prefix = os.path.splitext(canonicals[1])[0]
self.write_test_image(f"{prefix}_20260709101100.jpg")
self.write_test_image(f"{prefix}_20260709101200.jpg")
dialog = CoverGalleryDialog(
tasks[0],
cfg["image_dir"],
cfg["db_path"],
account=account,
visible_tasks=tasks,
task_index=0,
account_by_alias={"alias-a": account},
)
self.addCleanup(dialog.close)
initial_width = dialog.candidate_content.minimumWidth()
self.assertTrue(dialog.switch_task(1))
expected_width = (
len(dialog.candidates) * (dialog.THUMBNAIL_SIZE + 16)
+ (len(dialog.candidates) - 1) * dialog.candidate_layout.spacing()
)
self.assertEqual(tasks[1].id, dialog.task.id)
self.assertGreater(len(dialog.candidates), 2)
self.assertGreater(dialog.candidate_content.minimumWidth(), initial_width)
self.assertGreaterEqual(dialog.candidate_content.minimumWidth(), expected_width)
self.assertGreaterEqual(dialog.candidate_content.width(), expected_width)
self.assert_removed(temp_dir)
def test_cover_gallery_save_switches_current_cover(self):
with self.make_temp_dir() as temp_dir:
cfg = self.make_config(temp_dir)