Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ dependencies:
- pytest
- pytest-cov
- pytest-mpl
- pytest-qt
# --------------for testing the docs
# (e.g. parsing .rst code-blocks and Jupyter Notebooks)
- docutils
Expand Down
31 changes: 31 additions & 0 deletions tests/test_companion.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from eomaps import Maps, MapsGrid
from qtpy.QtCore import QPoint
import matplotlib.pyplot as plt

Maps.config(companion_widget_key="x")


def get_ax_center_pos(m):
# Note: QT position is measured from the TOP left corner!
return QPoint(
int(m.ax.bbox.x0 + m.ax.bbox.width / 2),
int(m.f.bbox.height - m.ax.bbox.y0 - m.ax.bbox.height / 2),
)


def test_open_companion(qtbot):
mg = MapsGrid()
qtbot.addWidget(mg.f.canvas)

for m in mg:
assert m._companion_widget is None, "Widget already created?"
qtbot.mouseMove(m.f.canvas, get_ax_center_pos(m))
qtbot.keyPress(m.f.canvas, m._CompanionMixin__companion_widget_key)
assert m._companion_widget is not None, "Widget not opened properly"
assert m._companion_widget.isVisible(), "Widget not visible after opening"

qtbot.mouseMove(m.f.canvas, get_ax_center_pos(m))
qtbot.keyPress(m.f.canvas, m._CompanionMixin__companion_widget_key)
assert not m._companion_widget.isVisible(), "Widget not properly hidden"

plt.close("all")
1 change: 1 addition & 0 deletions tests/test_env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ dependencies:
- coveralls
- pytest
- pytest-cov
- pytest-qt
# --------------for testing the docs
# (e.g. parsing .rst code-blocks and Jupyter Notebooks)
- docutils
Expand Down
Loading