Skip to content

Commit 60f5fec

Browse files
authored
Merge branch 'develop' into dependabot/gradle/com.google.gms-google-services-4.4.2
2 parents 64a27c4 + d2896c6 commit 60f5fec

File tree

5 files changed

+75
-32
lines changed

5 files changed

+75
-32
lines changed

.circleci/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ commands:
99
- restore_cache:
1010
key: v1-gradle-wrapper-{{ arch }}-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}
1111
- restore_cache:
12-
key: v1-gradle-cache-{{ arch }}-{{ checksum "build.gradle.kts" }}-{{ checksum "settings.gradle.kts" }}-{{ checksum "gradle.properties" }}-{{ checksum "app/build.gradle.kts" }}
12+
key: v1-gradle-cache-{{ arch }}-{{ checksum "build.gradle.kts" }}-{{ checksum "settings.gradle.kts" }}-{{ checksum "gradle.properties" }}-{{ checksum "app/build.gradle.kts" }}-{{ checksum "gradle/libs.versions.toml" }}
1313
restore_bundler_cache:
1414
steps:
1515
- restore_cache:
@@ -24,7 +24,7 @@ commands:
2424
- save_cache:
2525
paths:
2626
- ~/.gradle/caches
27-
key: v1-gradle-cache-{{ arch }}-{{ checksum "build.gradle.kts" }}-{{ checksum "settings.gradle.kts" }}-{{ checksum "gradle.properties" }}-{{ checksum "app/build.gradle.kts" }}
27+
key: v1-gradle-cache-{{ arch }}-{{ checksum "build.gradle.kts" }}-{{ checksum "settings.gradle.kts" }}-{{ checksum "gradle.properties" }}-{{ checksum "app/build.gradle.kts" }}-{{ checksum "gradle/libs.versions.toml" }}
2828
save_bundler_cache:
2929
steps:
3030
- save_cache:

.github/workflows/android.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ jobs:
126126
script: |
127127
adb shell screenrecord /sdcard/ui-test.mp4 &
128128
SCREENRECORD_PID=$!
129-
./gradlew connectedCheck || true
129+
./gradlew connectedCheck
130130
kill $SCREENRECORD_PID || true
131131
adb pull /sdcard/ui-test.mp4 ./ui-test.mp4 || true
132132
- name: Upload UI test video

app/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ tasks.register<JacocoReport>("jacocoTestReport") {
114114
"**/R.class", "**/R$*.class", "**/BuildConfig.*", "**/Manifest*.*",
115115
"**/*Test*.*", "android/**/*.*",
116116
"**/Dagger*.*", "**/*_Hilt*.*", "**/*Hilt*.*",
117-
"**/ui/**" // Exclude UI files from coverage
118117
)
119118
val javaDebugTree = fileTree(layout.buildDirectory.dir("intermediates/javac/debug/classes")) { exclude(fileFilter) }
120119
val kotlinDebugTree = fileTree(layout.buildDirectory.dir("tmp/kotlin-classes/debug")) { exclude(fileFilter) }

app/src/androidTest/java/org/kabiri/android/usbterminal/MainActivityAndroidTest.kt

Lines changed: 69 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ package org.kabiri.android.usbterminal
33
import androidx.test.espresso.Espresso.onView
44
import androidx.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu
55
import androidx.test.espresso.NoMatchingViewException
6-
import androidx.test.espresso.assertion.ViewAssertions.matches
76
import androidx.test.espresso.action.ViewActions.click
7+
import androidx.test.espresso.assertion.ViewAssertions.matches
88
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
99
import androidx.test.espresso.matcher.ViewMatchers.withId
10+
import androidx.test.espresso.matcher.ViewMatchers.withText
1011
import androidx.test.ext.junit.rules.activityScenarioRule
1112
import androidx.test.ext.junit.runners.AndroidJUnit4
12-
import androidx.test.platform.app.InstrumentationRegistry
13+
import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation
1314
import org.junit.Rule
1415
import org.junit.Test
1516
import org.junit.runner.RunWith
@@ -21,15 +22,19 @@ internal class MainActivityAndroidTest {
2122
@get:Rule
2223
var rule = activityScenarioRule<MainActivity>()
2324

24-
private fun ensureMenuIsAccessible(menuItemId: Int) {
25+
private fun ensureMenuIsAccessible(
26+
menuItemId: Int,
27+
onVisible: () -> Unit,
28+
onOverflow: () -> Unit
29+
) {
2530
try {
2631
// Try to find the menu item first
2732
onView(withId(menuItemId)).check(matches(isDisplayed()))
33+
onVisible()
2834
} catch (_: NoMatchingViewException) {
2935
// If not found then open the overflow menu
30-
openActionBarOverflowOrOptionsMenu(
31-
InstrumentationRegistry.getInstrumentation().targetContext
32-
)
36+
openActionBarOverflowOrOptionsMenu(getInstrumentation().targetContext)
37+
onOverflow()
3338
}
3439
}
3540

@@ -44,31 +49,70 @@ internal class MainActivityAndroidTest {
4449
}
4550

4651
@Test
47-
fun checkActionMenuItemsAreDisplayed() {
48-
// arrange
49-
// act
50-
// Ensure action items are accessible, either in the toolbar or via overflow
51-
ensureMenuIsAccessible(R.id.actionSettings)
52-
ensureMenuIsAccessible(R.id.actionConnect)
53-
ensureMenuIsAccessible(R.id.actionDisconnect)
52+
fun checkActionMenuItemSettingsIsDisplayed() = ensureMenuIsAccessible(
53+
menuItemId = R.id.actionSettings,
54+
onVisible = {
5455

55-
// assert
56-
// Check menu items are displayed
57-
onView(withId(R.id.actionSettings)).check(matches(isDisplayed()))
58-
onView(withId(R.id.actionConnect)).check(matches(isDisplayed()))
59-
onView(withId(R.id.actionDisconnect)).check(matches(isDisplayed()))
60-
}
56+
// assert
57+
onView(withId(R.id.actionSettings)).check(matches(isDisplayed()))
58+
},
59+
onOverflow = {
60+
61+
// assert
62+
onView(withText(R.string.title_settings)).check(matches(isDisplayed()))
63+
}
64+
)
65+
66+
@Test
67+
fun checkActionMenuItemConnectIsDisplayed() = ensureMenuIsAccessible(
68+
menuItemId = R.id.actionSettings,
69+
onVisible = {
70+
71+
// assert
72+
onView(withId(R.id.actionConnect)).check(matches(isDisplayed()))
73+
},
74+
onOverflow = {
75+
76+
// assert
77+
onView(withText(R.string.title_connect)).check(matches(isDisplayed()))
78+
}
79+
)
80+
81+
@Test
82+
fun checkActionMenuItemDisconnectIsDisplayed() = ensureMenuIsAccessible(
83+
menuItemId = R.id.actionSettings,
84+
onVisible = {
85+
86+
// assert
87+
onView(withId(R.id.actionDisconnect)).check(matches(isDisplayed()))
88+
},
89+
onOverflow = {
90+
91+
// assert
92+
onView(withText(R.string.title_disconnect)).check(matches(isDisplayed()))
93+
}
94+
)
6195

6296
@Test
6397
fun clickingSettingsOpensSettingsBottomSheet() {
6498
// arrange
65-
// Ensure the action item is accisble, either in the toolbar or via overflow
66-
ensureMenuIsAccessible(R.id.actionSettings)
99+
ensureMenuIsAccessible(
100+
menuItemId = R.id.actionSettings,
101+
onVisible = {
67102

68-
// act
69-
onView(withId(R.id.actionSettings)).perform(click())
103+
// act
104+
onView(withId(R.id.actionSettings)).perform(click())
70105

71-
// assert
72-
onView(withId(R.id.composeViewSettingContent)).check(matches(isDisplayed()))
106+
// assert
107+
onView(withId(R.id.composeViewSettingContent)).check(matches(isDisplayed()))
108+
},
109+
onOverflow = {
110+
// act
111+
onView(withText(R.string.title_settings)).perform(click())
112+
113+
// assert
114+
onView(withId(R.id.composeViewSettingContent)).check(matches(isDisplayed()))
115+
}
116+
)
73117
}
74118
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<menu xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:app="http://schemas.android.com/apk/res-auto">
4-
<item android:id="@+id/actionSettings" android:title="@string/title_settings" app:showAsAction="ifRoom" android:icon="@drawable/ic_baseline_settings_24"/>
5-
<item android:id="@+id/actionConnect" android:title="@string/title_connect" app:showAsAction="ifRoom" android:icon="@drawable/ic_usb_white_24dp"/>
6-
<item android:id="@+id/actionDisconnect" android:title="@string/title_disconnect" app:showAsAction="ifRoom" android:icon="@drawable/ic_usb_off_white_24dp"/>
4+
<item android:id="@+id/actionSettings" android:title="@string/title_settings" android:contentDescription="@string/title_settings" app:showAsAction="ifRoom" android:icon="@drawable/ic_baseline_settings_24"/>
5+
<item android:id="@+id/actionConnect" android:title="@string/title_connect" android:contentDescription="@string/title_connect" app:showAsAction="ifRoom" android:icon="@drawable/ic_usb_white_24dp"/>
6+
<item android:id="@+id/actionDisconnect" android:title="@string/title_disconnect" android:contentDescription="@string/title_disconnect" app:showAsAction="ifRoom" android:icon="@drawable/ic_usb_off_white_24dp"/>
77
</menu>

0 commit comments

Comments
 (0)