mirror of
https://github.com/MinimalBible/MinimalBible
synced 2024-11-22 07:58:20 -05:00
Remove the "testing" mode
This commit is contained in:
parent
abbcbb3947
commit
5ebd66b6c7
@ -1,15 +1,21 @@
|
||||
package org.bspeice.minimalbible.test.activity.downloader.manager;
|
||||
|
||||
import com.jayway.awaitility.Awaitility;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.bspeice.minimalbible.Injector;
|
||||
import org.bspeice.minimalbible.activity.downloader.manager.RefreshManager;
|
||||
import org.crosswire.jsword.book.Book;
|
||||
import org.crosswire.jsword.book.install.Installer;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
@ -19,6 +25,7 @@ import dagger.ObjectGraph;
|
||||
import dagger.Provides;
|
||||
import rx.functions.Action1;
|
||||
|
||||
import static com.jayway.awaitility.Awaitility.await;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
public class RefreshManagerTest extends TestCase implements Injector {
|
||||
@ -113,9 +120,36 @@ public class RefreshManagerTest extends TestCase implements Injector {
|
||||
verify(mockInstaller).getBooks();
|
||||
}
|
||||
|
||||
/*
|
||||
public void testIsRefreshComplete() throws Exception {
|
||||
|
||||
public void testRefreshSeparateThread() {
|
||||
Installer mockInstaller = mock(Installer.class);
|
||||
final List<Book> bookList = new ArrayList<Book>();
|
||||
when(mockInstaller.getBooks()).thenAnswer(new Answer<List<Book>>() {
|
||||
@Override
|
||||
public List<Book> answer(InvocationOnMock invocationOnMock) throws Throwable {
|
||||
Thread.sleep(1000); // Just long enough to give us a gap between
|
||||
// refresh start and complete
|
||||
return bookList;
|
||||
}
|
||||
});
|
||||
|
||||
Collection<Installer> mockInstallers = new ArrayList<Installer>();
|
||||
mockInstallers.add(mockInstaller);
|
||||
|
||||
RMTModules modules = new RMTModules(this, mockInstallers);
|
||||
mObjectGraph = ObjectGraph.create(modules);
|
||||
|
||||
// And the actual test
|
||||
mObjectGraph.inject(this);
|
||||
|
||||
// So the refresh should be kicked off at the constructor, meaning that it's not "complete"
|
||||
assertFalse(rM.isRefreshComplete());
|
||||
|
||||
// But, if it's on another thread, it should finish up eventually, right?
|
||||
await().atMost(5, TimeUnit.SECONDS).until(new Callable<Boolean>() {
|
||||
@Override
|
||||
public Boolean call() throws Exception {
|
||||
return rM.isRefreshComplete();
|
||||
}
|
||||
});
|
||||
}
|
||||
*/
|
||||
}
|
@ -5,22 +5,13 @@ package org.bspeice.minimalbible;
|
||||
* Also the entry point for setting whether or not we are using testing mode
|
||||
*/
|
||||
public class Modules {
|
||||
private static TestModules testModules = new TestModules();
|
||||
|
||||
private Modules() {}
|
||||
|
||||
public static void enableTestingMode() {
|
||||
testModules.setTestMode(true);
|
||||
}
|
||||
|
||||
public static void disableTestingMode() {
|
||||
testModules.setTestMode(false);
|
||||
}
|
||||
|
||||
public static Object[] list(MinimalBible app) {
|
||||
return new Object[] {
|
||||
new MinimalBibleModules(app),
|
||||
testModules
|
||||
new TestModules()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -26,19 +26,6 @@ public class TestModules {
|
||||
return testActivityTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide an application-wide hub to enable/disable a "testing" mode
|
||||
* Each application is free to interpret what this means, but allows for programming
|
||||
* different behavior to respond to different testing needs in code that can't be mocked
|
||||
* *cough cough* `Activities`.
|
||||
* @return
|
||||
*/
|
||||
@Provides
|
||||
@Named("Testing")
|
||||
boolean isTest() {
|
||||
return isTest;
|
||||
}
|
||||
|
||||
@Provides @Singleton
|
||||
@Named("ValidCategories")
|
||||
List<BookCategory> provideValidCategories() {
|
||||
@ -49,14 +36,4 @@ public class TestModules {
|
||||
add(BookCategory.MAPS);
|
||||
}};
|
||||
}
|
||||
|
||||
private boolean isTest;
|
||||
|
||||
public void setTestMode(boolean isTest) {
|
||||
this.isTest = isTest;
|
||||
}
|
||||
|
||||
public boolean getTestMode() {
|
||||
return isTest;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user