Merge branch 'main' into SimonMarquis-patch-1

pull/710/head
Simon Marquis 2 years ago committed by GitHub
commit deab03e217
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -10,9 +10,6 @@ jobs:
android-ci: android-ci:
runs-on: macos-12 runs-on: macos-12
strategy:
matrix:
device-config: [ "pixel4api30aospatd", "pixelcapi30aospatd" ]
steps: steps:
- name: Checkout - name: Checkout
@ -36,9 +33,12 @@ jobs:
- name: Setup Android SDK - name: Setup Android SDK
uses: android-actions/setup-android@v2 uses: android-actions/setup-android@v2
- name: Build AndroidTest apps
run: ./gradlew packageDemoDebug packageDemoDebugAndroidTest
- name: Run instrumented tests with GMD - name: Run instrumented tests with GMD
run: ./gradlew cleanManagedDevices --unused-only && run: ./gradlew cleanManagedDevices --unused-only &&
./gradlew ${{ matrix.device-config }}DemoDebugAndroidTest -Dorg.gradle.workers.max=1 ./gradlew ciDemoDebugAndroidTest -Dorg.gradle.workers.max=1
-Pandroid.testoptions.manageddevices.emulator.gpu="swiftshader_indirect" -Pandroid.experimental.testOptions.managedDevices.emulator.showKernelLogging=true -Pandroid.testoptions.manageddevices.emulator.gpu="swiftshader_indirect" -Pandroid.experimental.testOptions.managedDevices.emulator.showKernelLogging=true
- name: Upload test reports - name: Upload test reports
@ -46,5 +46,4 @@ jobs:
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
name: test-reports name: test-reports
path: | path: '**/build/reports/androidTests'
'**/*/build/reports/androidTests/'

@ -48,15 +48,22 @@ jobs:
- name: Upload build outputs (APKs) - name: Upload build outputs (APKs)
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
name: build-outputs name: APKs
path: app/build/outputs path: '**/build/outputs/apk/**/*.apk'
- name: Upload build reports - name: Upload lint reports (HTML)
if: always() if: always()
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
name: build-reports name: lint-reports
path: app/build/reports path: '**/build/reports/lint-results-*.html'
- name: Upload test results (XML)
if: always()
uses: actions/upload-artifact@v3
with:
name: test-results
path: '**/build/test-results/test*UnitTest/**.xml'
androidTest: androidTest:
needs: build needs: build
@ -82,6 +89,9 @@ jobs:
- name: Setup Gradle - name: Setup Gradle
uses: gradle/gradle-build-action@v2 uses: gradle/gradle-build-action@v2
- name: Build AndroidTest apps
run: ./gradlew packageDemoDebug packageDemoDebugAndroidTest --daemon
- name: Run instrumentation tests - name: Run instrumentation tests
uses: reactivecircus/android-emulator-runner@v2 uses: reactivecircus/android-emulator-runner@v2
with: with:
@ -90,11 +100,11 @@ jobs:
disable-animations: true disable-animations: true
disk-size: 6000M disk-size: 6000M
heap-size: 600M heap-size: 600M
script: ./gradlew connectedDemoDebugAndroidTest -x :benchmark:connectedDemoBenchmarkAndroidTest script: ./gradlew connectedDemoDebugAndroidTest -x :benchmark:connectedDemoBenchmarkAndroidTest --daemon
- name: Upload test reports - name: Upload test reports
if: always() if: always()
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
name: test-reports-${{ matrix.api-level }} name: test-reports-${{ matrix.api-level }}
path: '*/build/reports/androidTests' path: '**/build/reports/androidTests'

@ -16,12 +16,14 @@
package com.google.samples.apps.nowinandroid.ui package com.google.samples.apps.nowinandroid.ui
import androidx.annotation.StringRes
import androidx.compose.ui.test.assertCountEquals import androidx.compose.ui.test.assertCountEquals
import androidx.compose.ui.test.assertIsOn import androidx.compose.ui.test.assertIsOn
import androidx.compose.ui.test.assertIsSelected import androidx.compose.ui.test.assertIsSelected
import androidx.compose.ui.test.hasAnyAncestor import androidx.compose.ui.test.hasAnyAncestor
import androidx.compose.ui.test.hasTestTag import androidx.compose.ui.test.hasTestTag
import androidx.compose.ui.test.hasText import androidx.compose.ui.test.hasText
import androidx.compose.ui.test.junit4.AndroidComposeTestRule
import androidx.compose.ui.test.junit4.createAndroidComposeRule import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.compose.ui.test.onAllNodesWithText import androidx.compose.ui.test.onAllNodesWithText
import androidx.compose.ui.test.onNodeWithContentDescription import androidx.compose.ui.test.onNodeWithContentDescription
@ -34,10 +36,10 @@ import com.google.samples.apps.nowinandroid.R
import dagger.hilt.android.testing.BindValue import dagger.hilt.android.testing.BindValue
import dagger.hilt.android.testing.HiltAndroidRule import dagger.hilt.android.testing.HiltAndroidRule
import dagger.hilt.android.testing.HiltAndroidTest import dagger.hilt.android.testing.HiltAndroidTest
import org.junit.Before
import org.junit.Rule import org.junit.Rule
import org.junit.Test import org.junit.Test
import org.junit.rules.TemporaryFolder import org.junit.rules.TemporaryFolder
import kotlin.properties.ReadOnlyProperty
import com.google.samples.apps.nowinandroid.feature.bookmarks.R as BookmarksR import com.google.samples.apps.nowinandroid.feature.bookmarks.R as BookmarksR
import com.google.samples.apps.nowinandroid.feature.foryou.R as FeatureForyouR import com.google.samples.apps.nowinandroid.feature.foryou.R as FeatureForyouR
import com.google.samples.apps.nowinandroid.feature.interests.R as FeatureInterestsR import com.google.samples.apps.nowinandroid.feature.interests.R as FeatureInterestsR
@ -69,35 +71,19 @@ class NavigationTest {
@get:Rule(order = 2) @get:Rule(order = 2)
val composeTestRule = createAndroidComposeRule<MainActivity>() val composeTestRule = createAndroidComposeRule<MainActivity>()
// The strings used for matching in these tests private fun AndroidComposeTestRule<*, *>.stringResource(@StringRes resId: Int) =
private lateinit var done: String ReadOnlyProperty<Any?, String> { _, _ -> activity.getString(resId) }
private lateinit var navigateUp: String
private lateinit var forYouLoading: String
private lateinit var forYou: String
private lateinit var interests: String
private lateinit var sampleTopic: String
private lateinit var appName: String
private lateinit var saved: String
private lateinit var settings: String
private lateinit var brand: String
private lateinit var ok: String
@Before // The strings used for matching in these tests
fun setup() { private val navigateUp by composeTestRule.stringResource(FeatureForyouR.string.navigate_up)
composeTestRule.activity.apply { private val forYou by composeTestRule.stringResource(FeatureForyouR.string.for_you)
done = getString(FeatureForyouR.string.done) private val interests by composeTestRule.stringResource(FeatureInterestsR.string.interests)
navigateUp = getString(FeatureForyouR.string.navigate_up) private val sampleTopic = "Headlines"
forYouLoading = getString(FeatureForyouR.string.for_you_loading) private val appName by composeTestRule.stringResource(R.string.app_name)
forYou = getString(FeatureForyouR.string.for_you) private val saved by composeTestRule.stringResource(BookmarksR.string.saved)
interests = getString(FeatureInterestsR.string.interests) private val settings by composeTestRule.stringResource(SettingsR.string.top_app_bar_action_icon_description)
sampleTopic = "Headlines" private val brand by composeTestRule.stringResource(SettingsR.string.brand_android)
appName = getString(R.string.app_name) private val ok by composeTestRule.stringResource(SettingsR.string.dismiss_dialog_button_text)
saved = getString(BookmarksR.string.saved)
settings = getString(SettingsR.string.top_app_bar_action_icon_description)
brand = getString(SettingsR.string.brand_android)
ok = getString(SettingsR.string.dismiss_dialog_button_text)
}
}
@Test @Test
fun firstScreen_isForYou() { fun firstScreen_isForYou() {

@ -18,7 +18,7 @@ package com.google.samples.apps.nowinandroid
import com.android.build.api.dsl.CommonExtension import com.android.build.api.dsl.CommonExtension
import com.android.build.api.dsl.ManagedVirtualDevice import com.android.build.api.dsl.ManagedVirtualDevice
import org.gradle.api.Project import org.gradle.kotlin.dsl.get
import org.gradle.kotlin.dsl.invoke import org.gradle.kotlin.dsl.invoke
/** /**
@ -27,16 +27,17 @@ import org.gradle.kotlin.dsl.invoke
internal fun configureGradleManagedDevices( internal fun configureGradleManagedDevices(
commonExtension: CommonExtension<*, *, *, *>, commonExtension: CommonExtension<*, *, *, *>,
) { ) {
val deviceConfigs = listOf( val pixel4 = DeviceConfig("Pixel 4", 30, "aosp-atd")
DeviceConfig("Pixel 4", 30, "aosp-atd"), val pixel6 = DeviceConfig("Pixel 6", 31, "aosp")
DeviceConfig("Pixel 6", 31, "aosp"), val pixelC = DeviceConfig("Pixel C", 30, "aosp-atd")
DeviceConfig("Pixel C", 30, "aosp-atd"),
) val allDevices = listOf(pixel4, pixel6, pixelC)
val ciDevices = listOf(pixel4, pixelC)
commonExtension.testOptions { commonExtension.testOptions {
managedDevices { managedDevices {
devices { devices {
deviceConfigs.forEach { deviceConfig -> allDevices.forEach { deviceConfig ->
maybeCreate(deviceConfig.taskName, ManagedVirtualDevice::class.java).apply { maybeCreate(deviceConfig.taskName, ManagedVirtualDevice::class.java).apply {
device = deviceConfig.device device = deviceConfig.device
apiLevel = deviceConfig.apiLevel apiLevel = deviceConfig.apiLevel
@ -44,6 +45,13 @@ internal fun configureGradleManagedDevices(
} }
} }
} }
groups {
maybeCreate("ci").apply {
ciDevices.forEach { deviceConfig ->
targetDevices.add(devices[deviceConfig.taskName])
}
}
}
} }
} }
} }

Loading…
Cancel
Save