Skip to content

Commit

Permalink
fix testVerticalFlutterScrollableSemanticsObjectNoWindow flake (flutt…
Browse files Browse the repository at this point in the history
  • Loading branch information
chunhtai authored Jan 24, 2022
1 parent 28abc80 commit d92219e
Showing 1 changed file with 2 additions and 26 deletions.
28 changes: 2 additions & 26 deletions shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm
Original file line number Diff line number Diff line change
Expand Up @@ -237,15 +237,12 @@ - (void)testVerticalFlutterScrollableSemanticsObject {
CGPointMake(0, scrollPosition * effectivelyScale)));
}

- (void)testVerticalFlutterScrollableSemanticsObjectNoWindow {
- (void)testVerticalFlutterScrollableSemanticsObjectNoWindowDoesNotCrash {
fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(
new flutter::MockAccessibilityBridgeNoWindow());
fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();

float transformScale = 0.5f;
float screenScale =
[UIScreen mainScreen].scale; // Flutter view without window uses [UIScreen mainScreen];
float effectivelyScale = transformScale / screenScale;
float x = 10;
float y = 10;
float w = 100;
Expand All @@ -265,28 +262,7 @@ - (void)testVerticalFlutterScrollableSemanticsObjectNoWindow {
[[FlutterScrollableSemanticsObject alloc] initWithBridge:bridge uid:0];
[scrollable setSemanticsNode:&node];
[scrollable accessibilityBridgeDidFinishUpdate];
UIScrollView* scrollView = [scrollable nativeAccessibility];

CGRect actualFrame = scrollView.frame;
CGRect expectedFrame = CGRectMake(x * effectivelyScale, y * effectivelyScale,
w * effectivelyScale, h * effectivelyScale);
XCTAssertTrue(CGRectEqualToRect(actualFrame, expectedFrame),
@"Scroll view %@ frame is %@, expected %@", scrollView,
NSStringFromCGRect(actualFrame), NSStringFromCGRect(expectedFrame));

CGSize actualContentSize = scrollView.contentSize;
CGSize expectedContentSize =
CGSizeMake(w * effectivelyScale, (h + scrollExtentMax) * effectivelyScale);
XCTAssertTrue(CGSizeEqualToSize(actualContentSize, expectedContentSize),
@"Scroll view %@ size is %@, expected %@", scrollView,
NSStringFromCGSize(actualContentSize), NSStringFromCGSize(expectedContentSize));

CGPoint actualContentOffset = scrollView.contentOffset;
CGPoint expectedContentOffset = CGPointMake(0, scrollPosition * effectivelyScale);
XCTAssertTrue(CGPointEqualToPoint(actualContentOffset, expectedContentOffset),
@"Scroll view %@ offset is %@, expected %@", scrollView,
NSStringFromCGPoint(actualContentOffset),
NSStringFromCGPoint(expectedContentOffset));
XCTAssertNoThrow([scrollable accessibilityBridgeDidFinishUpdate]);
}

- (void)testHorizontalFlutterScrollableSemanticsObject {
Expand Down

0 comments on commit d92219e

Please sign in to comment.