pokemonList = TestDataFactory.makePokemonNamesList(10);
57 | when(mockDataManager.getPokemonList(10)).thenReturn(Single.just(pokemonList));
58 |
59 | mainPresenter.getPokemon(10);
60 |
61 | verify(mockMainMvpView, times(2)).showProgress(anyBoolean());
62 | verify(mockMainMvpView).showPokemon(pokemonList);
63 | verify(mockMainMvpView, never()).showError(any(Throwable.class));
64 | }
65 |
66 | @Test
67 | public void getPokemonReturnsError() throws Exception {
68 | when(mockDataManager.getPokemonList(10)).thenReturn(Single.error(new RuntimeException()));
69 |
70 | mainPresenter.getPokemon(10);
71 |
72 | verify(mockMainMvpView, times(2)).showProgress(anyBoolean());
73 | verify(mockMainMvpView).showError(any(Throwable.class));
74 | verify(mockMainMvpView, never()).showPokemon(ArgumentMatchers.anyList());
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/app/src/test/java/io/mvpstarter/sample/util/DefaultConfig.java:
--------------------------------------------------------------------------------
1 | package io.mvpstarter.sample.util;
2 |
3 | public class DefaultConfig {
4 | //The api level that Roboelectric will use to run the unit tests
5 | public static final int EMULATE_SDK = 24;
6 | }
7 |
--------------------------------------------------------------------------------
/app/src/test/java/io/mvpstarter/sample/util/RxSchedulersOverrideRule.java:
--------------------------------------------------------------------------------
1 | package io.mvpstarter.sample.util;
2 |
3 | import org.junit.rules.TestRule;
4 | import org.junit.runner.Description;
5 | import org.junit.runners.model.Statement;
6 |
7 | import java.util.concurrent.Callable;
8 |
9 | import io.reactivex.Scheduler;
10 | import io.reactivex.android.plugins.RxAndroidPlugins;
11 | import io.reactivex.functions.Function;
12 | import io.reactivex.plugins.RxJavaPlugins;
13 | import io.reactivex.schedulers.Schedulers;
14 |
15 | /**
16 | * NOTE: You MUST use this rule in every test class that targets app code that uses RxJava. Even
17 | * when that code doesn't use any scheduler. The RxJava {@link Schedulers} class is setup once and
18 | * caches the schedulers in memory. So if one of the test classes doesn't use this rule by the time
19 | * this rule runs it may be too late to override the schedulers. This is really not ideal but
20 | * currently there isn't a better approach. More info here:
21 | * https://github.com/ReactiveX/RxJava/issues/2297
22 | *
23 | *
This rule registers SchedulerHooks for RxJava and RxAndroid to ensure that subscriptions
24 | * always subscribeOn and observeOn Schedulers.immediate(). Warning, this rule will reset
25 | * RxAndroidPlugins and RxJavaPlugins before and after each test so if the application code uses
26 | * RxJava plugins this may affect the behaviour of the testing method.
27 | */
28 | public class RxSchedulersOverrideRule implements TestRule {
29 |
30 | public final Scheduler SCHEDULER_INSTANCE = Schedulers.trampoline();
31 | private Function schedulerFunction = scheduler -> SCHEDULER_INSTANCE;
32 | private Function, Scheduler> schedulerFunctionLazy =
33 | schedulerCallable -> SCHEDULER_INSTANCE;
34 |
35 | @Override
36 | public Statement apply(final Statement base, Description description) {
37 | return new Statement() {
38 | @Override
39 | public void evaluate() throws Throwable {
40 | RxAndroidPlugins.reset();
41 | RxAndroidPlugins.setInitMainThreadSchedulerHandler(schedulerFunctionLazy);
42 |
43 | RxJavaPlugins.reset();
44 | RxJavaPlugins.setIoSchedulerHandler(schedulerFunction);
45 | RxJavaPlugins.setNewThreadSchedulerHandler(schedulerFunction);
46 | RxJavaPlugins.setComputationSchedulerHandler(schedulerFunction);
47 |
48 | base.evaluate();
49 |
50 | RxAndroidPlugins.reset();
51 | RxJavaPlugins.reset();
52 | }
53 | };
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/app/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker:
--------------------------------------------------------------------------------
1 | mock-maker-inline
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | repositories {
3 | jcenter()
4 | mavenCentral()
5 | google()
6 | maven { url 'https://maven.fabric.io/public' }
7 | }
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:3.0.1'
10 | //noinspection GradleDynamicVersion
11 | classpath 'io.fabric.tools:gradle:1.+'
12 | classpath 'com.google.gms:google-services:3.1.2'
13 | classpath 'com.github.ben-manes:gradle-versions-plugin:0.17.0'
14 | }
15 | }
16 |
17 | allprojects {
18 | repositories {
19 | jcenter()
20 | mavenCentral()
21 | google()
22 | maven { url "https://jitpack.io" }
23 | maven { url 'https://maven.fabric.io/public' }
24 | flatDir {
25 | dirs '../aars'
26 | }
27 | }
28 | }
29 |
30 | task clean(type: Delete) {
31 | delete rootProject.buildDir
32 | }
33 |
--------------------------------------------------------------------------------
/circle.yml:
--------------------------------------------------------------------------------
1 | machine:
2 | environment:
3 | ANDROID_HOME: /usr/local/android-sdk-linux
4 | ANDROID_BUILD_TOOLS: 26.0.0
5 | ANDROID_PLATFORM: 26
6 |
7 | dependencies:
8 | pre:
9 | # Ensure we have the correct Android build environment
10 | - if [ ! -e $ANDROID_HOME/build-tools/$ANDROID_BUILD_TOOLS ]; then echo y | android update sdk --no-ui --all --filter build-tools-$ANDROID_BUILD_TOOLS; fi
11 | - if [ ! -e $ANDROID_HOME/platforms/android-$ANDROID_PLATFORM ]; then echo y | android update sdk --no-ui --all --filter "android-${ANDROID_PLATFORM}"; fi
12 | # Ensure we have the latest Android support libraries
13 | - echo y | android update sdk -u -a -t extra-android-m2repository
14 | - echo y | android update sdk -u -a -t extra-google-m2repository
15 |
16 | cache_directories:
17 | # Cache the build environment to speed up further builds
18 | - /usr/local/android-sdk-linux/build-tools/26.0.1
19 | - /usr/local/android-sdk-linux/platforms/android-26
20 | - /usr/local/android-sdk-linux/tools
21 |
22 | test:
23 | pre:
24 | # Start and Android emulator and wait for boot if we don't have Firebase cloud testing integrated
25 | - if [ ! -n "${GCLOUD_SERVICE_KEY+1}" ]; then emulator -avd circleci-android24 -no-audio -no-window; fi:
26 | background: true
27 | parallel: true
28 | - if [ ! -n "${GCLOUD_SERVICE_KEY+1}" ]; then circle-android wait-for-boot; fi
29 |
30 | override:
31 | # Run all build, test and reporting steps in ci.sh
32 | - scripts/ci.sh $CIRCLE_TEST_REPORTS
33 |
34 |
--------------------------------------------------------------------------------
/config/jacoco.gradle:
--------------------------------------------------------------------------------
1 | // Jacoco is a code coverage tool. By default, jacoco only runs for espresso tests. This contains the necessary configuration
2 | // that allows us to run coverage reports for unit tests, and also for the combination of unit tests + espresso tests.
3 |
4 | // For unit tests coverage run the 'testUnitTestCoverage' task. Results are in in 'build/reports/jacoco' folder.
5 | // For espresso tests coverage run the 'createCoverageReport' task. Results are in 'build/reports/coverage' folder.
6 | // For unit and espresso tests coverage run the 'unitAndEspressoTestCoverage' task. Results are in 'build/reports/jacoco'
7 | // folder.
8 | apply plugin: 'jacoco'
9 |
10 | // Jacoco version to use. See https://github.com/jacoco/jacoco/releases
11 | jacoco {
12 | toolVersion '0.7.9'
13 | }
14 |
15 | // Android Gradle Plugin out of the box only supports code coverage for instrumentation espresso) tests. This add support for unit tests as
16 | // well.
17 | project.afterEvaluate {
18 | // Grab all build types and product flavors
19 | def buildTypes = android.buildTypes.collect { type -> type.name }
20 | def productFlavors = android.productFlavors.collect { flavor -> flavor.name }
21 |
22 | // When no product flavors defined, use empty so that the for loop below can continue.
23 | if (!productFlavors) productFlavors.add('')
24 |
25 | productFlavors.each { productFlavorName ->
26 | buildTypes.each { buildTypeName ->
27 | def sourceName, sourcePath
28 | if (!productFlavorName) {
29 | sourceName = sourcePath = "${buildTypeName}"
30 | } else {
31 | sourceName = "${productFlavorName}${buildTypeName.capitalize()}"
32 | sourcePath = "${productFlavorName}/${buildTypeName}"
33 | }
34 | def testTaskName = "test${sourceName.capitalize()}UnitTest"
35 | def unitTestCoverageTaskName = "${testTaskName}Coverage"
36 | def unitAndEspressoTestCoverageTaskName = "unitAndEspresso${sourceName.capitalize()}TestCoverage"
37 |
38 | def excludedFiles = fileTree(
39 | dir: "${project.buildDir}/intermediates/classes/${sourcePath}",
40 | excludes: [
41 | '**/R.class', // Android generated classes
42 | '**/R$*.class', // Android generated classes
43 | '**/*Dagger*.*', // Dagger auto-generated code.
44 | '**/*MembersInjector*.*', // Dagger auto-generated code.
45 | '**/*_Factory.*', // Dagger auto-generated code.
46 | '**/*_Provide*Factory*.*', // Dagger auto-generated code.
47 | '**/*_ViewBinding*.*', // Butterknife auto-generated code.
48 | '**/AutoValue_*.*', // AutoValue auto-generated code.
49 | '**/R2.class', // Butterknife auto-generated code.
50 | '**/R2$*.class', // Butterknife auto-generated code.
51 | '**/com/example/mock/**', // Ignore collection of mock data, that is added in debug and qa builds.
52 | ]
53 | )
54 |
55 | // Create coverage task for unit tests of form 'testCoverage' depending on 'testUnitTest'
56 | task "${unitTestCoverageTaskName}"(type: JacocoReport, dependsOn: "$testTaskName") {
57 | group = 'Reporting'
58 | description = "Generate Jacoco coverage reports for the ${sourceName.capitalize()} build. Only unit tests."
59 |
60 | def coverageSourceDirs = [
61 | 'src/main/java',
62 | "src/$productFlavorName/java",
63 | "src/$buildTypeName/java"
64 | ]
65 | classDirectories = excludedFiles
66 | additionalSourceDirs = files(coverageSourceDirs)
67 | sourceDirectories = files(coverageSourceDirs)
68 | executionData = files("${project.buildDir}/jacoco/${testTaskName}.exec")
69 |
70 | reports {
71 | xml.enabled = true
72 | html.enabled = true
73 | }
74 | }
75 |
76 | // Create coverage task for unit and espresso tests of form 'unitAndEspressoTestCoverage' depending on
77 | // 'testUnitTest' and on 'createDebugCoverageReport' tasks. Notice that the espresso test task only points
78 | // to the debug build. This is on purpose as android only creates a task to run the debug espresso tests. This can be modified
79 | // by the 'testBuildType' flag in the 'android' clause of the build.gradle file. See
80 | // http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Testing for more info.
81 | task "${unitAndEspressoTestCoverageTaskName}"(type: JacocoReport, dependsOn: ["$testTaskName", "createDebugCoverageReport"]) {
82 | group = 'Reporting'
83 | description = "Generate Jacoco coverage reports for the ${sourceName.capitalize()} build. Both unit and espresso tests."
84 | def coverageSourceDirs = [
85 | 'src/main/java',
86 | "src/$productFlavorName/java",
87 | "src/$buildTypeName/java"
88 | ]
89 | classDirectories = excludedFiles
90 | additionalSourceDirs = files(coverageSourceDirs)
91 | sourceDirectories = files(coverageSourceDirs)
92 | executionData = fileTree(dir: "$project.buildDir", includes: [
93 | "jacoco/${testTaskName}.exec",
94 | "outputs/code-coverage/connected/*coverage.ec"
95 | ])
96 | reports {
97 | xml.enabled = true
98 | html.enabled = true
99 | }
100 | }
101 | }
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/config/quality/checkstyle/checkstyle-config.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
77 |
79 |
81 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
117 |
118 |
119 |
120 |
121 |
123 |
124 |
125 |
126 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
137 |
138 |
139 |
140 |
141 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
151 |
152 |
153 |
154 |
155 |
157 |
158 |
159 |
160 |
161 |
163 |
164 |
165 |
166 |
167 |
--------------------------------------------------------------------------------
/config/quality/findbugs/android-exclude-filter.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/config/quality/pmd/pmd-ruleset.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 | Custom ruleset for ribot Android application
8 |
9 | .*/R.java
10 | .*/gen/.*
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/config/quality/quality.gradle:
--------------------------------------------------------------------------------
1 | /**
2 | * Set up Checkstyle, Findbugs and PMD to perform extensive code analysis.
3 | *
4 | * Gradle tasks added:
5 | * - checkstyle
6 | * - findbugs
7 | * - pmd
8 | *
9 | * The three tasks above are added as dependencies of the check task so running check will
10 | * run all of them.
11 | */
12 |
13 | apply plugin: 'checkstyle'
14 | apply plugin: 'findbugs'
15 | apply plugin: 'pmd'
16 |
17 | findbugs {
18 | toolVersion = '3.0.1'
19 | }
20 |
21 | dependencies {
22 | checkstyle 'com.puppycrawl.tools:checkstyle:8.5'
23 | }
24 |
25 | def qualityConfigDir = "$project.rootDir/config/quality";
26 |
27 | check.dependsOn 'checkstyle', 'findbugs', 'pmd'
28 |
29 | task checkstyle(type: Checkstyle, group: 'Verification', description: 'Runs code style checks') {
30 | configFile file("$qualityConfigDir/checkstyle/checkstyle-config.xml")
31 | ignoreFailures false
32 | source 'src'
33 | include '**/*.java'
34 | showViolations true
35 |
36 | reports {
37 | xml.enabled = true
38 | html.enabled = true
39 | }
40 |
41 | classpath = files( )
42 | }
43 |
44 | task findbugs(type: FindBugs,
45 | group: 'Verification',
46 | description: 'Inspect java bytecode for bugs',
47 | dependsOn: ['compileDebugSources','compileReleaseSources']) {
48 |
49 | ignoreFailures = false
50 | effort = "max"
51 | reportLevel = "high"
52 | excludeFilter = new File("$qualityConfigDir/findbugs/android-exclude-filter.xml")
53 | classes = files("$project.rootDir/app/build/intermediates/classes")
54 |
55 | source 'src'
56 | include '**/*.java'
57 | exclude '**/gen/**'
58 |
59 | reports {
60 | xml.enabled = true
61 | html.enabled = false
62 | }
63 |
64 | classpath = files()
65 | }
66 |
67 |
68 | task pmd(type: Pmd, group: 'Verification', description: 'Inspect sourcecode for bugs') {
69 | ruleSetFiles = files("$qualityConfigDir/pmd/pmd-ruleset.xml")
70 | ignoreFailures = false
71 | ruleSets = []
72 |
73 | source 'src'
74 | include '**/*.java'
75 | exclude '**/gen/**'
76 | exclude '**/resources/**'
77 |
78 | reports {
79 | xml.enabled = true
80 | html.enabled = true
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
19 |
20 | org.gradle.daemon=true
21 | org.gradle.jvmargs=-Xmx14312M -XX:MaxPermSize=3072m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
22 | org.gradle.parallel=true
23 | org.gradle.configureondemand=true
24 | # Set to true or false to enable or disable the build cache.
25 | #If this parameter is not set, the build cache is disabled by default.
26 | android.enableBuildCache=true
27 |
28 | PokeapiApiUrl = http://pokeapi.co/api/v2/
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androidstarters/android-starter/a77488ccb337f3d08737259a2d17349fe783ac62/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Dec 21 11:38:13 IST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/scripts/ci.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -xe
3 |
4 | # Get the location for report directory from 1st param or use current directory
5 | if [ ! -z "$1" ]; then
6 | report_location=$1
7 | else
8 | report_location=`pwd`
9 | fi
10 |
11 | ./gradlew --no-daemon --info clean
12 | ./gradlew --no-daemon --info checkstyle -PdisablePreDex
13 |
14 | # If we have a service key for the GCloud Cli then use remote testing otherwise run local tests
15 | if [ -n "${GCLOUD_SERVICE_KEY+1}" ]; then
16 | ./gradlew --no-daemon --info assembleAndroidTest -PdisablePreDex
17 | scripts/remoteTesting.sh ${report_location}
18 | else
19 | ./gradlew --no-daemon --info testDebugUnitTest -PdisablePreDex
20 | fi
21 |
--------------------------------------------------------------------------------
/scripts/remoteTesting.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -xe
3 |
4 | report_location=$1
5 |
6 | if [ -n "${GCLOUD_SERVICE_KEY+1}" ]; then
7 | sudo pip install -U crcmod
8 | # Put our service key into a file for use later
9 | echo $GCLOUD_SERVICE_KEY > ${HOME}/client-secret.json
10 |
11 | GCLOUD=`which gcloud`
12 |
13 | # Activate gcloud with our key and update and install relevant components
14 | $GCLOUD auth activate-service-account $GCLOUD_SERVICE_ACCOUNT --key-file $HOME/client-secret.json
15 | sudo $GCLOUD --quiet components update
16 | sudo $GCLOUD --quiet components install beta
17 |
18 | GCLOUD_OUTPUT_LOG=gcloudLog.txt
19 |
20 | # Run our tests in the cloud and store the output temporarily in a file. Exit if any part errors
21 | $GCLOUD beta test android run --type instrumentation --uri --app app/build/outputs/apk/app-debug.apk --test app/build/outputs/apk/app-debug-androidTest.apk --orientations portrait --project $GCLOUD_PROJECT_ID 2>&1 | tee $GCLOUD_OUTPUT_LOG ; ( exit ${PIPESTATUS[0]} )
22 |
23 | # Grab the bucket ID for where our reports and artefacts are logged
24 | BUCKET_ID=`cat $GCLOUD_OUTPUT_LOG | sed -n -E 's#^.+test-lab-(.+)/.+#\1#p'`
25 |
26 | echo $BUCKET_ID
27 |
28 | TEST_OUTPUT_FOLDER=testResults
29 | mkdir $TEST_OUTPUT_FOLDER
30 | # Grab remote reports and artefacts and store locally
31 | gsutil -m cp -R -U gs://test-lab-$BUCKET_ID $TEST_OUTPUT_FOLDER || true
32 |
33 | # Copy reports and artefacts to relevant locations
34 | mkdir $report_location/cloudTesting
35 | cp -r $TEST_OUTPUT_FOLDER $report_location/cloudTesting
36 |
37 | # Cleanup temporary files
38 | rm $GCLOUD_OUTPUT_LOG
39 | rm -r $TEST_OUTPUT_FOLDER
40 | else
41 | echo "GCLOUD_SERVICE_KEY environment variable not set. This is required to run remote testing on Firebase."
42 | fi
43 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------