|
6 | 6 |
|
7 | 7 | import pytest |
8 | 8 | from mhfu_studio.monster.panels.node_graph import ( |
| 9 | + FADED, |
9 | 10 | NODE_W, |
10 | 11 | GraphView, |
11 | 12 | LinkSpec, |
12 | 13 | NodeSpec, |
13 | 14 | wrap, |
14 | 15 | ) |
15 | 16 | from mhfu_studio.shell.overlay import Ink |
16 | | -from PySide6.QtCore import QPoint, QPointF, Qt |
| 17 | +from PySide6.QtCore import QEvent, QPoint, QPointF, Qt |
17 | 18 | from PySide6.QtGui import ( |
18 | 19 | QFont, |
19 | 20 | QFontMetricsF, |
| 21 | + QHelpEvent, |
20 | 22 | QInputDevice, |
21 | 23 | QKeySequence, |
22 | 24 | QNativeGestureEvent, |
|
25 | 27 | QWheelEvent, |
26 | 28 | ) |
27 | 29 | from PySide6.QtTest import QTest |
28 | | -from PySide6.QtWidgets import QApplication |
| 30 | +from PySide6.QtWidgets import QApplication, QToolTip |
29 | 31 |
|
30 | 32 | LEFT, NONE = Qt.MouseButton.LeftButton, Qt.KeyboardModifier.NoModifier |
31 | 33 |
|
@@ -679,3 +681,43 @@ def test_the_canvas_takes_a_colour_and_frames_nodes(qtbot: Any) -> None: |
679 | 681 | node = view._shown["m"].view |
680 | 682 | assert abs(centre.x() - (node.scenePos().x() + node.boundingRect().width() / 2)) < 120 |
681 | 683 | view.frame(["nope"]) |
| 684 | + |
| 685 | + |
| 686 | +def test_a_nodes_tip_shows_over_its_title(qtbot: Any) -> None: |
| 687 | + view = make(qtbot) |
| 688 | + item = view._shown["m"].view |
| 689 | + assert item.text_item.toolTip() == "" |
| 690 | + vp = view.viewer.viewport() |
| 691 | + where = view.viewer.mapFromScene(item.mapToScene(QPointF(item.width / 2, 8))) |
| 692 | + QApplication.sendEvent(vp, QHelpEvent(QEvent.Type.ToolTip, where, vp.mapToGlobal(where))) |
| 693 | + qtbot.wait(20) |
| 694 | + assert QToolTip.text() == "spins" |
| 695 | + QToolTip.hideText() |
| 696 | + |
| 697 | + |
| 698 | +def test_faded_links_are_drawn_back_and_come_forward_again(qtbot: Any) -> None: |
| 699 | + view = make(qtbot) |
| 700 | + |
| 701 | + def ops() -> dict[LinkSpec, float]: |
| 702 | + return {w: p.opacity() for w, p in view._pipes().items()} |
| 703 | + |
| 704 | + assert set(ops().values()) == {1.0} |
| 705 | + view.show(nodes(), LINKS, faded=[LINKS[0]]) |
| 706 | + assert ops() == {LINKS[0]: FADED, LINKS[1]: 1.0} |
| 707 | + view.show(nodes(), LINKS) |
| 708 | + assert set(ops().values()) == {1.0} |
| 709 | + |
| 710 | + |
| 711 | +def test_a_selection_is_told_whole_and_a_show_does_not_tell_it(qtbot: Any) -> None: |
| 712 | + view = make(qtbot) |
| 713 | + got: list[list[str]] = [] |
| 714 | + view.selection_changed.connect(got.append) |
| 715 | + view.select(["t"]) |
| 716 | + qtbot.wait(20) |
| 717 | + assert got == [] |
| 718 | + view._shown["c"].view.setSelected(True) |
| 719 | + qtbot.wait(20) |
| 720 | + assert got == [["t", "c"]] |
| 721 | + view.show(nodes(), LINKS) |
| 722 | + qtbot.wait(20) |
| 723 | + assert got == [["t", "c"]] and view.selected() == ["t", "c"] |
0 commit comments