-
Notifications
You must be signed in to change notification settings - Fork 433
Fixed CI to avoid dynamic classloading #4152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
fa6f7b4
30dd950
52b1171
617b329
83baaea
e17ec30
951062e
8c274da
57d37a6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,35 +1,19 @@ | ||
| package com.codenameone.examples.hellocodenameone.tests; | ||
|
|
||
| import com.codename1.testing.AbstractTest; | ||
| import com.codename1.ui.Component; | ||
| import com.codename1.ui.Form; | ||
| import com.codename1.ui.layouts.BorderLayout; | ||
|
|
||
| abstract class AbstractGraphicsScreenshotTest extends AbstractTest { | ||
| abstract class AbstractGraphicsScreenshotTest extends BaseTest { | ||
| protected abstract Component createContent(); | ||
|
|
||
| protected abstract String screenshotName(); | ||
|
|
||
| @Override | ||
| public boolean runTest() throws Exception { | ||
| final Form[] holder = new Form[1]; | ||
| Cn1ssDeviceRunnerHelper.runOnEdtSync(() -> { | ||
| Form form = new Form("Graphics", new BorderLayout()); | ||
| form.add(BorderLayout.CENTER, createContent()); | ||
| holder[0] = form; | ||
| form.show(); | ||
| }); | ||
|
|
||
| Cn1ssDeviceRunnerHelper.waitForMillis(1200); | ||
|
|
||
| final boolean[] result = new boolean[1]; | ||
| Cn1ssDeviceRunnerHelper.runOnEdtSync(() -> { | ||
| if (holder[0] != null) { | ||
| holder[0].revalidate(); | ||
| holder[0].repaint(); | ||
| } | ||
| result[0] = Cn1ssDeviceRunnerHelper.emitCurrentFormScreenshot(screenshotName()); | ||
| }); | ||
| return result[0]; | ||
| Form form = createForm("Graphics", new BorderLayout(), screenshotName()); | ||
| form.add(BorderLayout.CENTER, createContent()); | ||
| form.show(); | ||
| return waitForDone(); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| package com.codenameone.examples.hellocodenameone.tests; | ||
|
|
||
| import com.codename1.testing.AbstractTest; | ||
| import com.codename1.ui.Form; | ||
| import com.codename1.ui.util.UITimer; | ||
| import com.codename1.ui.layouts.Layout; | ||
| import com.codename1.testing.TestUtils; | ||
|
|
||
| public abstract class BaseTest extends AbstractTest { | ||
| private boolean done; | ||
|
|
||
| protected Form createForm(String title, Layout layout, final String imageName) { | ||
| return new Form(title, layout) { | ||
| @Override | ||
| protected void onShowCompleted() { | ||
| registerReadyCallback(this, () -> { | ||
| Cn1ssDeviceRunnerHelper.emitCurrentFormScreenshot(imageName); | ||
| done = true; | ||
| }); | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| protected void registerReadyCallback(Form parent, Runnable run) { | ||
| // Android misses some images when the time is lower | ||
| UITimer.timer(1500, false, parent, run); | ||
| } | ||
|
|
||
| protected boolean waitForDone() { | ||
| int timeout = 100; | ||
| while(!done) { | ||
| TestUtils.waitFor(20); | ||
| timeout--; | ||
| if(timeout == 0) { | ||
| return false; | ||
| } | ||
| } | ||
| // give the test a few additional milliseconds for the screenshot emission | ||
| TestUtils.waitFor(100); | ||
| return true; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,26 +4,40 @@ | |
| import com.codename1.testing.TestReporting; | ||
| import com.codename1.ui.Display; | ||
| import com.codename1.ui.Form; | ||
| import com.codename1.testing.AbstractTest; | ||
|
|
||
| public final class Cn1ssDeviceRunner extends DeviceRunner { | ||
| private static final String[] TEST_CLASSES = new String[] { | ||
| MainScreenScreenshotTest.class.getName(), | ||
| BrowserComponentScreenshotTest.class.getName(), | ||
| MediaPlaybackScreenshotTest.class.getName(), | ||
| GraphicsPipelineScreenshotTest.class.getName(), | ||
| GraphicsShapesAndGradientsScreenshotTest.class.getName(), | ||
| GraphicsStateAndTextScreenshotTest.class.getName(), | ||
| GraphicsTransformationsScreenshotTest.class.getName(), | ||
| GraphicsMethodsScreenshotTest.class.getName() | ||
| private static final AbstractTest[] TEST_CLASSES = new AbstractTest[] { | ||
| new MainScreenScreenshotTest(), | ||
| new GraphicsPipelineScreenshotTest(), | ||
| new GraphicsShapesAndGradientsScreenshotTest(), | ||
| new GraphicsStateAndTextScreenshotTest(), | ||
| new GraphicsTransformationsScreenshotTest(), | ||
| new BrowserComponentScreenshotTest(), | ||
| new MediaPlaybackScreenshotTest() | ||
| }; | ||
|
|
||
| public void runSuite() { | ||
| for (String testClass : TEST_CLASSES) { | ||
| runTest(testClass); | ||
| for (AbstractTest testClass : TEST_CLASSES) { | ||
| log("CN1SS:INFO:suite starting test=" + testClass); | ||
| try { | ||
| testClass.prepare(); | ||
| testClass.runTest(); | ||
| testClass.cleanup(); | ||
|
Comment on lines
+22
to
+26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The suite now executes each Useful? React with 👍 / 👎. |
||
| log("CN1SS:INFO:suite finished test=" + testClass); | ||
| } catch (Throwable t) { | ||
| log("CN1SS:ERR:suite test=" + testClass + " failed=" + t); | ||
| t.printStackTrace(); | ||
| } | ||
| } | ||
| log("CN1SS:SUITE:FINISHED"); | ||
| TestReporting.getInstance().testExecutionFinished(getClass().getName()); | ||
| } | ||
|
|
||
| private static void log(String msg) { | ||
| System.out.println(msg); | ||
| } | ||
|
|
||
| @Override | ||
| protected void startApplicationInstance() { | ||
| Cn1ssDeviceRunnerHelper.runOnEdtSync(() -> { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
runSuite now calls
testClass.prepare(); testClass.runTest(); testClass.cleanup();directly and never checks the boolean returned byrunTest()or notifiesTestReportingabout start/finish. If any test returnsfalse(e.g.,MediaPlaybackScreenshotTestwhen media creation fails), the suite logs it as “finished” and still emitsCN1SS:SUITE:FINISHED, so CI andCn1ssDeviceRunnerReporterwill never mark the test as failed. Please capture the return value and callstartingTestCase/finishedTestCaseso failed tests are surfaced.Useful? React with 👍 / 👎.