Skip to content

Commit

Permalink
Merge changes in upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
maeda-kazuya committed Feb 22, 2019
2 parents 2d9dcd8 + cb7a41a commit 759d758
Show file tree
Hide file tree
Showing 49 changed files with 483 additions and 386 deletions.
93 changes: 93 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
version: 2
config_android:
docker:
- image: circleci/android:api-28-alpha
working_directory: ~/project
environment:
JAVA_TOOL_OPTIONS: -Xmx1024m
GRADLE_OPTS: -Dorg.gradle.daemon=false -Dorg.gradle.workers.max=2 -Dkotlin.incremental=false
TERM: dumb
setup_ftl:
- run:
name: Authorize gcloud and set config defaults
command: |
echo $GCLOUD_SERVICE_KEY | base64 -di > ${HOME}/gcloud-service-key.json
sudo gcloud auth activate-service-account --key-file=${HOME}/gcloud-service-key.json
sudo gcloud --quiet config set project ${GOOGLE_PROJECT_ID}
jobs:
build_and_setup:
docker:
- image: circleci/android:api-28-alpha
working_directory: ~/project
environment:
- JAVA_TOOL_OPTIONS: -Xmx1024m
- GRADLE_OPTS: -Dorg.gradle.daemon=false -Dorg.gradle.workers.max=2 -Dkotlin.incremental=false
- TERM: dumb
steps:
- checkout
- run:
name: Build test and lint
command: |
cd todoapp
./gradlew assembleMockDebug assembleProdDebug assembleMockDebugAndroidTest testMockDebug testProdDebug lintMockDebug lintProdDebug
- run:
name: Save test results
command: |
mkdir -p ~/junit/
find . -type f -regex "./todoapp/.*/build/test-results/.*xml" -exec cp {} ~/junit/ \;
when: always
- store_test_results:
path: ~/junit
- store_artifacts:
path: ~/junit
destination: tests
- store_artifacts:
path: ./todoapp/app/build/reports
destination: reports/
- persist_to_workspace:
root: .
paths:
- ./todoapp/app/build
run_ftl:
docker:
- image: circleci/android:api-28-alpha
working_directory: ~/project
environment:
- JAVA_TOOL_OPTIONS: -Xmx1024m
- GRADLE_OPTS: -Dorg.gradle.daemon=false -Dorg.gradle.workers.max=2 -Dkotlin.incremental=false
- TERM: dumb
steps:
- attach_workspace:
at: .
- run:
name: Authorize gcloud and set config defaults
command: |
echo $GCLOUD_SERVICE_KEY | base64 -di > ${HOME}/gcloud-service-key.json
sudo gcloud auth activate-service-account --key-file=${HOME}/gcloud-service-key.json
sudo gcloud --quiet config set project ${GOOGLE_PROJECT_ID}
- run:
name: Test with Firebase Test Lab
command: |
BUILD_DIR=build_${CIRCLE_BUILD_NUM}
sudo gcloud firebase test android run \
--app todoapp/app/build/outputs/apk/mock/debug/app-mock-debug.apk \
--test todoapp/app/build/outputs/apk/androidTest/mock/debug/app-mock-debug-androidTest.apk \
--results-bucket cloud-test-${GOOGLE_PROJECT_ID}-blueprints \
--results-dir=${BUILD_DIR}
- run:
name: Download results
command: |
BUILD_DIR=build_${CIRCLE_BUILD_NUM}
sudo pip install -U crcmod
mkdir firebase_test_results
sudo gsutil -m mv -r -U `sudo gsutil ls gs://cloud-test-${GOOGLE_PROJECT_ID}-blueprints/${BUILD_DIR} | tail -1` firebase_test_results/ | true
- store_artifacts:
path: firebase_test_results
workflows:
version: 2
build_and_test:
jobs:
- build_and_setup
- run_ftl:
requires:
- build_and_setup
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ android:
components:
- tools
- platform-tools
- build-tools-26.0.2
- android-26
- build-tools-28.0.3
- android-28
- extra-android-m2repository
- extra-google-m2repository
jdk:
Expand Down
29 changes: 0 additions & 29 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -1,29 +0,0 @@
machine:
java:
version: oraclejdk8
environment:
GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError"'

checkout:
post:
- cp -r licenses/. $ANDROID_HOME/licenses
dependencies:
pre:
- sudo pip install -U crcmod
- echo y | android update sdk --no-ui --all --filter "tools,platform-tools,build-tools-26.0.2,android-26,extra-android-m2repository,extra-google-m2repository"

post:
- cd todoapp;./gradlew :app:assembleDebug -PdisablePreDex
- cd todoapp;./gradlew :app:assembleAndroidTest -PdisablePreDex
- echo ${GCLOUD_SERVICE_KEY} | base64 --decode > ${HOME}/client-secret.json
- sudo /opt/google-cloud-sdk/bin/gcloud config set project android-devrel-ci
- sudo /opt/google-cloud-sdk/bin/gcloud --quiet components update
- sudo /opt/google-cloud-sdk/bin/gcloud auth activate-service-account travis-ci-for-blueprints@android-devrel-ci.iam.gserviceaccount.com --key-file ${HOME}/client-secret.json

test:
override:
- echo "y" | sudo /opt/google-cloud-sdk/bin/gcloud firebase test android run --app todoapp/app/build/outputs/apk/mock/debug/app-mock-debug.apk --test todoapp/app/build/outputs/apk/androidTest/mock/debug/app-mock-debug-androidTest.apk -d Nexus5X -v 26 -l fr --results-bucket cloud-test-android-devrel-ci
post:
- sudo /opt/google-cloud-sdk/bin/gsutil -m cp -r -U `sudo /opt/google-cloud-sdk/bin/gsutil ls gs://cloud-test-android-devrel-ci | tail -1` $CIRCLE_ARTIFACTS/ | true
- mkdir -p $CIRCLE_TEST_REPORTS/junit/
- find $CIRCLE_ARTIFACTS -name \*.xml -exec cp {} $CIRCLE_TEST_REPORTS/junit/ \;
3 changes: 2 additions & 1 deletion todoapp/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ build
.gradle
# Eclipse project files
.project
.settings/
.settings/
.classpath
.DS_Store
75 changes: 38 additions & 37 deletions todoapp/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@ android {
versionCode 1
versionName "1.0"

testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}

buildTypes {
debug {
minifyEnabled true
// Uses new built-in shrinker http://tools.android.com/tech-docs/new-build-system/built-in-shrinker
useProguard false
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
testProguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguardTest-rules.pro'
}
Expand All @@ -37,8 +36,8 @@ android {
// If you need to add more flavors, consider using flavor dimensions.
productFlavors {
mock {
applicationIdSuffix = ".mock"
dimension "default"
applicationIdSuffix = ".mock"
}
prod {
dimension "default"
Expand All @@ -48,8 +47,8 @@ android {
// Remove mockRelease as it's not needed.
android.variantFilter { variant ->
if (variant.buildType.name == 'release'
&& variant.flavors[0].name == 'mock') {
variant.ignore = true
&& variant.getFlavors().get(0).name == 'mock') {
variant.setIgnore(true)
}
}

Expand All @@ -66,43 +65,45 @@ android {
all versions in a single place. This improves readability and helps managing project complexity.
*/
dependencies {
// App's dependencies, including test
implementation "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion"
implementation "com.android.support:cardview-v7:$rootProject.supportLibraryVersion"
implementation "com.android.support:design:$rootProject.supportLibraryVersion"
implementation "com.android.support:recyclerview-v7:$rootProject.supportLibraryVersion"
implementation "com.android.support:support-v4:$rootProject.supportLibraryVersion"
implementation "com.android.support.test.espresso:espresso-idling-resource:$rootProject.espressoVersion"
implementation "android.arch.persistence.room:runtime:$rootProject.roomVersion"
kapt "android.arch.persistence.room:compiler:$rootProject.roomVersion"
implementation "com.google.guava:guava:$rootProject.guavaVersion"
// App dependencies
implementation "androidx.appcompat:appcompat:$appCompatVersion"
implementation "androidx.cardview:cardview:$cardVersion"
implementation "com.google.android.material:material:$materialVersion"
implementation "androidx.recyclerview:recyclerview:$recyclerViewVersion"
implementation "androidx.annotation:annotation:$androidXAnnotations"
implementation "androidx.legacy:legacy-support-v4:$androidXLegacySupport"
implementation "androidx.test.espresso:espresso-idling-resource:$espressoVersion"
implementation "com.google.guava:guava:$guavaVersion"
implementation "androidx.room:room-runtime:$roomVersion"
kapt "androidx.room:room-compiler:$roomVersion"

// Dependencies for local unit tests
testImplementation "junit:junit:$rootProject.ext.junitVersion"
testImplementation "org.hamcrest:hamcrest-all:$rootProject.ext.hamcrestVersion"
testImplementation "org.mockito:mockito-core:$rootProject.ext.mockitoVersion"

// Android Testing Support Library's runner and rules
androidTestImplementation "com.android.support.test:runner:$rootProject.ext.runnerVersion"
androidTestImplementation "com.android.support.test:rules:$rootProject.ext.runnerVersion"
testImplementation "junit:junit:$junitVersion"
testImplementation "org.mockito:mockito-core:$mockitoVersion"
testImplementation "org.hamcrest:hamcrest-all:$hamcrestVersion"

// Dependencies for Android unit tests
androidTestImplementation "junit:junit:$rootProject.ext.junitVersion"
androidTestImplementation "org.mockito:mockito-android:$rootProject.ext.mockitoVersion"
androidTestImplementation "junit:junit:$junitVersion"
androidTestImplementation "org.mockito:mockito-core:$mockitoVersion"
androidTestImplementation "com.linkedin.dexmaker:dexmaker-mockito:$dexMakerVersion"

// Espresso UI Testing
androidTestImplementation "com.android.support.test.espresso:espresso-core:$rootProject.espressoVersion"
androidTestImplementation "com.android.support.test.espresso:espresso-contrib:$rootProject.espressoVersion"
androidTestImplementation "com.android.support.test.espresso:espresso-intents:$rootProject.espressoVersion"
// Android Testing Support Library - Instrumented testing
androidTestImplementation "androidx.test:runner:$androidXTestVersion"
androidTestImplementation "androidx.test:rules:$androidXTestVersion"
androidTestImplementation "androidx.room:room-testing:$roomVersion"
androidTestImplementation "androidx.test.espresso:espresso-core:$espressoVersion"
androidTestImplementation "androidx.test.espresso:espresso-contrib:$espressoVersion"
androidTestImplementation "androidx.test.espresso:espresso-intents:$espressoVersion"
androidTestImplementation "androidx.test.espresso.idling:idling-concurrent:$espressoVersion"
implementation "androidx.test.espresso:espresso-idling-resource:$espressoVersion"

// Resolve conflicts between main and test APK:
androidTestImplementation "com.android.support:support-annotations:$rootProject.supportLibraryVersion"
androidTestImplementation "com.android.support:support-v4:$rootProject.supportLibraryVersion"
androidTestImplementation "com.android.support:recyclerview-v7:$rootProject.supportLibraryVersion"
androidTestImplementation "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion"
androidTestImplementation "com.android.support:design:$rootProject.supportLibraryVersion"
androidTestImplementation "com.android.support.test.espresso.idling:idling-concurrent:$rootProject.espressoVersion"
androidTestImplementation "android.arch.persistence.room:testing:$rootProject.roomVersion"
implementation "com.google.code.findbugs:jsr305:3.0.2"
androidTestImplementation "androidx.annotation:annotation:$androidXAnnotations"
androidTestImplementation "androidx.legacy:legacy-support-v4:$androidXLegacySupport"
androidTestImplementation "androidx.recyclerview:recyclerview:$recyclerViewVersion"
androidTestImplementation "androidx.appcompat:appcompat:$appCompatVersion"
androidTestImplementation "com.google.android.material:material:$materialVersion"

// Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
}
20 changes: 14 additions & 6 deletions todoapp/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
-dontoptimize

# Some methods are only called from tests, so make sure the shrinker keeps them.
-keep class com.example.android.architecture.blueprints.** { *; }

-keep class android.support.v4.widget.DrawerLayout { *; }
-keep class android.support.test.espresso.IdlingResource { *; }
-keep class android.support.test.espresso.IdlingRegistry { *; }
-keep class androidx.drawerlayout.widget.DrawerLayout { *; }
-keep class androidx.test.espresso.**
# keep the class and specified members from being removed or renamed
-keep class androidx.test.espresso.IdlingRegistry { *; }
-keep class androidx.test.espresso.IdlingResource { *; }

-keep class com.google.common.base.Preconditions { *; }

-keep class androidx.room.RoomDataBase { *; }
-keep class androidx.room.Room { *; }
-keep class android.arch.** { *; }

# For Guava:
-dontwarn javax.annotation.**
-dontwarn javax.inject.**
Expand All @@ -19,10 +28,9 @@
-dontnote junit.framework.**
-dontnote junit.runner.**

-dontwarn android.test.**
-dontwarn android.support.test.**
-dontwarn androidx.test.**
-dontwarn org.junit.**
-dontwarn org.hamcrest.**
-dontwarn com.squareup.javawriter.JavaWriter
# Uncomment this if you use Mockito
-dontwarn org.mockito.**
-dontwarn org.mockito.**
9 changes: 7 additions & 2 deletions todoapp/app/proguardTest-rules.pro
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
# Proguard rules that are applied to your test apk/code.
-ignorewarnings
-dontoptimize

-keepattributes *Annotation*

-keep class androidx.test.espresso.**
# keep the class and specified members from being removed or renamed
-keep class androidx.test.espresso.IdlingRegistry { *; }
-keep class androidx.test.espresso.IdlingResource { *; }

-dontnote junit.framework.**
-dontnote junit.runner.**

-dontwarn android.test.**
-dontwarn android.support.test.**
-dontwarn androidx.test.**
-dontwarn org.junit.**
-dontwarn org.hamcrest.**
-dontwarn com.squareup.javawriter.JavaWriter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ package com.example.android.architecture.blueprints.todoapp
import android.app.Activity
import android.content.pm.ActivityInfo
import android.content.res.Configuration
import android.support.annotation.IdRes
import android.support.test.InstrumentationRegistry.getInstrumentation
import android.support.test.runner.lifecycle.ActivityLifecycleMonitor
import android.support.test.runner.lifecycle.ActivityLifecycleMonitorRegistry
import android.support.test.runner.lifecycle.Stage.RESUMED
import android.support.v7.widget.Toolbar
import androidx.annotation.IdRes
import androidx.test.InstrumentationRegistry.getInstrumentation
import androidx.test.runner.lifecycle.ActivityLifecycleMonitor
import androidx.test.runner.lifecycle.ActivityLifecycleMonitorRegistry
import androidx.test.runner.lifecycle.Stage.RESUMED
import androidx.appcompat.widget.Toolbar

/**
* Useful test methods common to all activities
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
package com.example.android.architecture.blueprints.todoapp.custom.action

import android.content.res.Resources.NotFoundException
import android.support.design.widget.NavigationView
import android.support.test.espresso.PerformException
import android.support.test.espresso.UiController
import android.support.test.espresso.ViewAction
import android.support.test.espresso.matcher.ViewMatchers
import android.support.test.espresso.matcher.ViewMatchers.isAssignableFrom
import android.support.test.espresso.matcher.ViewMatchers.isDisplayingAtLeast
import android.support.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
import android.support.test.espresso.util.HumanReadables
import android.support.v4.widget.DrawerLayout
import com.google.android.material.navigation.NavigationView
import androidx.test.espresso.PerformException
import androidx.test.espresso.UiController
import androidx.test.espresso.ViewAction
import androidx.test.espresso.matcher.ViewMatchers
import androidx.test.espresso.matcher.ViewMatchers.isAssignableFrom
import androidx.test.espresso.matcher.ViewMatchers.isDisplayingAtLeast
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
import androidx.test.espresso.util.HumanReadables
import androidx.drawerlayout.widget.DrawerLayout
import android.view.Menu
import android.view.View
import org.hamcrest.Matcher
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

package com.example.android.architecture.blueprints.todoapp.data.source.local

import android.arch.persistence.room.Room
import android.support.test.InstrumentationRegistry
import android.support.test.runner.AndroidJUnit4
import androidx.room.Room
import androidx.test.InstrumentationRegistry
import androidx.test.runner.AndroidJUnit4
import com.example.android.architecture.blueprints.todoapp.data.Task
import org.hamcrest.CoreMatchers.`is`
import org.hamcrest.CoreMatchers.notNullValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
*/
package com.example.android.architecture.blueprints.todoapp.data.source.local

import android.support.test.InstrumentationRegistry
import android.support.test.filters.LargeTest
import android.support.test.runner.AndroidJUnit4
import androidx.test.InstrumentationRegistry
import androidx.test.filters.LargeTest
import androidx.test.runner.AndroidJUnit4
import com.example.android.architecture.blueprints.todoapp.data.Task
import com.example.android.architecture.blueprints.todoapp.data.source.TasksDataSource
import org.hamcrest.core.Is.`is`
Expand All @@ -33,7 +33,7 @@ import org.mockito.Mockito.mock
import org.mockito.Mockito.never
import org.mockito.Mockito.verify
import java.util.LinkedList
import android.arch.persistence.room.Room
import androidx.room.Room
import com.example.android.architecture.blueprints.todoapp.utils.SingleExecutors

/**
Expand Down
Loading

0 comments on commit 759d758

Please sign in to comment.