Skip to content

Commit

Permalink
Initial GUI tests
Browse files Browse the repository at this point in the history
The GUI is rather useless when the app is being run in the test environment, as there are no printers connected (there is no USB backend at all).
This simple test verifies the most basic existence of selected widget, and their content.
We will need to figure out how to test the app with a state that resembles actual printer. We might need to introduce test mode, in which all supported printers are shown in the device selector, so we can test various features for each.
  • Loading branch information
Tomer Shalev committed May 4, 2024
1 parent c024563 commit 3ae54e2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
sudo apt-get install -y libegl1 libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xfixes0 x11-utils
sudo apt-get install -y libegl1 libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xfixes0 x11-utils libgl1 libdbus-1-3 libxcb-cursor0
/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 1920x1200x24 -ac +extension GLX
python -m pip install --upgrade pip
pip install tox tox-gh-actions
Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ requires-python = ">=3.8,<4"
[project.optional-dependencies]
test = [
"pytest-cov",
"pytest-image-diff"
"pytest-image-diff",
"pytest-qt",
"pytest-xvfb",
]

[project.urls]
Expand Down
25 changes: 25 additions & 0 deletions src/labelle/gui/tests/test_gui.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from labelle.gui.gui import LabelleWindow
from labelle.gui.q_label_widgets import (
TextDymoLabelWidget,
)


def test_main_window(qtbot):
widget = LabelleWindow()
qtbot.addWidget(widget)

assert not widget._actions.isEnabled()
assert widget._device_selector.isEnabled()
assert not widget._label_list.isEnabled()
assert not widget._render_widget.isEnabled()
assert not widget._render.isEnabled()
assert not widget._settings_toolbar.isEnabled()
assert (
widget._device_selector._error_label.text()
== "Failed scanning devices: No backend available"
)
assert not widget._actions._print_button.isEnabled()
assert widget._label_list.count() == 1
item = widget._label_list.itemWidget(widget._label_list.item(0))
assert isinstance(item, TextDymoLabelWidget)
assert item.label.toPlainText() == "text"

0 comments on commit 3ae54e2

Please sign in to comment.