Skip to content

Commit 5bd470e

Browse files
authored
Merge pull request #1 from android/master
Master
2 parents 078b353 + 86cdd11 commit 5bd470e

File tree

517 files changed

+16344
-5921
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

517 files changed

+16344
-5921
lines changed

.circleci/config.yml

+138
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
version: 2
2+
3+
config_android: &config_android
4+
docker:
5+
- image: circleci/android:api-29
6+
environment:
7+
JAVA_TOOL_OPTIONS: "-Xmx1024m"
8+
GRADLE_OPTS: "-Dorg.gradle.daemon=false -Dorg.gradle.workers.max=2 -Dkotlin.incremental=false"
9+
TERM: dumb
10+
working_directory: ~/project
11+
12+
setup_ftl: &setup_ftl
13+
name: Authorize gcloud and set config defaults
14+
command: |
15+
echo $GCLOUD_SERVICE_KEY | base64 -di > ${HOME}/gcloud-service-key.json
16+
sudo gcloud auth activate-service-account --key-file=${HOME}/gcloud-service-key.json
17+
sudo gcloud --quiet config set project ${GOOGLE_PROJECT_ID}
18+
19+
download_results: &download_results
20+
name: Install gsutil dependency and copy test results data
21+
command: |
22+
BUCKETNAME=${PROJECT_DIR:0:29} # limit length
23+
sudo pip install -U crcmod
24+
sudo gsutil -m cp -r -U `sudo gsutil ls gs://cloud-test-${GOOGLE_PROJECT_ID}-arch-${BUCKETNAME,,}/ | tail -1` ${CIRCLE_ARTIFACTS}/ | true
25+
26+
test_sample: &test_sample
27+
<<: *config_android
28+
steps:
29+
- checkout
30+
- run:
31+
<<: *setup_ftl
32+
- run:
33+
name: Assemble APKs
34+
command: |
35+
cd ${PROJECT_DIR}
36+
./gradlew :app:assembleDebug :app:assembleDebugAndroidTest :app:test :app:lint
37+
- run:
38+
name: Test $PROJECT_DIR with Firebase Test Lab
39+
command: |
40+
BUCKETNAME=${PROJECT_DIR:0:29} # limit length
41+
sudo gcloud firebase test android run \
42+
--app ${PROJECT_DIR}/app/build/outputs/apk/debug/app-debug.apk \
43+
--test ${PROJECT_DIR}/app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk \
44+
--results-bucket cloud-test-${GOOGLE_PROJECT_ID}-arch-${BUCKETNAME,,}
45+
- run:
46+
<<: *download_results
47+
- run:
48+
name: Save test results
49+
command: |
50+
mkdir -p ~/junit/
51+
find . -type f -regex ".*/build/test-results/.*xml" -exec cp {} ~/junit/ \;
52+
when: always
53+
- store_test_results:
54+
path: ~/junit
55+
- store_artifacts:
56+
path: ~/junit
57+
destination: tests
58+
- run:
59+
name: Save test/lint reports
60+
command: |
61+
mkdir -p ~/reports/${PROJECT_DIR}/
62+
cp -R ./${PROJECT_DIR}/app/build/reports/* ~/reports/${PROJECT_DIR}/
63+
when: always
64+
- store_artifacts:
65+
path: ~/reports/
66+
destination: reports
67+
68+
jobs:
69+
test_basic_sample:
70+
environment:
71+
PROJECT_DIR: BasicSample
72+
<<: *test_sample
73+
test_rx_java_sample:
74+
environment:
75+
PROJECT_DIR: BasicRxJavaSample
76+
<<: *test_sample
77+
test_rx_java_sample_kotlin:
78+
environment:
79+
PROJECT_DIR: BasicRxJavaSampleKotlin
80+
<<: *test_sample
81+
test_github_browser_sample:
82+
environment:
83+
PROJECT_DIR: GithubBrowserSample
84+
<<: *test_sample
85+
test_livedata_sample:
86+
environment:
87+
PROJECT_DIR: LiveDataSample
88+
<<: *test_sample
89+
test_navigation_basic_sample:
90+
environment:
91+
PROJECT_DIR: NavigationBasicSample
92+
<<: *test_sample
93+
test_navigation_advanced_sample:
94+
environment:
95+
PROJECT_DIR: NavigationAdvancedSample
96+
<<: *test_sample
97+
test_paging_sample:
98+
environment:
99+
PROJECT_DIR: PagingSample
100+
<<: *test_sample
101+
test_paging_network_sample:
102+
environment:
103+
PROJECT_DIR: PagingWithNetworkSample
104+
<<: *test_sample
105+
test_persistence_content_provider_sample:
106+
environment:
107+
PROJECT_DIR: PersistenceContentProviderSample
108+
<<: *test_sample
109+
test_persistence_migrations_sample:
110+
environment:
111+
PROJECT_DIR: PersistenceMigrationsSample
112+
<<: *test_sample
113+
test_workmanager_sample:
114+
environment:
115+
PROJECT_DIR: WorkManagerSample
116+
<<: *test_sample
117+
test_viewbinding_sample:
118+
environment:
119+
PROJECT_DIR: ViewBindingSample
120+
<<: *test_sample
121+
122+
workflows:
123+
version: 2
124+
build_and_test:
125+
jobs:
126+
- test_basic_sample
127+
- test_rx_java_sample
128+
- test_rx_java_sample_kotlin
129+
- test_github_browser_sample
130+
- test_livedata_sample
131+
- test_navigation_basic_sample
132+
- test_navigation_advanced_sample
133+
- test_paging_sample
134+
# flaky, deprecated - test_paging_network_sample
135+
- test_persistence_content_provider_sample
136+
# inst tests with flavors - test_persistence_migrations_sample
137+
# temporarily disabled due to #804 - test_workmanager_sample
138+
- test_viewbinding_sample

.github/ISSUE_TEMPLATE/config.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
blank_issues_enabled: false
2+
contact_links:
3+
- name: Lifecycle
4+
url: https://issuetracker.google.com/issues/new?component=413132&template=1096619
5+
about: File a bug or feature request for Lifecycle
6+
- name: Navigation
7+
url: https://issuetracker.google.com/issues/new?component=409828&template=1093757
8+
about: File a bug or feature request for Navigation or SafeArgs
9+
- name: Paging
10+
url: https://issuetracker.google.com/issues/new?component=413106&template=1096385
11+
about: File a bug or feature request for Paging
12+
- name: Room
13+
url: https://issuetracker.google.com/issues/new?component=413107&template=1096568
14+
about: File a bug or feature request for Room
15+
- name: WorkManager
16+
url: https://issuetracker.google.com/issues/new?component=409906&template=1094197
17+
about: File a bug or feature request for WorkManager

.github/issue_template.md renamed to .github/ISSUE_TEMPLATE/issue_template.md

+9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
---
2+
name: Samples
3+
about: Report an issue with one of the samples in this repository
4+
title: ''
5+
labels:
6+
assignees: ''
7+
8+
---
9+
110
/* Remove this comment
211

312
Reporting an issue with the Architecture Components or the samples?

.github/workflows/copy-branch.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Duplicates default main branch to the old master branch
2+
3+
name: Duplicates main to old master branch
4+
5+
# Controls when the action will run. Triggers the workflow on push or pull request
6+
# events but only for the main branch
7+
on:
8+
push:
9+
branches: [ main ]
10+
11+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
12+
jobs:
13+
# This workflow contains a single job called "copy-branch"
14+
copy-branch:
15+
# The type of runner that the job will run on
16+
runs-on: ubuntu-latest
17+
18+
# Steps represent a sequence of tasks that will be executed as part of the job
19+
steps:
20+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it,
21+
# but specifies master branch (old default).
22+
- uses: actions/checkout@v2
23+
with:
24+
fetch-depth: 0
25+
ref: master
26+
27+
- run: |
28+
git config user.name github-actions
29+
git config user.email [email protected]
30+
git merge origin/main
31+
git push

BasicRxJavaSample/app/build.gradle

+9-15
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apply plugin: 'com.android.application'
22

33
android {
4-
compileSdkVersion build_versions.target_sdk
4+
compileSdkVersion build_versions.compile_sdk
55
buildToolsVersion build_versions.build_tools
66

77
defaultConfig {
@@ -27,13 +27,11 @@ android {
2727
}
2828

2929
dependencies {
30-
// Support libraries
31-
implementation deps.support.app_compat
32-
implementation deps.support.v4
33-
implementation deps.support.design
30+
implementation deps.app_compat
31+
implementation deps.fragment.runtime
32+
implementation deps.material
3433
// Architecture components
3534
implementation deps.lifecycle.runtime
36-
implementation deps.lifecycle.extensions
3735
annotationProcessor deps.lifecycle.compiler
3836
implementation deps.room.runtime
3937
annotationProcessor deps.room.compiler
@@ -47,13 +45,10 @@ dependencies {
4745
testImplementation deps.junit
4846
testImplementation deps.hamcrest
4947
testImplementation deps.arch_core.testing
50-
testImplementation deps.mockito.all
51-
52-
// Resolve conflicts between main and local unit tests
53-
testImplementation deps.support.annotations
54-
testImplementation deps.support.core_utils
48+
testImplementation deps.mockito.core
5549

5650
// Android Testing Support Library's runner and rules
51+
androidTestImplementation deps.atsl.ext_junit
5752
androidTestImplementation deps.atsl.runner
5853
androidTestImplementation deps.atsl.rules
5954
androidTestImplementation deps.room.testing
@@ -70,8 +65,7 @@ dependencies {
7065
androidTestImplementation deps.espresso.intents
7166

7267
// Resolve conflicts between main and test APK:
73-
androidTestImplementation deps.support.annotations
74-
androidTestImplementation deps.support.v4
75-
androidTestImplementation deps.support.app_compat
76-
androidTestImplementation deps.support.design
68+
androidTestImplementation deps.annotations
69+
androidTestImplementation deps.app_compat
70+
androidTestImplementation deps.material
7771
}

BasicRxJavaSample/app/src/androidTest/java/com/example/android/observability/persistence/LocalUserDataSourceTest.java

+9-8
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818

1919
import androidx.arch.core.executor.testing.InstantTaskExecutorRule;
2020
import androidx.room.Room;
21-
import androidx.test.InstrumentationRegistry;
21+
import androidx.test.core.app.ApplicationProvider;
22+
2223
import org.junit.After;
2324
import org.junit.Before;
2425
import org.junit.Rule;
@@ -38,10 +39,10 @@ public class LocalUserDataSourceTest {
3839
private LocalUserDataSource mDataSource;
3940

4041
@Before
41-
public void initDb() throws Exception {
42+
public void initDb() {
4243
// using an in-memory database because the information stored here disappears when the
4344
// process is killed
44-
mDatabase = Room.inMemoryDatabaseBuilder(InstrumentationRegistry.getContext(),
45+
mDatabase = Room.inMemoryDatabaseBuilder(ApplicationProvider.getApplicationContext(),
4546
UsersDatabase.class)
4647
// allowing main thread queries, just for testing
4748
.allowMainThreadQueries()
@@ -50,14 +51,14 @@ public void initDb() throws Exception {
5051
}
5152

5253
@After
53-
public void closeDb() throws Exception {
54+
public void closeDb() {
5455
mDatabase.close();
5556
}
5657

5758
@Test
5859
public void insertAndGetUser() {
5960
// When inserting a new user in the data source
60-
mDataSource.insertOrUpdateUser(USER);
61+
mDataSource.insertOrUpdateUser(USER).blockingAwait();
6162

6263
// When subscribing to the emissions of the user
6364
mDataSource.getUser()
@@ -73,11 +74,11 @@ public void insertAndGetUser() {
7374
@Test
7475
public void updateAndGetUser() {
7576
// Given that we have a user in the data source
76-
mDataSource.insertOrUpdateUser(USER);
77+
mDataSource.insertOrUpdateUser(USER).blockingAwait();
7778

7879
// When we are updating the name of the user
7980
User updatedUser = new User(USER.getId(), "new username");
80-
mDataSource.insertOrUpdateUser(updatedUser);
81+
mDataSource.insertOrUpdateUser(updatedUser).blockingAwait();
8182

8283
// When subscribing to the emissions of the user
8384
mDatabase.userDao().getUser()
@@ -93,7 +94,7 @@ public void updateAndGetUser() {
9394
@Test
9495
public void deleteAndGetUser() {
9596
// Given that we have a user in the data source
96-
mDataSource.insertOrUpdateUser(USER);
97+
mDataSource.insertOrUpdateUser(USER).blockingAwait();
9798

9899
//When we are deleting all users
99100
mDataSource.deleteAllUsers();

BasicRxJavaSample/app/src/androidTest/java/com/example/android/observability/persistence/UserDaoTest.java

+9-9
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818

1919
import androidx.arch.core.executor.testing.InstantTaskExecutorRule;
2020
import androidx.room.Room;
21-
import androidx.test.InstrumentationRegistry;
22-
import androidx.test.runner.AndroidJUnit4;
21+
import androidx.test.core.app.ApplicationProvider;
22+
import androidx.test.ext.junit.runners.AndroidJUnit4;
2323
import org.junit.After;
2424
import org.junit.Before;
2525
import org.junit.Rule;
@@ -40,18 +40,18 @@ public class UserDaoTest {
4040
private UsersDatabase mDatabase;
4141

4242
@Before
43-
public void initDb() throws Exception {
43+
public void initDb() {
4444
// using an in-memory database because the information stored here disappears when the
4545
// process is killed
46-
mDatabase = Room.inMemoryDatabaseBuilder(InstrumentationRegistry.getContext(),
46+
mDatabase = Room.inMemoryDatabaseBuilder(ApplicationProvider.getApplicationContext(),
4747
UsersDatabase.class)
4848
// allowing main thread queries, just for testing
4949
.allowMainThreadQueries()
5050
.build();
5151
}
5252

5353
@After
54-
public void closeDb() throws Exception {
54+
public void closeDb() {
5555
mDatabase.close();
5656
}
5757

@@ -65,7 +65,7 @@ public void getUsersWhenNoUserInserted() {
6565
@Test
6666
public void insertAndGetUser() {
6767
// When inserting a new user in the data source
68-
mDatabase.userDao().insertUser(USER);
68+
mDatabase.userDao().insertUser(USER).blockingAwait();
6969

7070
// When subscribing to the emissions of the user
7171
mDatabase.userDao().getUser()
@@ -81,11 +81,11 @@ public void insertAndGetUser() {
8181
@Test
8282
public void updateAndGetUser() {
8383
// Given that we have a user in the data source
84-
mDatabase.userDao().insertUser(USER);
84+
mDatabase.userDao().insertUser(USER).blockingAwait();
8585

8686
// When we are updating the name of the user
8787
User updatedUser = new User(USER.getId(), "new username");
88-
mDatabase.userDao().insertUser(updatedUser);
88+
mDatabase.userDao().insertUser(updatedUser).blockingAwait();
8989

9090
// When subscribing to the emissions of the user
9191
mDatabase.userDao().getUser()
@@ -101,7 +101,7 @@ public void updateAndGetUser() {
101101
@Test
102102
public void deleteAndGetUser() {
103103
// Given that we have a user in the data source
104-
mDatabase.userDao().insertUser(USER);
104+
mDatabase.userDao().insertUser(USER).blockingAwait();
105105

106106
//When we are deleting all users
107107
mDatabase.userDao().deleteAllUsers();

0 commit comments

Comments
 (0)