Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kuiper apps tests new and improvements #13

Merged
merged 67 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
6f2da5a
print active window titles
cseptimo Apr 23, 2024
cdfe775
perform action based on the dound screen then screenshot then assert
cseptimo Apr 25, 2024
cdbafd1
fix indent error
cseptimo Apr 25, 2024
057a806
improve conditional statement and get position coordinates
cseptimo Apr 25, 2024
922caa0
fix indent error
cseptimo Apr 25, 2024
50530dc
fix indent error
cseptimo Apr 25, 2024
26e6132
added attribute or method get_window_position
cseptimo Apr 25, 2024
11c5eee
update self.gui.get_window_position
cseptimo Apr 25, 2024
43d6511
fix indent error
cseptimo Apr 25, 2024
94e4dbb
add logic statement for getting position coordinates
cseptimo Apr 25, 2024
0cf3011
comment other test builds
cseptimo Jul 22, 2024
01baacc
cropped images
cseptimo Oct 8, 2024
57afc8a
check window with capture1
cseptimo Oct 9, 2024
b7f53a7
add delay
cseptimo Oct 9, 2024
616ae1e
change window title
cseptimo Oct 9, 2024
cd0886b
print titles
cseptimo Oct 9, 2024
072995a
less confidence
cseptimo Oct 11, 2024
18f195a
locatecenterscreen
cseptimo Oct 11, 2024
f5f4d4a
center main window
cseptimo Oct 11, 2024
84f6219
center windows
cseptimo Oct 11, 2024
bd9a10a
comment checkbox click
cseptimo Oct 11, 2024
09e5724
add test build comment
cseptimo Oct 11, 2024
78d5f7e
add checbox capture
cseptimo Oct 15, 2024
5f4beb2
removed
cseptimo Oct 15, 2024
b4f617a
Revert "add checbox capture"
cseptimo Oct 15, 2024
35cc67a
ennable checkbox
cseptimo Oct 15, 2024
857e311
add run button
cseptimo Oct 15, 2024
044ad1f
adjust confidence
cseptimo Oct 15, 2024
2fa51e5
add logs
cseptimo Oct 15, 2024
93f4437
add button reference
cseptimo Oct 16, 2024
859bbd7
add diagnostic folder
cseptimo Oct 16, 2024
a1a7879
added result folder
cseptimo Oct 16, 2024
ac54975
Revert "added result folder"
cseptimo Oct 16, 2024
ce48538
remove = symbol in naming of tested image
cseptimo Oct 17, 2024
2b16fb6
Added test build for diagnostic app
cseptimo Oct 17, 2024
1d83512
add --gui in app name
cseptimo Oct 17, 2024
3455d84
check if --gui will reflect
cseptimo Oct 17, 2024
21166d9
Added terminal temporary to open gui
cseptimo Oct 18, 2024
579ab0a
change open_app
cseptimo Oct 18, 2024
79a231e
change path
cseptimo Oct 18, 2024
21e106c
change path
cseptimo Oct 18, 2024
8c3cf96
comment out terminal app open
cseptimo Oct 18, 2024
e09ef04
change path
cseptimo Oct 18, 2024
c8c5db0
change app name and path
cseptimo Oct 18, 2024
fc0a6fe
change app name and path
cseptimo Oct 18, 2024
8ab7132
change app name and path
cseptimo Oct 18, 2024
a8139d7
change app name and path
cseptimo Oct 18, 2024
356024b
try open win
cseptimo Oct 18, 2024
3907955
add --gui in path
cseptimo Oct 25, 2024
1b65d50
Added Scopy open app
cseptimo Nov 5, 2024
033d67a
Check title scopy
cseptimo Nov 5, 2024
8ba0335
print w value
cseptimo Nov 5, 2024
ec25f61
print w value
cseptimo Nov 5, 2024
84d9ca3
add title checker
cseptimo Nov 6, 2024
a24413c
add title checker
cseptimo Nov 6, 2024
aaf513f
add --gui
cseptimo Nov 6, 2024
1c5c95d
added gui click functions
cseptimo Nov 19, 2024
ee30ca8
add clicks
cseptimo Nov 19, 2024
700049a
correct image naming
cseptimo Nov 19, 2024
51be4c4
correct image naming
cseptimo Nov 19, 2024
dbe9979
added image app
cseptimo Nov 19, 2024
4c095e6
update scopy
cseptimo Nov 20, 2024
cedb1e1
add picture
cseptimo Nov 20, 2024
0c76b23
images
cseptimo Nov 20, 2024
189079d
update self.gui.get_window_position
cseptimo Apr 25, 2024
acdd428
add logic statement for getting position coordinates
cseptimo Apr 25, 2024
ae41fc5
correct image naming
cseptimo Nov 19, 2024
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
19 changes: 19 additions & 0 deletions pyguit/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import re
from Xlib import display, X, Xatom
from ewmh import EWMH
import argparse

from sys import platform
if not (platform == "linux" or platform == "linux2"):
Expand Down Expand Up @@ -118,6 +119,24 @@ def get_window_title(self, window):
return window_name.value
return window_name.value.decode("utf-8")
return None

def get_window_position(self, window):
try:
# Get the window's position and size using pyautogui
window_info = self.gui.get_window_position(window)
if window_info:
# Extract position and size information
x = window_info[0].left
y = window_info[0].top
width = window_info[0].width
height = window_info[0].height
return x, y, width, height
else:
print(f"Window '{window}' not found.")
return None
except Exception as e:
print(f"Error occurred while getting window position: {e}")
return None

def frame(self, window):
frame = window
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import re
import setuptools

def _get_version():
Expand Down
59 changes: 59 additions & 0 deletions test/adi-diagnostic/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import pytest

def pytest_addoption(parser):
parser.addoption(
"--remote",
action="store_true",
help="Run test on network mode",
)

parser.addoption(
"--local",
action="store_true",
help="Run test on local mode",
)

parser.addoption(
"--ip",
action="store",
default="localhost",
help="IP of DUT",
)

parser.addoption(
"--delay",
action="store",
type=int,
default=10,
help="adding delay",
)

def pytest_configure(config):
# register marker
config.addinivalue_line("markers", "remote: mark remote tests")
config.addinivalue_line("markers", "local: mark local tests")


def pytest_runtest_setup(item):
remote = item.config.getoption("--remote")
marks = [mark.name for mark in item.iter_markers()]
if not remote and "remote" in marks:
pytest.skip(
"Testing requires network flag: --remote"
)

local = item.config.getoption("--local")
marks = [mark.name for mark in item.iter_markers()]
if not local and "local" in marks:
pytest.skip(
"Testing requires local flag: --local"
)

@pytest.fixture(scope="session")
def ip(pytestconfig):
return pytestconfig.getoption("ip")


@pytest.fixture(scope="session")
def delay(pytestconfig):
return pytestconfig.getoption("delay")
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/adi-diagnostic/ref_test_open_app_rpi.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/adi-diagnostic/ref_test_open_diagnostic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
82 changes: 82 additions & 0 deletions test/adi-diagnostic/test_adi_diagnostic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import pytest
import pyguit
import time
import os
import shutil

class TestDiagnostic:

@classmethod
def setup_class(self):
'''Setup the pyguit object. Will be called once before the start of test'''
self.gui = pyguit.gui()
self.gui.attach_openbox()
# self.gui.run_ssh_agent()
time.sleep(10)
try:
os.makedirs("results")
except FileExistsError:
# directory already exists
shutil.rmtree('results')
os.makedirs("results")

@classmethod
def teardown_class(self):
'''Garbage collector. Will be called once after running of tests'''
time.sleep(10)
self.gui.dettach_openbox()
del self.gui

@pytest.mark.remote
def test_open_app_terminal_on_remote(self, ip, delay):
'''Test if app opens, and checks main window'''
self.gui.open_app(
host=ip,
user="analog",
app_name="adi_diagnostic_report",
path="/usr/local/bin/adi_diagnostic_report --gui")
time.sleep(delay)
print("Test build: Check application title")
# Find main screen
found_window = None
for w in self.gui.get_open_windows():
if w:
print(self.gui.get_window_title(w))
print("Test build: Check application title")
#Find main screen
found_window = None
for w in self.gui.get_open_windows():
if w:
print(self.gui.get_window_title(w))
time.sleep(delay)
self.gui.find_window("Generate Diagnostic Report")
print("Test build: Done main window")
time.sleep(delay)
# assert self.gui.controller.locateOnScreen("ref_test_open_diagnostic.png", grayscale=True, confidence=0.9)
assert self.gui.controller.locateOnScreen("ref_test_open_app_rpi.png", grayscale=True, confidence=0.9)
self.gui.controller.screenshot("results/test_open_diagnostic.png")
time.sleep(5)

#click functons
noneBtn = self.gui.controller.locateCenterOnScreen("ref_test_click_none_button.png", grayscale=True, confidence=0.9)
assert noneBtn
self.gui.controller.click(noneBtn)
time.sleep(5)
self.gui.controller.screenshot("results/test_click_none_button.png")
print("Test build: Done None button")
time.sleep(delay)
analogItem = self.gui.controller.locateCenterOnScreen("ref_test_click_analog_item.png", grayscale=True, confidence=0.9)
assert analogItem
self.gui.controller.click(analogItem)
time.sleep(5)
self.gui.controller.screenshot("results/test_click_analog.png")
print("Test build: Done analog item")
generateBtn = self.gui.controller.locateCenterOnScreen("ref_test_click_generate_button.png", grayscale=True, confidence=0.9)
assert generateBtn
self.gui.controller.click(generateBtn)
time.sleep(5)
self.gui.controller.screenshot("results/test_generate_button.png")
print("Test build: Done Generate button")



2 changes: 1 addition & 1 deletion test/gnuradio/test_adi_gnuradio.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_open_app_on_remote(self, ip, delay):
self.gui.open_app(
host= ip,
user="analog",
app_name="gnuradio",
app_name="gnuradio-companion",
path="/usr/bin/gnuradio-companion",
)
time.sleep(delay)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/iio-oscilloscope/ref_test_run_button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/iio-oscilloscope/results/test_run_button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 36 additions & 3 deletions test/iio-oscilloscope/test_adi_oscilloscope.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,43 @@ def test_open_app_on_remote(self, ip, delay):
path="/usr/local/bin/osc",
)
time.sleep(delay)
#find_active_screen
print("Test build: Check application title")
# Find main screen
found_window = None
for w in self.gui.get_open_windows():
if w:
if w:
print(self.gui.get_window_title(w))
time.sleep(delay)
self.gui.controller.screenshot("results/test_open_a_app.png")
#find_small_window
time.sleep(delay)
small_window = self.gui.find_window("ADI IIO Oscilloscope")
self.gui.set_window_center(small_window)
print("Test build: Done small window")
time.sleep(delay)
assert self.gui.controller.locateCenterOnScreen("ref_test_open_adi_iio_oscilloscope_app.png", grayscale=True, confidence=0.5)
self.gui.controller.screenshot("results/test_open_adi_iio_oscilloscope_app.png")
# find_main screen
main_window = self.gui.find_window("ADI IIO Oscilloscope - Capture1")
self.gui.set_window_center(main_window)
time.sleep(delay)
assert self.gui.controller.locateCenterOnScreen("ref_test_open_adi_iio_oscilloscope-capture1_app.png", grayscale=True, confidence=0.5)
self.gui.controller.screenshot("results/test_open_adi_iio_oscilloscope-capture1_app.png")
print("Test build: Done main window")

def test_play_button(self,delay):
'''Test if capture works by clicking the checkbox button'''
checkboxBtn = self.gui.controller.locateCenterOnScreen("ref_test_enable_all_checkbox.png", grayscale=True, confidence=0.9)
assert checkboxBtn
self.gui.controller.click(checkboxBtn)
time.sleep(5)
self.gui.controller.screenshot("results/test_checkbox_button.png")
print("Test build: Done checkbox")
time.sleep(delay)
runBtn = self.gui.controller.locateCenterOnScreen("ref_test_run_button.png", grayscale=True, confidence=0.5)
assert runBtn
self.gui.controller.click(runBtn)
time.sleep(5)
self.gui.controller.screenshot("results/test_run_button.png")
print("Test build: Done run button")


60 changes: 60 additions & 0 deletions test/scopy/linux/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import pytest

def pytest_addoption(parser):
parser.addoption(
"--remote",
action="store_true",
help="Run test on network mode",
)

parser.addoption(
"--local",
action="store_true",
help="Run test on local mode",
)

parser.addoption(
"--ip",
action="store",
default="localhost",
help="IP of DUT",
)

parser.addoption(
"--delay",
action="store",
type=int,
default=10,
help="adding delay",
)


def pytest_configure(config):
# register marker
config.addinivalue_line("markers", "remote: mark remote tests")
config.addinivalue_line("markers", "local: mark local tests")


def pytest_runtest_setup(item):
remote = item.config.getoption("--remote")
marks = [mark.name for mark in item.iter_markers()]
if not remote and "remote" in marks:
pytest.skip(
"Testing requires network flag: --remote"
)

local = item.config.getoption("--local")
marks = [mark.name for mark in item.iter_markers()]
if not local and "local" in marks:
pytest.skip(
"Testing requires local flag: --local"
)

@pytest.fixture(scope="session")
def ip(pytestconfig):
return pytestconfig.getoption("ip")


@pytest.fixture(scope="session")
def delay(pytestconfig):
return pytestconfig.getoption("delay")
Binary file added test/scopy/linux/ref_test_open_appScopy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/scopy/linux/ref_test_open_scopy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions test/scopy/linux/test_adi_scopy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import pytest
import pyguit
import time
import os
import shutil

class TestScopy:

@classmethod
def setup_class(self):
'''Setup the pyguit object. Will be called once before the start of test'''
self.gui = pyguit.gui()
self.gui.attach_openbox()
# self.gui.run_ssh_agent()
time.sleep(10)
try:
os.makedirs("results")
except FileExistsError:
# directory already exists
shutil.rmtree('results')
os.makedirs("results")

@classmethod
def teardown_class(self):
'''Garbage collector. Will be called once after running of tests'''
time.sleep(10)
self.gui.dettach_openbox()
del self.gui

@pytest.mark.remote
def test_open_app_on_remote(self, ip, delay):
'''Test if app opens, and checks main window'''
self.gui.open_app(
host=ip,
user="analog",
app_name="flatpak",
path="/usr/bin/flatpak",
)
time.sleep(delay)
print("Test build: Check application title")
# Find main screen
found_window = None
for w in self.gui.get_open_windows():
if w:
print(self.gui.get_window_title(w))
print(self.gui.get_window_title(w))
time.sleep(delay)


Loading