@@ -36,6 +36,7 @@ import androidx.compose.ui.platform.LocalHapticFeedback
36
36
import androidx.compose.ui.platform.LocalLayoutDirection
37
37
import androidx.compose.ui.platform.LocalTextToolbar
38
38
import androidx.compose.ui.platform.testTag
39
+ import androidx.compose.ui.test.center
39
40
import androidx.compose.ui.test.click
40
41
import androidx.compose.ui.test.hasTestTag
41
42
import androidx.compose.ui.test.junit4.createAndroidComposeRule
@@ -49,7 +50,6 @@ import androidx.compose.ui.unit.LayoutDirection
49
50
import androidx.compose.ui.unit.dp
50
51
import androidx.compose.ui.unit.sp
51
52
import androidx.test.ext.junit.runners.AndroidJUnit4
52
- import androidx.test.filters.FlakyTest
53
53
import androidx.test.filters.LargeTest
54
54
import com.google.common.truth.Truth.assertThat
55
55
import com.nhaarman.mockitokotlin2.mock
@@ -78,11 +78,9 @@ class SelectionContainerFocusTest {
78
78
79
79
private val hapticFeedback = mock<HapticFeedback >()
80
80
81
- @FlakyTest(bugId = 179770443 )
82
81
@Test
83
- fun click_anywhere_to_cancel () {
82
+ fun tap_to_cancel () {
84
83
// Setup. Long press to create a selection.
85
- // A reasonable number.
86
84
createSelectionContainer()
87
85
// Touch position. In this test, each character's width and height equal to fontSize.
88
86
// Position is computed so that (position, position) is the center of the first character.
@@ -95,14 +93,9 @@ class SelectionContainerFocusTest {
95
93
assertThat(selection1.value).isNotNull()
96
94
}
97
95
98
- // Touch position. In this test, each character's width and height equal to fontSize.
99
- // Position is computed so that (position, position) is the center of the first character.
100
- val positionInBox = with (Density (view.context)) {
101
- boxSize.toPx() / 2
102
- }
103
96
// Act.
104
97
rule.onNode(hasTestTag(" box" ))
105
- .performGesture { click(Offset (x = positionInBox, y = positionInBox) ) }
98
+ .performGesture { click(center ) }
106
99
107
100
// Assert.
108
101
rule.runOnIdle {
@@ -118,7 +111,6 @@ class SelectionContainerFocusTest {
118
111
@Test
119
112
fun select_anotherContainer_cancelOld () {
120
113
// Setup. Long press to create a selection.
121
- // A reasonable number.
122
114
createSelectionContainer()
123
115
// Touch position. In this test, each character's width and height equal to fontSize.
124
116
// Position is computed so that (position, position) is the center of the first character.
@@ -168,16 +160,19 @@ class SelectionContainerFocusTest {
168
160
selection1.value = it
169
161
}
170
162
) {
171
- CoreText (
172
- AnnotatedString (textContent),
173
- Modifier .fillMaxWidth(),
174
- style = TextStyle (fontFamily = fontFamily, fontSize = fontSize),
175
- softWrap = true ,
176
- overflow = TextOverflow .Clip ,
177
- maxLines = Int .MAX_VALUE ,
178
- inlineContent = mapOf (),
179
- onTextLayout = {}
180
- )
163
+ Column {
164
+ CoreText (
165
+ AnnotatedString (textContent),
166
+ Modifier .fillMaxWidth(),
167
+ style = TextStyle (fontFamily = fontFamily, fontSize = fontSize),
168
+ softWrap = true ,
169
+ overflow = TextOverflow .Clip ,
170
+ maxLines = Int .MAX_VALUE ,
171
+ inlineContent = mapOf (),
172
+ onTextLayout = {}
173
+ )
174
+ Box (Modifier .size(boxSize, boxSize).testTag(" box" ))
175
+ }
181
176
}
182
177
183
178
SelectionContainer (
@@ -200,8 +195,6 @@ class SelectionContainerFocusTest {
200
195
onTextLayout = {}
201
196
)
202
197
}
203
-
204
- Box (Modifier .size(boxSize, boxSize).testTag(" box" ))
205
198
}
206
199
}
207
200
}
0 commit comments