author | GP Orcullo <kinsamanka@gmail.com> |
Mon, 20 Feb 2023 08:56:25 +0800 | |
branch | python3 |
changeset 3789 | 8def429216ca |
parent 3720 | d0a9c01ee7a5 |
permissions | -rw-r--r-- |
3436
ccaabb9da623
Tests: add an IDE test that relies on image matching.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3424
diff
changeset
|
1 |
""" This test opens, modifies, builds and runs exemple project named "python". |
3424
7db96e011fe7
Tests: added tests/Makefile and a first test in tests/ide_tests. Test requires sikuli and Xvfb or Xnest.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
2 |
Test succeeds if runtime's stdout behaves as expected |
7db96e011fe7
Tests: added tests/Makefile and a first test in tests/ide_tests. Test requires sikuli and Xvfb or Xnest.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
3 |
""" |
7db96e011fe7
Tests: added tests/Makefile and a first test in tests/ide_tests. Test requires sikuli and Xvfb or Xnest.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
4 |
|
7db96e011fe7
Tests: added tests/Makefile and a first test in tests/ide_tests. Test requires sikuli and Xvfb or Xnest.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
5 |
import os |
7db96e011fe7
Tests: added tests/Makefile and a first test in tests/ide_tests. Test requires sikuli and Xvfb or Xnest.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
6 |
import time |
7db96e011fe7
Tests: added tests/Makefile and a first test in tests/ide_tests. Test requires sikuli and Xvfb or Xnest.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
7 |
|
7db96e011fe7
Tests: added tests/Makefile and a first test in tests/ide_tests. Test requires sikuli and Xvfb or Xnest.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
8 |
# allow module import from current test directory's parent |
7db96e011fe7
Tests: added tests/Makefile and a first test in tests/ide_tests. Test requires sikuli and Xvfb or Xnest.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
9 |
addImportPath(os.path.dirname(getBundlePath())) |
7db96e011fe7
Tests: added tests/Makefile and a first test in tests/ide_tests. Test requires sikuli and Xvfb or Xnest.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
10 |
|
7db96e011fe7
Tests: added tests/Makefile and a first test in tests/ide_tests. Test requires sikuli and Xvfb or Xnest.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
11 |
# common test definitions module |
3447
65c5f66e9298
Tests: add HTML report generation and a workaround to bad exception handling in sikuli.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3446
diff
changeset
|
12 |
from sikuliberemiz import run_test |
3424
7db96e011fe7
Tests: added tests/Makefile and a first test in tests/ide_tests. Test requires sikuli and Xvfb or Xnest.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
13 |
|
3447
65c5f66e9298
Tests: add HTML report generation and a workaround to bad exception handling in sikuli.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3446
diff
changeset
|
14 |
def test(app): |
3424
7db96e011fe7
Tests: added tests/Makefile and a first test in tests/ide_tests. Test requires sikuli and Xvfb or Xnest.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
15 |
|
3528
c269f256a7c4
tests: add (broken) debug_project test, fix edit_project
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3447
diff
changeset
|
16 |
app.k.Clean() |
c269f256a7c4
tests: add (broken) debug_project test, fix edit_project
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3447
diff
changeset
|
17 |
|
c269f256a7c4
tests: add (broken) debug_project test, fix edit_project
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3447
diff
changeset
|
18 |
app.waitForChangeAndIdleStdout() |
c269f256a7c4
tests: add (broken) debug_project test, fix edit_project
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3447
diff
changeset
|
19 |
|
c269f256a7c4
tests: add (broken) debug_project test, fix edit_project
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3447
diff
changeset
|
20 |
app.k.Build() |
c269f256a7c4
tests: add (broken) debug_project test, fix edit_project
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3447
diff
changeset
|
21 |
|
3720
d0a9c01ee7a5
Tests: IDE: explicitely wait for build success rather than just stdout to become silent.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3679
diff
changeset
|
22 |
app.waitPatternInStdout("Successfully built.", 10) |
3528
c269f256a7c4
tests: add (broken) debug_project test, fix edit_project
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3447
diff
changeset
|
23 |
|
c269f256a7c4
tests: add (broken) debug_project test, fix edit_project
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3447
diff
changeset
|
24 |
app.k.Connect() |
c269f256a7c4
tests: add (broken) debug_project test, fix edit_project
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3447
diff
changeset
|
25 |
|
c269f256a7c4
tests: add (broken) debug_project test, fix edit_project
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3447
diff
changeset
|
26 |
app.waitForChangeAndIdleStdout() |
c269f256a7c4
tests: add (broken) debug_project test, fix edit_project
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3447
diff
changeset
|
27 |
|
c269f256a7c4
tests: add (broken) debug_project test, fix edit_project
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3447
diff
changeset
|
28 |
app.k.Transfer() |
c269f256a7c4
tests: add (broken) debug_project test, fix edit_project
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3447
diff
changeset
|
29 |
|
c269f256a7c4
tests: add (broken) debug_project test, fix edit_project
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3447
diff
changeset
|
30 |
app.waitForChangeAndIdleStdout() |
c269f256a7c4
tests: add (broken) debug_project test, fix edit_project
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3447
diff
changeset
|
31 |
|
3679
b6bca75bf3fa
Tests: force bigger fonts and flat theme in GTK to make OCR more reliable.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3565
diff
changeset
|
32 |
app.click("main") |
3528
c269f256a7c4
tests: add (broken) debug_project test, fix edit_project
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3447
diff
changeset
|
33 |
|
c269f256a7c4
tests: add (broken) debug_project test, fix edit_project
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3447
diff
changeset
|
34 |
app.WaitIdleUI() |
c269f256a7c4
tests: add (broken) debug_project test, fix edit_project
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3447
diff
changeset
|
35 |
|
c269f256a7c4
tests: add (broken) debug_project test, fix edit_project
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3447
diff
changeset
|
36 |
app.click("1646066996789.png") |
3424
7db96e011fe7
Tests: added tests/Makefile and a first test in tests/ide_tests. Test requires sikuli and Xvfb or Xnest.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
37 |
|
3447
65c5f66e9298
Tests: add HTML report generation and a workaround to bad exception handling in sikuli.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3446
diff
changeset
|
38 |
app.WaitIdleUI() |
3436
ccaabb9da623
Tests: add an IDE test that relies on image matching.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3424
diff
changeset
|
39 |
|
3447
65c5f66e9298
Tests: add HTML report generation and a workaround to bad exception handling in sikuli.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3446
diff
changeset
|
40 |
app.click("example") |
3437
ce366d67a5b7
Tests: Enhance robustness of stdout driven waiting state in Sikuli based tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3436
diff
changeset
|
41 |
|
3447
65c5f66e9298
Tests: add HTML report generation and a workaround to bad exception handling in sikuli.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3446
diff
changeset
|
42 |
app.WaitIdleUI() |
3436
ccaabb9da623
Tests: add an IDE test that relies on image matching.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3424
diff
changeset
|
43 |
|
3447
65c5f66e9298
Tests: add HTML report generation and a workaround to bad exception handling in sikuli.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3446
diff
changeset
|
44 |
app.type(Key.DOWN * 10, Key.CTRL) |
3437
ce366d67a5b7
Tests: Enhance robustness of stdout driven waiting state in Sikuli based tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3436
diff
changeset
|
45 |
|
3447
65c5f66e9298
Tests: add HTML report generation and a workaround to bad exception handling in sikuli.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3446
diff
changeset
|
46 |
app.WaitIdleUI() |
3436
ccaabb9da623
Tests: add an IDE test that relies on image matching.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3424
diff
changeset
|
47 |
|
3528
c269f256a7c4
tests: add (broken) debug_project test, fix edit_project
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3447
diff
changeset
|
48 |
app.k.Run() |
3437
ce366d67a5b7
Tests: Enhance robustness of stdout driven waiting state in Sikuli based tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3436
diff
changeset
|
49 |
|
3528
c269f256a7c4
tests: add (broken) debug_project test, fix edit_project
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3447
diff
changeset
|
50 |
# wait up to 10 seconds for 10 Grumpfs |
c269f256a7c4
tests: add (broken) debug_project test, fix edit_project
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3447
diff
changeset
|
51 |
app.waitPatternInStdout("Grumpf", 10, 10) |
3436
ccaabb9da623
Tests: add an IDE test that relies on image matching.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3424
diff
changeset
|
52 |
|
3528
c269f256a7c4
tests: add (broken) debug_project test, fix edit_project
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3447
diff
changeset
|
53 |
app.rightClick("1646066996790.png") |
3437
ce366d67a5b7
Tests: Enhance robustness of stdout driven waiting state in Sikuli based tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3436
diff
changeset
|
54 |
|
3565
6d3cb1ab1ef7
tests: debug_project IDE test: give up with unreliable OCR for "Force value" menu entry.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3563
diff
changeset
|
55 |
# app.click("Force value") |
6d3cb1ab1ef7
tests: debug_project IDE test: give up with unreliable OCR for "Force value" menu entry.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3563
diff
changeset
|
56 |
|
6d3cb1ab1ef7
tests: debug_project IDE test: give up with unreliable OCR for "Force value" menu entry.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3563
diff
changeset
|
57 |
app.type(Key.DOWN) |
6d3cb1ab1ef7
tests: debug_project IDE test: give up with unreliable OCR for "Force value" menu entry.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3563
diff
changeset
|
58 |
|
6d3cb1ab1ef7
tests: debug_project IDE test: give up with unreliable OCR for "Force value" menu entry.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3563
diff
changeset
|
59 |
app.type(Key.ENTER) |
6d3cb1ab1ef7
tests: debug_project IDE test: give up with unreliable OCR for "Force value" menu entry.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3563
diff
changeset
|
60 |
|
3563
d2d2a11366b1
test: IDE: Fix non repeatable select-all-delete in debug_project.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3551
diff
changeset
|
61 |
# app.click("1646062660790.png") |
3528
c269f256a7c4
tests: add (broken) debug_project test, fix edit_project
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3447
diff
changeset
|
62 |
|
3563
d2d2a11366b1
test: IDE: Fix non repeatable select-all-delete in debug_project.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3551
diff
changeset
|
63 |
# app.type("a", Key.CTRL) |
3528
c269f256a7c4
tests: add (broken) debug_project test, fix edit_project
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3447
diff
changeset
|
64 |
|
3563
d2d2a11366b1
test: IDE: Fix non repeatable select-all-delete in debug_project.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3551
diff
changeset
|
65 |
# app.type(Key.BACKSPACE) |
d2d2a11366b1
test: IDE: Fix non repeatable select-all-delete in debug_project.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3551
diff
changeset
|
66 |
app.type(Key.HOME) |
d2d2a11366b1
test: IDE: Fix non repeatable select-all-delete in debug_project.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3551
diff
changeset
|
67 |
|
d2d2a11366b1
test: IDE: Fix non repeatable select-all-delete in debug_project.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3551
diff
changeset
|
68 |
app.type("a", Key.CTRL) |
d2d2a11366b1
test: IDE: Fix non repeatable select-all-delete in debug_project.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3551
diff
changeset
|
69 |
|
d2d2a11366b1
test: IDE: Fix non repeatable select-all-delete in debug_project.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3551
diff
changeset
|
70 |
app.type(Key.DELETE) |
3540
75a83cc07f27
tests: fix debug_project.sikuli again.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3528
diff
changeset
|
71 |
|
3528
c269f256a7c4
tests: add (broken) debug_project test, fix edit_project
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3447
diff
changeset
|
72 |
app.type("'sys.stdout.write(\"DEBUG TEST OK\\n\")'") |
3436
ccaabb9da623
Tests: add an IDE test that relies on image matching.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3424
diff
changeset
|
73 |
|
3447
65c5f66e9298
Tests: add HTML report generation and a workaround to bad exception handling in sikuli.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3446
diff
changeset
|
74 |
app.type(Key.ENTER) |
3528
c269f256a7c4
tests: add (broken) debug_project test, fix edit_project
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3447
diff
changeset
|
75 |
|
3447
65c5f66e9298
Tests: add HTML report generation and a workaround to bad exception handling in sikuli.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3446
diff
changeset
|
76 |
# wait 10 seconds for 10 patterns |
3528
c269f256a7c4
tests: add (broken) debug_project test, fix edit_project
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3447
diff
changeset
|
77 |
return app.waitPatternInStdout("DEBUG TEST OK", 10) |
3424
7db96e011fe7
Tests: added tests/Makefile and a first test in tests/ide_tests. Test requires sikuli and Xvfb or Xnest.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
78 |
|
3447
65c5f66e9298
Tests: add HTML report generation and a workaround to bad exception handling in sikuli.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3446
diff
changeset
|
79 |
run_test(test, exemple="python") |