Skip to content

Commit de71c18

Browse files
authored
Add graphics pipeline screenshot test (#4142)
* Add graphics pipeline screenshot test * Add comprehensive graphics method screenshot tests * Fix graphics screenshot test dependencies * Fix LinearGradientPaint construction in screenshot test * Add per-method graphics screenshots and trigger iOS runs * Fix graphics screenshot compatibility and PR workflow triggers * Remove reflection in graphics methods screenshot test
1 parent 8e3a241 commit de71c18

9 files changed

+1074
-1
lines changed

.github/workflows/pr.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ on:
55
branches:
66
- master
77
paths-ignore:
8+
- '.github/workflows/scripts-android.yml'
9+
- '.github/workflows/scripts-ios.yml'
810
- 'scripts/**'
911
- 'docs/**'
1012
- '**/*.md'
@@ -14,6 +16,8 @@ on:
1416
branches:
1517
- master
1618
paths-ignore:
19+
- '.github/workflows/scripts-android.yml'
20+
- '.github/workflows/scripts-ios.yml'
1721
- 'scripts/**'
1822
- 'docs/**'
1923
- '**/*.md'

.github/workflows/scripts-ios.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88
- 'scripts/build-ios-port.sh'
99
- 'scripts/build-ios-app.sh'
1010
- 'scripts/run-ios-ui-tests.sh'
11+
- 'scripts/device-runner-app/**/*.java'
1112
- 'scripts/ios/tests/**'
1213
- 'scripts/ios/screenshots/**'
1314
- 'scripts/templates/**'
@@ -29,6 +30,7 @@ on:
2930
- 'scripts/build-ios-port.sh'
3031
- 'scripts/build-ios-app.sh'
3132
- 'scripts/run-ios-ui-tests.sh'
33+
- 'scripts/device-runner-app/**/*.java'
3234
- 'scripts/ios/tests/**'
3335
- 'scripts/ios/screenshots/**'
3436
- 'scripts/templates/**'
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.codenameone.examples.hellocodenameone.tests;
2+
3+
import com.codename1.testing.AbstractTest;
4+
import com.codename1.ui.Component;
5+
import com.codename1.ui.Form;
6+
import com.codename1.ui.layouts.BorderLayout;
7+
8+
abstract class AbstractGraphicsScreenshotTest extends AbstractTest {
9+
protected abstract Component createContent();
10+
11+
protected abstract String screenshotName();
12+
13+
@Override
14+
public boolean runTest() throws Exception {
15+
final Form[] holder = new Form[1];
16+
Cn1ssDeviceRunnerHelper.runOnEdtSync(() -> {
17+
Form form = new Form("Graphics", new BorderLayout());
18+
form.add(BorderLayout.CENTER, createContent());
19+
holder[0] = form;
20+
form.show();
21+
});
22+
23+
Cn1ssDeviceRunnerHelper.waitForMillis(1200);
24+
25+
final boolean[] result = new boolean[1];
26+
Cn1ssDeviceRunnerHelper.runOnEdtSync(() -> {
27+
if (holder[0] != null) {
28+
holder[0].revalidate();
29+
holder[0].repaint();
30+
}
31+
result[0] = Cn1ssDeviceRunnerHelper.emitCurrentFormScreenshot(screenshotName());
32+
});
33+
return result[0];
34+
}
35+
}

scripts/device-runner-app/tests/Cn1ssDeviceRunner.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ public final class Cn1ssDeviceRunner extends DeviceRunner {
99
private static final String[] TEST_CLASSES = new String[] {
1010
MainScreenScreenshotTest.class.getName(),
1111
BrowserComponentScreenshotTest.class.getName(),
12-
MediaPlaybackScreenshotTest.class.getName()
12+
MediaPlaybackScreenshotTest.class.getName(),
13+
GraphicsPipelineScreenshotTest.class.getName(),
14+
GraphicsShapesAndGradientsScreenshotTest.class.getName(),
15+
GraphicsStateAndTextScreenshotTest.class.getName(),
16+
GraphicsTransformationsScreenshotTest.class.getName(),
17+
GraphicsMethodsScreenshotTest.class.getName()
1318
};
1419

1520
public void runSuite() {

0 commit comments

Comments
 (0)