From 561f7e3ace3d2db87696a90f43759cabba3ccf55 Mon Sep 17 00:00:00 2001 From: mhutti1 Date: Wed, 26 Apr 2017 15:55:40 +0200 Subject: [PATCH 01/20] Mocked more JNI Methods --- .../kiwixmobile/di/modules/TestJNIModule.java | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/di/modules/TestJNIModule.java b/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/di/modules/TestJNIModule.java index 651425555..3f9177cf2 100644 --- a/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/di/modules/TestJNIModule.java +++ b/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/di/modules/TestJNIModule.java @@ -2,6 +2,7 @@ package org.kiwix.kiwixmobile.di.modules; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doReturn; import android.content.Context; @@ -12,7 +13,11 @@ import java.io.InputStream; import javax.inject.Singleton; import org.apache.commons.io.IOUtils; import org.kiwix.kiwixlib.JNIKiwix; +import org.kiwix.kiwixlib.JNIKiwixString; +import org.mockito.ArgumentCaptor; import org.mockito.Mockito; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; /** * Created by mhutti1 on 13/04/17. @@ -23,8 +28,23 @@ public class TestJNIModule{ @Provides @Singleton - public JNIKiwix providesJNIKiwix(Context context) { + public JNIKiwix providesJNIKiwix() { JNIKiwix jniKiwix = Mockito.mock(JNIKiwix.class); + + doReturn("A/index.htm").when(jniKiwix).getMainPage(); + doReturn(true).when(jniKiwix).loadZIM(any()); + doReturn(true).when(jniKiwix).loadFulltextIndex(any()); + doReturn("mockid").when(jniKiwix).getId(); + doReturn("mockname").when(jniKiwix).getName(); + doReturn("Test Description").when(jniKiwix).getDescription(); + doAnswer(invocation -> { + ((JNIKiwixString) invocation.getArgument(0)).value = "Test Title"; + return true; + }).when(jniKiwix).getTitle(any()); + doReturn("Test Publisher").when(jniKiwix).getPublisher(); + doReturn("Test Date").when(jniKiwix).getDate(); + doReturn("Test Language").when(jniKiwix).getLanguage(); + try { InputStream inStream = TestJNIModule.class.getClassLoader().getResourceAsStream("summary"); byte[] summary = IOUtils.toByteArray(inStream); @@ -32,14 +52,10 @@ public class TestJNIModule{ byte[] fool = IOUtils.toByteArray(inStream2); doReturn(summary).when(jniKiwix).getContent(eq("A/index.htm"),any(),any()); doReturn(fool).when(jniKiwix).getContent(eq("A/A_Fool_for_You.html"),any(),any()); - doReturn("A/index.htm").when(jniKiwix).getMainPage(); - doReturn(true).when(jniKiwix).loadZIM(any()); - doReturn(true).when(jniKiwix).loadFulltextIndex(any()); - doReturn("mockid").when(jniKiwix).getId(); - doReturn("mockname").when(jniKiwix).getName(); } catch (IOException e) { e.printStackTrace(); } + return jniKiwix; } From 503a929003980b823e9c5c6d3a5ece325931e6f8 Mon Sep 17 00:00:00 2001 From: mhutti1 Date: Wed, 26 Apr 2017 16:07:54 +0200 Subject: [PATCH 02/20] Rearranged build.gradle --- app/build.gradle | 213 ++++++++++++++++++++++++++--------------------- 1 file changed, 117 insertions(+), 96 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 6310e349e..0a766c9c3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -15,7 +15,6 @@ buildscript { } } -//apply plugin: 'android-sdk-manager' apply plugin: 'com.android.application' apply plugin: 'com.neenbedankt.android-apt' apply plugin: 'me.tatarka.retrolambda' @@ -29,56 +28,23 @@ repositories { } dependencies { + // Kiwixlib + compile project(":kiwixlib") + + // Storage Devices + compile 'eu.mhutti1.utils.storage:android-storage-devices:0.5.0' + + // Android Support compile 'com.android.support:appcompat-v7:25.3.1' compile 'com.android.support:support-v13:25.3.1' compile 'com.android.support:support-v4:25.3.1' compile 'com.android.support:design:25.3.1' compile 'com.android.support:cardview-v7:25.3.1' - androidTestCompile 'com.android.support:support-annotations:25.3.1' - androidTestCompile 'com.android.support.test:runner:0.5' - androidTestCompile 'com.android.support.test:rules:0.5' - - compile 'com.google.dagger:dagger:2.0.2' - compile project(":kiwixlib") - - apt "com.google.dagger:dagger-compiler:2.0.2" - androidTestApt "com.google.dagger:dagger-compiler:2.0.2" - - compile 'com.yahoo.squidb:squidb:2.0.0' - compile 'com.yahoo.squidb:squidb-annotations:2.0.0' - apt 'com.yahoo.squidb:squidb-processor:2.0.0' - - compile 'commons-io:commons-io:2.5' - - androidTestCompile 'com.squareup.okhttp3:mockwebserver:3.6.0' - - compile 'com.squareup.okhttp3:okhttp:3.6.0' - compile 'com.squareup.retrofit2:retrofit:2.1.0' - compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0' - compile('com.squareup.retrofit2:converter-simplexml:2.1.0') { - exclude group: 'xpp3', module: 'xpp3' - exclude group: 'stax', module: 'stax-api' - exclude group: 'stax', module: 'stax' - } - - compile 'io.reactivex:rxandroid:1.1.0' - compile 'io.reactivex:rxjava:1.1.3' - - testCompile "org.mockito:mockito-core:2.7.22" - androidTestCompile "org.mockito:mockito-android:2.7.22" - - compile 'eu.mhutti1.utils.storage:android-storage-devices:0.5.0' - compile 'com.jakewharton:butterknife:8.0.1' - apt 'com.jakewharton:butterknife-compiler:8.0.1' - compile group: 'com.google.guava', name: 'guava', version: '20.0' compile 'com.android.support:multidex:1.0.1' - - testCompile 'junit:junit:4.12' - androidTestCompile 'junit:junit:4.12' - androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2' compile 'com.android.support.test:runner:0.5' - compile 'junit:junit:4.12' + + androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2' androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' @@ -91,7 +57,56 @@ dependencies { exclude group: 'com.android.support', module: 'appcompat-v7' exclude group: 'com.android.support', module: 'design' exclude group: 'com.android.support', module: 'recyclerview-v7' - }} + } + + androidTestCompile 'com.android.support:support-annotations:25.3.1' + androidTestCompile 'com.android.support.test:runner:0.5' + androidTestCompile 'com.android.support.test:rules:0.5' + + // Guava + compile group: 'com.google.guava', name: 'guava', version: '20.0' + + // Dagger + compile 'com.google.dagger:dagger:2.0.2' + apt "com.google.dagger:dagger-compiler:2.0.2" + androidTestApt "com.google.dagger:dagger-compiler:2.0.2" + + // SquiDB + compile 'com.yahoo.squidb:squidb:2.0.0' + compile 'com.yahoo.squidb:squidb-annotations:2.0.0' + apt 'com.yahoo.squidb:squidb-processor:2.0.0' + + // Apache + compile 'commons-io:commons-io:2.5' + + // Square + compile 'com.squareup.okhttp3:okhttp:3.6.0' + compile 'com.squareup.retrofit2:retrofit:2.1.0' + compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0' + compile('com.squareup.retrofit2:converter-simplexml:2.1.0') { + exclude group: 'xpp3', module: 'xpp3' + exclude group: 'stax', module: 'stax-api' + exclude group: 'stax', module: 'stax' + } + androidTestCompile 'com.squareup.okhttp3:mockwebserver:3.6.0' + + // Butterknife + compile 'com.jakewharton:butterknife:8.0.1' + apt 'com.jakewharton:butterknife-compiler:8.0.1' + + // RxJava + compile 'io.reactivex:rxandroid:1.1.0' + compile 'io.reactivex:rxjava:1.1.3' + + // JUnit + compile 'junit:junit:4.12' + testCompile 'junit:junit:4.12' + androidTestCompile 'junit:junit:4.12' + + // Mockito + testCompile "org.mockito:mockito-core:2.7.22" + androidTestCompile "org.mockito:mockito-android:2.7.22" +} // Set custom app import directory def map = [:] @@ -101,10 +116,10 @@ if (project.hasProperty('customDir')) { } // Set up flavours for each custom app in the directory -custom.eachFile() { file-> +custom.eachFile() { file -> def fileName = file.getName() - if( fileName.contains("test") || fileName == "main" || fileName.contains("Test")) { + if (fileName.contains("test") || fileName == "main" || fileName.contains("Test")) { return } map.put(fileName, file.getAbsolutePath()) @@ -124,6 +139,7 @@ android { } lintOptions { + // Treat lint seriously abortOnError true // Hardcoded strings in xml error 'HardcodedText' @@ -139,6 +155,7 @@ android { } buildTypes { + // Main build type for debugging debug { // True breaks local variables being shown in breakpoints testCoverageEnabled false @@ -146,21 +163,22 @@ android { multiDexKeepProguard file('multidex-instrumentation-config.pro') } + // Used to assess code coverage coverage { initWith debug testCoverageEnabled true } + // Release Type release { } } - - productFlavors { + productFlavors { // Vanilla Kiwix app kiwix { - println "Building Kiwix" + println "Configuring Kiwix" // Set vanilla config buildConfigField "boolean", "IS_CUSTOM_APP", "false" buildConfigField "boolean", "HAS_EMBEDDED_ZIM", "false" @@ -174,53 +192,54 @@ android { // Custom apps built from a json file, zim file and icon set map.each { name, directory -> "$name" { - println "Building Custom" - def jsonFile = "" - if (project.hasProperty('jsonFile')) { - // Read json file from properties e.g command line - jsonFile = file(project.property('jsonFile')) - } else { - // If no file provided use the test file - jsonFile = file(directory + '/test.json') - } - def parsedJson = new JsonSlurper().parseText(jsonFile.text) - def File zimfile = new File(parsedJson.zim_file) - if (parsedJson.embed_zim) { - // Place content in each lib directory for embeded zims - file("../kiwixlib/src/main/jniLibs").eachDir() { folder -> - copy { - from parsedJson.zim_file - into file(directory + "/jniLibs/" + folder.name) - rename { String filename -> "libcontent.so" } - } - } - parsedJson.zim_file = "libcontent.so" - } - // Set custom config from json - applicationId "$parsedJson.package" - buildConfigField "boolean", "IS_CUSTOM_APP", "true" - buildConfigField "boolean", "HAS_EMBEDDED_ZIM", "$parsedJson.embed_zim" - def filename = "" - if (parsedJson.zim_file.lastIndexOf('/') >= 0) { - filename = parsedJson.zim_file.substring(parsedJson.zim_file.lastIndexOf('/') + 1) - } else { - filename = parsedJson.zim_file - } - buildConfigField "String", "ZIM_FILE_NAME", "\"$filename\"" - long length = zimfile.length() - buildConfigField "long", "ZIM_FILE_SIZE", "$length" - if (parsedJson.content_version_code != null) { - buildConfigField "int", "CONTENT_VERSION_CODE", "$parsedJson.content_version_code" - } else { - buildConfigField "int", "CONTENT_VERSION_CODE", "$parsedJson.version_code" - } - buildConfigField "String", "ENFORCED_LANG", "\"$parsedJson.enforced_lang\"" - resValue "string", "app_name", "$parsedJson.app_name" - resValue "string", "app_search_string", 'Search ' + "$parsedJson.app_name" + println "Configuring $name" + def jsonFile = "" + if (project.hasProperty('jsonFile')) { + // Read json file from properties e.g command line + jsonFile = file(project.property('jsonFile')) + } else { + // If no file provided use the test file + jsonFile = file(directory + '/test.json') } + def parsedJson = new JsonSlurper().parseText(jsonFile.text) + def File zimfile = new File(parsedJson.zim_file) + if (parsedJson.embed_zim) { + // Place content in each lib directory for embeded zims + file("../kiwixlib/src/main/jniLibs").eachDir() { folder -> + copy { + from parsedJson.zim_file + into file(directory + "/jniLibs/" + folder.name) + rename { String filename -> "libcontent.so" } + } + } + parsedJson.zim_file = "libcontent.so" + } + // Set custom config from json + applicationId "$parsedJson.package" + buildConfigField "boolean", "IS_CUSTOM_APP", "true" + buildConfigField "boolean", "HAS_EMBEDDED_ZIM", "$parsedJson.embed_zim" + def filename = "" + if (parsedJson.zim_file.lastIndexOf('/') >= 0) { + filename = parsedJson.zim_file.substring(parsedJson.zim_file.lastIndexOf('/') + 1) + } else { + filename = parsedJson.zim_file + } + buildConfigField "String", "ZIM_FILE_NAME", "\"$filename\"" + long length = zimfile.length() + buildConfigField "long", "ZIM_FILE_SIZE", "$length" + if (parsedJson.content_version_code != null) { + buildConfigField "int", "CONTENT_VERSION_CODE", "$parsedJson.content_version_code" + } else { + buildConfigField "int", "CONTENT_VERSION_CODE", "$parsedJson.version_code" + } + buildConfigField "String", "ENFORCED_LANG", "\"$parsedJson.enforced_lang\"" + resValue "string", "app_name", "$parsedJson.app_name" + resValue "string", "app_search_string", 'Search ' + "$parsedJson.app_name" } + } } + // Set each custom apps respective source directory sourceSets { map.each { name, directory -> "$name" { @@ -231,7 +250,6 @@ android { compileOptions { encoding = "UTF-8" - sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } @@ -240,19 +258,22 @@ android { javaMaxHeapSize "4g" } - /* Add back once proguard is configured + /* + Add back once proguard is configured buildTypes { release { minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt') } - }*/ + } + */ } task wrapper(type: Wrapper) { gradleVersion = '2.4' } +// Testdroid deployment configuration def buildNumber = System.getenv('TRAVIS_BUILD_NUMBER') testdroid { @@ -263,6 +284,6 @@ testdroid { testRunName "Auto Test " + buildNumber fullRunConfig { - instrumentationRunner = "android.support.test.runner.AndroidJUnitRunner" + instrumentationRunner = "android.support.test.runner.AndroidJUnitRunner" } } \ No newline at end of file From bdcdbf91157e2868715b70dc1c3981b94e058229 Mon Sep 17 00:00:00 2001 From: mhutti1 Date: Wed, 26 Apr 2017 16:21:46 +0200 Subject: [PATCH 03/20] Target SDK 25 --- app/build.gradle | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 0a766c9c3..c6eedd6f3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -123,17 +123,15 @@ custom.eachFile() { file -> return } map.put(fileName, file.getAbsolutePath()) - - } android { - compileSdkVersion 24 - buildToolsVersion '25.0.0' + compileSdkVersion 25 + buildToolsVersion '25.0.2' defaultConfig { minSdkVersion 14 - targetSdkVersion 24 + targetSdkVersion 25 testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" multiDexEnabled true } From 16c5b869454e0c0fa46707c995c3f8356cbfc002 Mon Sep 17 00:00:00 2001 From: mhutti1 Date: Wed, 26 Apr 2017 17:39:56 +0200 Subject: [PATCH 04/20] Try to accept licences --- .travis.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3143eac4f..0cee04094 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,14 +11,13 @@ android: # use the latest revision of Android SDK Tools # - platform-tools - tools - - tools - - platform-tools + - tools # The BuildTools version used by your project - - build-tools-25.0.0 + - build-tools-25.0.2 # The SDK version used to compile your project - - android-24 + - android-25 # The support library - extra-android-m2repository From 5a9c9759d110b6d752d21e0fe30f471c1c846237 Mon Sep 17 00:00:00 2001 From: mhutti1 Date: Wed, 26 Apr 2017 17:53:23 +0200 Subject: [PATCH 05/20] Try again to accept licences --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0cee04094..e0ed0fa33 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,9 +10,6 @@ android: # Uncomment the lines below if you want to # use the latest revision of Android SDK Tools # - platform-tools - - tools - - platform-tools - - tools # The BuildTools version used by your project - build-tools-25.0.2 From acc72f7f13669ae914deb4aa0902a64453db7fa0 Mon Sep 17 00:00:00 2001 From: mhutti1 Date: Thu, 27 Apr 2017 10:17:46 +0200 Subject: [PATCH 06/20] More attempts to fix travis --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e0ed0fa33..4705bcc3c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,8 +11,9 @@ android: # use the latest revision of Android SDK Tools # - platform-tools # The BuildTools version used by your project + - tools - build-tools-25.0.2 - + - platform-tools # The SDK version used to compile your project - android-25 # The support library From 68b8c5282b48fcf18555fc4ee7d2b8aed39e20cb Mon Sep 17 00:00:00 2001 From: mhutti1 Date: Thu, 27 Apr 2017 10:27:36 +0200 Subject: [PATCH 07/20] More attempts to fix travis --- .travis.yml | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4705bcc3c..4ef9fb48a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,21 +4,11 @@ jdk: oraclejdk8 install: - pip install --user 'requests[security]' - -android: - components: - # Uncomment the lines below if you want to - # use the latest revision of Android SDK Tools - # - platform-tools - # The BuildTools version used by your project - - tools - - build-tools-25.0.2 - - platform-tools - # The SDK version used to compile your project - - android-25 - # The support library - - extra-android-m2repository - + - echo y | android update sdk -u -a -t tools + - echo y | android update sdk -u -a -t platform-tools + - echo y | android update sdk -u -a -t build-tools-25.0.2 + - echo y | android update sdk -u -a -t android-25 + - echo y | android update sdk -u -a -t extra-google-m2repository before_cache: - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock From cfffaa2ba146514ef262a6cf2c8b678cb037b151 Mon Sep 17 00:00:00 2001 From: mhutti1 Date: Thu, 27 Apr 2017 10:46:46 +0200 Subject: [PATCH 08/20] More attempts to fix travis --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 4ef9fb48a..d5269a961 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,8 @@ install: - echo y | android update sdk -u -a -t build-tools-25.0.2 - echo y | android update sdk -u -a -t android-25 - echo y | android update sdk -u -a -t extra-google-m2repository + - sdkmanager --uninstall "platforms;android-24" + - sdkmanager --uninstall "build-tools;25.0.0" before_cache: - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock From a0d5b897695fab74a7491da9c2261fbd1c407a5a Mon Sep 17 00:00:00 2001 From: mhutti1 Date: Thu, 27 Apr 2017 11:02:38 +0200 Subject: [PATCH 09/20] Updated travis path --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index d5269a961..46a541199 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,7 @@ install: - echo y | android update sdk -u -a -t build-tools-25.0.2 - echo y | android update sdk -u -a -t android-25 - echo y | android update sdk -u -a -t extra-google-m2repository + - export PATH=$PATH:$HOME/android/sdk/tools:$HOME/android/sdk/tools/bin - sdkmanager --uninstall "platforms;android-24" - sdkmanager --uninstall "build-tools;25.0.0" From 870f54659d594af1aaafcae971beff80de4d48b7 Mon Sep 17 00:00:00 2001 From: mhutti1 Date: Thu, 27 Apr 2017 11:11:04 +0200 Subject: [PATCH 10/20] Yet another attempt --- .travis.yml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 46a541199..97ca9cb80 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,16 +2,17 @@ language: android jdk: oraclejdk8 +android: + components: + - tools + - tools + - platform-tools + - build-tools-25.0.2 + - android-25 + - extra-android-m2repository + install: - pip install --user 'requests[security]' - - echo y | android update sdk -u -a -t tools - - echo y | android update sdk -u -a -t platform-tools - - echo y | android update sdk -u -a -t build-tools-25.0.2 - - echo y | android update sdk -u -a -t android-25 - - echo y | android update sdk -u -a -t extra-google-m2repository - - export PATH=$PATH:$HOME/android/sdk/tools:$HOME/android/sdk/tools/bin - - sdkmanager --uninstall "platforms;android-24" - - sdkmanager --uninstall "build-tools;25.0.0" before_cache: - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock From 33d7ad79d13bb8f808ea14682e6c1418885db97a Mon Sep 17 00:00:00 2001 From: mhutti1 Date: Thu, 27 Apr 2017 11:31:35 +0200 Subject: [PATCH 11/20] Still fixing licences --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 97ca9cb80..47dbc93da 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,8 @@ android: install: - pip install --user 'requests[security]' + - yes | $ANDROID_HOME/tools/bin/sdkmanager --licences + before_cache: - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock From 5d9e2471c71bdc275faa72c5b4b846679931ad28 Mon Sep 17 00:00:00 2001 From: mhutti1 Date: Thu, 27 Apr 2017 11:43:12 +0200 Subject: [PATCH 12/20] Fix spelling error --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 47dbc93da..2b79dc7a4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ android: install: - pip install --user 'requests[security]' - - yes | $ANDROID_HOME/tools/bin/sdkmanager --licences + - yes | $ANDROID_HOME/tools/bin/sdkmanager --licenses before_cache: From bd23837fa3d67e62a60ba361c9a96a861b423fcc Mon Sep 17 00:00:00 2001 From: mhutti1 Date: Thu, 27 Apr 2017 13:28:10 +0200 Subject: [PATCH 13/20] Tell sdkmanager to update --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 2b79dc7a4..1eda6be79 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,7 @@ android: install: - pip install --user 'requests[security]' + - $ANDROID_HOME/tools/bin/sdkmanager --update - yes | $ANDROID_HOME/tools/bin/sdkmanager --licenses From 1a447f05e69613a6073359e2071ed577b9b468e3 Mon Sep 17 00:00:00 2001 From: mhutti1 Date: Thu, 27 Apr 2017 13:58:59 +0200 Subject: [PATCH 14/20] Accept licenses --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1eda6be79..685830c25 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ android: install: - pip install --user 'requests[security]' - - $ANDROID_HOME/tools/bin/sdkmanager --update + - yes | $ANDROID_HOME/tools/bin/sdkmanager --update - yes | $ANDROID_HOME/tools/bin/sdkmanager --licenses From aa532e2f78434e8178a2b711673c5af714060c3b Mon Sep 17 00:00:00 2001 From: mhutti1 Date: Thu, 27 Apr 2017 14:42:14 +0200 Subject: [PATCH 15/20] Reduce size --- .travis.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 685830c25..d14773fca 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,10 +4,6 @@ jdk: oraclejdk8 android: components: - - tools - - tools - - platform-tools - - build-tools-25.0.2 - android-25 - extra-android-m2repository From 0db0ce510dbfc1504d5ee9cd93ad11df3acc43c4 Mon Sep 17 00:00:00 2001 From: mhutti1 Date: Thu, 27 Apr 2017 14:48:25 +0200 Subject: [PATCH 16/20] More attempts --- .travis.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index d14773fca..04e3a8b8d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,14 +4,12 @@ jdk: oraclejdk8 android: components: + - build-tools-25.0.2 - android-25 - extra-android-m2repository install: - pip install --user 'requests[security]' - - yes | $ANDROID_HOME/tools/bin/sdkmanager --update - - yes | $ANDROID_HOME/tools/bin/sdkmanager --licenses - before_cache: - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock From 7f8ee3eccef1a4e94a42d9507a613572bc89131f Mon Sep 17 00:00:00 2001 From: mhutti1 Date: Thu, 27 Apr 2017 14:55:21 +0200 Subject: [PATCH 17/20] More attempts --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 04e3a8b8d..88b34447a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ jdk: oraclejdk8 android: components: + - tools - build-tools-25.0.2 - android-25 - extra-android-m2repository From 06cbf27b538aa814a6df1de09730ff2960a39170 Mon Sep 17 00:00:00 2001 From: mhutti1 Date: Thu, 27 Apr 2017 15:14:52 +0200 Subject: [PATCH 18/20] try to get gradlew donwnaloding --- .travis.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 88b34447a..ed79a8d14 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,14 +4,11 @@ jdk: oraclejdk8 android: components: - - tools - - build-tools-25.0.2 - - android-25 - - extra-android-m2repository install: - pip install --user 'requests[security]' - + - mkdir $ANDROID_HOME/licenses + - wget -r -nH -nd -np -R index.html* mhutti1.eu/api/licenses/ -P $ANDROID_HOME/licenses before_cache: - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock - rm -fr $HOME/.gradle/caches/*/plugin-resolution/ From af065e43185e6305844cafb0f628134565bc7a86 Mon Sep 17 00:00:00 2001 From: mhutti1 Date: Thu, 27 Apr 2017 15:37:55 +0200 Subject: [PATCH 19/20] Make sure tests start in correct state --- .../kiwix/kiwixmobile/tests/BasicTest.java | 3 +++ .../kiwix/kiwixmobile/tests/ContentTest.java | 2 ++ .../kiwix/kiwixmobile/tests/DownloadTest.java | 2 ++ .../kiwix/kiwixmobile/tests/NetworkTest.java | 3 ++- .../kiwixmobile/utils/StandardActions.java | 23 +++++++++++++++++++ 5 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/utils/StandardActions.java diff --git a/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/tests/BasicTest.java b/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/tests/BasicTest.java index 742322a04..efceb4681 100644 --- a/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/tests/BasicTest.java +++ b/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/tests/BasicTest.java @@ -14,6 +14,7 @@ import static android.support.test.espresso.matcher.ViewMatchers.withParent; import static android.support.test.espresso.matcher.ViewMatchers.withText; import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.is; +import static org.kiwix.kiwixmobile.utils.StandardActions.enterHelp; import android.support.test.espresso.ViewInteraction; import android.support.test.espresso.contrib.DrawerActions; @@ -82,6 +83,8 @@ public class BasicTest { @Test public void testRightDrawer() { + enterHelp(); + onView(withId(R.id.drawer_layout)).perform(DrawerActions.open(Gravity.RIGHT)); ViewInteraction textView = onView( diff --git a/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/tests/ContentTest.java b/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/tests/ContentTest.java index b671a3da1..266f5f17a 100644 --- a/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/tests/ContentTest.java +++ b/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/tests/ContentTest.java @@ -10,6 +10,7 @@ import static android.support.test.espresso.matcher.ViewMatchers.withContentDesc import static android.support.test.espresso.matcher.ViewMatchers.withId; import static android.support.test.espresso.matcher.ViewMatchers.withText; import static org.hamcrest.Matchers.allOf; +import static org.kiwix.kiwixmobile.utils.StandardActions.enterHelp; import android.support.test.espresso.ViewInteraction; import android.support.test.rule.ActivityTestRule; @@ -40,6 +41,7 @@ public class ContentTest { @Test public void contentTest() { + enterHelp(); ViewInteraction appCompatButton = onView( allOf(withId(R.id.get_content_card), withText("Get Content") )); diff --git a/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/tests/DownloadTest.java b/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/tests/DownloadTest.java index 142282f66..f77dba4e0 100644 --- a/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/tests/DownloadTest.java +++ b/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/tests/DownloadTest.java @@ -16,6 +16,7 @@ import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.Matchers.allOf; import static org.hamcrest.core.Is.is; import static org.kiwix.kiwixmobile.testutils.TestUtils.withContent; +import static org.kiwix.kiwixmobile.utils.StandardActions.enterHelp; import android.support.test.espresso.Espresso; import android.support.test.espresso.ViewInteraction; @@ -50,6 +51,7 @@ public class DownloadTest { @Test public void downloadTest() { + enterHelp(); ViewInteraction appCompatButton = onView( allOf(withId(R.id.get_content_card), withText("Get Content"))); appCompatButton.perform(scrollTo(), click()); diff --git a/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/tests/NetworkTest.java b/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/tests/NetworkTest.java index c894b6a9f..31b22ed2a 100644 --- a/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/tests/NetworkTest.java +++ b/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/tests/NetworkTest.java @@ -13,6 +13,7 @@ import static android.support.test.espresso.matcher.ViewMatchers.withId; import static android.support.test.espresso.matcher.ViewMatchers.withParent; import static android.support.test.espresso.matcher.ViewMatchers.withText; import static org.hamcrest.Matchers.allOf; +import static org.kiwix.kiwixmobile.utils.StandardActions.enterHelp; import android.support.test.espresso.Espresso; import android.support.test.espresso.IdlingPolicies; @@ -103,7 +104,7 @@ public class NetworkTest { public void networkTest() { mActivityTestRule.launchActivity(null); - + enterHelp(); ViewInteraction appCompatButton = onView( allOf(withId(R.id.get_content_card), withText("Get Content"))); appCompatButton.perform(scrollTo(), click()); diff --git a/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/utils/StandardActions.java b/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/utils/StandardActions.java new file mode 100644 index 000000000..9559fdddf --- /dev/null +++ b/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/utils/StandardActions.java @@ -0,0 +1,23 @@ +package org.kiwix.kiwixmobile.utils; + +import static android.support.test.InstrumentationRegistry.getInstrumentation; +import static android.support.test.espresso.Espresso.onView; +import static android.support.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu; +import static android.support.test.espresso.action.ViewActions.click; +import static android.support.test.espresso.matcher.ViewMatchers.withText; + +/** + * Created by mhutti1 on 27/04/17. + */ + +public class StandardActions { + + public static void enterHelp() { + openActionBarOverflowOrOptionsMenu(getInstrumentation().getTargetContext()); + + onView(withText("Help")) + .perform(click()); + } + + +} From 865c535f8888cb5a03acb7de84b3698e405dff12 Mon Sep 17 00:00:00 2001 From: mhutti1 Date: Thu, 27 Apr 2017 15:53:45 +0200 Subject: [PATCH 20/20] Extend test timeout --- .../java/org/kiwix/kiwixmobile/tests/DownloadTest.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/tests/DownloadTest.java b/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/tests/DownloadTest.java index f77dba4e0..e8794c163 100644 --- a/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/tests/DownloadTest.java +++ b/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/tests/DownloadTest.java @@ -19,13 +19,16 @@ import static org.kiwix.kiwixmobile.testutils.TestUtils.withContent; import static org.kiwix.kiwixmobile.utils.StandardActions.enterHelp; import android.support.test.espresso.Espresso; +import android.support.test.espresso.IdlingPolicies; import android.support.test.espresso.ViewInteraction; import android.support.test.rule.ActivityTestRule; import android.support.test.runner.AndroidJUnit4; import android.test.suitebuilder.annotation.LargeTest; +import java.util.concurrent.TimeUnit; import javax.inject.Inject; import org.junit.After; import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -44,6 +47,12 @@ public class DownloadTest { public ActivityTestRule mActivityTestRule = new ActivityTestRule<>( SplashActivity.class); + @BeforeClass + public static void beforeClass() { + IdlingPolicies.setMasterPolicyTimeout(350, TimeUnit.SECONDS); + IdlingPolicies.setIdlingResourceTimeout(350, TimeUnit.SECONDS); + } + @Before public void setUp() { Espresso.registerIdlingResources(KiwixIdlingResource.getInstance());