Added two build variants to help us control the scope of our testing of

network operations. This is the initial skeleton that proves the
approach can work. Future work will enable us to control whether to
fully mock network operatins, have a local download server, or use the
public kiwix download server.
This commit is contained in:
Julian Harty 2017-08-17 10:02:17 -04:00
parent aced181a3e
commit e28a04542f
3 changed files with 17 additions and 2 deletions

View File

@ -162,14 +162,26 @@ android {
} }
buildTypes { buildTypes {
// Main build type for debugging // Main build type for debugging
debug { debug {
buildConfigField "String", "KIWIX_DOWNLOAD_URL", "\"http://download.kiwix.org/\""
// True breaks local variables being shown in breakpoints // True breaks local variables being shown in breakpoints
testCoverageEnabled false testCoverageEnabled false
// Needed for instrumentation tests on Pre 5.0 // Needed for instrumentation tests on Pre 5.0
multiDexKeepProguard file('multidex-instrumentation-config.pro') multiDexKeepProguard file('multidex-instrumentation-config.pro')
} }
mock_network {
initWith(buildTypes.debug)
// TODO add DI for the mock network
}
local_download_server {
initWith(buildTypes.debug)
buildConfigField "String", "KIWIX_DOWNLOAD_URL", "\"http://192.168.1.55/\""
}
// Used to assess code coverage // Used to assess code coverage
coverage { coverage {
initWith debug initWith debug
@ -178,8 +190,9 @@ android {
// Release Type // Release Type
release { release {
buildConfigField "String", "KIWIX_DOWNLOAD_URL", "\"http://download.kiwix.org/\""
} }
} }
productFlavors { productFlavors {

View File

@ -15,7 +15,7 @@ import okhttp3.OkHttpClient;
@Module public class NetworkModule { @Module public class NetworkModule {
public static String KIWIX_DOWNLOAD_URL = "http://download.kiwix.org/"; public static String KIWIX_DOWNLOAD_URL = BuildConfig.KIWIX_DOWNLOAD_URL; //"http://download.kiwix.org/";
private final static String useragent = "kiwix-android-version:" + BuildConfig.VERSION_CODE; private final static String useragent = "kiwix-android-version:" + BuildConfig.VERSION_CODE;
@Provides @Singleton OkHttpClient provideOkHttpClient() { @Provides @Singleton OkHttpClient provideOkHttpClient() {

View File

@ -1,6 +1,7 @@
package org.kiwix.kiwixmobile.zim_manager.library_view; package org.kiwix.kiwixmobile.zim_manager.library_view;
import android.content.Context; import android.content.Context;
import android.util.Log;
import org.kiwix.kiwixmobile.base.BasePresenter; import org.kiwix.kiwixmobile.base.BasePresenter;
import org.kiwix.kiwixmobile.database.BookDao; import org.kiwix.kiwixmobile.database.BookDao;
@ -33,6 +34,7 @@ public class LibraryPresenter extends BasePresenter<LibraryViewCallback> {
.subscribe(library -> { .subscribe(library -> {
getMvpView().showBooks(library.getBooks()); getMvpView().showBooks(library.getBooks());
}, error -> { }, error -> {
Log.w("kiwixLibrary", error.getLocalizedMessage());
getMvpView().displayNoNetworkConnection(); getMvpView().displayNoNetworkConnection();
}); });
} }