Skip to content

Commit 16be21b

Browse files
authored
Merge pull request #14 from sdgtt/app_tests_scopy_excluded
Added tests for other Kuiper linux apps, excluded scopy test
2 parents 09ed84a + 79f6165 commit 16be21b

25 files changed

Lines changed: 307 additions & 4 deletions

pyguit/gui.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import re
1111
from Xlib import display, X, Xatom
1212
from ewmh import EWMH
13+
import argparse
1314

1415
from sys import platform
1516
if not (platform == "linux" or platform == "linux2"):
@@ -118,6 +119,24 @@ def get_window_title(self, window):
118119
return window_name.value
119120
return window_name.value.decode("utf-8")
120121
return None
122+
123+
def get_window_position(self, window):
124+
try:
125+
# Get the window's position and size using pyautogui
126+
window_info = self.gui.get_window_position(window)
127+
if window_info:
128+
# Extract position and size information
129+
x = window_info[0].left
130+
y = window_info[0].top
131+
width = window_info[0].width
132+
height = window_info[0].height
133+
return x, y, width, height
134+
else:
135+
print(f"Window '{window}' not found.")
136+
return None
137+
except Exception as e:
138+
print(f"Error occurred while getting window position: {e}")
139+
return None
121140

122141
def frame(self, window):
123142
frame = window

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import re
12
import setuptools
23

34
def _get_version():

test/adi-diagnostic/conftest.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import pytest
2+
3+
def pytest_addoption(parser):
4+
parser.addoption(
5+
"--remote",
6+
action="store_true",
7+
help="Run test on network mode",
8+
)
9+
10+
parser.addoption(
11+
"--local",
12+
action="store_true",
13+
help="Run test on local mode",
14+
)
15+
16+
parser.addoption(
17+
"--ip",
18+
action="store",
19+
default="localhost",
20+
help="IP of DUT",
21+
)
22+
23+
parser.addoption(
24+
"--delay",
25+
action="store",
26+
type=int,
27+
default=10,
28+
help="adding delay",
29+
)
30+
31+
def pytest_configure(config):
32+
# register marker
33+
config.addinivalue_line("markers", "remote: mark remote tests")
34+
config.addinivalue_line("markers", "local: mark local tests")
35+
36+
37+
def pytest_runtest_setup(item):
38+
remote = item.config.getoption("--remote")
39+
marks = [mark.name for mark in item.iter_markers()]
40+
if not remote and "remote" in marks:
41+
pytest.skip(
42+
"Testing requires network flag: --remote"
43+
)
44+
45+
local = item.config.getoption("--local")
46+
marks = [mark.name for mark in item.iter_markers()]
47+
if not local and "local" in marks:
48+
pytest.skip(
49+
"Testing requires local flag: --local"
50+
)
51+
52+
@pytest.fixture(scope="session")
53+
def ip(pytestconfig):
54+
return pytestconfig.getoption("ip")
55+
56+
57+
@pytest.fixture(scope="session")
58+
def delay(pytestconfig):
59+
return pytestconfig.getoption("delay")
1.43 KB
Loading
3.32 KB
Loading
2.18 KB
Loading
86.5 KB
Loading
30.7 KB
Loading
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import pytest
2+
import pyguit
3+
import time
4+
import os
5+
import shutil
6+
7+
class TestDiagnostic:
8+
9+
@classmethod
10+
def setup_class(self):
11+
'''Setup the pyguit object. Will be called once before the start of test'''
12+
self.gui = pyguit.gui()
13+
self.gui.attach_openbox()
14+
# self.gui.run_ssh_agent()
15+
time.sleep(10)
16+
try:
17+
os.makedirs("results")
18+
except FileExistsError:
19+
# directory already exists
20+
shutil.rmtree('results')
21+
os.makedirs("results")
22+
23+
@classmethod
24+
def teardown_class(self):
25+
'''Garbage collector. Will be called once after running of tests'''
26+
time.sleep(10)
27+
self.gui.dettach_openbox()
28+
del self.gui
29+
30+
@pytest.mark.remote
31+
def test_open_app_terminal_on_remote(self, ip, delay):
32+
'''Test if app opens, and checks main window'''
33+
self.gui.open_app(
34+
host=ip,
35+
user="analog",
36+
app_name="adi_diagnostic_report",
37+
path="/usr/local/bin/adi_diagnostic_report --gui")
38+
time.sleep(delay)
39+
print("Test build: Check application title")
40+
# Find main screen
41+
found_window = None
42+
for w in self.gui.get_open_windows():
43+
if w:
44+
print(self.gui.get_window_title(w))
45+
print("Test build: Check application title")
46+
#Find main screen
47+
found_window = None
48+
for w in self.gui.get_open_windows():
49+
if w:
50+
print(self.gui.get_window_title(w))
51+
time.sleep(delay)
52+
self.gui.find_window("Generate Diagnostic Report")
53+
print("Test build: Done main window")
54+
time.sleep(delay)
55+
# assert self.gui.controller.locateOnScreen("ref_test_open_diagnostic.png", grayscale=True, confidence=0.9)
56+
assert self.gui.controller.locateOnScreen("ref_test_open_app_rpi.png", grayscale=True, confidence=0.9)
57+
self.gui.controller.screenshot("results/test_open_diagnostic.png")
58+
time.sleep(5)
59+
60+
#click functons
61+
noneBtn = self.gui.controller.locateCenterOnScreen("ref_test_click_none_button.png", grayscale=True, confidence=0.9)
62+
assert noneBtn
63+
self.gui.controller.click(noneBtn)
64+
time.sleep(5)
65+
self.gui.controller.screenshot("results/test_click_none_button.png")
66+
print("Test build: Done None button")
67+
time.sleep(delay)
68+
analogItem = self.gui.controller.locateCenterOnScreen("ref_test_click_analog_item.png", grayscale=True, confidence=0.9)
69+
assert analogItem
70+
self.gui.controller.click(analogItem)
71+
time.sleep(5)
72+
self.gui.controller.screenshot("results/test_click_analog.png")
73+
print("Test build: Done analog item")
74+
generateBtn = self.gui.controller.locateCenterOnScreen("ref_test_click_generate_button.png", grayscale=True, confidence=0.9)
75+
assert generateBtn
76+
self.gui.controller.click(generateBtn)
77+
time.sleep(5)
78+
self.gui.controller.screenshot("results/test_generate_button.png")
79+
print("Test build: Done Generate button")
80+
81+
82+

test/gnuradio/test_adi_gnuradio.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def test_open_app_on_remote(self, ip, delay):
3737
self.gui.open_app(
3838
host= ip,
3939
user="analog",
40-
app_name="gnuradio",
40+
app_name="gnuradio-companion",
4141
path="/usr/bin/gnuradio-companion",
4242
)
4343
time.sleep(delay)

0 commit comments

Comments
 (0)