Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #289 from wealthfront/dog-recyclerview
Use RecyclerView to display dog breeds
- Loading branch information
Showing
40 changed files
with
476 additions
and
548 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...althfront/magellan/CoroutineIdlingRule.kt → ...n/sample/migration/CoroutineIdlingRule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...n/src/androidTest/java/com/wealthfront/magellan/sample/migration/IntegrationTestRunner.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.wealthfront.magellan.sample.migration | ||
|
||
import android.app.Application | ||
import android.content.Context | ||
import androidx.test.runner.AndroidJUnitRunner | ||
|
||
class IntegrationTestRunner : AndroidJUnitRunner() { | ||
|
||
@Throws( | ||
InstantiationException::class, | ||
IllegalAccessException::class, | ||
ClassNotFoundException::class | ||
) | ||
override fun newApplication( | ||
cl: ClassLoader, | ||
className: String, | ||
context: Context, | ||
): Application { | ||
return super.newApplication(cl, TestSampleApplication::class.java.name, context) | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...ration/src/androidTest/java/com/wealthfront/magellan/sample/migration/TestAppComponent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.wealthfront.magellan.sample.migration | ||
|
||
import com.wealthfront.magellan.sample.migration.uitest.NavigationTest | ||
import dagger.Component | ||
import javax.inject.Singleton | ||
|
||
@Component(modules = [AppModule::class, ToolbarHelperModule::class, TestDogApiModule::class]) | ||
@Singleton | ||
interface TestAppComponent : AppComponent { | ||
|
||
fun inject(test: NavigationTest) | ||
} |
17 changes: 17 additions & 0 deletions
17
...ration/src/androidTest/java/com/wealthfront/magellan/sample/migration/TestDogApiModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.wealthfront.magellan.sample.migration | ||
|
||
import com.wealthfront.magellan.sample.migration.api.DogApi | ||
import dagger.Module | ||
import dagger.Provides | ||
import org.mockito.Mockito.mock | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
object TestDogApiModule { | ||
|
||
@Provides | ||
@Singleton | ||
fun provideDogApi(): DogApi { | ||
return mock(DogApi::class.java) | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...igration/src/androidTest/java/com/wealthfront/magellan/sample/migration/TestExtensions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
@file:Suppress("UNCHECKED_CAST") | ||
|
||
package com.wealthfront.magellan.sample.migration | ||
|
||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.runBlocking | ||
import org.mockito.Mockito.verify | ||
import org.mockito.Mockito.`when` | ||
import org.mockito.stubbing.LenientStubber | ||
import org.mockito.stubbing.OngoingStubbing | ||
import org.mockito.verification.VerificationMode | ||
|
||
fun <T> LenientStubber.coWhen(block: suspend CoroutineScope.() -> T): OngoingStubbing<T> = | ||
runBlocking { | ||
this@coWhen.`when`(block()) | ||
} | ||
|
||
fun <T> coWhen(block: suspend CoroutineScope.() -> T): OngoingStubbing<T> = | ||
runBlocking { | ||
`when`(block()) | ||
} | ||
|
||
fun <T> coVerify(mock: T, block: suspend CoroutineScope.(T) -> Unit) { | ||
runBlocking { | ||
block(verify(mock)) | ||
} | ||
} | ||
|
||
fun <T> coVerify(mock: T, mode: VerificationMode, block: suspend CoroutineScope.(T) -> Unit) { | ||
runBlocking { | ||
block(verify(mock, mode)) | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...n/src/androidTest/java/com/wealthfront/magellan/sample/migration/TestSampleApplication.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.wealthfront.magellan.sample.migration | ||
|
||
import android.app.Application | ||
|
||
class TestSampleApplication : Application(), AppComponentContainer { | ||
|
||
private lateinit var appComponent: TestAppComponent | ||
|
||
override fun onCreate() { | ||
super.onCreate() | ||
appComponent = DaggerTestAppComponent.builder() | ||
.appModule(AppModule) | ||
.testDogApiModule(TestDogApiModule) | ||
.toolbarHelperModule(ToolbarHelperModule) | ||
.build() | ||
} | ||
|
||
override fun injector(): AppComponent { | ||
return appComponent | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
...n/src/androidTest/java/com/wealthfront/magellan/sample/migration/uitest/NavigationTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.wealthfront.magellan.sample.migration.uitest | ||
|
||
import android.app.Application | ||
import androidx.test.core.app.ActivityScenario | ||
import androidx.test.core.app.ApplicationProvider | ||
import androidx.test.core.app.launchActivity | ||
import androidx.test.espresso.Espresso.onView | ||
import androidx.test.espresso.action.ViewActions.click | ||
import androidx.test.espresso.assertion.ViewAssertions.matches | ||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed | ||
import androidx.test.espresso.matcher.ViewMatchers.withId | ||
import androidx.test.espresso.matcher.ViewMatchers.withText | ||
import com.wealthfront.magellan.sample.migration.AppComponentContainer | ||
import com.wealthfront.magellan.sample.migration.CoroutineIdlingRule | ||
import com.wealthfront.magellan.sample.migration.MainActivity | ||
import com.wealthfront.magellan.sample.migration.R | ||
import com.wealthfront.magellan.sample.migration.TestAppComponent | ||
import com.wealthfront.magellan.sample.migration.api.DogApi | ||
import com.wealthfront.magellan.sample.migration.api.DogBreedsResponse | ||
import com.wealthfront.magellan.sample.migration.api.DogImageResponse | ||
import com.wealthfront.magellan.sample.migration.coWhen | ||
import org.junit.Before | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import javax.inject.Inject | ||
|
||
class NavigationTest { | ||
|
||
@Rule @JvmField | ||
val coroutineIdlingRule = CoroutineIdlingRule() | ||
|
||
@Inject lateinit var api: DogApi | ||
|
||
private lateinit var activityScenario: ActivityScenario<MainActivity> | ||
|
||
@Before | ||
fun setup() { | ||
val context = ApplicationProvider.getApplicationContext<Application>() | ||
((context as AppComponentContainer).injector() as TestAppComponent).inject(this) | ||
|
||
coWhen { api.getAllBreeds() } | ||
.thenReturn(DogBreedsResponse(message = mapOf("robotic" to emptyList()), status = "success")) | ||
coWhen { api.getRandomImageForBreed("robotic") }.thenReturn( | ||
DogImageResponse(message = "image-url", status = "success") | ||
) | ||
} | ||
|
||
@Test | ||
fun visitRetriever() { | ||
activityScenario = launchActivity() | ||
onView(withText("robotic")).perform(click()) | ||
onView(withId(R.id.dogDetailsView)).check(matches(isDisplayed())) | ||
} | ||
} |
35 changes: 0 additions & 35 deletions
35
...n-sample-migration/src/androidTest/java/com/wealthfront/magellan/uitest/NavigationTest.kt
This file was deleted.
Oops, something went wrong.
27 changes: 0 additions & 27 deletions
27
...ample-migration/src/main/java/com/wealthfront/magellan/sample/migration/AppComponent.java
This file was deleted.
Oops, something went wrong.
16 changes: 16 additions & 0 deletions
16
...-sample-migration/src/main/java/com/wealthfront/magellan/sample/migration/AppComponent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.wealthfront.magellan.sample.migration | ||
|
||
import com.wealthfront.magellan.sample.migration.tide.DogDetailsScreen | ||
import com.wealthfront.magellan.sample.migration.tide.DogListStep | ||
import dagger.Component | ||
import javax.inject.Singleton | ||
|
||
@Component(modules = [AppModule::class, DogApiModule::class, ToolbarHelperModule::class]) | ||
@Singleton | ||
interface AppComponent { | ||
|
||
fun inject(activity: MainActivity) | ||
fun inject(step: DogListStep) | ||
fun inject(screen: DogDetailsScreen) | ||
fun inject(expedition: Expedition) | ||
} |
67 changes: 0 additions & 67 deletions
67
...n-sample-migration/src/main/java/com/wealthfront/magellan/sample/migration/AppModule.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.