File tree Expand file tree Collapse file tree 4 files changed +57
-5
lines changed
src/androidTest/java/it/niedermann/nextcloud/deck Expand file tree Collapse file tree 4 files changed +57
-5
lines changed Original file line number Diff line number Diff line change 10
10
- uses : gradle/wrapper-validation-action@v1
11
11
12
12
test :
13
- name : Run Unit Tests
13
+ name : Unit tests
14
14
runs-on : ubuntu-18.04
15
15
16
16
steps :
22
22
- name : Unit tests
23
23
run : bash ./gradlew test --stacktrace
24
24
25
+ instrumented :
26
+ name : Android instrumented tests
27
+ runs-on : macos-latest
28
+
29
+ steps :
30
+ - uses : actions/checkout@v2
31
+ - name : set up JDK 1.8
32
+ uses : actions/setup-java@v1
33
+ with :
34
+ java-version : 1.8
35
+ - name : Android instrumented tests
36
+ uses : reactivecircus/android-emulator-runner@v2
37
+ with :
38
+ api-level : 29
39
+ script : ./gradlew connectDevDebugAndroidTest --stacktrace
40
+
25
41
apk :
26
42
name : Generate APK
27
43
runs-on : ubuntu-18.04
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ android {
16
16
}
17
17
}
18
18
multiDexEnabled true
19
+ testInstrumentationRunner " androidx.test.runner.AndroidJUnitRunner"
19
20
}
20
21
buildTypes {
21
22
release {
@@ -123,5 +124,6 @@ dependencies {
123
124
// Tests
124
125
testImplementation ' junit:junit:4.13'
125
126
androidTestImplementation ' androidx.test:runner:1.2.0'
127
+ androidTestImplementation ' androidx.test.ext:junit:1.1.1'
126
128
androidTestImplementation ' androidx.test.espresso:espresso-core:3.2.0'
127
129
}
Original file line number Diff line number Diff line change 1
1
package it .niedermann .nextcloud .deck ;
2
2
3
3
import android .content .Context ;
4
- import androidx .test .InstrumentationRegistry ;
5
- import androidx .test .runner .AndroidJUnit4 ;
4
+
5
+ import androidx .test .ext .junit .runners .AndroidJUnit4 ;
6
+ import androidx .test .platform .app .InstrumentationRegistry ;
6
7
7
8
import org .junit .Test ;
8
9
import org .junit .runner .RunWith ;
@@ -19,8 +20,8 @@ public class ExampleInstrumentedTest {
19
20
@ Test
20
21
public void useAppContext () {
21
22
// Context of the app under test.
22
- Context appContext = InstrumentationRegistry .getTargetContext ();
23
+ Context appContext = InstrumentationRegistry .getInstrumentation (). getTargetContext ();
23
24
24
- assertEquals ("it.niedermann.nextcloud.deck" , appContext .getPackageName ());
25
+ assertEquals ("it.niedermann.nextcloud.deck.dev " , appContext .getPackageName ());
25
26
}
26
27
}
Original file line number Diff line number Diff line change
1
+ package it .niedermann .nextcloud .deck .util ;
2
+
3
+ import android .graphics .Color ;
4
+
5
+ import androidx .annotation .ColorInt ;
6
+ import androidx .test .ext .junit .runners .AndroidJUnit4 ;
7
+
8
+ import org .junit .Test ;
9
+ import org .junit .runner .RunWith ;
10
+
11
+ import static org .junit .Assert .assertFalse ;
12
+ import static org .junit .Assert .assertTrue ;
13
+
14
+ /**
15
+ * Instrumented test, which will execute on an Android device.
16
+ *
17
+ * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
18
+ */
19
+ @ RunWith (AndroidJUnit4 .class )
20
+ public class ColorUtilTest {
21
+
22
+ @ Test
23
+ public void testIsColorDark () {
24
+ @ ColorInt int [] darkColors = new int []{Color .BLACK };
25
+ @ ColorInt int [] lightColors = new int []{Color .WHITE };
26
+ for (@ ColorInt int darkColor : darkColors ) {
27
+ assertTrue (ColorUtil .isColorDark (darkColor ));
28
+ }
29
+ for (@ ColorInt int lightColor : lightColors ) {
30
+ assertFalse (ColorUtil .isColorDark (lightColor ));
31
+ }
32
+ }
33
+ }
You can’t perform that action at this time.
0 commit comments