From 9a2ede432ed0b2f923d71aee18580949168454e9 Mon Sep 17 00:00:00 2001 From: Bradlee Speice Date: Sun, 20 Jul 2014 21:21:24 -0400 Subject: [PATCH] One more RM test case --- .../manager/RefreshManagerTest.java | 27 ++++++++++++++++--- .../downloader/manager/RefreshManager.java | 1 + 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/app/src/androidTest/java/org/bspeice/minimalbible/test/activity/downloader/manager/RefreshManagerTest.java b/app/src/androidTest/java/org/bspeice/minimalbible/test/activity/downloader/manager/RefreshManagerTest.java index 9a535b3..b0ed9b9 100644 --- a/app/src/androidTest/java/org/bspeice/minimalbible/test/activity/downloader/manager/RefreshManagerTest.java +++ b/app/src/androidTest/java/org/bspeice/minimalbible/test/activity/downloader/manager/RefreshManagerTest.java @@ -37,11 +37,11 @@ public class RefreshManagerTest extends TestCase implements Injector { @Inject RefreshManager rM; @Module (injects = {RefreshManagerTest.class, RefreshManager.class}) - class TGAMFModules { + class RMTModules { Injector i; Collection installers; - TGAMFModules(Injector i, Collection installers) { + RMTModules(Injector i, Collection installers) { this.i = i; this.installers = installers; } @@ -71,7 +71,7 @@ public class RefreshManagerTest extends TestCase implements Injector { Collection mockInstallers = new ArrayList(); mockInstallers.add(mockInstaller); - TGAMFModules modules = new TGAMFModules(this, mockInstallers); + RMTModules modules = new RMTModules(this, mockInstallers); mObjectGraph = ObjectGraph.create(modules); // Now the actual test @@ -90,11 +90,30 @@ public class RefreshManagerTest extends TestCase implements Injector { verify(mockBook).getName(); } - /* public void testInstallerFromBook() throws Exception { + // Environment setup + Book mockBook = mock(Book.class); + Installer mockInstaller = mock(Installer.class); + List bookList = new ArrayList(); + bookList.add(mockBook); + when(mockInstaller.getBooks()).thenReturn(bookList); + + Collection mockInstallers = new ArrayList(); + mockInstallers.add(mockInstaller); + + RMTModules modules = new RMTModules(this, mockInstallers); + mObjectGraph = ObjectGraph.create(modules); + + // And the actual test + mObjectGraph.inject(this); + Installer i = rM.installerFromBook(mockBook); + + assertSame(mockInstaller, i); + verify(mockInstaller).getBooks(); } + /* public void testIsRefreshComplete() throws Exception { } diff --git a/app/src/main/java/org/bspeice/minimalbible/activity/downloader/manager/RefreshManager.java b/app/src/main/java/org/bspeice/minimalbible/activity/downloader/manager/RefreshManager.java index a3c4521..4481279 100644 --- a/app/src/main/java/org/bspeice/minimalbible/activity/downloader/manager/RefreshManager.java +++ b/app/src/main/java/org/bspeice/minimalbible/activity/downloader/manager/RefreshManager.java @@ -101,6 +101,7 @@ public class RefreshManager { /** * Find the installer that a Book comes from. + * TODO: Should this be @link{Observable} so we don't have to block? * @param b The book to search for * @return The Installer that should be used for this book. */