diff --git a/scripts/hellocodenameone/common/src/main/java/com/codenameone/examples/hellocodenameone/HelloCodenameOne.java b/scripts/hellocodenameone/common/src/main/java/com/codenameone/examples/hellocodenameone/HelloCodenameOne.java deleted file mode 100644 index 9f1175fca4..0000000000 --- a/scripts/hellocodenameone/common/src/main/java/com/codenameone/examples/hellocodenameone/HelloCodenameOne.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.codenameone.examples.hellocodenameone; - -import com.codename1.system.Lifecycle; -import com.codename1.testing.TestReporting; -import com.codename1.ui.Button; -import com.codename1.ui.BrowserComponent; -import com.codename1.ui.Container; -import com.codename1.ui.Display; -import com.codename1.ui.FontImage; -import com.codename1.ui.Form; -import com.codename1.ui.Label; -import com.codename1.ui.layouts.BorderLayout; -import com.codename1.ui.layouts.BoxLayout; -import com.codename1.ui.CN; - -import com.codenameone.examples.hellocodenameone.tests.Cn1ssDeviceRunner; -import com.codenameone.examples.hellocodenameone.tests.Cn1ssDeviceRunnerReporter; - -public class HelloCodenameOne extends Lifecycle { - @Override - public void init(Object context) { - super.init(context); - TestReporting.setInstance(new Cn1ssDeviceRunnerReporter()); - } - - @Override - public void runApp() { - new Thread(() -> new Cn1ssDeviceRunner().runSuite()).start(); - } -} diff --git a/scripts/hellocodenameone/common/src/main/java/com/codenameone/examples/hellocodenameone/tests/Cn1ssDeviceRunner.java b/scripts/hellocodenameone/common/src/main/java/com/codenameone/examples/hellocodenameone/tests/Cn1ssDeviceRunner.java index ec11277697..5f458c33e0 100644 --- a/scripts/hellocodenameone/common/src/main/java/com/codenameone/examples/hellocodenameone/tests/Cn1ssDeviceRunner.java +++ b/scripts/hellocodenameone/common/src/main/java/com/codenameone/examples/hellocodenameone/tests/Cn1ssDeviceRunner.java @@ -34,8 +34,12 @@ import com.codenameone.examples.hellocodenameone.tests.graphics.TransformTranslation; import com.codenameone.examples.hellocodenameone.tests.accessibility.AccessibilityTest; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + public final class Cn1ssDeviceRunner extends DeviceRunner { - private static final BaseTest[] TEST_CLASSES = new BaseTest[] { + private static final List TEST_CLASSES = new ArrayList<>(Arrays.asList( new MainScreenScreenshotTest(), new DrawLine(), new FillRect(), @@ -66,8 +70,11 @@ public final class Cn1ssDeviceRunner extends DeviceRunner { new MediaPlaybackScreenshotTest(), new OrientationLockScreenshotTest(), new InPlaceEditViewTest(), - new AccessibilityTest() - }; + new AccessibilityTest())); + + public static void addTest(BaseTest test) { + TEST_CLASSES.add(0, test); + } public void runSuite() { CN.callSerially(() -> { diff --git a/scripts/hellocodenameone/common/src/main/kotlin/com/codenameone/examples/hellocodenameone/HelloCodenameOne.kt b/scripts/hellocodenameone/common/src/main/kotlin/com/codenameone/examples/hellocodenameone/HelloCodenameOne.kt new file mode 100644 index 0000000000..83b0708ab4 --- /dev/null +++ b/scripts/hellocodenameone/common/src/main/kotlin/com/codenameone/examples/hellocodenameone/HelloCodenameOne.kt @@ -0,0 +1,19 @@ +package com.codenameone.examples.hellocodenameone + +import com.codename1.system.Lifecycle +import com.codename1.testing.TestReporting +import com.codenameone.examples.hellocodenameone.tests.Cn1ssDeviceRunner +import com.codenameone.examples.hellocodenameone.tests.Cn1ssDeviceRunnerReporter +import com.codenameone.examples.hellocodenameone.tests.KotlinUiTest + +open class HelloCodenameOne : Lifecycle() { + override fun init(context: Any?) { + super.init(context) + Cn1ssDeviceRunner.addTest(KotlinUiTest()) + TestReporting.setInstance(Cn1ssDeviceRunnerReporter()) + } + + override fun runApp() { + Thread(Runnable { Cn1ssDeviceRunner().runSuite() }).start() + } +} \ No newline at end of file diff --git a/scripts/hellocodenameone/common/src/main/kotlin/com/codenameone/examples/hellocodenameone/tests/KotlinUiTest.kt b/scripts/hellocodenameone/common/src/main/kotlin/com/codenameone/examples/hellocodenameone/tests/KotlinUiTest.kt new file mode 100644 index 0000000000..3a80081d18 --- /dev/null +++ b/scripts/hellocodenameone/common/src/main/kotlin/com/codenameone/examples/hellocodenameone/tests/KotlinUiTest.kt @@ -0,0 +1,22 @@ +package com.codenameone.examples.hellocodenameone.tests + +import com.codename1.components.Accordion +import com.codename1.components.MultiButton +import com.codename1.components.Switch +import com.codename1.ui.Button +import com.codename1.ui.layouts.BoxLayout + +class KotlinUiTest : BaseTest() { + override fun runTest(): Boolean { + var kotlinForm = createForm("Kotlin", BoxLayout.y(), "kotlin") + kotlinForm.add(Button("Kotlin Button")) + var on = Switch() + on.setOn() + kotlinForm.add(BoxLayout.encloseX(Switch(), on)) + var acc = Accordion() + acc.add(MultiButton("MultiButton Line 1")) + kotlinForm.add(acc); + kotlinForm.show() + return true + } +} \ No newline at end of file