mirror of
https://github.com/MinimalBible/MinimalBible-Legacy
synced 2024-11-14 12:08:51 -05:00
Unit test fixes, works locally.
We'll see if it finally runs on Travis...
This commit is contained in:
parent
8fe05dc70b
commit
ed219bc8a4
@ -18,9 +18,6 @@ dependencies {
|
|||||||
compile project(path: ':jsword-minimalbible', configuration: 'buildJSword')
|
compile project(path: ':jsword-minimalbible', configuration: 'buildJSword')
|
||||||
compile project(':appcompat_v7')
|
compile project(':appcompat_v7')
|
||||||
|
|
||||||
apt "org.androidannotations:androidannotations:3.0+"
|
|
||||||
compile "org.androidannotations:androidannotations-api:3.0+"
|
|
||||||
|
|
||||||
apt 'com.squareup.dagger:dagger-compiler:1.2.0'
|
apt 'com.squareup.dagger:dagger-compiler:1.2.0'
|
||||||
compile 'com.squareup.dagger:dagger:1.2.0'
|
compile 'com.squareup.dagger:dagger:1.2.0'
|
||||||
|
|
||||||
@ -30,7 +27,7 @@ dependencies {
|
|||||||
compile 'de.devland.esperandro:esperandro-api:1.1.2'
|
compile 'de.devland.esperandro:esperandro-api:1.1.2'
|
||||||
apt 'de.devland.esperandro:esperandro:1.1.2'
|
apt 'de.devland.esperandro:esperandro:1.1.2'
|
||||||
|
|
||||||
compile 'com.f2prateek.dart:dart:1.1.0'
|
// compile 'com.f2prateek.dart:dart:1.1.0'
|
||||||
|
|
||||||
compile 'com.readystatesoftware.systembartint:systembartint:1.0.3'
|
compile 'com.readystatesoftware.systembartint:systembartint:1.0.3'
|
||||||
compile 'de.greenrobot:eventbus:2.2.0'
|
compile 'de.greenrobot:eventbus:2.2.0'
|
||||||
@ -40,6 +37,7 @@ dependencies {
|
|||||||
|
|
||||||
// And our unit testing needs some specific stuff (and specific stuff included again)
|
// And our unit testing needs some specific stuff (and specific stuff included again)
|
||||||
androidTestCompile 'junit:junit:4.11+'
|
androidTestCompile 'junit:junit:4.11+'
|
||||||
|
androidTestCompile 'com.jayway.awaitility:awaitility:1.6.0'
|
||||||
androidTestProvided 'com.squareup.dagger:dagger-compiler:1.2.0'
|
androidTestProvided 'com.squareup.dagger:dagger-compiler:1.2.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,26 +1,27 @@
|
|||||||
package org.bspeice.minimalbible.test;
|
package org.bspeice.minimalbible.test;
|
||||||
|
|
||||||
import android.test.InstrumentationTestCase;
|
import android.test.InstrumentationTestCase;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
import org.bspeice.minimalbible.MinimalBible;
|
import org.bspeice.minimalbible.MinimalBible;
|
||||||
import org.bspeice.minimalbible.MinimalBibleModules;
|
import org.bspeice.minimalbible.MinimalBibleModules;
|
||||||
import org.bspeice.minimalbible.R;
|
import org.bspeice.minimalbible.activities.downloader.manager.BookDownloadThread;
|
||||||
import org.bspeice.minimalbible.activities.downloader.BookItemHolder;
|
|
||||||
import org.bspeice.minimalbible.activities.downloader.manager.DLProgressEvent;
|
import org.bspeice.minimalbible.activities.downloader.manager.DLProgressEvent;
|
||||||
import org.bspeice.minimalbible.activities.downloader.manager.DownloadManager;
|
import org.bspeice.minimalbible.activities.downloader.manager.DownloadManager;
|
||||||
|
import org.bspeice.minimalbible.activities.downloader.manager.RefreshManager;
|
||||||
import org.crosswire.jsword.book.Book;
|
import org.crosswire.jsword.book.Book;
|
||||||
import org.crosswire.jsword.book.install.Installer;
|
import org.crosswire.jsword.book.install.Installer;
|
||||||
|
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Provider;
|
||||||
|
|
||||||
import dagger.Module;
|
import dagger.Module;
|
||||||
|
|
||||||
|
import static com.jayway.awaitility.Awaitility.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for the Download activity
|
* Tests for the Download activity
|
||||||
*/
|
*/
|
||||||
@ -30,8 +31,9 @@ public class DownloadActivityTest extends InstrumentationTestCase {
|
|||||||
injects = DownloadActivityTest.class)
|
injects = DownloadActivityTest.class)
|
||||||
public static class DownloadActivityTestModule {}
|
public static class DownloadActivityTestModule {}
|
||||||
|
|
||||||
@Inject
|
@Inject DownloadManager dm;
|
||||||
DownloadManager dm;
|
@Inject Provider<BookDownloadThread> bookDownloadThreadProvider;
|
||||||
|
@Inject RefreshManager rm;
|
||||||
|
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
MinimalBible.getApplication().getObjGraph()
|
MinimalBible.getApplication().getObjGraph()
|
||||||
@ -47,21 +49,28 @@ public class DownloadActivityTest extends InstrumentationTestCase {
|
|||||||
*/
|
*/
|
||||||
public void testInitialProgressEventOnDownload() throws InterruptedException {
|
public void testInitialProgressEventOnDownload() throws InterruptedException {
|
||||||
final CountDownLatch signal = new CountDownLatch(1);
|
final CountDownLatch signal = new CountDownLatch(1);
|
||||||
Installer i = (Installer) dm.getInstallers().values().toArray()[0];
|
|
||||||
Book testBook = i.getBooks().get(0);
|
|
||||||
View dummyView = LayoutInflater.from(MinimalBible.getApplication())
|
|
||||||
.inflate(R.layout.list_download_items, null);
|
|
||||||
BookItemHolder holder = new BookItemHolder(dummyView, testBook);
|
|
||||||
|
|
||||||
|
// Need to make sure we've refreshed the refreshmanager first
|
||||||
|
Installer i = (Installer) dm.getInstallers().values().toArray()[0];
|
||||||
|
final Book testBook = i.getBooks().get(0);
|
||||||
|
await().until(new Callable<Boolean>() {
|
||||||
|
@Override
|
||||||
|
public Boolean call() throws Exception {
|
||||||
|
return rm.installerFromBook(testBook) != null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// And wait for the actual download
|
||||||
dm.getDownloadBus().register(new Object() {
|
dm.getDownloadBus().register(new Object() {
|
||||||
public void onEvent(DLProgressEvent event) {
|
public void onEvent(DLProgressEvent event) {
|
||||||
Log.d("testInitial", Integer.toString(event.getProgress()));
|
|
||||||
if (event.getProgress() == 0) {
|
if (event.getProgress() == 0) {
|
||||||
signal.countDown();
|
signal.countDown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
holder.onDownloadItem(dummyView);
|
|
||||||
|
BookDownloadThread thread = bookDownloadThreadProvider.get();
|
||||||
|
thread.downloadBook(testBook);
|
||||||
|
|
||||||
signal.await(10, TimeUnit.SECONDS);
|
signal.await(10, TimeUnit.SECONDS);
|
||||||
if (signal.getCount() != 0) {
|
if (signal.getCount() != 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user