-
-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
189 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
""" | ||
novelWriter – Progress Bar Tester | ||
================================= | ||
This file is a part of novelWriter | ||
Copyright 2018–2024, Veronica Berglyd Olsen | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, but | ||
WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
""" | ||
from __future__ import annotations | ||
|
||
from time import sleep | ||
|
||
import pytest | ||
|
||
from PyQt5.QtGui import QColor | ||
|
||
from novelwriter.extensions.progressbars import NProgressCircle, NProgressSimple | ||
|
||
from tests.tools import SimpleDialog | ||
|
||
|
||
@pytest.mark.gui | ||
def testExtProgressBars_NProgressCircle(qtbot): | ||
"""Test the NProgressCircle class.""" | ||
dialog = SimpleDialog() | ||
progress = NProgressCircle(dialog, 200, 16) | ||
|
||
with qtbot.waitExposed(dialog): | ||
# This ensures the paint event is executed | ||
dialog.show() | ||
|
||
dialog.resize(200, 200) | ||
progress.setColours( | ||
QColor(255, 255, 255), QColor(255, 192, 192), | ||
QColor(255, 0, 0), QColor(0, 0, 0), | ||
) | ||
|
||
progress.setMaximum(100) | ||
for i in range(1, 101): | ||
progress.setValue(i) | ||
sleep(0.0025) | ||
assert progress.value() == i | ||
|
||
progress.setCentreText("Done!") | ||
assert progress._text == "Done!" | ||
|
||
# qtbot.stop() | ||
|
||
|
||
@pytest.mark.gui | ||
def testExtProgressBars_NProgressSimple(qtbot): | ||
"""Test the NProgressSimple class.""" | ||
dialog = SimpleDialog() | ||
progress = NProgressSimple(dialog) | ||
|
||
with qtbot.waitExposed(dialog): | ||
# This ensures the paint event is executed | ||
dialog.show() | ||
|
||
progress.setMaximum(100) | ||
for i in range(1, 101): | ||
progress.setValue(i) | ||
sleep(0.0025) | ||
assert progress.value() == i | ||
|
||
# qtbot.stop() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
""" | ||
novelWriter – Switch Tester | ||
=========================== | ||
This file is a part of novelWriter | ||
Copyright 2018–2024, Veronica Berglyd Olsen | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, but | ||
WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
""" | ||
from __future__ import annotations | ||
|
||
import pytest | ||
|
||
from PyQt5.QtCore import QEvent, QPoint | ||
from PyQt5.QtGui import QMouseEvent | ||
|
||
from novelwriter.extensions.switch import NSwitch | ||
from novelwriter.types import QtModNone, QtMouseLeft | ||
|
||
from tests.tools import SimpleDialog | ||
|
||
|
||
@pytest.mark.gui | ||
def testExtSwitch_Main(qtbot): | ||
"""Test the NSwitch class. This is mostly a check that all the calls | ||
work as the result is visual. | ||
""" | ||
dialog = SimpleDialog() | ||
switch = NSwitch(dialog, 40) | ||
|
||
with qtbot.waitExposed(dialog): | ||
# This ensures the paint event is executed | ||
dialog.show() | ||
|
||
dialog.resize(200, 100) | ||
|
||
switch.setEnabled(False) | ||
switch.setChecked(False) | ||
switch.repaint() | ||
qtbot.wait(20) | ||
|
||
switch.setChecked(True) | ||
switch.repaint() | ||
qtbot.wait(20) | ||
|
||
switch.setEnabled(True) | ||
switch.setChecked(False) | ||
switch.repaint() | ||
qtbot.wait(20) | ||
|
||
switch.setChecked(True) | ||
switch.repaint() | ||
qtbot.wait(20) | ||
|
||
button = QtMouseLeft | ||
modifier = QtModNone | ||
event = QMouseEvent(QEvent.Type.MouseButtonRelease, QPoint(), button, button, modifier) | ||
switch.mouseReleaseEvent(event) | ||
|
||
event = QEvent(QEvent.Type.Enter) | ||
switch.enterEvent(event) | ||
|
||
# qtbot.stop() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters