Merge pull request #127 from android/jun9merge

Internal > Public merge June 9th
pull/118/head
Jolanda Verhoef 3 years ago committed by GitHub
commit 2acae8f709
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -46,27 +46,37 @@ jobs:
- name: Check lint
run: ./gradlew lintDebug --stacktrace
- name: Build debug
run: ./gradlew assembleDebug --stacktrace
- name: Build release
run: ./gradlew assembleRelease --stacktrace
- name: Build all build type and flavor permutations
run: ./gradlew assemble --stacktrace
- name: Run local tests
run: ./gradlew testDebug --stacktrace
run: ./gradlew testDemoDebug testProdDebug --stacktrace
- name: Upload Demo build outputs (APKs)
uses: actions/upload-artifact@v2
with:
name: build-outputs-demo
path: app/demo/build/outputs
- name: Upload build outputs (APKs)
- name: Upload Prod build outputs (APKs)
uses: actions/upload-artifact@v2
with:
name: build-outputs-prod
path: app/prod/build/outputs
- name: Upload Demo build reports
if: always()
uses: actions/upload-artifact@v2
with:
name: build-outputs
path: app/build/outputs
name: build-reports-demo
path: app/demo/build/reports
- name: Upload build reports
- name: Upload Prod build reports
if: always()
uses: actions/upload-artifact@v2
with:
name: build-reports
path: app/build/reports
name: build-reports-prod
path: app/prod/build/reports
androidTest:
needs: build
@ -107,7 +117,7 @@ jobs:
disable-animations: true
disk-size: 1500M
heap-size: 512M
script: ./gradlew connectedAndroidTest -x :benchmark:connectedBenchmarkAndroidTest
script: ./gradlew connectedProdDebugAndroidTest -x :benchmark:connectedBenchmarkAndroidTest
- name: Upload test reports
if: always()

@ -52,18 +52,26 @@ and is described in detail in the
# Build
The `debug` variant of `app` uses local data to allow immediate building and exploring the UI.
The app contains the usual `debug` and `release` build variants.
The `staging` and `release` variants of `app` make real network calls to a backend server, providing
up-to-date data as new episodes of Now in Android are released. At this time, there is not a
public backend available.
The `benchmark` variant of `app` is used to test startup performance and generate a baseline profile
(see below for more information).
In addition, the `benchmark` variant of `app` is used to test startup performance and generate a
baseline profile (see below for more information).
`app-nia-catalog` is a standalone app that displays the list of components that are stylized for
Now in Android.
The app also uses
[product flavors](https://developer.android.com/studio/build/build-variants#product-flavors) to
control where content for the app should be loaded from.
The `demo` flavor uses static local data to allow immediate building and exploring the UI.
The `prod` flavor makes real network calls to a backend server, providing up-to-date content. At
this time, there is not a public backend available.
For normal development use the `demoDebug` variant. For UI performance testing use the
`demoRelease` variant.
# Testing
To facilitate testing of components, Now in Android uses dependency injection with

@ -22,6 +22,10 @@ plugins {
android {
defaultConfig {
applicationId = "com.google.samples.apps.niacatalog"
// The UI catalog does not depend on content from the app, however, it depends on modules
// which do, so we must specify a default value for the contentType dimension.
missingDimensionStrategy("contentType", "demo")
}
packagingOptions {

@ -13,6 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import com.google.samples.apps.nowinandroid.FlavorDimension
import com.google.samples.apps.nowinandroid.Flavor
plugins {
id("nowinandroid.android.application")
id("nowinandroid.android.application.compose")
@ -43,23 +46,41 @@ android {
val release by getting {
isMinifyEnabled = true
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
val staging by creating {
initWith(debug)
// To publish on the Play store a private signing key is required, but to allow anyone
// who clones the code to sign and run the release variant, use the debug signing key.
// TODO: Abstract the signing configuration to a separate file to avoid hardcoding this.
signingConfig = signingConfigs.getByName("debug")
matchingFallbacks.add("debug")
applicationIdSuffix = ".staging"
}
val benchmark by creating {
initWith(staging) // Usually should be `initWith(release)`. Connecting to demo backend.
matchingFallbacks.add("debug") // Making some settings below to align closer to release.
// Enable all the optimizations from release build through initWith(release).
initWith(release)
matchingFallbacks.add("release")
// Debug key signing is available to everyone.
signingConfig = signingConfigs.getByName("debug")
proguardFiles("benchmark-rules.pro") // Only use benchmark proguard rules
isMinifyEnabled = false // FIXME enabling minification breaks access to demo backend.
// Only use benchmark proguard rules
proguardFiles("benchmark-rules.pro")
// FIXME enabling minification breaks access to demo backend.
isMinifyEnabled = false
// Keep the build type debuggable so we can attach a debugger if needed.
isDebuggable = true
applicationIdSuffix = ".benchmark"
}
}
// @see Flavor for more details on the app product flavors.
flavorDimensions += FlavorDimension.contentType.name
productFlavors {
Flavor.values().forEach {
create(it.name) {
dimension = it.dimension.name
if (it.applicationIdSuffix != null) {
applicationIdSuffix = it.applicationIdSuffix
}
}
}
}
packagingOptions {
resources {
excludes.add("/META-INF/{AL2.0,LGPL2.1}")

@ -25,6 +25,7 @@ android {
defaultConfig {
minSdk = 23
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
missingDimensionStrategy("contentType", "demo")
}
buildTypes {
@ -34,7 +35,7 @@ android {
val benchmark by creating {
isDebuggable = false
signingConfig = signingConfigs.getByName("debug")
matchingFallbacks.add("debug")
matchingFallbacks.add("release")
}
}

@ -33,7 +33,7 @@ class BaselineProfileGenerator {
@Test
fun startup() =
baselineProfileRule.collectBaselineProfile(
packageName = "com.google.samples.apps.nowinandroid"
packageName = "com.google.samples.apps.nowinandroid.demo.benchmark"
) {
pressHome()
// This block defines the app's critical user journey. Here we are interested in

@ -15,6 +15,7 @@
*/
import com.android.build.gradle.LibraryExtension
import com.google.samples.apps.nowinandroid.configureFlavors
import com.google.samples.apps.nowinandroid.configureKotlinAndroid
import org.gradle.api.Plugin
import org.gradle.api.Project
@ -34,6 +35,7 @@ class AndroidLibraryConventionPlugin : Plugin<Project> {
extensions.configure<LibraryExtension> {
configureKotlinAndroid(this)
defaultConfig.targetSdk = 32
configureFlavors(this)
}
val libs = extensions.getByType<VersionCatalogsExtension>().named("libs")
@ -49,4 +51,4 @@ class AndroidLibraryConventionPlugin : Plugin<Project> {
}
}
}
}

@ -0,0 +1,31 @@
package com.google.samples.apps.nowinandroid
import com.android.build.api.dsl.CommonExtension
import org.gradle.api.Project
enum class FlavorDimension {
contentType
}
// The content for the app can either come from local static data which is useful for demo
// purposes, or from a production backend server which supplies up-to-date, real content.
// These two product flavors reflect this behaviour.
enum class Flavor (val dimension : FlavorDimension, val applicationIdSuffix : String? = null) {
demo(FlavorDimension.contentType, ".demo"),
prod(FlavorDimension.contentType)
}
fun Project.configureFlavors(
commonExtension: CommonExtension<*, *, *, *>
) {
commonExtension.apply {
flavorDimensions += FlavorDimension.contentType.name
productFlavors {
Flavor.values().forEach{
create(it.name) {
dimension = it.dimension.name
}
}
}
}
}

@ -23,22 +23,6 @@ plugins {
id("com.google.android.libraries.mapsplatform.secrets-gradle-plugin")
}
android {
buildTypes {
val staging by creating {
initWith(getByName("debug"))
matchingFallbacks.add("debug")
}
}
// Force the staging variant to use the release source directory. This is necessary so that the
// staging variant uses the remote network.
sourceSets {
getByName("staging") {
java.srcDir("src/release/java")
}
}
}
secrets {
defaultPropertiesFileName = "secrets.defaults.properties"
}

@ -0,0 +1,247 @@
# Modularization learning journey
In this learning journey you will learn about modularization, and the modularization strategy used
to create the modules in the Now in Android app.
## Overview
Modularization is the practice of breaking the concept of a monolithic, one-module codebase into
loosely coupled, self contained modules.
### Benefits of modularization
This offers many benefits, including:
**Scalability** - In a tightly coupled codebase, a single change can trigger a cascade of
alterations. A properly modularized project will embrace
the [separation of concerns](https://en.wikipedia.org/wiki/Separation_of_concerns) principle. This
in turn empowers the contributors with more autonomy while also enforcing architectural patterns.
**Enabling work in parallel** - Modularization helps decrease version control conflicts and enables
more efficient work in parallel for developers in larger teams.
**Ownership** - A module can have a dedicated owner who is responsible for maintaining the code and
tests, fixing bugs, and reviewing changes.
**Encapsulation** - Isolated code is easier to read, understand, test and maintain.
**Reduced build time** - Leveraging Gradles parallel and incremental build can reduce build times.
**Dynamic delivery** - Modularization is a requirement
for [Play Feature Delivery](https://developer.android.com/guide/playcore/feature-delivery) which
allows certain features of your app to be delivered conditionally or downloaded on demand.
**Reusability** - Proper modularization enables opportunities for code sharing and building multiple
apps, across different platforms, from the same foundation.
### Modularization pitfalls
However, modularization is a pattern that can be misused, and there are some gotchas to be aware of
when modularizing an app:
**Too many modules** - each module has an overhead that comes in the form of increased complexity of
the build configuration. This can cause Gradle sync times to increase, and incurs an ongoing
maintenance cost. In addition, adding more modules increases the complexity of the projects Gradle
setup, when compared to a single monolithic module. This can be mitigated by making use of
convention plugins, to extract reusable and composable build configuration into type-safe Kotlin
code. In the Now in Android app, these convention plugins can be found in
the [`build-logic` folder](https://github.com/android/nowinandroid/tree/main/build-logic).
**Not enough modules** - conversely if your modules are few, large and tightly coupled, you end up
with yet another monolith. This means you lose some benefits of modularization. If your module is
bloated and has no single, well defined purpose, you should consider splitting it.
**Too complex** - there is no silver bullet here. In fact it doesnt always make sense to modularize
your project. A dominating factor is the size and relative complexity of the codebase. If your
project is not expected to grow beyond a certain threshold, the scalability and build time gains
wont apply.
## Modularization strategy
Its important to note that there is no single modularization strategy that fits all projects.
However, there are general guidelines that can be followed to ensure you maximize its benefits and
minimize its downsides.
A barebone module is simply a directory with a Gradle build script inside. Usually though, a module
will consist of one or more source sets and possibly a collection of resources or assets. Modules
can be built and tested independently. Due to Gradle's flexibility there are few constraints as to
how you can organize your project. In general, you should strive for low coupling and high cohesion.
* **Low coupling** - Modules should be as independent as possible from one another, so that changes
to one module have zero or minimal impact on other modules. They should not possess knowledge of
the inner workings of other modules.
* **High cohesion** - A module should comprise a collection of code that acts as a system. It should
have clearly defined responsibilities and stay within boundaries of certain domain knowledge. For
example,
the [`core-network` module](https://github.com/android/nowinandroid/tree/main/core-network) in Now
in Android is responsible for making network requests, handling responses from a remote data
source, and supplying data to other modules.
## Types of modules in Now in Android
![Diagram showing types of modules and their dependencies in Now in Android](images/modularization-graph.png "Diagram showing types of modules and their dependencies in Now in Android")
**Top tip**: A module graph (shown above) can be useful during modularization planning for
visualizing dependencies between modules.
The Now in Android app contains the following types of modules:
* The `app` module - contains app level and scaffolding classes that bind the rest of the codebase,
such as `MainActivity`, `NiaApp` and app-level controlled navigation. A good example of this is
the navigation setup through `NiaNavHost` and the bottom navigation bar setup
through `NiaTopLevelNavigation`. The `app` module depends on all `feature` modules and
required `core` modules.
* `feature-` modules - feature specific modules which are scoped to handle a single responsibility
in the app. These modules can be reused by any app, including test or other flavoured apps, when
needed, while still keeping it separated and isolated. If a class is needed only by one `feature`
module, it should remain within that module. If not, it should be extracted into an
appropriate `core` module. A `feature` module should have no dependencies on other feature
modules. They only depend on the `core` modules that they require.
* `core-` modules - common library modules containing auxiliary code and specific dependencies that
need to be shared between other modules in the app. These modules can depend on other core
modules, but they shouldnt depend on feature nor app modules.
* Miscellaneous modules - such as `sync`, `benchmark` and `test` modules, as well
as `app-nia-catalog` - a catalog app for displaying our design system quickly.
## Modules
Using the above modularization strategy, the Now in Android app has the following modules:
<table>
<tr>
<td><strong>Name</strong>
</td>
<td><strong>Responsibilities</strong>
</td>
<td><strong>Key classes and good examples</strong>
</td>
</tr>
<tr>
<td><code>app</code>
</td>
<td>Brings everything together required for the app to function correctly. This includes UI scaffolding and navigation.
</td>
<td><code>NiaApp, MainActivity</code><br>
App-level controlled navigation via <code>NiaNavHost, NiaTopLevelNavigation</code>
</td>
</tr>
<tr>
<td><code>feature-1,</code><br>
<code>feature-2</code><br>
...
</td>
<td>Functionality associated with a specific feature or user journey. Typically contains UI components and ViewModels which read data from other modules.<br>
Examples include:<br>
<ul>
<li><a href="https://github.com/android/nowinandroid/tree/main/feature-author"><code>feature-author</code></a> displays information about an author on the AuthorScreen.</li>
<li><a href="https://github.com/android/nowinandroid/tree/main/feature-foryou"><code>feature-foryou</code></a> which displays the user's news feed, and onboarding during first run, on the For You screen.</li>
</ul>
</td>
<td><code>AuthorScreen</code><br>
<code>AuthorViewModel</code>
</td>
</tr>
<tr>
<td><code>core-data</code>
</td>
<td>Fetching app data from multiple sources, shared by different features.
</td>
<td><code>TopicsRepository</code><br>
<code>AuthorsRepository</code>
</td>
</tr>
<tr>
<td><code>core-ui</code>
</td>
<td>UI components, composables and resources, such as icons, used by different features.
</td>
<td><code>NiaIcons</code><br>
<code>NewsResourceCardExpanded</code>
</td>
</tr>
<tr>
<td><code>core-common</code>
</td>
<td>Common classes shared between modules.
</td>
<td><code>NiaDispatchers</code><br>
<code>Result</code>
</td>
</tr>
<tr>
<td><code>core-network</code>
</td>
<td>Making network requests and handling responses from a remote data source.
</td>
<td><code>RetrofitNiANetworkApi</code>
</td>
</tr>
<tr>
<td><code>core-testing</code>
</td>
<td>Testing dependencies, repositories and util classes.
</td>
<td><code>NiaTestRunner</code><br>
<code>TestDispatcherRule</code>
</td>
</tr>
<tr>
<td><code>core-datastore</code>
</td>
<td>Storing persistent data using DataStore.
</td>
<td><code>NiaPreferences</code><br>
<code>UserPreferencesSerializer</code>
</td>
</tr>
<tr>
<td><code>core-database</code>
</td>
<td>Local database storage using Room.
</td>
<td><code>NiADatabase</code><br>
<code>DatabaseMigrations</code><br>
<code>Dao</code> classes
</td>
</tr>
<tr>
<td><code>core-model</code>
</td>
<td>Model classes used throughout the app.
</td>
<td><code>Author</code><br>
<code>Episode</code><br>
<code>NewsResource</code>
</td>
</tr>
<tr>
<td><code>core-navigation</code>
</td>
<td>Navigation dependencies and shared navigation classes.
</td>
<td><code>NiaNavigationDestination</code>
</td>
</tr>
</table>
## Modularization in Now in Android
Our modularization approach was defined taking into account the “Now in Android” project roadmap, upcoming work and new features. Additionally, our aim this time around was to find the right balance between overmodularizing a relatively small app and using this opportunity to showcase a modularization pattern fit for a much larger codebase, closer to real world apps in production environments.
This approach was discussed with the Android community, and evolved taking their feedback into account. With modularization however, there isnt one right answer that makes all others wrong. Ultimately, there are many ways and approaches to modularizing an app and rarely does one approach fit all purposes, codebases and team preferences. This is why planning beforehand and taking into account all goals, problems youre trying to solve, future work and predicting potential stepping stones are all crucial steps for defining the best fit structure under your own, unique circumstances. Developers can benefit from a brainstorming session to draw out a graph of modules and dependencies to visualize and plan this better.
Our approach is such an example - we dont expect it to be an unchangeable structure applicable to all cases, and in fact, it could evolve and change in the future. Its a general guideline we found to be the best fit for our project and offer it as one example you can further modify, expand and build on top of. One way of doing this would be to increase the granularity of the codebase even more. Granularity is the extent to which your codebase is composed of modules. If your data layer is small, its fine to keep it in a single module. But once the number of repositories and data sources starts to grow, it might be worth considering splitting them into separate modules.
We are also always open to your constructive feedback - learning from the community and exchanging ideas is one of the key elements to improving our guidance.

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

@ -20,8 +20,6 @@ import androidx.activity.ComponentActivity
import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.material3.windowsizeclass.ExperimentalMaterial3WindowSizeClassApi
import androidx.compose.material3.windowsizeclass.WindowSizeClass
import androidx.compose.material3.windowsizeclass.WindowWidthSizeClass
import androidx.compose.material3.windowsizeclass.WindowWidthSizeClass.Companion
import androidx.compose.ui.test.assertHasClickAction
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.assertIsEnabled
@ -39,12 +37,7 @@ import androidx.compose.ui.unit.DpSize
import com.google.samples.apps.nowinandroid.core.model.data.Author
import com.google.samples.apps.nowinandroid.core.model.data.FollowableAuthor
import com.google.samples.apps.nowinandroid.core.model.data.FollowableTopic
import com.google.samples.apps.nowinandroid.core.model.data.NewsResource
import com.google.samples.apps.nowinandroid.core.model.data.NewsResourceType.Video
import com.google.samples.apps.nowinandroid.core.model.data.SaveableNewsResource
import com.google.samples.apps.nowinandroid.core.model.data.Topic
import kotlinx.datetime.Instant
import org.junit.Assert.assertTrue
import org.junit.Rule
import org.junit.Test
@ -554,155 +547,155 @@ class ForYouScreenTest {
.assertExists()
}
@Test
fun feed_whenNoInterestsSelectionAndLoaded_showsFeed() {
lateinit var windowSizeClass: WindowSizeClass
val saveableNewsResources = listOf(
SaveableNewsResource(
newsResource = NewsResource(
id = "1",
episodeId = "52",
title = "Thanks for helping us reach 1M YouTube Subscribers",
content = "Thank you everyone for following the Now in Android series " +
"and everything the Android Developers YouTube channel has to offer. " +
"During the Android Developer Summit, our YouTube channel reached 1 " +
"million subscribers! Heres a small video to thank you all.",
url = "https://youtu.be/-fJ6poHQrjM",
headerImageUrl = "https://i.ytimg.com/vi/-fJ6poHQrjM/maxresdefault.jpg",
publishDate = Instant.parse("2021-11-09T00:00:00.000Z"),
type = Video,
topics = listOf(
Topic(
id = "0",
name = "Headlines",
shortDescription = "",
longDescription = "",
url = "",
imageUrl = ""
)
),
authors = emptyList()
),
isSaved = false
),
SaveableNewsResource(
newsResource = NewsResource(
id = "2",
episodeId = "52",
title = "Transformations and customisations in the Paging Library",
content = "A demonstration of different operations that can be performed " +
"with Paging. Transformations like inserting separators, when to " +
"create a new pager, and customisation options for consuming " +
"PagingData.",
url = "https://youtu.be/ZARz0pjm5YM",
headerImageUrl = "https://i.ytimg.com/vi/ZARz0pjm5YM/maxresdefault.jpg",
publishDate = Instant.parse("2021-11-01T00:00:00.000Z"),
type = Video,
topics = listOf(
Topic(
id = "1",
name = "UI",
shortDescription = "",
longDescription = "",
url = "",
imageUrl = ""
),
),
authors = emptyList()
),
isSaved = false
),
SaveableNewsResource(
newsResource = NewsResource(
id = "3",
episodeId = "52",
title = "Community tip on Paging",
content = "Tips for using the Paging library from the developer community",
url = "https://youtu.be/r5JgIyS3t3s",
headerImageUrl = "https://i.ytimg.com/vi/r5JgIyS3t3s/maxresdefault.jpg",
publishDate = Instant.parse("2021-11-08T00:00:00.000Z"),
type = Video,
topics = listOf(
Topic(
id = "1",
name = "UI",
shortDescription = "",
longDescription = "",
url = "",
imageUrl = ""
),
),
authors = emptyList()
),
isSaved = false
),
)
composeTestRule.setContent {
BoxWithConstraints {
windowSizeClass = WindowSizeClass.calculateFromSize(
DpSize(maxWidth, maxHeight)
)
ForYouScreen(
windowSizeClass = windowSizeClass,
interestsSelectionState = ForYouInterestsSelectionUiState.NoInterestsSelection,
feedState = ForYouFeedUiState.Success(
feed = saveableNewsResources
),
onAuthorCheckedChanged = { _, _ -> },
onTopicCheckedChanged = { _, _ -> },
saveFollowedTopics = {},
onNewsResourcesCheckedChanged = { _, _ -> }
)
}
}
// Scroll until the second feed item is visible
// This will cause both the first and second feed items to be visible at the same time,
// so we can compare their positions to each other.
composeTestRule
.onAllNodes(hasScrollToNodeAction())
.onFirst()
.performScrollToNode(
hasText(
"Transformations and customisations in the Paging Library",
substring = true
)
)
val firstFeedItem = composeTestRule
.onNodeWithText(
"Thanks for helping us reach 1M YouTube Subscribers",
substring = true
)
.assertHasClickAction()
.fetchSemanticsNode()
val secondFeedItem = composeTestRule
.onNodeWithText(
"Transformations and customisations in the Paging Library",
substring = true
)
.assertHasClickAction()
.fetchSemanticsNode()
when (windowSizeClass.widthSizeClass) {
WindowWidthSizeClass.Compact, Companion.Medium -> {
// On smaller screen widths, the second feed item should be below the first because
// they are displayed in a single column
assertTrue(
firstFeedItem.positionInRoot.y < secondFeedItem.positionInRoot.y
)
}
else -> {
// On larger screen widths, the second feed item should be inline with the first
// because they are displayed in more than one column
assertTrue(
firstFeedItem.positionInRoot.y == secondFeedItem.positionInRoot.y
)
}
}
}
// @Test
// fun feed_whenNoInterestsSelectionAndLoaded_showsFeed() {
// lateinit var windowSizeClass: WindowSizeClass
//
// val saveableNewsResources = listOf(
// SaveableNewsResource(
// newsResource = NewsResource(
// id = "1",
// episodeId = "52",
// title = "Thanks for helping us reach 1M YouTube Subscribers",
// content = "Thank you everyone for following the Now in Android series " +
// "and everything the Android Developers YouTube channel has to offer. " +
// "During the Android Developer Summit, our YouTube channel reached 1 " +
// "million subscribers! Heres a small video to thank you all.",
// url = "https://youtu.be/-fJ6poHQrjM",
// headerImageUrl = "https://i.ytimg.com/vi/-fJ6poHQrjM/maxresdefault.jpg",
// publishDate = Instant.parse("2021-11-09T00:00:00.000Z"),
// type = Video,
// topics = listOf(
// Topic(
// id = "0",
// name = "Headlines",
// shortDescription = "",
// longDescription = "",
// url = "",
// imageUrl = ""
// )
// ),
// authors = emptyList()
// ),
// isSaved = false
// ),
// SaveableNewsResource(
// newsResource = NewsResource(
// id = "2",
// episodeId = "52",
// title = "Transformations and customisations in the Paging Library",
// content = "A demonstration of different operations that can be performed " +
// "with Paging. Transformations like inserting separators, when to " +
// "create a new pager, and customisation options for consuming " +
// "PagingData.",
// url = "https://youtu.be/ZARz0pjm5YM",
// headerImageUrl = "https://i.ytimg.com/vi/ZARz0pjm5YM/maxresdefault.jpg",
// publishDate = Instant.parse("2021-11-01T00:00:00.000Z"),
// type = Video,
// topics = listOf(
// Topic(
// id = "1",
// name = "UI",
// shortDescription = "",
// longDescription = "",
// url = "",
// imageUrl = ""
// ),
// ),
// authors = emptyList()
// ),
// isSaved = false
// ),
// SaveableNewsResource(
// newsResource = NewsResource(
// id = "3",
// episodeId = "52",
// title = "Community tip on Paging",
// content = "Tips for using the Paging library from the developer community",
// url = "https://youtu.be/r5JgIyS3t3s",
// headerImageUrl = "https://i.ytimg.com/vi/r5JgIyS3t3s/maxresdefault.jpg",
// publishDate = Instant.parse("2021-11-08T00:00:00.000Z"),
// type = Video,
// topics = listOf(
// Topic(
// id = "1",
// name = "UI",
// shortDescription = "",
// longDescription = "",
// url = "",
// imageUrl = ""
// ),
// ),
// authors = emptyList()
// ),
// isSaved = false
// ),
// )
//
// composeTestRule.setContent {
// BoxWithConstraints {
// windowSizeClass = WindowSizeClass.calculateFromSize(
// DpSize(maxWidth, maxHeight)
// )
//
// ForYouScreen(
// windowSizeClass = windowSizeClass,
// interestsSelectionState = ForYouInterestsSelectionUiState.NoInterestsSelection,
// feedState = ForYouFeedUiState.Success(
// feed = saveableNewsResources
// ),
// onAuthorCheckedChanged = { _, _ -> },
// onTopicCheckedChanged = { _, _ -> },
// saveFollowedTopics = {},
// onNewsResourcesCheckedChanged = { _, _ -> }
// )
// }
// }
//
// // Scroll until the second feed item is visible
// // This will cause both the first and second feed items to be visible at the same time,
// // so we can compare their positions to each other.
// composeTestRule
// .onAllNodes(hasScrollToNodeAction())
// .onFirst()
// .performScrollToNode(
// hasText(
// "Transformations and customisations in the Paging Library",
// substring = true
// )
// )
//
// val firstFeedItem = composeTestRule
// .onNodeWithText(
// "Thanks for helping us reach 1M YouTube Subscribers",
// substring = true
// )
// .assertHasClickAction()
// .fetchSemanticsNode()
//
// val secondFeedItem = composeTestRule
// .onNodeWithText(
// "Transformations and customisations in the Paging Library",
// substring = true
// )
// .assertHasClickAction()
// .fetchSemanticsNode()
//
// when (windowSizeClass.widthSizeClass) {
// WindowWidthSizeClass.Compact, Companion.Medium -> {
// // On smaller screen widths, the second feed item should be below the first because
// // they are displayed in a single column
// assertTrue(
// firstFeedItem.positionInRoot.y < secondFeedItem.positionInRoot.y
// )
// }
// else -> {
// // On larger screen widths, the second feed item should be inline with the first
// // because they are displayed in more than one column
// assertTrue(
// firstFeedItem.positionInRoot.y == secondFeedItem.positionInRoot.y
// )
// }
// }
// }
}

@ -62,8 +62,8 @@ run_firebase_test_lab() {
while [ $result != 0 -a $counter -lt $MAX_RETRY ]; do
gcloud firebase test android run \
--type instrumentation \
--app "app/build/outputs/apk/debug/app-debug.apk" \
--test "$module/build/outputs/apk/androidTest/debug/$module-debug-androidTest.apk" \
--app "app/build/outputs/apk/demo/debug/app-demo-debug.apk" \
--test "$module/build/outputs/apk/androidTest/demo/debug/$module-demo-debug-androidTest.apk" \
--device-ids $deviceIds \
--os-version-ids $osVersionIds \
--locales en \

Loading…
Cancel
Save