@@ -4,6 +4,7 @@ import android.content.ClipboardManager
4
4
import android.content.Context
5
5
import androidx.activity.ComponentActivity
6
6
import androidx.compose.runtime.mutableStateListOf
7
+ import androidx.compose.ui.Modifier
7
8
import androidx.compose.ui.platform.testTag
8
9
import androidx.compose.ui.test.assertIsDisplayed
9
10
import androidx.compose.ui.test.junit4.createAndroidComposeRule
@@ -91,9 +92,7 @@ class TerminalOutputAndroidTest {
91
92
TerminalOutput (
92
93
logs = logs,
93
94
autoScroll = false ,
94
- modifier =
95
- androidx.compose.ui.Modifier
96
- .testTag(" terminal" ),
95
+ modifier = Modifier .testTag(" terminal" ),
97
96
)
98
97
}
99
98
}
@@ -115,8 +114,7 @@ class TerminalOutputAndroidTest {
115
114
logs = logs,
116
115
autoScroll = false ,
117
116
modifier =
118
- androidx.compose.ui.Modifier
119
- .testTag(" terminal" ),
117
+ Modifier .testTag(" terminal" ),
120
118
)
121
119
}
122
120
}
@@ -134,4 +132,52 @@ class TerminalOutputAndroidTest {
134
132
?.toString()
135
133
assertThat(copied).isEqualTo(" " )
136
134
}
135
+
136
+ @Test
137
+ fun terminalOutput_autoScrollTrue_withEmptyList_isStable () {
138
+ // arrange
139
+ val logs = mutableStateListOf<OutputText >()
140
+
141
+ // act
142
+ composeRule.setContent {
143
+ UsbTerminalTheme {
144
+ TerminalOutput (
145
+ logs = logs,
146
+ autoScroll = true ,
147
+ modifier = Modifier .testTag(" terminal" ),
148
+ )
149
+ }
150
+ }
151
+
152
+ // assert: composable exists even with empty logs and autoScroll enabled
153
+ composeRule.onNodeWithTag(" terminal" ).assertExists().assertIsDisplayed()
154
+ }
155
+
156
+ @Test
157
+ fun terminalOutput_noAutoScroll_append_rendersNewItem () {
158
+ // arrange
159
+ val logs =
160
+ mutableStateListOf(
161
+ OutputText (" Initial" , OutputText .OutputType .TYPE_NORMAL ),
162
+ )
163
+
164
+ composeRule.setContent {
165
+ UsbTerminalTheme {
166
+ TerminalOutput (
167
+ logs = logs,
168
+ autoScroll = false ,
169
+ modifier = Modifier .testTag(" terminal" ),
170
+ )
171
+ }
172
+ }
173
+
174
+ // act: append a new line while autoScroll is disabled
175
+ composeRule.runOnUiThread {
176
+ logs.add(OutputText (" Next" , OutputText .OutputType .TYPE_NORMAL ))
177
+ }
178
+ composeRule.waitForIdle()
179
+
180
+ // assert: new item is rendered (if condition path with autoScroll=false evaluated)
181
+ composeRule.onNodeWithText(" Next" ).assertIsDisplayed()
182
+ }
137
183
}
0 commit comments