Skip to content

Commit 0c9445b

Browse files
author
thirumani-vihaan
committed
Add missing KDoc documentation to MainFragmentStateTest.kt
1 parent 5944be0 commit 0c9445b

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

app/src/test/java/com/amaze/filemanager/ui/fragments/MainFragmentStateTest.kt

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ class MainFragmentStateTest {
6060

6161
private lateinit var scenario: ActivityScenario<MainActivity>
6262

63+
/**
64+
* Sets up the RxJava and RxAndroid schedulers to run synchronously for testing.
65+
*/
6366
@Before
6467
fun setUp() {
6568
RxJavaPlugins.reset()
@@ -70,6 +73,9 @@ class MainFragmentStateTest {
7073
ShadowSQLiteConnection.reset()
7174
}
7275

76+
/**
77+
* Cleans up the Rx schedulers and releases the activity scenario.
78+
*/
7379
@After
7480
fun tearDown() {
7581
if (::scenario.isInitialized) {
@@ -82,6 +88,10 @@ class MainFragmentStateTest {
8288

8389
private fun MainActivity.firstMainFragment(): MainFragment? = getTabFragment()?.getFragmentAtIndex(0) as? MainFragment
8490

91+
/**
92+
* Verifies that the MainFragment correctly persists its internal state
93+
* (currentPath and openMode) across activity recreation (e.g., rotation).
94+
*/
8595
@Test
8696
fun testMainFragmentSavesAndRestoresState() {
8797
scenario = ActivityScenario.launch(MainActivity::class.java)
@@ -94,8 +104,8 @@ class MainFragmentStateTest {
94104
val viewModel = mainFragment!!.mainFragmentViewModel
95105

96106
// Set custom state that is different from default
97-
viewModel.currentPath = "0"
98-
viewModel.openMode = OpenMode.CUSTOM
107+
viewModel!!.currentPath = "0"
108+
viewModel!!.openMode = OpenMode.CUSTOM
99109
}
100110

101111
// Trigger recreation (simulates configuration change/process death)
@@ -107,8 +117,8 @@ class MainFragmentStateTest {
107117
assertNotNull("MainFragment must be restored", mainFragment)
108118
val viewModel = mainFragment!!.mainFragmentViewModel
109119

110-
assertEquals("Path should be restored after recreation", "0", viewModel.currentPath)
111-
assertEquals("OpenMode should be restored after recreation", OpenMode.CUSTOM, viewModel.openMode)
120+
assertEquals("Path should be restored after recreation", "0", viewModel!!.currentPath)
121+
assertEquals("OpenMode should be restored after recreation", OpenMode.CUSTOM, viewModel!!.openMode)
112122
}
113123
}
114124
}

screenshot.png

241 KB
Loading

0 commit comments

Comments
 (0)