-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add info button to trace/shape questions #7021
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
4c65541
Add info button
grzesiek2010 fb86f34
Implement layouts
grzesiek2010 dd9055f
Move strings to strings.xml file
grzesiek2010 b2b123c
Make columns scrollable
grzesiek2010 4e0812e
Add a button to the error snackbar
grzesiek2010 41ae741
Display appropriate info based on circumstances
grzesiek2010 793cb69
Update accepted apk size
grzesiek2010 f7c3f7a
Update icon used for 'Tap to add a point'
grzesiek2010 d2686d7
Move recording mode state to ViewModel
grzesiek2010 e2bb2f4
Use recording mode from viewmodel to set up info dialog
grzesiek2010 800e0a2
Add tests
grzesiek2010 6815817
Fix naming
grzesiek2010 69a034f
Add test for InfoContent done action
grzesiek2010 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
Add tests
- Loading branch information
commit 800e0a2ba3f08be8233a95b3d62115516932ffe3
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
154 changes: 154 additions & 0 deletions
154
geo/src/test/java/org/odk/collect/geo/geopoly/InfoDialogTest.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,154 @@ | ||
| package org.odk.collect.geo.geopoly | ||
|
|
||
| import android.app.Application | ||
| import androidx.compose.ui.test.assertIsDisplayed | ||
| import androidx.compose.ui.test.junit4.createComposeRule | ||
| import androidx.compose.ui.test.onNodeWithText | ||
| import androidx.compose.ui.test.performScrollTo | ||
| import androidx.test.core.app.ApplicationProvider | ||
| import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
| import org.junit.Rule | ||
| import org.junit.Test | ||
| import org.junit.runner.RunWith | ||
| import org.mockito.kotlin.mock | ||
| import org.mockito.kotlin.whenever | ||
|
|
||
| @RunWith(AndroidJUnit4::class) | ||
| class InfoDialogTest { | ||
grzesiek2010 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| @get:Rule | ||
| val composeTestRule = createComposeRule() | ||
|
|
||
| private val context = ApplicationProvider.getApplicationContext<Application>() | ||
|
|
||
| @Test | ||
| fun `shows dialog content from snackbar in PLACEMENT mode`() { | ||
| val viewModel = mock<GeoPolyViewModel>().apply { | ||
| whenever(recordingMode).thenReturn(GeoPolyViewModel.RecordingMode.PLACEMENT) | ||
| } | ||
|
|
||
| composeTestRule.setContent { | ||
| InfoContent(viewModel, fromSnackbar = true, {}) | ||
| } | ||
|
|
||
| assertInfo( | ||
| listOf( | ||
| org.odk.collect.strings.R.string.long_press_to_move_point_info_item, | ||
| org.odk.collect.strings.R.string.remove_last_point_info_item, | ||
| org.odk.collect.strings.R.string.delete_shape_to_start_over_info_item, | ||
| org.odk.collect.strings.R.string.add_point_info_item, | ||
| ) | ||
| ) | ||
| } | ||
|
|
||
| @Test | ||
| fun `shows dialog content from info button in PLACEMENT mode`() { | ||
| val viewModel = mock<GeoPolyViewModel>().apply { | ||
| whenever(recordingMode).thenReturn(GeoPolyViewModel.RecordingMode.PLACEMENT) | ||
| } | ||
|
|
||
| composeTestRule.setContent { | ||
| InfoContent(viewModel, fromSnackbar = false, {}) | ||
| } | ||
|
|
||
| assertInfo( | ||
| listOf( | ||
| org.odk.collect.strings.R.string.tap_to_add_a_point_info_item, | ||
| org.odk.collect.strings.R.string.long_press_to_move_point_info_item, | ||
| org.odk.collect.strings.R.string.remove_last_point_info_item, | ||
| org.odk.collect.strings.R.string.delete_entire_shape_info_item, | ||
| ) | ||
| ) | ||
| } | ||
|
|
||
| @Test | ||
| fun `shows dialog content from snackbar in MANUAL mode`() { | ||
| val viewModel = mock<GeoPolyViewModel>().apply { | ||
| whenever(recordingMode).thenReturn(GeoPolyViewModel.RecordingMode.MANUAL) | ||
| } | ||
|
|
||
| composeTestRule.setContent { | ||
| InfoContent(viewModel, fromSnackbar = true, {}) | ||
| } | ||
|
|
||
| assertInfo( | ||
| listOf( | ||
| org.odk.collect.strings.R.string.physically_move_to_correct_info_item, | ||
| org.odk.collect.strings.R.string.long_press_to_move_point_info_item, | ||
| org.odk.collect.strings.R.string.remove_last_point_info_item, | ||
| org.odk.collect.strings.R.string.delete_entire_shape_info_item, | ||
| ) | ||
| ) | ||
| } | ||
|
|
||
| @Test | ||
| fun `shows dialog content from info button in MANUAL mode`() { | ||
| val viewModel = mock<GeoPolyViewModel>().apply { | ||
| whenever(recordingMode).thenReturn(GeoPolyViewModel.RecordingMode.MANUAL) | ||
| } | ||
|
|
||
| composeTestRule.setContent { | ||
| InfoContent(viewModel, fromSnackbar = false, {}) | ||
| } | ||
|
|
||
| assertInfo( | ||
| listOf( | ||
| org.odk.collect.strings.R.string.tap_to_add_a_point_info_item, | ||
| org.odk.collect.strings.R.string.physically_move_to_correct_info_item, | ||
| org.odk.collect.strings.R.string.long_press_to_move_point_info_item, | ||
| org.odk.collect.strings.R.string.remove_last_point_info_item, | ||
| org.odk.collect.strings.R.string.delete_entire_shape_info_item, | ||
| ) | ||
| ) | ||
| } | ||
|
|
||
| @Test | ||
| fun `shows dialog content from snackbar in AUTOMATIC mode`() { | ||
| val viewModel = mock<GeoPolyViewModel>().apply { | ||
| whenever(recordingMode).thenReturn(GeoPolyViewModel.RecordingMode.AUTOMATIC) | ||
| } | ||
|
|
||
| composeTestRule.setContent { | ||
| InfoContent(viewModel, fromSnackbar = true, {}) | ||
| } | ||
|
|
||
| assertInfo( | ||
| listOf( | ||
| org.odk.collect.strings.R.string.physically_move_to_correct_info_item, | ||
| org.odk.collect.strings.R.string.long_press_to_move_point_info_item, | ||
| org.odk.collect.strings.R.string.remove_last_point_info_item, | ||
| org.odk.collect.strings.R.string.delete_entire_shape_info_item, | ||
| ) | ||
| ) | ||
| } | ||
|
|
||
| @Test | ||
| fun `shows dialog content from info button in AUTOMATIC mode`() { | ||
| val viewModel = mock<GeoPolyViewModel>().apply { | ||
| whenever(recordingMode).thenReturn(GeoPolyViewModel.RecordingMode.AUTOMATIC) | ||
| } | ||
|
|
||
| composeTestRule.setContent { | ||
| InfoContent(viewModel, fromSnackbar = false, {}) | ||
| } | ||
|
|
||
| assertInfo( | ||
| listOf( | ||
| org.odk.collect.strings.R.string.tap_to_add_a_point_info_item, | ||
| org.odk.collect.strings.R.string.physically_move_to_correct_info_item, | ||
| org.odk.collect.strings.R.string.long_press_to_move_point_info_item, | ||
| org.odk.collect.strings.R.string.remove_last_point_info_item, | ||
| org.odk.collect.strings.R.string.delete_entire_shape_info_item, | ||
| ) | ||
| ) | ||
| } | ||
|
|
||
| private fun assertInfo(items: List<Int>) { | ||
| items.forEach { | ||
| composeTestRule | ||
| .onNodeWithText(context.getString(it)) | ||
| .performScrollTo() | ||
| .assertIsDisplayed() | ||
| } | ||
| } | ||
| } | ||
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
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.
Why is this change needed? If I take it out, then there's a failure, but it seems completely unrelated to everything else here.
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.
This happens because
androidx.compose.ui:ui-test-manifestprovides its own test manifest, which changes the default app theme used during tests. Robolectric picks up that manifest even for non-Compose tests, and the new default theme is not AppCompat/Material.