-
Notifications
You must be signed in to change notification settings - Fork 72
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
Showing
12 changed files
with
96 additions
and
8 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
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
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: 2 additions & 0 deletions
2
magellan-sample-migration/src/testAndroidViews/resources/robolectric.properties
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,2 @@ | ||
sdk=28 | ||
application=com.wealthfront.magellan.sample.migration.TestSampleApplication |
30 changes: 30 additions & 0 deletions
30
...tion/src/testCompose/java/com/wealthfront/magellan/sample/migration/tide/DogBreedsTest.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,30 @@ | ||
package com.wealthfront.magellan.sample.migration.tide | ||
|
||
import androidx.compose.ui.test.junit4.createComposeRule | ||
import androidx.compose.ui.test.onChildAt | ||
import androidx.compose.ui.test.onNodeWithTag | ||
import androidx.compose.ui.test.performClick | ||
import com.google.common.truth.Truth.assertThat | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.robolectric.RobolectricTestRunner | ||
|
||
@RunWith(RobolectricTestRunner::class) | ||
class DogBreedsTest { | ||
|
||
@get:Rule | ||
val composeTestRule = createComposeRule() | ||
|
||
@Test | ||
fun goesToSelectedDogBreed() { | ||
var clicked = false | ||
composeTestRule.setContent { | ||
DogBreeds(dogBreeds = listOf("akita"), onBreedClick = { clicked = true }) | ||
} | ||
|
||
composeTestRule.onNodeWithTag("DogBreeds").onChildAt(0).performClick() | ||
|
||
assertThat(clicked).isTrue() | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
...on/src/testCompose/java/com/wealthfront/magellan/sample/migration/tide/DogListStepTest.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.tide | ||
|
||
import android.app.Application | ||
import android.os.Looper.getMainLooper | ||
import androidx.activity.ComponentActivity | ||
import androidx.compose.ui.test.junit4.createComposeRule | ||
import androidx.compose.ui.test.onChildAt | ||
import androidx.compose.ui.test.onNodeWithTag | ||
import androidx.compose.ui.test.performClick | ||
import androidx.test.core.app.ApplicationProvider | ||
import com.google.common.truth.Truth.assertThat | ||
import com.wealthfront.magellan.lifecycle.setContentScreen | ||
import com.wealthfront.magellan.sample.migration.AppComponentContainer | ||
import com.wealthfront.magellan.sample.migration.TestAppComponent | ||
import com.wealthfront.magellan.sample.migration.api.DogBreedsResponse | ||
import io.mockk.coEvery | ||
import org.junit.Before | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.robolectric.Robolectric | ||
import org.robolectric.RobolectricTestRunner | ||
import org.robolectric.Shadows.shadowOf | ||
|
||
@RunWith(RobolectricTestRunner::class) | ||
class DogListStepTest { | ||
|
||
@get:Rule | ||
val composeTestRule = createComposeRule() | ||
|
||
private lateinit var dogListStep: DogListStep | ||
private val activityController = Robolectric.buildActivity(ComponentActivity::class.java) | ||
|
||
private var chosenBreed: String? = null | ||
|
||
@Before | ||
fun setUp() { | ||
val context = ApplicationProvider.getApplicationContext<Application>() | ||
val component = ((context as AppComponentContainer).injector() as TestAppComponent) | ||
dogListStep = component.dogListStepFactory.create { chosenBreed = it } | ||
coEvery { component.api.getAllBreeds() } returns | ||
DogBreedsResponse(message = mapOf("akita" to emptyList()), status = "success") | ||
} | ||
|
||
@Test | ||
fun goesToSelectedDogBreed() { | ||
activityController.get().setContentScreen(dogListStep) | ||
activityController.setup() | ||
shadowOf(getMainLooper()).idle() | ||
|
||
composeTestRule.onNodeWithTag("DogBreeds").onChildAt(0).performClick() | ||
assertThat(chosenBreed).isEqualTo("akita") | ||
} | ||
} |