Skip to content

Commit fa6f7b4

Browse files
committed
Fixed CI to avoid dynamic classloading
Also used callSerially to avoid blocking the start method on Android
1 parent a5e243a commit fa6f7b4

File tree

2 files changed

+29
-68
lines changed

2 files changed

+29
-68
lines changed

scripts/device-runner-app/main/HelloCodenameOne.java

Lines changed: 3 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import com.codename1.ui.Label;
1111
import com.codename1.ui.layouts.BorderLayout;
1212
import com.codename1.ui.layouts.BoxLayout;
13+
import com.codename1.ui.CN;
1314

1415
import com.codenameone.examples.hellocodenameone.tests.Cn1ssDeviceRunner;
1516
import com.codenameone.examples.hellocodenameone.tests.Cn1ssDeviceRunnerReporter;
@@ -30,9 +31,9 @@ public void start() {
3031
}
3132
if (!deviceRunnerExecuted) {
3233
deviceRunnerExecuted = true;
33-
new Cn1ssDeviceRunner().runSuite();
34+
CN.callSerially(() -> new Cn1ssDeviceRunner().runSuite());
3435
}
35-
showMainForm();
36+
new Form("Fallback").show();
3637
}
3738

3839
public void stop() {
@@ -42,59 +43,4 @@ public void stop() {
4243
public void destroy() {
4344
// Nothing to clean up for this sample
4445
}
45-
46-
private void showMainForm() {
47-
if (mainForm == null) {
48-
mainForm = new Form("Main Screen", new BorderLayout());
49-
50-
Container content = new Container(BoxLayout.y());
51-
content.getAllStyles().setBgColor(0x1f2937);
52-
content.getAllStyles().setBgTransparency(255);
53-
content.getAllStyles().setPadding(6, 6, 6, 6);
54-
content.getAllStyles().setFgColor(0xf9fafb);
55-
56-
Label heading = new Label("Hello Codename One");
57-
heading.getAllStyles().setFgColor(0x38bdf8);
58-
heading.getAllStyles().setMargin(0, 4, 0, 0);
59-
60-
Label body = new Label("Instrumentation main activity preview");
61-
body.getAllStyles().setFgColor(0xf9fafb);
62-
63-
Button openBrowser = new Button("Open Browser Screen");
64-
openBrowser.addActionListener(evt -> showBrowserForm());
65-
66-
content.add(heading);
67-
content.add(body);
68-
content.add(openBrowser);
69-
70-
mainForm.add(BorderLayout.CENTER, content);
71-
}
72-
current = mainForm;
73-
mainForm.show();
74-
}
75-
76-
private void showBrowserForm() {
77-
Form browserForm = new Form("Browser Screen", new BorderLayout());
78-
79-
BrowserComponent browser = new BrowserComponent();
80-
browser.setPage(buildBrowserHtml(), null);
81-
browserForm.add(BorderLayout.CENTER, browser);
82-
browserForm.getToolbar().addMaterialCommandToLeftBar(
83-
"Back",
84-
FontImage.MATERIAL_ARROW_BACK,
85-
evt -> showMainForm()
86-
);
87-
88-
current = browserForm;
89-
browserForm.show();
90-
}
91-
92-
private String buildBrowserHtml() {
93-
return "<html><head><meta charset='utf-8'/>"
94-
+ "<style>body{margin:0;font-family:sans-serif;background:#0e1116;color:#f3f4f6;}"
95-
+ ".container{padding:24px;text-align:center;}h1{font-size:24px;margin-bottom:12px;}"
96-
+ "p{font-size:16px;line-height:1.4;}span{color:#4cc9f0;}</style></head>"
97-
+ "<body><div class='container'><h1>Codename One</h1>"
98-
+ "<p>BrowserComponent <span>instrumentation</span> test content.</p></div></body></html>";
99-
}
10046
}

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

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,41 @@
44
import com.codename1.testing.TestReporting;
55
import com.codename1.ui.Display;
66
import com.codename1.ui.Form;
7+
import com.codename1.testing.AbstractTest;
78

89
public final class Cn1ssDeviceRunner extends DeviceRunner {
9-
private static final String[] TEST_CLASSES = new String[] {
10-
MainScreenScreenshotTest.class.getName(),
11-
BrowserComponentScreenshotTest.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()
10+
private static final AbstractTest[] TEST_CLASSES = new AbstractTest[] {
11+
new MainScreenScreenshotTest(),
12+
new GraphicsPipelineScreenshotTest(),
13+
new GraphicsShapesAndGradientsScreenshotTest(),
14+
new GraphicsStateAndTextScreenshotTest(),
15+
new GraphicsTransformationsScreenshotTest(),
16+
new GraphicsMethodsScreenshotTest(),
17+
new BrowserComponentScreenshotTest(),
18+
new MediaPlaybackScreenshotTest()
1819
};
1920

2021
public void runSuite() {
21-
for (String testClass : TEST_CLASSES) {
22-
runTest(testClass);
22+
for (AbstractTest testClass : TEST_CLASSES) {
23+
log("CN1SS:INFO:suite starting test=" + testClass);
24+
try {
25+
testClass.prepare();
26+
testClass.runTest();
27+
testClass.cleanup();
28+
log("CN1SS:INFO:suite finished test=" + testClass);
29+
} catch (Throwable t) {
30+
log("CN1SS:ERR:suite test=" + testClass + " failed=" + t);
31+
t.printStackTrace();
32+
}
2333
}
34+
log("CN1SS:SUITE:FINISHED");
2435
TestReporting.getInstance().testExecutionFinished(getClass().getName());
2536
}
2637

38+
private static void log(String msg) {
39+
System.out.println(msg);
40+
}
41+
2742
@Override
2843
protected void startApplicationInstance() {
2944
Cn1ssDeviceRunnerHelper.runOnEdtSync(() -> {

0 commit comments

Comments
 (0)