-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4d94af6
commit 5121c4c
Showing
32 changed files
with
249 additions
and
263 deletions.
There are no files selected for viewing
Binary file added
BIN
+12 KB
...ActivityTest_doesNotShowAvengersBadgeIfASuperHeroIsNotPartOfTheAvengersTeam.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+45.8 KB
...view.MainActivityTest_showsAvengersBadgeIfASuperHeroIsPartOfTheAvengersTeam.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.96 KB
....superheroes.ui.view.MainActivityTest_showsEmptyCaseIfThereAreNoSuperHeroes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.23 KB
...m.karumi.jetpack.superheroes.ui.view.MainActivityTest_showsJustOneSuperHero.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+12 KB
...erheroes.ui.view.MainActivityTest_showsSuperHeroesIfThereAreSomeSuperHeroes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+12.9 KB
...lActivityTest_doesNotShowAvengersBadgeIfSuperHeroIsNotPartOfTheAvengersTeam.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+29.9 KB
...HeroDetailActivityTest_showsAvengersBadgeIfSuperHeroIsPartOfTheAvengersTeam.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
Binary file added
BIN
+36.7 KB
...k.superheroes.ui.view.SuperHeroViewHolderTest_showsSuperHeroesWithLongNames.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed
BIN
-13.2 KB
...ActivityTest_doesNotShowAvengersBadgeIfASuperHeroIsNotPartOfTheAvengersTeam.png
Binary file not shown.
Binary file removed
BIN
-47 KB
...view.MainActivityTest_showsAvengersBadgeIfASuperHeroIsPartOfTheAvengersTeam.png
Binary file not shown.
Binary file removed
BIN
-9.16 KB
...s/com.karumi.ui.view.MainActivityTest_showsEmptyCaseIfThereAreNoSuperHeroes.png
Binary file not shown.
Binary file removed
BIN
-10.4 KB
app/screenshots/com.karumi.ui.view.MainActivityTest_showsJustOneSuperHero.png
Binary file not shown.
Binary file removed
BIN
-13.2 KB
...m.karumi.ui.view.MainActivityTest_showsSuperHeroesIfThereAreSomeSuperHeroes.png
Binary file not shown.
Binary file removed
BIN
-12.4 KB
...lActivityTest_doesNotShowAvengersBadgeIfSuperHeroIsNotPartOfTheAvengersTeam.png
Binary file not shown.
Binary file removed
BIN
-29.7 KB
...HeroDetailActivityTest_showsAvengersBadgeIfSuperHeroIsPartOfTheAvengersTeam.png
Binary file not shown.
Binary file removed
BIN
-40.9 KB
...ts/com.karumi.ui.view.SuperHeroViewHolderTest_showsSuperHeroesWithLongNames.png
Binary file not shown.
26 changes: 0 additions & 26 deletions
26
app/src/androidTest/java/com/karumi/com.karumi.InjectedTestRunner.kt
This file was deleted.
Oops, something went wrong.
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
99 changes: 99 additions & 0 deletions
99
app/src/androidTest/java/com/karumi/jetpack/superheroes/ui/view/MainActivityTest.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,99 @@ | ||
package com.karumi.jetpack.superheroes.ui.view | ||
|
||
import com.github.salomonbrys.kodein.Kodein.Module | ||
import com.github.salomonbrys.kodein.bind | ||
import com.github.salomonbrys.kodein.instance | ||
import com.karumi.jetpack.superheroes.data.repository.SuperHeroRepository | ||
import com.karumi.jetpack.superheroes.domain.model.SuperHero | ||
import com.karumi.ui.view.AcceptanceTest | ||
import com.nhaarman.mockitokotlin2.whenever | ||
import kotlinx.coroutines.runBlocking | ||
import org.junit.Test | ||
import org.mockito.Mock | ||
|
||
class MainActivityTest : AcceptanceTest<MainActivity>(MainActivity::class.java) { | ||
|
||
companion object { | ||
private const val ANY_NUMBER_OF_SUPER_HEROES = 100 | ||
} | ||
|
||
@Mock | ||
private lateinit var repository: SuperHeroRepository | ||
|
||
@Test | ||
fun showsEmptyCaseIfThereAreNoSuperHeroes() { | ||
givenThereAreNoSuperHeroes() | ||
|
||
val activity = startActivity() | ||
|
||
compareScreenshot(activity) | ||
} | ||
|
||
@Test | ||
fun showsJustOneSuperHero() = runBlocking { | ||
givenThereAreSomeSuperHeroes(1) | ||
|
||
val activity = startActivity() | ||
|
||
compareScreenshot(activity) | ||
} | ||
|
||
@Test | ||
fun showsSuperHeroesIfThereAreSomeSuperHeroes() { | ||
givenThereAreSomeSuperHeroes(ANY_NUMBER_OF_SUPER_HEROES) | ||
|
||
val activity = startActivity() | ||
|
||
compareScreenshot(activity) | ||
} | ||
|
||
@Test | ||
fun showsAvengersBadgeIfASuperHeroIsPartOfTheAvengersTeam() { | ||
givenThereAreSomeAvengers(ANY_NUMBER_OF_SUPER_HEROES) | ||
|
||
val activity = startActivity() | ||
|
||
compareScreenshot(activity) | ||
} | ||
|
||
@Test | ||
fun doesNotShowAvengersBadgeIfASuperHeroIsNotPartOfTheAvengersTeam() { | ||
givenThereAreSomeSuperHeroes(ANY_NUMBER_OF_SUPER_HEROES) | ||
|
||
val activity = startActivity() | ||
|
||
compareScreenshot(activity) | ||
} | ||
|
||
private fun givenThereAreSomeAvengers(numberOfAvengers: Int): List<SuperHero> = | ||
givenThereAreSomeSuperHeroes(numberOfAvengers, areAvengers = true) | ||
|
||
private fun givenThereAreSomeSuperHeroes( | ||
numberOfSuperHeroes: Int = 1, | ||
areAvengers: Boolean = false | ||
): List<SuperHero> { | ||
val superHeroes = IntRange(0, numberOfSuperHeroes - 1).map { id -> | ||
val superHeroId = "#$id" | ||
val superHeroName = "SuperHero - $id" | ||
val superHeroDescription = "Description Super Hero - $id" | ||
SuperHero( | ||
superHeroId, | ||
superHeroName, | ||
null, | ||
areAvengers, | ||
superHeroDescription | ||
) | ||
} | ||
|
||
whenever(runBlocking { repository.getAllSuperHeroes() }).thenReturn(superHeroes) | ||
return superHeroes | ||
} | ||
|
||
private fun givenThereAreNoSuperHeroes() { | ||
whenever(runBlocking { repository.getAllSuperHeroes() }).thenReturn(emptyList()) | ||
} | ||
|
||
override val testDependencies = Module(allowSilentOverride = true) { | ||
bind<SuperHeroRepository>() with instance(repository) | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
.../karumi/jetpack/ui/view/ScreenshotTest.kt → ...ack/superheroes/ui/view/ScreenshotTest.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
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
51 changes: 0 additions & 51 deletions
51
app/src/androidTest/java/com/karumi/jetpack/ui/view/MainActivityTest.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.