Skip to content

Commit

Permalink
Adapt tests for updated dialogs
Browse files Browse the repository at this point in the history
  • Loading branch information
kbengs committed Sep 3, 2023
1 parent 893ff03 commit 7beb4d4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 19 deletions.
24 changes: 15 additions & 9 deletions tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ def _save_as_chooser(self, filebasename, expected=None):

def _scale_selected(self, scale):
app = self._app()
app.keyCombo("C")
app.keyCombo("S")
dialog = app.child(roleName="dialog")
from dogtail import rawinput
rawinput.keyCombo("Tab")
Expand Down Expand Up @@ -430,19 +430,18 @@ def test_05_duplicate(self):
app.keyCombo("Up")
self._assert_selected("2")

def test_06_page_format(self):
def test_06_crop_margins(self):
self._popupmenu(0, ["Select", "Select Odd Pages"])
self._assert_selected("1, 3, 5, 7")
self._popupmenu(0, "Page Format…")
self._popupmenu(0, "Crop Margins…")
dialog = self._app().child(roleName="dialog")
dialog.child(name="Show values").click()
time.sleep(0.2) # Avoid 'GTK_IS_RANGE (range)' failed
croppanel = dialog.child(name="Crop Margins")
cropbuttons = self._find_by_role("spin button", croppanel)
for i in range(4):
cropbuttons[i].click()
cropbuttons[i].text = str((i+1)*4)
scalebutton = dialog.child(roleName="spin button")
scalebutton.click()
scalebutton.text = "120"
dialog.child(name="OK").click()
# TODO: find the condition which could replace this ugly sleep
time.sleep(0.5)
Expand Down Expand Up @@ -511,6 +510,8 @@ def test_04_past_overlay(self):
app.keyCombo("Right")
app.keyCombo("<shift><ctrl>o")
dialog = self._app().child(roleName="dialog")
dialog.child(name="Show values").click()
time.sleep(0.2) # Avoid 'GTK_IS_RANGE (range)' failed
spinbtns = self._find_by_role("spin button", dialog)
spinbtns[0].click()
spinbtns[0].text = "10"
Expand Down Expand Up @@ -656,12 +657,17 @@ def test_03_booklet(self):
self._popupmenu(0, ["Select", "Select All"])
self._popupmenu(0, ["Generate Booklet"])
self._wait_cond(lambda: len(self._icons()) == 2)
self._assert_page_size(489, 212.2, 0)
self._assert_page_size(489, 212.2, 1)
self._app().child(roleName="layered pane").keyCombo("Home")
self._assert_page_size(489, 212.2)
self._app().child(roleName="layered pane").keyCombo("End")
self._assert_page_size(489, 212.2)

def test_04_crop_white_border(self):
# Test selection with shift+arrow
self._app().keyCombo("<shift>Left")
#lp = self._app().child(roleName="layered pane")
#lp.grabFocus()
#self._wait_cond(lambda: lp.sensitive)
self._app().child(roleName="layered pane").keyCombo("<shift>Left")
self._assert_selected("1-2")
self._popupmenu(0, ["Crop White Borders"])
self._assert_page_size(244.1, 211.8, 0)
Expand Down
20 changes: 10 additions & 10 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,23 @@ def _lpage1_270() -> core.LayerPage:

def _page1(self) -> core.Page:
"""Sample page 1"""
return core.Page(1, 2, 0.55, 'copy', 0, 2, core.Sides(0.1, 0.2, 0.3, 0.4), core.Dims(100.33, 200.66), 'base',
[self._lpage1()])
return core.Page(1, 2, 0.55, 'copy', 0, 2, core.Sides(0.1, 0.2, 0.3, 0.4),
core.Sides(0.11, 0.21, 0.31, 0.41), core.Dims(100.33, 200.66), 'base', [self._lpage1()])

def _page1_90(self) -> core.Page:
"""Sample page 1 rotated 90 degrees"""
return core.Page(1, 2, 0.55, 'copy', 90, 2, core.Sides(0.4, 0.3, 0.1, 0.2), core.Dims(100.33, 200.66), 'base',
[self._lpage1_90()])
return core.Page(1, 2, 0.55, 'copy', 90, 2, core.Sides(0.4, 0.3, 0.1, 0.2),
core.Sides(0.41, 0.31, 0.11, 0.21), core.Dims(100.33, 200.66), 'base', [self._lpage1_90()])

def _page1_180(self) -> core.Page:
"""Sample page 1 rotated 90 degrees"""
return core.Page(1, 2, 0.55, 'copy', 180, 2, core.Sides(0.2, 0.1, 0.4, 0.3), core.Dims(100.33, 200.66), 'base',
[self._lpage1_180()])
return core.Page(1, 2, 0.55, 'copy', 180, 2, core.Sides(0.2, 0.1, 0.4, 0.3),
core.Sides(0.21, 0.11, 0.41, 0.31), core.Dims(100.33, 200.66), 'base', [self._lpage1_180()])

def _page1_270(self) -> core.Page:
"""Sample page 1 rotated 90 degrees"""
return core.Page(1, 2, 0.55, 'copy', 270, 2, core.Sides(0.3, 0.4, 0.2, 0.1), core.Dims(100.33, 200.66), 'base',
[self._lpage1_270()])
return core.Page(1, 2, 0.55, 'copy', 270, 2, core.Sides(0.3, 0.4, 0.2, 0.1),
core.Sides(0.31, 0.41, 0.21, 0.11), core.Dims(100.33, 200.66), 'base', [self._lpage1_270()])


class BasePageTest(PTest):
Expand Down Expand Up @@ -109,8 +109,8 @@ def test02(self):
def test03(self):
"""Test serialize"""
self.assertEqual(self._page1().serialize(),
'copy\n2\nbase\n0\n2\n0.1\n0.2\n0.3\n0.4\nlcopy\n4\n90\n2\nOVERLAY\n0.11\n0.21\n0.31\n0.41\n'
'0.12\n0.22\n0.32\n0.42')
'copy\n2\nbase\n0\n2\n0.1\n0.2\n0.3\n0.4\n0.11\n0.21\n0.31\n0.41\n'
'lcopy\n4\n90\n2\nOVERLAY\n0.11\n0.21\n0.31\n0.41\n0.12\n0.22\n0.32\n0.42')

def test04(self):
"""Test width | height | size_in_pixel"""
Expand Down

0 comments on commit 7beb4d4

Please sign in to comment.