Gitlab@Informatics
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
WordList
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Android
WordList
Commits
27e2f115
Commit
27e2f115
authored
Aug 18, 2022
by
62160286
Browse files
Options
Downloads
Patches
Plain Diff
Test Navigation Component
parent
a5ebf32e
Branches
master
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/build.gradle
+5
-0
5 additions, 0 deletions
app/build.gradle
app/src/androidTest/java/com/example/wordsapp/NavigationTests.kt
+44
-0
44 additions, 0 deletions
.../androidTest/java/com/example/wordsapp/NavigationTests.kt
with
49 additions
and
0 deletions
app/build.gradle
+
5
−
0
View file @
27e2f115
...
...
@@ -61,4 +61,9 @@ dependencies {
implementation
"androidx.constraintlayout:constraintlayout:$constraintlayout_version"
implementation
"androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation
"androidx.navigation:navigation-ui-ktx:$nav_version"
androidTestImplementation
'com.android.support.test.espresso:espresso-contrib:3.4.0'
androidTestImplementation
'androidx.navigation:navigation-testing:2.4.2'
debugImplementation
'androidx.fragment:fragment-testing:1.4.1'
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
app/src/androidTest/java/com/example/wordsapp/NavigationTests.kt
0 → 100644
+
44
−
0
View file @
27e2f115
package
com.example.wordsapp
import
androidx.fragment.app.testing.launchFragmentInContainer
import
androidx.navigation.Navigation
import
androidx.navigation.testing.TestNavHostController
import
androidx.recyclerview.widget.RecyclerView
import
androidx.test.core.app.ApplicationProvider
import
androidx.test.espresso.Espresso.onView
import
androidx.test.espresso.action.ViewActions.click
import
androidx.test.espresso.contrib.RecyclerViewActions
import
androidx.test.espresso.matcher.ViewMatchers.withId
import
androidx.test.runner.AndroidJUnit4
import
junit.framework.Assert.assertEquals
import
org.junit.Test
import
org.junit.runner.RunWith
@RunWith
(
AndroidJUnit4
::
class
)
class
NavigationTests
{
@Test
fun
navigate_to_words_nav_component
()
{
val
navController
=
TestNavHostController
(
ApplicationProvider
.
getApplicationContext
()
)
val
letterListScenario
=
launchFragmentInContainer
<
LetterListFragment
>(
themeResId
=
R
.
style
.
Theme_Words
)
letterListScenario
.
onFragment
{
fragment
->
navController
.
setGraph
(
R
.
navigation
.
nav_graph
)
Navigation
.
setViewNavController
(
fragment
.
requireView
(),
navController
)
}
onView
(
withId
(
R
.
id
.
recycler_view
))
.
perform
(
RecyclerViewActions
.
actionOnItemAtPosition
<
RecyclerView
.
ViewHolder
>(
2
,
click
())
)
assertEquals
(
navController
.
currentDestination
?.
id
,
R
.
id
.
wordListFragment
)
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment