Skip to content

Commit 6271d1c

Browse files
Merge branch 'android:main' into main
2 parents 56f8a27 + 21777ab commit 6271d1c

File tree

29 files changed

+250
-216
lines changed

29 files changed

+250
-216
lines changed

.github/workflows/AndroidCIWithGmd.yaml

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

.github/workflows/Build.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
branches:
66
- main
77
pull_request:
8+
89
concurrency:
910
group: build-${{ github.ref }}
1011
cancel-in-progress: true
@@ -108,3 +109,42 @@ jobs:
108109
with:
109110
name: test-reports-${{ matrix.api-level }}
110111
path: '**/build/reports/androidTests'
112+
113+
androidTest-GMD:
114+
needs: build
115+
runs-on: macOS-latest # enables hardware acceleration in the virtual machine
116+
timeout-minutes: 55
117+
118+
steps:
119+
- name: Checkout
120+
uses: actions/checkout@v3
121+
122+
- name: Copy CI gradle.properties
123+
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties
124+
125+
- name: Set up JDK 17
126+
uses: actions/setup-java@v3
127+
with:
128+
distribution: 'zulu'
129+
java-version: 17
130+
131+
- name: Setup Gradle
132+
uses: gradle/gradle-build-action@v2
133+
134+
- name: Accept Android licenses
135+
run: yes | "$ANDROID_HOME"/cmdline-tools/latest/bin/sdkmanager --licenses || true
136+
137+
- name: Build AndroidTest apps
138+
run: ./gradlew packageDemoDebug packageDemoDebugAndroidTest
139+
140+
- name: Run instrumented tests with GMD
141+
run: ./gradlew cleanManagedDevices --unused-only &&
142+
./gradlew ciDemoDebugAndroidTest -Dorg.gradle.workers.max=1
143+
-Pandroid.testoptions.manageddevices.emulator.gpu="swiftshader_indirect" -Pandroid.experimental.testOptions.managedDevices.emulator.showKernelLogging=true
144+
145+
- name: Upload test reports
146+
if: success() || failure()
147+
uses: actions/upload-artifact@v3
148+
with:
149+
name: test-reports
150+
path: '**/build/reports/androidTests'

.idea/icon.png

9.48 KB
Loading

.idea/icon_dark.png

10.7 KB
Loading

README.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,6 @@ understanding of which libraries and tools are being used, the reasoning behind
4545
UI, testing, architecture and more, and how all of these different pieces of the project fit
4646
together to create a complete app.
4747

48-
NOTE: Building the app using an M1 Mac will require the use of
49-
[Rosetta](https://support.apple.com/en-gb/HT211861). See
50-
[the following bug](https://github.com/protocolbuffers/protobuf/issues/9397#issuecomment-1086138036)
51-
for more details.
52-
5348
# Architecture
5449

5550
The **Now in Android** app follows the

app-nia-catalog/proguard-rules.pro

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

app/proguard-rules.pro

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,3 @@
1-
# Keep `Companion` object fields of serializable classes.
2-
# This avoids serializer lookup through `getDeclaredClasses` as done for named companion objects.
3-
-if @kotlinx.serialization.Serializable class **
4-
-keepclassmembers class <1> {
5-
static <1>$Companion Companion;
6-
}
7-
8-
# Keep `serializer()` on companion objects (both default and named) of serializable classes.
9-
-if @kotlinx.serialization.Serializable class ** {
10-
static **$* *;
11-
}
12-
-keepclassmembers class <2>$<3> {
13-
kotlinx.serialization.KSerializer serializer(...);
14-
}
15-
16-
# Keep `INSTANCE.serializer()` of serializable objects.
17-
-if @kotlinx.serialization.Serializable class ** {
18-
public static ** INSTANCE;
19-
}
20-
-keepclassmembers class <1> {
21-
public static <1> INSTANCE;
22-
kotlinx.serialization.KSerializer serializer(...);
23-
}
24-
25-
# @Serializable and @Polymorphic are used at runtime for polymorphic serialization.
26-
-keepattributes RuntimeVisibleAnnotations,AnnotationDefault
27-
281
-dontwarn org.bouncycastle.jsse.BCSSLParameters
292
-dontwarn org.bouncycastle.jsse.BCSSLSocket
303
-dontwarn org.bouncycastle.jsse.provider.BouncyCastleJsseProvider

app/src/androidTest/java/com/google/samples/apps/nowinandroid/ui/NavigationTest.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import androidx.test.espresso.Espresso
3333
import androidx.test.espresso.NoActivityResumedException
3434
import com.google.samples.apps.nowinandroid.MainActivity
3535
import com.google.samples.apps.nowinandroid.R
36+
import com.google.samples.apps.nowinandroid.core.rules.GrantPostNotificationsPermissionRule
3637
import dagger.hilt.android.testing.BindValue
3738
import dagger.hilt.android.testing.HiltAndroidRule
3839
import dagger.hilt.android.testing.HiltAndroidTest
@@ -66,9 +67,15 @@ class NavigationTest {
6667
val tmpFolder: TemporaryFolder = TemporaryFolder.builder().assureDeletion().build()
6768

6869
/**
69-
* Use the primary activity to initialize the app normally.
70+
* Grant [android.Manifest.permission.POST_NOTIFICATIONS] permission.
7071
*/
7172
@get:Rule(order = 2)
73+
val postNotificationsPermission = GrantPostNotificationsPermissionRule()
74+
75+
/**
76+
* Use the primary activity to initialize the app normally.
77+
*/
78+
@get:Rule(order = 3)
7279
val composeTestRule = createAndroidComposeRule<MainActivity>()
7380

7481
private fun AndroidComposeTestRule<*, *>.stringResource(@StringRes resId: Int) =

app/src/androidTest/java/com/google/samples/apps/nowinandroid/ui/NavigationUiTest.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import androidx.compose.ui.unit.dp
2727
import com.google.accompanist.testharness.TestHarness
2828
import com.google.samples.apps.nowinandroid.core.data.repository.CompositeUserNewsResourceRepository
2929
import com.google.samples.apps.nowinandroid.core.data.util.NetworkMonitor
30+
import com.google.samples.apps.nowinandroid.core.rules.GrantPostNotificationsPermissionRule
3031
import com.google.samples.apps.nowinandroid.core.testing.repository.TestNewsRepository
3132
import com.google.samples.apps.nowinandroid.core.testing.repository.TestUserDataRepository
3233
import com.google.samples.apps.nowinandroid.uitesthiltmanifest.HiltComponentActivity
@@ -61,9 +62,15 @@ class NavigationUiTest {
6162
val tmpFolder: TemporaryFolder = TemporaryFolder.builder().assureDeletion().build()
6263

6364
/**
64-
* Use a test activity to set the content on.
65+
* Grant [android.Manifest.permission.POST_NOTIFICATIONS] permission.
6566
*/
6667
@get:Rule(order = 2)
68+
val postNotificationsPermission = GrantPostNotificationsPermissionRule()
69+
70+
/**
71+
* Use a test activity to set the content on.
72+
*/
73+
@get:Rule(order = 3)
6774
val composeTestRule = createAndroidComposeRule<HiltComponentActivity>()
6875

6976
val userNewsResourceRepository = CompositeUserNewsResourceRepository(
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* Copyright 2023 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.samples.apps.nowinandroid.interests
18+
19+
import androidx.benchmark.macro.CompilationMode
20+
import androidx.benchmark.macro.FrameTimingMetric
21+
import androidx.benchmark.macro.StartupMode
22+
import androidx.benchmark.macro.junit4.MacrobenchmarkRule
23+
import androidx.test.ext.junit.runners.AndroidJUnit4
24+
import androidx.test.uiautomator.By
25+
import com.google.samples.apps.nowinandroid.PACKAGE_NAME
26+
import com.google.samples.apps.nowinandroid.allowNotifications
27+
import org.junit.Rule
28+
import org.junit.Test
29+
import org.junit.runner.RunWith
30+
31+
@RunWith(AndroidJUnit4::class)
32+
class ScrollTopicListBenchmark {
33+
@get:Rule
34+
val benchmarkRule = MacrobenchmarkRule()
35+
36+
@Test
37+
fun benchmarkStateChangeCompilationBaselineProfile() =
38+
benchmarkStateChange(CompilationMode.Partial())
39+
40+
private fun benchmarkStateChange(compilationMode: CompilationMode) =
41+
benchmarkRule.measureRepeated(
42+
packageName = PACKAGE_NAME,
43+
metrics = listOf(FrameTimingMetric()),
44+
compilationMode = compilationMode,
45+
iterations = 10,
46+
startupMode = StartupMode.WARM,
47+
setupBlock = {
48+
// Start the app
49+
pressHome()
50+
startActivityAndWait()
51+
allowNotifications()
52+
// Navigate to interests screen
53+
device.findObject(By.text("Interests")).click()
54+
device.waitForIdle()
55+
},
56+
) {
57+
interestsWaitForTopics()
58+
repeat(3) {
59+
interestsScrollTopicsDownUp()
60+
}
61+
}
62+
}

0 commit comments

Comments
 (0)