Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B-ASIC - Better ASIC Toolbox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Computer Engineering
B-ASIC - Better ASIC Toolbox
Commits
e06e5026
Commit
e06e5026
authored
2 years ago
by
Oscar Gustafsson
Browse files
Options
Downloads
Patches
Plain Diff
Add GUI test adding operation and creating SFG
parent
a5eed061
No related branches found
No related tags found
1 merge request
!171
Add GUI test adding operation and creating SFG
Pipeline
#89086
passed
2 years ago
Stage: test
Stage: deploy
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/test_gui.py
+89
-0
89 additions, 0 deletions
test/test_gui.py
with
89 additions
and
0 deletions
test/test_gui.py
+
89
−
0
View file @
e06e5026
import
pytest
import
pytest
from
qtpy
import
QtCore
from
qtpy
import
QtCore
from
qtpy.QtWidgets
import
QInputDialog
try
:
try
:
import
b_asic.GUI
as
GUI
import
b_asic.GUI
as
GUI
except
ImportError
:
except
ImportError
:
pytestmark
=
pytest
.
mark
.
skip
(
"
Qt not setup
"
)
pytestmark
=
pytest
.
mark
.
skip
(
"
Qt not setup
"
)
from
b_asic.core_operations
import
SquareRoot
from
b_asic.special_operations
import
Input
,
Output
def
test_start
(
qtbot
):
def
test_start
(
qtbot
):
widget
=
GUI
.
MainWindow
()
widget
=
GUI
.
MainWindow
()
...
@@ -183,3 +187,88 @@ def test_properties_window_change_name(qtbot, datadir):
...
@@ -183,3 +187,88 @@ def test_properties_window_change_name(qtbot, datadir):
assert
dragbutton
.
operation
.
name
==
"
cmul73
"
assert
dragbutton
.
operation
.
name
==
"
cmul73
"
widget
.
exit_app
()
widget
.
exit_app
()
def
test_add_operation_and_create_sfg
(
qtbot
,
monkeypatch
):
widget
=
GUI
.
MainWindow
()
qtbot
.
addWidget
(
widget
)
in1
=
Input
()
sqrt
=
SquareRoot
()
out1
=
Output
()
# Create operations
widget
.
create_operation
(
in1
)
widget
.
create_operation
(
sqrt
)
widget
.
create_operation
(
out1
)
# Should be three operations
assert
len
(
widget
.
operationDragDict
)
==
3
# These particular three
for
op
in
(
in1
,
sqrt
,
out1
):
assert
op
in
widget
.
operationDragDict
# No signals
assert
not
widget
.
signalList
# Click on first port
in1_port
=
widget
.
portDict
[
widget
.
operationDragDict
[
in1
]][
0
]
qtbot
.
mouseClick
(
in1_port
,
QtCore
.
Qt
.
MouseButton
.
LeftButton
,
)
assert
len
(
widget
.
pressed_ports
)
==
1
# Click on second port
sqrt_in_port
=
widget
.
portDict
[
widget
.
operationDragDict
[
sqrt
]][
0
]
qtbot
.
mouseClick
(
sqrt_in_port
,
QtCore
.
Qt
.
MouseButton
.
LeftButton
,
QtCore
.
Qt
.
KeyboardModifier
.
ControlModifier
,
)
assert
len
(
widget
.
pressed_ports
)
==
2
# Connect ports
widget
.
_connect_button
()
# Not sure why this won't work
# qtbot.keyClick(widget, QtCore.Qt.Key.Key_Space, delay=10)
# Still one selected!?
assert
len
(
widget
.
signalList
)
==
1
# Click on first port
sqrt_out_port
=
widget
.
portDict
[
widget
.
operationDragDict
[
sqrt
]][
1
]
qtbot
.
mouseClick
(
sqrt_out_port
,
QtCore
.
Qt
.
MouseButton
.
LeftButton
,
)
# Click on second port
out1_port
=
widget
.
portDict
[
widget
.
operationDragDict
[
out1
]][
0
]
qtbot
.
mouseClick
(
out1_port
,
QtCore
.
Qt
.
MouseButton
.
LeftButton
,
QtCore
.
Qt
.
KeyboardModifier
.
ControlModifier
,
)
# Connect
widget
.
_connect_button
()
assert
len
(
widget
.
signalList
)
==
2
# Select input op
qtbot
.
mouseClick
(
widget
.
operationDragDict
[
in1
],
QtCore
.
Qt
.
MouseButton
.
LeftButton
,
)
# And output op
qtbot
.
mouseClick
(
widget
.
operationDragDict
[
out1
],
QtCore
.
Qt
.
MouseButton
.
LeftButton
,
QtCore
.
Qt
.
KeyboardModifier
.
ControlModifier
,
)
# Monkey patch dialog to return the expected thing
monkeypatch
.
setattr
(
QInputDialog
,
"
getText
"
,
lambda
*
args
:
(
"
foo
"
,
True
))
# Create SFG
widget
.
create_sfg_from_toolbar
()
# Should be in sfg_dict now
assert
"
foo
"
in
widget
.
sfg_dict
assert
len
(
widget
.
sfg_dict
)
==
1
widget
.
exit_app
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment