Skip to content

Commit 1bdbc58

Browse files
authored
Merge branch 'master' into rename_exception_for_consistency
2 parents 458d870 + 124e3ad commit 1bdbc58

43 files changed

Lines changed: 245 additions & 318 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.idea/AndroidProjectSystem.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/deploymentTargetSelector.xml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/kotlinc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations.xml

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.mitteloupe.whoami.launcher
2+
3+
import androidx.appcompat.app.AppCompatActivity
4+
import com.mitteloupe.whoami.di.testAppDependenciesEntryPoint
5+
import com.mitteloupe.whoami.test.launcher.AppLauncher
6+
import com.mitteloupe.whoami.test.launcher.fromComposable
7+
import com.mitteloupe.whoami.test.test.TypedAndroidComposeTestRule
8+
import com.mitteloupe.whoami.ui.main.AppNavHost
9+
import com.mitteloupe.whoami.ui.theme.WhoAmITheme
10+
11+
fun <ACTIVITY : AppCompatActivity> fromScreen(
12+
composeContentTestRule: TypedAndroidComposeTestRule<ACTIVITY>,
13+
startDestination: Any
14+
) = AppLauncher {
15+
fromComposable(composeContentTestRule) { activity ->
16+
WhoAmITheme {
17+
with(testAppDependenciesEntryPoint(activity).appNavHostDependencies) {
18+
AppNavHost(
19+
supportFragmentManager = activity.supportFragmentManager,
20+
startDestination = startDestination
21+
)
22+
}
23+
}
24+
}.launch()
25+
}

app/src/androidTest/java/com/mitteloupe/whoami/launcher/HistoryActivityLauncher.kt

Lines changed: 0 additions & 30 deletions
This file was deleted.

app/src/androidTest/java/com/mitteloupe/whoami/test/HistoryHighlightedIpAddressTest.kt

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ package com.mitteloupe.whoami.test
22

33
import androidx.compose.ui.test.ExperimentalTestApi
44
import androidx.compose.ui.test.junit4.createAndroidComposeRule
5-
import com.mitteloupe.whoami.analytics.Analytics
6-
import com.mitteloupe.whoami.coroutine.CoroutineContextProvider
7-
import com.mitteloupe.whoami.launcher.historyScreenLauncher
5+
import com.mitteloupe.whoami.launcher.fromScreen
86
import com.mitteloupe.whoami.localstore.KEY_VALUE_SAVED_HISTORY
97
import com.mitteloupe.whoami.screen.HistoryScreen
108
import com.mitteloupe.whoami.test.annotation.LocalStore
9+
import com.mitteloupe.whoami.test.launcher.AppLauncher
1110
import com.mitteloupe.whoami.test.test.BaseTest
1211
import com.mitteloupe.whoami.test.test.retry
1312
import com.mitteloupe.whoami.ui.main.MainActivity
13+
import com.mitteloupe.whoami.ui.main.route.History
1414
import dagger.hilt.android.testing.HiltAndroidTest
1515
import javax.inject.Inject
1616
import org.junit.Test
@@ -23,22 +23,14 @@ class HistoryHighlightedIpAddressTest : BaseTest() {
2323
override val composeTestRule = createAndroidComposeRule<MainActivity>()
2424

2525
override val startActivityLauncher: AppLauncher by lazy {
26-
historyScreenLauncher(highlightedIpAddress = HIGHLIGHTED_IP_ADDRESS)
26+
fromScreen(composeTestRule, History(highlightedIpAddress = HIGHLIGHTED_IP_ADDRESS))
2727
}
2828

2929
@Inject
3030
lateinit var historyScreen: HistoryScreen
3131

32-
@Inject
33-
lateinit var coroutineContextProvider: CoroutineContextProvider
34-
35-
@Inject
36-
lateinit var analytics: Analytics
37-
3832
@Test
39-
@LocalStore(
40-
localStoreDataIds = [KEY_VALUE_SAVED_HISTORY]
41-
)
33+
@LocalStore(localStoreDataIds = [KEY_VALUE_SAVED_HISTORY])
4234
fun givenSavedHistoryAndHighlightedIpAddressWhenOnHistoryScreenTheSeesHighlight() {
4335
with(historyScreen) {
4436
retry(repeat = 20) {

app/src/androidTest/java/com/mitteloupe/whoami/test/HistoryTest.kt

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ package com.mitteloupe.whoami.test
22

33
import androidx.compose.ui.test.ExperimentalTestApi
44
import androidx.compose.ui.test.junit4.createAndroidComposeRule
5-
import com.mitteloupe.whoami.analytics.Analytics
6-
import com.mitteloupe.whoami.coroutine.CoroutineContextProvider
7-
import com.mitteloupe.whoami.launcher.historyScreenLauncher
5+
import com.mitteloupe.whoami.launcher.fromScreen
86
import com.mitteloupe.whoami.localstore.KEY_VALUE_NO_HISTORY
97
import com.mitteloupe.whoami.localstore.KEY_VALUE_SAVED_HISTORY
108
import com.mitteloupe.whoami.screen.HistoryScreen
119
import com.mitteloupe.whoami.test.annotation.LocalStore
10+
import com.mitteloupe.whoami.test.launcher.AppLauncher
1211
import com.mitteloupe.whoami.test.test.BaseTest
1312
import com.mitteloupe.whoami.test.test.doesNot
1413
import com.mitteloupe.whoami.test.test.retry
1514
import com.mitteloupe.whoami.ui.main.MainActivity
15+
import com.mitteloupe.whoami.ui.main.route.History
1616
import dagger.hilt.android.testing.HiltAndroidTest
1717
import javax.inject.Inject
1818
import org.junit.Test
@@ -23,18 +23,12 @@ class HistoryTest : BaseTest() {
2323
override val composeTestRule = createAndroidComposeRule<MainActivity>()
2424

2525
override val startActivityLauncher: AppLauncher by lazy {
26-
historyScreenLauncher(highlightedIpAddress = null)
26+
fromScreen(composeTestRule, History(highlightedIpAddress = null))
2727
}
2828

2929
@Inject
3030
lateinit var historyScreen: HistoryScreen
3131

32-
@Inject
33-
lateinit var coroutineContextProvider: CoroutineContextProvider
34-
35-
@Inject
36-
lateinit var analytics: Analytics
37-
3832
@Test
3933
@LocalStore(
4034
localStoreDataIds = [KEY_VALUE_SAVED_HISTORY]
Lines changed: 8 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,29 @@
11
package com.mitteloupe.whoami.test
22

3-
import androidx.activity.ComponentActivity
4-
import androidx.compose.ui.platform.LocalContext
53
import androidx.compose.ui.test.ExperimentalTestApi
6-
import androidx.compose.ui.test.junit4.AndroidComposeTestRule
74
import androidx.compose.ui.test.junit4.createAndroidComposeRule
85
import androidx.test.espresso.intent.Intents
6+
import com.mitteloupe.whoami.launcher.fromScreen
97
import com.mitteloupe.whoami.screen.HomeScreen
108
import com.mitteloupe.whoami.screen.OpenSourceNoticesScreen
119
import com.mitteloupe.whoami.server.REQUEST_RESPONSE_GET_IP
1210
import com.mitteloupe.whoami.server.REQUEST_RESPONSE_GET_IP_DETAILS
1311
import com.mitteloupe.whoami.test.annotation.ServerRequestResponse
12+
import com.mitteloupe.whoami.test.launcher.AppLauncher
1413
import com.mitteloupe.whoami.test.test.BaseTest
15-
import com.mitteloupe.whoami.test.test.BaseTest.AppLauncher.FromComposable
16-
import com.mitteloupe.whoami.ui.main.AppNavHost
1714
import com.mitteloupe.whoami.ui.main.MainActivity
18-
import com.mitteloupe.whoami.ui.main.di.AppNavHostDependencies
19-
import com.mitteloupe.whoami.ui.theme.WhoAmITheme
20-
import dagger.hilt.EntryPoint
21-
import dagger.hilt.EntryPoints
22-
import dagger.hilt.InstallIn
23-
import dagger.hilt.android.components.ActivityComponent
15+
import com.mitteloupe.whoami.ui.main.route.Home
2416
import dagger.hilt.android.testing.HiltAndroidTest
2517
import javax.inject.Inject
26-
import org.junit.After
27-
import org.junit.Before
2818
import org.junit.Test
29-
import org.junit.rules.TestRule
3019

3120
@HiltAndroidTest
3221
@ExperimentalTestApi
3322
class HomeTest : BaseTest() {
34-
@EntryPoint
35-
@InstallIn(ActivityComponent::class)
36-
interface ActivityEntryPoint {
37-
fun appNavHostDependencies(): AppNavHostDependencies
38-
}
39-
4023
override val composeTestRule = createAndroidComposeRule<MainActivity>()
4124

4225
override val startActivityLauncher: AppLauncher by lazy {
43-
@Suppress("UNCHECKED_CAST")
44-
val composeContentTestRule =
45-
composeTestRule as AndroidComposeTestRule<TestRule, ComponentActivity>
46-
FromComposable(composeContentTestRule) {
47-
WhoAmITheme {
48-
val activity = LocalContext.current as MainActivity
49-
EntryPoints.get(activity, ActivityEntryPoint::class.java).appNavHostDependencies()
50-
.AppNavHost(
51-
activity.supportFragmentManager
52-
)
53-
}
54-
}
26+
fromScreen(composeTestRule, Home)
5527
}
5628

5729
@Inject
@@ -60,24 +32,8 @@ class HomeTest : BaseTest() {
6032
@Inject
6133
lateinit var openSourceNoticesScreen: OpenSourceNoticesScreen
6234

63-
@Before
64-
override fun setUp() {
65-
super.setUp()
66-
Intents.init()
67-
}
68-
69-
@After
70-
fun tearDown() {
71-
Intents.release()
72-
}
73-
7435
@Test
75-
@ServerRequestResponse(
76-
[
77-
REQUEST_RESPONSE_GET_IP,
78-
REQUEST_RESPONSE_GET_IP_DETAILS
79-
]
80-
)
36+
@ServerRequestResponse([REQUEST_RESPONSE_GET_IP, REQUEST_RESPONSE_GET_IP_DETAILS])
8137
fun givenConnectedWhenStartingAppThenIpAddressPresented() {
8238
with(composeTestRule) {
8339
with(homeScreen) {
@@ -88,12 +44,7 @@ class HomeTest : BaseTest() {
8844
}
8945

9046
@Test
91-
@ServerRequestResponse(
92-
[
93-
REQUEST_RESPONSE_GET_IP,
94-
REQUEST_RESPONSE_GET_IP_DETAILS
95-
]
96-
)
47+
@ServerRequestResponse([REQUEST_RESPONSE_GET_IP, REQUEST_RESPONSE_GET_IP_DETAILS])
9748
fun givenConnectedWhenStartingAppThenIpAddressDetailsPresented() {
9849
with(composeTestRule) {
9950
with(homeScreen) {
@@ -110,6 +61,7 @@ class HomeTest : BaseTest() {
11061

11162
@Test
11263
fun whenTappingOnOpenSourceNoticesLaunchesActivity() {
64+
Intents.init()
11365
with(composeTestRule) {
11466
with(homeScreen) {
11567
tapOpenSourceNotices()
@@ -119,5 +71,6 @@ class HomeTest : BaseTest() {
11971
seesScreen()
12072
}
12173
}
74+
Intents.release()
12275
}
12376
}

app/src/test/java/com/mitteloupe/whoami/navigation/mapper/HistoryNavigationEventDestinationMapperTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class HistoryNavigationEventDestinationMapperTest(
1919
companion object {
2020
@JvmStatic
2121
@Parameters(name = "Given {0}")
22-
fun data(): Collection<Array<*>> = listOf(
22+
fun data(): Iterable<Array<*>> = setOf(
2323
testCase(Back) { navController ->
2424
verify(navController).navigateUp()
2525
}

0 commit comments

Comments
 (0)