Skip to content

Commit 3b3619f

Browse files
authored
Added test coverage to the Kotlin support (#4261)
1 parent 040e09e commit 3b3619f

File tree

4 files changed

+51
-33
lines changed

4 files changed

+51
-33
lines changed

scripts/hellocodenameone/common/src/main/java/com/codenameone/examples/hellocodenameone/HelloCodenameOne.java

Lines changed: 0 additions & 30 deletions
This file was deleted.

scripts/hellocodenameone/common/src/main/java/com/codenameone/examples/hellocodenameone/tests/Cn1ssDeviceRunner.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,12 @@
3434
import com.codenameone.examples.hellocodenameone.tests.graphics.TransformTranslation;
3535
import com.codenameone.examples.hellocodenameone.tests.accessibility.AccessibilityTest;
3636

37+
import java.util.ArrayList;
38+
import java.util.Arrays;
39+
import java.util.List;
40+
3741
public final class Cn1ssDeviceRunner extends DeviceRunner {
38-
private static final BaseTest[] TEST_CLASSES = new BaseTest[] {
42+
private static final List<BaseTest> TEST_CLASSES = new ArrayList<>(Arrays.asList(
3943
new MainScreenScreenshotTest(),
4044
new DrawLine(),
4145
new FillRect(),
@@ -66,8 +70,11 @@ public final class Cn1ssDeviceRunner extends DeviceRunner {
6670
new MediaPlaybackScreenshotTest(),
6771
new OrientationLockScreenshotTest(),
6872
new InPlaceEditViewTest(),
69-
new AccessibilityTest()
70-
};
73+
new AccessibilityTest()));
74+
75+
public static void addTest(BaseTest test) {
76+
TEST_CLASSES.add(0, test);
77+
}
7178

7279
public void runSuite() {
7380
CN.callSerially(() -> {
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.codenameone.examples.hellocodenameone
2+
3+
import com.codename1.system.Lifecycle
4+
import com.codename1.testing.TestReporting
5+
import com.codenameone.examples.hellocodenameone.tests.Cn1ssDeviceRunner
6+
import com.codenameone.examples.hellocodenameone.tests.Cn1ssDeviceRunnerReporter
7+
import com.codenameone.examples.hellocodenameone.tests.KotlinUiTest
8+
9+
open class HelloCodenameOne : Lifecycle() {
10+
override fun init(context: Any?) {
11+
super.init(context)
12+
Cn1ssDeviceRunner.addTest(KotlinUiTest())
13+
TestReporting.setInstance(Cn1ssDeviceRunnerReporter())
14+
}
15+
16+
override fun runApp() {
17+
Thread(Runnable { Cn1ssDeviceRunner().runSuite() }).start()
18+
}
19+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.codenameone.examples.hellocodenameone.tests
2+
3+
import com.codename1.components.Accordion
4+
import com.codename1.components.MultiButton
5+
import com.codename1.components.Switch
6+
import com.codename1.ui.Button
7+
import com.codename1.ui.layouts.BoxLayout
8+
9+
class KotlinUiTest : BaseTest() {
10+
override fun runTest(): Boolean {
11+
var kotlinForm = createForm("Kotlin", BoxLayout.y(), "kotlin")
12+
kotlinForm.add(Button("Kotlin Button"))
13+
var on = Switch()
14+
on.setOn()
15+
kotlinForm.add(BoxLayout.encloseX(Switch(), on))
16+
var acc = Accordion()
17+
acc.add(MultiButton("MultiButton Line 1"))
18+
kotlinForm.add(acc);
19+
kotlinForm.show()
20+
return true
21+
}
22+
}

0 commit comments

Comments
 (0)