Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 45 additions & 39 deletions lib/web_ui/test/engine/semantics/semantics_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
// found in the LICENSE file.

// @dart = 2.6
@TestOn('chrome')
// TODO(nurhan): https://github.com/flutter/flutter/issues/50590
@TestOn('chrome || safari || firefox')

import 'dart:async';
import 'dart:html' as html;
Expand Down Expand Up @@ -378,11 +377,17 @@ void _testContainer() {
final html.Element container =
html.document.querySelector('flt-semantics-container');

expect(parentElement.style.transform, 'matrix(1, 0, 0, 1, 10, 10)');
expect(parentElement.style.transformOrigin, '0px 0px 0px');
expect(container.style.transform, 'translate(-10px, -10px)');
expect(container.style.transformOrigin, '0px 0px 0px');

if (isDesktop) {
expect(parentElement.style.transform, 'matrix(1, 0, 0, 1, 10, 10)');
expect(parentElement.style.transformOrigin, '0px 0px 0px');
expect(container.style.transform, 'translate(-10px, -10px)');
expect(container.style.transformOrigin, '0px 0px 0px');
} else {
expect(parentElement.style.top, '20px');
expect(parentElement.style.left, '20px');
expect(container.style.top, '-10px');
expect(container.style.left, '-10px');
}
semantics().semanticsEnabled = false;
},
// TODO(nurhan): https://github.com/flutter/flutter/issues/50754
Expand Down Expand Up @@ -412,10 +417,8 @@ void _testVerticalScrolling() {

semantics().semanticsEnabled = false;
},
// TODO(nurhan): https://github.com/flutter/flutter/issues/50590
// TODO(nurhan): https://github.com/flutter/flutter/issues/50754
skip: browserEngine == BrowserEngine.webkit ||
browserEngine == BrowserEngine.edge);
skip: browserEngine == BrowserEngine.edge);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file isn't running on edge anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's true. I think I'll create another PR for removing all edge requirements though. Since our Edge testing code is for legacy edge. If we change it to new Edge all should pass (I hope :) )


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

semantics().semanticsEnabled = false;
},
// TODO(nurhan): https://github.com/flutter/flutter/issues/50590
// TODO(nurhan): https://github.com/flutter/flutter/issues/50754
skip: browserEngine == BrowserEngine.webkit ||
browserEngine == BrowserEngine.edge);
skip: browserEngine == BrowserEngine.edge);

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

for (int id = 1; id <= 3; id++) {
for (int id = 1; id <= 5; id++) {
updateNode(
builder,
id: id,
Expand All @@ -520,29 +521,35 @@ void _testVerticalScrolling() {
expect(scrollable, isNotNull);

// When there's more content than the available size the neutral scrollTop
// is greater than 0 with a maximum of 10.
expect(scrollable.scrollTop, 10);
// is greater than 0 with a maximum of 10 or 9.
int browserMaxScrollDiff = 0;
// The max scroll value varies between `9` and `10` for Safari desktop
// browsers.
if (browserEngine == BrowserEngine.webkit &&
operatingSystem == OperatingSystem.macOs) {
browserMaxScrollDiff = 1;
}

expect(scrollable.scrollTop >= (10 - browserMaxScrollDiff), isTrue);

scrollable.scrollTop = 20;
expect(scrollable.scrollTop, 20);
expect(await idLog.first, 0);
expect(await actionLog.first, ui.SemanticsAction.scrollUp);
// Engine semantics returns scroll top back to neutral.
expect(scrollable.scrollTop, 10);
expect(scrollable.scrollTop >= (10 - browserMaxScrollDiff), isTrue);

scrollable.scrollTop = 5;
expect(scrollable.scrollTop, 5);
expect(scrollable.scrollTop >= (5 - browserMaxScrollDiff), isTrue);
expect(await idLog.first, 0);
expect(await actionLog.first, ui.SemanticsAction.scrollDown);
// Engine semantics returns scroll top back to neutral.
expect(scrollable.scrollTop, 10);
expect(scrollable.scrollTop >= (10 - browserMaxScrollDiff), isTrue);

semantics().semanticsEnabled = false;
},
// TODO(nurhan): https://github.com/flutter/flutter/issues/50754
// TODO(nurhan): https://github.com/flutter/flutter/issues/50590
skip: browserEngine == BrowserEngine.webkit ||
browserEngine == BrowserEngine.edge);
skip: browserEngine == BrowserEngine.edge);
}

void _testHorizontalScrolling() {
Expand All @@ -568,10 +575,8 @@ void _testHorizontalScrolling() {

semantics().semanticsEnabled = false;
},
// TODO(nurhan): https://github.com/flutter/flutter/issues/50590
// TODO(nurhan): https://github.com/flutter/flutter/issues/50754
skip: browserEngine == BrowserEngine.webkit ||
browserEngine == BrowserEngine.edge);
skip: browserEngine == BrowserEngine.edge);

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

semantics().semanticsEnabled = false;
},
// TODO(nurhan): https://github.com/flutter/flutter/issues/50590
// TODO(nurhan): https://github.com/flutter/flutter/issues/50754
skip: browserEngine == BrowserEngine.webkit ||
browserEngine == BrowserEngine.edge);
skip: browserEngine == BrowserEngine.edge);

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

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

scrollable.scrollLeft = 20;
expect(scrollable.scrollLeft, 20);
expect(await logger.idLog.first, 0);
expect(await logger.actionLog.first, ui.SemanticsAction.scrollLeft);
// Engine semantics returns scroll position back to neutral.
expect(scrollable.scrollLeft, 10);
expect(scrollable.scrollLeft >= (10 - browserMaxScrollDiff), isTrue);

scrollable.scrollLeft = 5;
expect(scrollable.scrollLeft, 5);
expect(scrollable.scrollLeft >= (5 - browserMaxScrollDiff), isTrue);
expect(await logger.idLog.first, 0);
expect(await logger.actionLog.first, ui.SemanticsAction.scrollRight);
// Engine semantics returns scroll top back to neutral.
expect(scrollable.scrollLeft, 10);
expect(scrollable.scrollLeft >= (10 - browserMaxScrollDiff), isTrue);

semantics().semanticsEnabled = false;
},
// TODO(nurhan): https://github.com/flutter/flutter/issues/50590
// TODO(nurhan): https://github.com/flutter/flutter/issues/50754
skip: browserEngine == BrowserEngine.webkit ||
browserEngine == BrowserEngine.edge);
skip: browserEngine == BrowserEngine.edge);
}

void _testIncrementables() {
Expand Down Expand Up @@ -878,7 +886,7 @@ void _testTextField() {
expect(await logger.actionLog.first, ui.SemanticsAction.tap);

semantics().semanticsEnabled = false;
}, // TODO(nurhan): https://github.com/flutter/flutter/issues/46638
}, // TODO(nurhan): https://github.com/flutter/flutter/issues/46638
// TODO(nurhan): https://github.com/flutter/flutter/issues/50590
// TODO(nurhan): https://github.com/flutter/flutter/issues/50754
skip: (browserEngine != BrowserEngine.blink));
Expand Down Expand Up @@ -1197,10 +1205,8 @@ void _testTappable() {

semantics().semanticsEnabled = false;
},
// TODO(nurhan): https://github.com/flutter/flutter/issues/50590
// TODO(nurhan): https://github.com/flutter/flutter/issues/50754
skip: browserEngine == BrowserEngine.webkit ||
browserEngine == BrowserEngine.edge);
skip: browserEngine == BrowserEngine.edge);
}

void _testImage() {
Expand Down