Unit testing now working

Also demo test case for async testing.
This commit is contained in:
Bradlee Speice
2014-05-24 15:11:26 -04:00
parent bba77bb45a
commit 2c494edadc
5 changed files with 79 additions and 7 deletions

View File

@ -60,4 +60,6 @@ public class MinimalBible extends Application {
public void inject(Object o) {
graph.inject(o);
}
public ObjectGraph getObjGraph() { return graph; }
}

View File

@ -1,6 +1,5 @@
package org.bspeice.minimalbible.activities.downloader;
import android.util.Log;
import android.view.View;
import android.widget.ImageButton;
import android.widget.RelativeLayout;
@ -55,14 +54,20 @@ public class BookItemHolder {
@OnClick(R.id.download_ibtn_download)
public void onDownloadItem(View v) {
Log.d("BookListAdapter", v.toString());
displayProgress(0); // Can assume 0 since the download is now starting
// TODO: Write a unit test to make sure that this is called - displayProgress() assumes it
downloadManager.getDownloadBus().register(this);
downloadManager.getDownloadBus()
.post(new DownloadProgressEvent(DownloadProgressEvent.PROGRESS_BEGINNING, b));
// TODO: Kick off a service to actually do the downloading, rather than simulate
downloadManager.getDownloadBus().post(new DownloadProgressEvent(47, b));
}
public void onEventMainThread(DownloadProgressEvent event) {
if (event.getB().equals(this.b)) {
displayProgress((int) event.toCircular());
}
}
/**
* Display the current progress of this download
* @param progress The progress out of 360 (degrees of a circle)
@ -70,7 +75,7 @@ public class BookItemHolder {
private void displayProgress(int progress) {
if (progress <= 0) {
if (progress == DownloadProgressEvent.PROGRESS_BEGINNING) {
// Download starting
RelativeLayout.LayoutParams acronymParams =
(RelativeLayout.LayoutParams)acronym.getLayoutParams();

View File

@ -3,12 +3,15 @@ package org.bspeice.minimalbible.activities.downloader.manager;
import org.crosswire.jsword.book.Book;
/**
* Created by bspeice on 5/19/14.
* Used for notifying that a book's download progress is ongoing
*/
public class DownloadProgressEvent {
private int progress;
private Book b;
public static final int PROGRESS_COMPLETE = 100;
public static final int PROGRESS_BEGINNING = 0;
public DownloadProgressEvent(int progress, Book b) {
this.progress = progress;
this.b = b;