-
-
Notifications
You must be signed in to change notification settings - Fork 846
Remove/Address TODOs in onboarding #6116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
TimoPtr
wants to merge
3
commits into
feature/onboarding-rework-onboardapp
Choose a base branch
from
feature/onboarding-address-todos
base: feature/onboarding-rework-onboardapp
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,074
−690
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -194,7 +194,6 @@ private fun ServerUrlTextField( | |
| if (isError) { | ||
| Text( | ||
| text = stringResource(commonR.string.manual_server_wrong_url), | ||
| // TODO probably wrong style and color/token | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All TODOs regarding the color and sytle have been removed since the design team won't have time for us and for now it looks ok. We are going to need a more general change over the app later at least for the typographie. |
||
| style = HATextStyle.BodyMedium.copy(color = LocalHAColorScheme.current.colorBorderDangerNormal), | ||
| ) | ||
| } | ||
|
|
||
This file contains hidden or 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
116 changes: 116 additions & 0 deletions
116
...test/kotlin/io/homeassistant/companion/android/onboarding/BaseOnboardingNavigationTest.kt
This file contains hidden or 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,116 @@ | ||
| package io.homeassistant.companion.android.onboarding | ||
|
|
||
| import android.content.pm.PackageManager | ||
| import androidx.activity.compose.LocalActivityResultRegistryOwner | ||
| import androidx.activity.result.ActivityResultRegistry | ||
| import androidx.activity.result.ActivityResultRegistryOwner | ||
| import androidx.compose.runtime.CompositionLocalProvider | ||
| import androidx.compose.ui.platform.LocalContext | ||
| import androidx.compose.ui.test.junit4.AndroidComposeTestRule | ||
| import androidx.compose.ui.test.junit4.createAndroidComposeRule | ||
| import androidx.core.content.ContextCompat | ||
| import androidx.navigation.NavController | ||
| import androidx.navigation.compose.ComposeNavigator | ||
| import androidx.navigation.compose.NavHost | ||
| import androidx.navigation.testing.TestNavHostController | ||
| import dagger.hilt.android.testing.HiltAndroidRule | ||
| import io.homeassistant.companion.android.HiltComponentActivity | ||
| import io.homeassistant.companion.android.testing.unit.ConsoleLogRule | ||
| import io.homeassistant.companion.android.util.LocationPermissionActivityResultRegistry | ||
| import io.homeassistant.companion.android.util.compose.navigateToUri | ||
| import io.mockk.Runs | ||
| import io.mockk.every | ||
| import io.mockk.just | ||
| import io.mockk.mockkStatic | ||
| import kotlinx.coroutines.test.runTest | ||
| import org.junit.Before | ||
| import org.junit.Rule | ||
|
|
||
| /** | ||
| * Base class for onboarding navigation tests providing shared setup, mocks, and utilities. | ||
| * | ||
| * Subclasses should extend this class and use [testNavigation] to set up the navigation | ||
| * test environment with the onboarding flow. | ||
| */ | ||
| internal abstract class BaseOnboardingNavigationTest { | ||
|
|
||
| @get:Rule(order = 0) | ||
| var consoleLog = ConsoleLogRule() | ||
|
|
||
| @get:Rule(order = 1) | ||
| val hiltRule = HiltAndroidRule(this) | ||
|
|
||
| @get:Rule(order = 2) | ||
| val composeTestRule = createAndroidComposeRule<HiltComponentActivity>() | ||
|
|
||
| protected lateinit var navController: TestNavHostController | ||
|
|
||
| protected var onboardingDone = false | ||
|
|
||
| @Before | ||
| fun baseSetup() { | ||
| mockkStatic(NavController::navigateToUri) | ||
| every { any<NavController>().navigateToUri(any()) } just Runs | ||
| } | ||
|
|
||
| protected fun setContent( | ||
| urlToOnboard: String? = null, | ||
| hideExistingServers: Boolean = false, | ||
| skipWelcome: Boolean = false, | ||
| hasLocationTracking: Boolean = true, | ||
| ) { | ||
| composeTestRule.setContent { | ||
| navController = TestNavHostController(LocalContext.current) | ||
| navController.navigatorProvider.addNavigator(ComposeNavigator()) | ||
|
|
||
| CompositionLocalProvider( | ||
| LocalActivityResultRegistryOwner provides object : ActivityResultRegistryOwner { | ||
| override val activityResultRegistry: ActivityResultRegistry = | ||
| LocationPermissionActivityResultRegistry(true) | ||
| }, | ||
| ) { | ||
| NavHost( | ||
| navController = navController, | ||
| startDestination = OnboardingRoute(hasLocationTracking = true), | ||
| ) { | ||
| onboarding( | ||
| navController, | ||
| onShowSnackbar = { _, _ -> true }, | ||
| onOnboardingDone = { | ||
| onboardingDone = true | ||
| }, | ||
| urlToOnboard = urlToOnboard, | ||
| hideExistingServers = hideExistingServers, | ||
| skipWelcome = skipWelcome, | ||
| hasLocationTracking = hasLocationTracking, | ||
| ) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| protected fun testNavigation( | ||
| urlToOnboard: String? = null, | ||
| hideExistingServers: Boolean = false, | ||
| skipWelcome: Boolean = false, | ||
| hasLocationTracking: Boolean = true, | ||
| testContent: suspend AndroidComposeTestRule<*, *>.() -> Unit, | ||
| ) { | ||
| setContent( | ||
| urlToOnboard = urlToOnboard, | ||
| hideExistingServers = hideExistingServers, | ||
| skipWelcome = skipWelcome, | ||
| hasLocationTracking = hasLocationTracking, | ||
| ) | ||
| runTest { | ||
| composeTestRule.testContent() | ||
| } | ||
| } | ||
|
|
||
| protected fun mockCheckPermission(grant: Boolean) { | ||
| mockkStatic(ContextCompat::class) | ||
| every { | ||
| ContextCompat.checkSelfPermission(any(), any()) | ||
| } returns if (grant) PackageManager.PERMISSION_GRANTED else PackageManager.PERMISSION_DENIED | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried it (I have a stash with the changes). I've used a value class in the AuthRepository to enforce a strong type but then this types is not properly use by the navigation library and it needs a custom NavType mapping which I don't like.
I hope this is going to work in nav3 let see, for now I'm going to keep it like this.