@@ -67,6 +67,8 @@ void main() {
67
67
'0123456789ABCDEFGHIJ'
68
68
'0123456789ABCDEFGHIJ'
69
69
'0123456789ABCDEFGHIJ' ;
70
+
71
+ const String testVerticalText = '1\n 2\n 3\n 4\n 5\n 6\n 7\n 8\n 9' ;
70
72
final TextEditingController controller = TextEditingController (text: testText);
71
73
72
74
final FocusNode focusNode = FocusNode ();
@@ -2043,7 +2045,8 @@ void main() {
2043
2045
}, variant: appleOnly);
2044
2046
});
2045
2047
2046
- testWidgets ('vertical movement' , (WidgetTester tester) async {
2048
+ testWidgets ('vertical movement outside of selection' ,
2049
+ (WidgetTester tester) async {
2047
2050
controller.text = testText;
2048
2051
controller.selection = const TextSelection .collapsed (
2049
2052
offset: 0 ,
@@ -2052,6 +2055,10 @@ void main() {
2052
2055
await tester.pumpWidget (buildEditableText ());
2053
2056
2054
2057
for (final SingleActivator activator in allModifierVariants (LogicalKeyboardKey .arrowDown)) {
2058
+ // Skip for the shift shortcut since web accepts it.
2059
+ if (activator.shift) {
2060
+ continue ;
2061
+ }
2055
2062
await sendKeyCombination (tester, activator);
2056
2063
await tester.pump ();
2057
2064
@@ -2201,4 +2208,102 @@ void main() {
2201
2208
}, variant: appleOnly);
2202
2209
2203
2210
}, skip: ! kIsWeb);// [intended] specific tests target web.
2211
+
2212
+ group ('Web does accept' , () {
2213
+ testWidgets ('select up' , (WidgetTester tester) async {
2214
+ const SingleActivator selectUp =
2215
+ SingleActivator (LogicalKeyboardKey .arrowUp, shift: true );
2216
+ controller.text = testVerticalText;
2217
+ controller.selection = const TextSelection .collapsed (
2218
+ offset: 5 ,
2219
+ );
2220
+
2221
+ await tester.pumpWidget (buildEditableText ());
2222
+ await sendKeyCombination (tester, selectUp);
2223
+ await tester.pump ();
2224
+
2225
+ expect (controller.text, testVerticalText);
2226
+ expect (
2227
+ controller.selection,
2228
+ const TextSelection (
2229
+ baseOffset: 5 ,
2230
+ extentOffset: 3 ), // selection extends upwards from 5
2231
+ reason: selectUp.toString (),
2232
+ );
2233
+ }, variant: TargetPlatformVariant .desktop ());
2234
+
2235
+ testWidgets ('select down' , (WidgetTester tester) async {
2236
+ const SingleActivator selectDown =
2237
+ SingleActivator (LogicalKeyboardKey .arrowDown, shift: true );
2238
+ controller.text = testVerticalText;
2239
+ controller.selection = const TextSelection .collapsed (
2240
+ offset: 5 ,
2241
+ );
2242
+
2243
+ await tester.pumpWidget (buildEditableText ());
2244
+ await sendKeyCombination (tester, selectDown);
2245
+ await tester.pump ();
2246
+
2247
+ expect (controller.text, testVerticalText);
2248
+ expect (
2249
+ controller.selection,
2250
+ const TextSelection (
2251
+ baseOffset: 5 ,
2252
+ extentOffset: 7 ), // selection extends downwards from 5
2253
+ reason: selectDown.toString (),
2254
+ );
2255
+ }, variant: TargetPlatformVariant .desktop ());
2256
+
2257
+ testWidgets ('select all up' , (WidgetTester tester) async {
2258
+ final bool isMacOS = defaultTargetPlatform == TargetPlatform .macOS;
2259
+ final SingleActivator selectAllUp = isMacOS
2260
+ ? const SingleActivator (LogicalKeyboardKey .arrowUp,
2261
+ shift: true , meta: true )
2262
+ : const SingleActivator (LogicalKeyboardKey .arrowUp,
2263
+ shift: true , alt: true );
2264
+ controller.text = testVerticalText;
2265
+ controller.selection = const TextSelection .collapsed (
2266
+ offset: 5 ,
2267
+ );
2268
+
2269
+ await tester.pumpWidget (buildEditableText ());
2270
+ await sendKeyCombination (tester, selectAllUp);
2271
+ await tester.pump ();
2272
+
2273
+ expect (controller.text, testVerticalText);
2274
+ expect (
2275
+ controller.selection,
2276
+ const TextSelection (
2277
+ baseOffset: 5 ,
2278
+ extentOffset: 0 ), // selection extends all the way up
2279
+ reason: selectAllUp.toString (),
2280
+ );
2281
+ }, variant: TargetPlatformVariant .desktop ());
2282
+
2283
+ testWidgets ('select all down' , (WidgetTester tester) async {
2284
+ final bool isMacOS = defaultTargetPlatform == TargetPlatform .macOS;
2285
+ final SingleActivator selectAllDown = isMacOS
2286
+ ? const SingleActivator (LogicalKeyboardKey .arrowDown,
2287
+ shift: true , meta: true )
2288
+ : const SingleActivator (LogicalKeyboardKey .arrowDown,
2289
+ shift: true , alt: true );
2290
+ controller.text = testVerticalText;
2291
+ controller.selection = const TextSelection .collapsed (
2292
+ offset: 5 ,
2293
+ );
2294
+
2295
+ await tester.pumpWidget (buildEditableText ());
2296
+ await sendKeyCombination (tester, selectAllDown);
2297
+ await tester.pump ();
2298
+
2299
+ expect (controller.text, testVerticalText);
2300
+ expect (
2301
+ controller.selection,
2302
+ const TextSelection (
2303
+ baseOffset: 5 ,
2304
+ extentOffset: 17 ), // selection extends all the way down
2305
+ reason: selectAllDown.toString (),
2306
+ );
2307
+ }, variant: TargetPlatformVariant .desktop ());
2308
+ }, skip: ! kIsWeb); // [intended] specific tests target web.
2204
2309
}
0 commit comments