Skip to content

Commit fbf6818

Browse files
author
nturgut
authored
Enabling semantics tests for safari, ios-safari and firefox (flutter#22662)
* enable safari tests for almost all the methods for semantics tests * enable almost all semantics tests for firefox * Safari desktop have different scroll max values for different versions * fix assert
1 parent 291774a commit fbf6818

File tree

1 file changed

+45
-39
lines changed

1 file changed

+45
-39
lines changed

lib/web_ui/test/engine/semantics/semantics_test.dart

Lines changed: 45 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
// found in the LICENSE file.
44

55
// @dart = 2.6
6-
@TestOn('chrome')
7-
// TODO(nurhan): https://github.com/flutter/flutter/issues/50590
6+
@TestOn('chrome || safari || firefox')
87

98
import 'dart:async';
109
import 'dart:html' as html;
@@ -378,11 +377,17 @@ void _testContainer() {
378377
final html.Element container =
379378
html.document.querySelector('flt-semantics-container');
380379

381-
expect(parentElement.style.transform, 'matrix(1, 0, 0, 1, 10, 10)');
382-
expect(parentElement.style.transformOrigin, '0px 0px 0px');
383-
expect(container.style.transform, 'translate(-10px, -10px)');
384-
expect(container.style.transformOrigin, '0px 0px 0px');
385-
380+
if (isDesktop) {
381+
expect(parentElement.style.transform, 'matrix(1, 0, 0, 1, 10, 10)');
382+
expect(parentElement.style.transformOrigin, '0px 0px 0px');
383+
expect(container.style.transform, 'translate(-10px, -10px)');
384+
expect(container.style.transformOrigin, '0px 0px 0px');
385+
} else {
386+
expect(parentElement.style.top, '20px');
387+
expect(parentElement.style.left, '20px');
388+
expect(container.style.top, '-10px');
389+
expect(container.style.left, '-10px');
390+
}
386391
semantics().semanticsEnabled = false;
387392
},
388393
// TODO(nurhan): https://github.com/flutter/flutter/issues/50754
@@ -412,10 +417,8 @@ void _testVerticalScrolling() {
412417

413418
semantics().semanticsEnabled = false;
414419
},
415-
// TODO(nurhan): https://github.com/flutter/flutter/issues/50590
416420
// TODO(nurhan): https://github.com/flutter/flutter/issues/50754
417-
skip: browserEngine == BrowserEngine.webkit ||
418-
browserEngine == BrowserEngine.edge);
421+
skip: browserEngine == BrowserEngine.edge);
419422

420423
test('scrollable node with children has a container node', () async {
421424
semantics()
@@ -451,10 +454,8 @@ void _testVerticalScrolling() {
451454

452455
semantics().semanticsEnabled = false;
453456
},
454-
// TODO(nurhan): https://github.com/flutter/flutter/issues/50590
455457
// TODO(nurhan): https://github.com/flutter/flutter/issues/50754
456-
skip: browserEngine == BrowserEngine.webkit ||
457-
browserEngine == BrowserEngine.edge);
458+
skip: browserEngine == BrowserEngine.edge);
458459

459460
test('scrollable node dispatches scroll events', () async {
460461
final StreamController<int> idLogController = StreamController<int>();
@@ -495,7 +496,7 @@ void _testVerticalScrolling() {
495496
childrenInTraversalOrder: Int32List.fromList(<int>[1, 2, 3]),
496497
);
497498

498-
for (int id = 1; id <= 3; id++) {
499+
for (int id = 1; id <= 5; id++) {
499500
updateNode(
500501
builder,
501502
id: id,
@@ -520,29 +521,35 @@ void _testVerticalScrolling() {
520521
expect(scrollable, isNotNull);
521522

522523
// When there's more content than the available size the neutral scrollTop
523-
// is greater than 0 with a maximum of 10.
524-
expect(scrollable.scrollTop, 10);
524+
// is greater than 0 with a maximum of 10 or 9.
525+
int browserMaxScrollDiff = 0;
526+
// The max scroll value varies between `9` and `10` for Safari desktop
527+
// browsers.
528+
if (browserEngine == BrowserEngine.webkit &&
529+
operatingSystem == OperatingSystem.macOs) {
530+
browserMaxScrollDiff = 1;
531+
}
532+
533+
expect(scrollable.scrollTop >= (10 - browserMaxScrollDiff), isTrue);
525534

526535
scrollable.scrollTop = 20;
527536
expect(scrollable.scrollTop, 20);
528537
expect(await idLog.first, 0);
529538
expect(await actionLog.first, ui.SemanticsAction.scrollUp);
530539
// Engine semantics returns scroll top back to neutral.
531-
expect(scrollable.scrollTop, 10);
540+
expect(scrollable.scrollTop >= (10 - browserMaxScrollDiff), isTrue);
532541

533542
scrollable.scrollTop = 5;
534-
expect(scrollable.scrollTop, 5);
543+
expect(scrollable.scrollTop >= (5 - browserMaxScrollDiff), isTrue);
535544
expect(await idLog.first, 0);
536545
expect(await actionLog.first, ui.SemanticsAction.scrollDown);
537546
// Engine semantics returns scroll top back to neutral.
538-
expect(scrollable.scrollTop, 10);
547+
expect(scrollable.scrollTop >= (10 - browserMaxScrollDiff), isTrue);
539548

540549
semantics().semanticsEnabled = false;
541550
},
542551
// TODO(nurhan): https://github.com/flutter/flutter/issues/50754
543-
// TODO(nurhan): https://github.com/flutter/flutter/issues/50590
544-
skip: browserEngine == BrowserEngine.webkit ||
545-
browserEngine == BrowserEngine.edge);
552+
skip: browserEngine == BrowserEngine.edge);
546553
}
547554

548555
void _testHorizontalScrolling() {
@@ -568,10 +575,8 @@ void _testHorizontalScrolling() {
568575

569576
semantics().semanticsEnabled = false;
570577
},
571-
// TODO(nurhan): https://github.com/flutter/flutter/issues/50590
572578
// TODO(nurhan): https://github.com/flutter/flutter/issues/50754
573-
skip: browserEngine == BrowserEngine.webkit ||
574-
browserEngine == BrowserEngine.edge);
579+
skip: browserEngine == BrowserEngine.edge);
575580

576581
test('scrollable node with children has a container node', () async {
577582
semantics()
@@ -607,10 +612,8 @@ void _testHorizontalScrolling() {
607612

608613
semantics().semanticsEnabled = false;
609614
},
610-
// TODO(nurhan): https://github.com/flutter/flutter/issues/50590
611615
// TODO(nurhan): https://github.com/flutter/flutter/issues/50754
612-
skip: browserEngine == BrowserEngine.webkit ||
613-
browserEngine == BrowserEngine.edge);
616+
skip: browserEngine == BrowserEngine.edge);
614617

615618
test('scrollable node dispatches scroll events', () async {
616619
final SemanticsActionLogger logger = SemanticsActionLogger();
@@ -658,28 +661,33 @@ void _testHorizontalScrolling() {
658661

659662
// When there's more content than the available size the neutral scrollTop
660663
// is greater than 0 with a maximum of 10.
661-
expect(scrollable.scrollLeft, 10);
664+
int browserMaxScrollDiff = 0;
665+
// The max scroll value varies between `9` and `10` for Safari desktop
666+
// browsers.
667+
if (browserEngine == BrowserEngine.webkit &&
668+
operatingSystem == OperatingSystem.macOs) {
669+
browserMaxScrollDiff = 1;
670+
}
671+
expect(scrollable.scrollLeft >= (10 - browserMaxScrollDiff), isTrue);
662672

663673
scrollable.scrollLeft = 20;
664674
expect(scrollable.scrollLeft, 20);
665675
expect(await logger.idLog.first, 0);
666676
expect(await logger.actionLog.first, ui.SemanticsAction.scrollLeft);
667677
// Engine semantics returns scroll position back to neutral.
668-
expect(scrollable.scrollLeft, 10);
678+
expect(scrollable.scrollLeft >= (10 - browserMaxScrollDiff), isTrue);
669679

670680
scrollable.scrollLeft = 5;
671-
expect(scrollable.scrollLeft, 5);
681+
expect(scrollable.scrollLeft >= (5 - browserMaxScrollDiff), isTrue);
672682
expect(await logger.idLog.first, 0);
673683
expect(await logger.actionLog.first, ui.SemanticsAction.scrollRight);
674684
// Engine semantics returns scroll top back to neutral.
675-
expect(scrollable.scrollLeft, 10);
685+
expect(scrollable.scrollLeft >= (10 - browserMaxScrollDiff), isTrue);
676686

677687
semantics().semanticsEnabled = false;
678688
},
679-
// TODO(nurhan): https://github.com/flutter/flutter/issues/50590
680689
// TODO(nurhan): https://github.com/flutter/flutter/issues/50754
681-
skip: browserEngine == BrowserEngine.webkit ||
682-
browserEngine == BrowserEngine.edge);
690+
skip: browserEngine == BrowserEngine.edge);
683691
}
684692

685693
void _testIncrementables() {
@@ -878,7 +886,7 @@ void _testTextField() {
878886
expect(await logger.actionLog.first, ui.SemanticsAction.tap);
879887

880888
semantics().semanticsEnabled = false;
881-
}, // TODO(nurhan): https://github.com/flutter/flutter/issues/46638
889+
}, // TODO(nurhan): https://github.com/flutter/flutter/issues/46638
882890
// TODO(nurhan): https://github.com/flutter/flutter/issues/50590
883891
// TODO(nurhan): https://github.com/flutter/flutter/issues/50754
884892
skip: (browserEngine != BrowserEngine.blink));
@@ -1197,10 +1205,8 @@ void _testTappable() {
11971205

11981206
semantics().semanticsEnabled = false;
11991207
},
1200-
// TODO(nurhan): https://github.com/flutter/flutter/issues/50590
12011208
// TODO(nurhan): https://github.com/flutter/flutter/issues/50754
1202-
skip: browserEngine == BrowserEngine.webkit ||
1203-
browserEngine == BrowserEngine.edge);
1209+
skip: browserEngine == BrowserEngine.edge);
12041210
}
12051211

12061212
void _testImage() {

0 commit comments

Comments
 (0)