Skip to content

Commit

Permalink
Add a spix test to insure we will never silently regress on basic ima…
Browse files Browse the repository at this point in the history
…ge attachments
  • Loading branch information
nirvn committed Aug 7, 2024
1 parent 89674e3 commit 4ed5af5
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/qml/FeatureListForm.qml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Rectangle {
width: {
if ( props.isVisible || featureForm.canvasOperationRequested )
{
if (fullScreenView || parent.width < parent.height || parent.width < 300)
if (fullScreenView || parent.width <= parent.height || parent.width < 300)
{
parent.width
}
Expand Down
1 change: 1 addition & 0 deletions test/spix/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ py
pytest
pytest-html
pytest-image-diff
pyautogui
47 changes: 47 additions & 0 deletions test/spix/smoke_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import platform
from pathlib import Path
from PIL import Image
import pyautogui


@pytest.fixture
Expand Down Expand Up @@ -166,6 +167,52 @@ def test_projection(app, screenshot_path, screenshot_check, extra, process_alive
assert messagesCount == 0


@pytest.mark.project_file("test_image_attachment.qgz")
def test_projection(app, screenshot_path, screenshot_check, extra, process_alive):
"""
Starts a test app and check for proper reprojection support (including rendering check and message logs).
This also tests that QField is able to reach proj's crucial proj.db
"""
assert app.existsAndVisible("mainWindow")

# Arbitrary wait period to insure project fully loaded and rendered
time.sleep(4)

messagesCount = 0
for i in range(0, 10):
message = app.getStringProperty(
"mainWindow/messageLog/messageItem_{}/messageText".format(i), "text"
)
if message == "":
break
extra.append(extras.html("Message logs content: {}".format(message)))
messagesCount = messagesCount + 1
extra.append(extras.html("Message logs count: {}".format(messagesCount)))
assert messagesCount == 0

bounds = app.getBoundingBox("mainWindow/mapCanvas")
move_x = bounds[0] + bounds[2] / 2
move_y = bounds[1] + bounds[3] / 3

pyautogui.moveTo(move_x, move_y, duration=0.5)
pyautogui.click(interval=0.5)

bounds = app.getBoundingBox("mainWindow/featureForm")
move_x = bounds[0] + bounds[2] / 2
move_y = bounds[1] + 80

pyautogui.moveTo(move_x, move_y, duration=0.5)
pyautogui.click(interval=0.5)

app.takeScreenshot(
"mainWindow", os.path.join(screenshot_path, "test_image_attachment.png")
)
assert process_alive()
extra.append(extras.html('<img src="images/test_image_attachment.png"/>'))

assert screenshot_check("test_image_attachment", "test_image_attachment")


@pytest.mark.project_file("test_svg.qgz")
def test_svg(app, screenshot_path, screenshot_check, extra, process_alive):
"""
Expand Down
Binary file added test/testdata/polygons.gpkg
Binary file not shown.
Binary file modified test/testdata/projection_dataset.gpkg
Binary file not shown.
Binary file added test/testdata/reserve.jpg
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/testdata/test_image_attachment.qgz
Binary file not shown.

0 comments on commit 4ed5af5

Please sign in to comment.