From a9f3ed3e46b1d9b79b9c482cefb4e24e27f0a997 Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Thu, 17 Feb 2022 14:34:08 -0800 Subject: [PATCH] Delete scenario test TextSemanticsFocusTest (flutter/engine#29370) --- .../flutter/testing/scenario_app/README.md | 2 +- .../Scenarios.xcodeproj/project.pbxproj | 6 - .../xcshareddata/xcschemes/Scenarios.xcscheme | 4 - .../ios/Scenarios/Scenarios/AppDelegate.m | 1 - .../ScenariosUITests/TextSemanticsFocusTest.h | 14 -- .../ScenariosUITests/TextSemanticsFocusTest.m | 87 ----------- .../scenario_app/lib/src/scenarios.dart | 2 - .../lib/src/send_text_focus_semantics.dart | 143 ------------------ 8 files changed, 1 insertion(+), 258 deletions(-) delete mode 100644 engine/src/flutter/testing/scenario_app/ios/Scenarios/ScenariosUITests/TextSemanticsFocusTest.h delete mode 100644 engine/src/flutter/testing/scenario_app/ios/Scenarios/ScenariosUITests/TextSemanticsFocusTest.m delete mode 100644 engine/src/flutter/testing/scenario_app/lib/src/send_text_focus_semantics.dart diff --git a/engine/src/flutter/testing/scenario_app/README.md b/engine/src/flutter/testing/scenario_app/README.md index fd68009ec7..b443eb4494 100644 --- a/engine/src/flutter/testing/scenario_app/README.md +++ b/engine/src/flutter/testing/scenario_app/README.md @@ -30,7 +30,7 @@ Build the `ios_debug_sim_unopt` engine variant, and run in your shell. To run or debug in Xcode, open the xcodeproj file located in -`/scenario_app/Scenarios/Scenaios.xoceproj`. +`/ios_debug_sim_unopt/scenario_app/Scenarios/Scenaios.xcodeproj`. ### iOS Platform View Tests diff --git a/engine/src/flutter/testing/scenario_app/ios/Scenarios/Scenarios.xcodeproj/project.pbxproj b/engine/src/flutter/testing/scenario_app/ios/Scenarios/Scenarios.xcodeproj/project.pbxproj index 94ff3c9549..af7c7321d3 100644 --- a/engine/src/flutter/testing/scenario_app/ios/Scenarios/Scenarios.xcodeproj/project.pbxproj +++ b/engine/src/flutter/testing/scenario_app/ios/Scenarios/Scenarios.xcodeproj/project.pbxproj @@ -8,7 +8,6 @@ /* Begin PBXBuildFile section */ 0A02E8F724EFAD27002D54E5 /* BogusFontTextTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A02E8F624EFAD27002D54E5 /* BogusFontTextTest.m */; }; - 0A42BFB42447E179007E212E /* TextSemanticsFocusTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A42BFB32447E179007E212E /* TextSemanticsFocusTest.m */; }; 0A57B3BD2323C4BD00DD9521 /* ScreenBeforeFlutter.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A57B3BC2323C4BD00DD9521 /* ScreenBeforeFlutter.m */; }; 0A57B3BF2323C74200DD9521 /* FlutterEngine+ScenariosTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A57B3BE2323C74200DD9521 /* FlutterEngine+ScenariosTest.m */; }; 0A57B3C22323D2D700DD9521 /* AppLifecycleTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A57B3C12323D2D700DD9521 /* AppLifecycleTests.m */; }; @@ -113,8 +112,6 @@ /* Begin PBXFileReference section */ 0A02E8F624EFAD27002D54E5 /* BogusFontTextTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BogusFontTextTest.m; sourceTree = ""; }; - 0A42BFB32447E179007E212E /* TextSemanticsFocusTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TextSemanticsFocusTest.m; sourceTree = ""; }; - 0A42BFB52447E19F007E212E /* TextSemanticsFocusTest.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TextSemanticsFocusTest.h; sourceTree = ""; }; 0A57B3BB2323C4BD00DD9521 /* ScreenBeforeFlutter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ScreenBeforeFlutter.h; sourceTree = ""; }; 0A57B3BC2323C4BD00DD9521 /* ScreenBeforeFlutter.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ScreenBeforeFlutter.m; sourceTree = ""; }; 0A57B3BE2323C74200DD9521 /* FlutterEngine+ScenariosTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "FlutterEngine+ScenariosTest.m"; sourceTree = ""; }; @@ -272,8 +269,6 @@ 68A5B63323EB71D300BDBCDB /* PlatformViewGestureRecognizerTests.m */, 0D8470A2240F0B1F0030B565 /* StatusBarTest.h */, 0D8470A3240F0B1F0030B565 /* StatusBarTest.m */, - 0A42BFB32447E179007E212E /* TextSemanticsFocusTest.m */, - 0A42BFB52447E19F007E212E /* TextSemanticsFocusTest.h */, 246A6610252E693A00EAB0F3 /* RenderingSelectionTest.m */, 0DDEBC88258830B40065D0E8 /* SpawnEngineTest.m */, F26F15B7268B6B5500EC54D3 /* iPadGestureTests.m */, @@ -494,7 +489,6 @@ F26F15B8268B6B5600EC54D3 /* iPadGestureTests.m in Sources */, 246A6611252E693A00EAB0F3 /* RenderingSelectionTest.m in Sources */, 4F06F1B32473296E000AF246 /* LocalizationInitializationTest.m in Sources */, - 0A42BFB42447E179007E212E /* TextSemanticsFocusTest.m in Sources */, 0DDEBC89258830B40065D0E8 /* SpawnEngineTest.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/engine/src/flutter/testing/scenario_app/ios/Scenarios/Scenarios.xcodeproj/xcshareddata/xcschemes/Scenarios.xcscheme b/engine/src/flutter/testing/scenario_app/ios/Scenarios/Scenarios.xcodeproj/xcshareddata/xcschemes/Scenarios.xcscheme index f189429128..8a13784bbe 100644 --- a/engine/src/flutter/testing/scenario_app/ios/Scenarios/Scenarios.xcodeproj/xcshareddata/xcschemes/Scenarios.xcscheme +++ b/engine/src/flutter/testing/scenario_app/ios/Scenarios/Scenarios.xcodeproj/xcshareddata/xcschemes/Scenarios.xcscheme @@ -82,10 +82,6 @@ argument = "--bogus-font-text" isEnabled = "NO"> - - diff --git a/engine/src/flutter/testing/scenario_app/ios/Scenarios/Scenarios/AppDelegate.m b/engine/src/flutter/testing/scenario_app/ios/Scenarios/Scenarios/AppDelegate.m index c2bbf24706..f69b402fa7 100644 --- a/engine/src/flutter/testing/scenario_app/ios/Scenarios/Scenarios/AppDelegate.m +++ b/engine/src/flutter/testing/scenario_app/ios/Scenarios/Scenarios/AppDelegate.m @@ -55,7 +55,6 @@ @"--gesture-reject-eager" : @"platform_view_gesture_reject_eager", @"--gesture-accept" : @"platform_view_gesture_accept", @"--tap-status-bar" : @"tap_status_bar", - @"--text-semantics-focus" : @"text_semantics_focus", @"--animated-color-square" : @"animated_color_square", @"--platform-view-with-continuous-texture" : @"platform_view_with_continuous_texture", @"--bogus-font-text" : @"bogus_font_text", diff --git a/engine/src/flutter/testing/scenario_app/ios/Scenarios/ScenariosUITests/TextSemanticsFocusTest.h b/engine/src/flutter/testing/scenario_app/ios/Scenarios/ScenariosUITests/TextSemanticsFocusTest.h deleted file mode 100644 index 45e0a5dd9b..0000000000 --- a/engine/src/flutter/testing/scenario_app/ios/Scenarios/ScenariosUITests/TextSemanticsFocusTest.h +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2020 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#import -#import - -NS_ASSUME_NONNULL_BEGIN - -@interface TextSemanticsFocusTest : XCTestCase -@property(nonatomic, strong) XCUIApplication* application; -@end - -NS_ASSUME_NONNULL_END diff --git a/engine/src/flutter/testing/scenario_app/ios/Scenarios/ScenariosUITests/TextSemanticsFocusTest.m b/engine/src/flutter/testing/scenario_app/ios/Scenarios/ScenariosUITests/TextSemanticsFocusTest.m deleted file mode 100644 index cd92e2cad7..0000000000 --- a/engine/src/flutter/testing/scenario_app/ios/Scenarios/ScenariosUITests/TextSemanticsFocusTest.m +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright 2020 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#import "TextSemanticsFocusTest.h" - -FLUTTER_ASSERT_ARC - -@interface XCUIElement (ftr_waitForNonExistence) -/// Keeps waiting until the element doesn't exist. Returns NO if the timeout is -/// reached before it doesn't exist. -- (BOOL)ftr_waitForNonExistenceWithTimeout:(NSTimeInterval)timeout; -/// Waits the full duration to ensure something doesn't exist for that duration. -/// Returns NO if at some point the element exists during the duration. -- (BOOL)ftr_waitForNonExistenceForDuration:(NSTimeInterval)duration; -@end - -@implementation XCUIElement (ftr_waitForNonExistence) -- (BOOL)ftr_waitForNonExistenceWithTimeout:(NSTimeInterval)timeout { - NSTimeInterval delta = 0.5; - while (timeout > 0.0) { - if (!self.exists) { - return YES; - } - usleep(delta * 1000000); - timeout -= delta; - } - return NO; -} - -- (BOOL)ftr_waitForNonExistenceForDuration:(NSTimeInterval)duration { - return ![self waitForExistenceWithTimeout:duration]; -} - -@end - -@implementation TextSemanticsFocusTest - -- (void)setUp { - [super setUp]; - self.continueAfterFailure = NO; - - self.application = [[XCUIApplication alloc] init]; - self.application.launchArguments = @[ @"--text-semantics-focus" ]; - [self.application launch]; -} - -- (void)skip_testAccessibilityFocusOnTextSemanticsProducesCorrectIosViews { - NSTimeInterval timeout = 10.0; - // Find the initial TextInputSemanticsObject which was sent from the mock framework on first - // frame. - XCUIElement* textInputSemanticsObject = - [[[self.application textFields] matchingIdentifier:@"flutter textfield"] element]; - XCTAssertTrue([textInputSemanticsObject waitForExistenceWithTimeout:timeout]); - XCTAssertEqualObjects([textInputSemanticsObject valueForKey:@"hasKeyboardFocus"], @(NO)); - - // Since the first mock framework text field isn't focused on, it shouldn't produce a UITextInput - // in the view hierarchy. - XCUIElement* delegateTextInput = [[self.application textViews] element]; - XCTAssertTrue([delegateTextInput ftr_waitForNonExistenceWithTimeout:timeout]); - - // Nor should there be a keyboard for text entry. - XCUIElement* keyboard = [[self.application keyboards] element]; - XCTAssertTrue([keyboard ftr_waitForNonExistenceWithTimeout:timeout]); - - // The tap location doesn't matter. The mock framework just sends a focused text field on tap. - [textInputSemanticsObject tap]; - - // The new TextInputSemanticsObject now has keyboard focus (the only trait accessible through - // UI tests on a XCUIElement). - textInputSemanticsObject = - [[[self.application textFields] matchingIdentifier:@"focused flutter textfield"] element]; - XCTAssertTrue([textInputSemanticsObject waitForExistenceWithTimeout:timeout]); - XCTAssertEqualObjects([textInputSemanticsObject valueForKey:@"hasKeyboardFocus"], @(YES)); - - // The delegate UITextInput is also inserted on the window but we make only the - // TextInputSemanticsObject visible and not the FlutterTextInputView to avoid confusing - // accessibility, it shouldn't be visible to the UI test either. - delegateTextInput = [[self.application textViews] element]; - XCTAssertTrue([delegateTextInput ftr_waitForNonExistenceForDuration:3.0]); - - // But since there is focus, the soft keyboard is visible on the simulator. - keyboard = [[self.application keyboards] element]; - XCTAssertTrue([keyboard waitForExistenceWithTimeout:timeout]); -} - -@end diff --git a/engine/src/flutter/testing/scenario_app/lib/src/scenarios.dart b/engine/src/flutter/testing/scenario_app/lib/src/scenarios.dart index 261467c9db..e7ff5bfcd2 100644 --- a/engine/src/flutter/testing/scenario_app/lib/src/scenarios.dart +++ b/engine/src/flutter/testing/scenario_app/lib/src/scenarios.dart @@ -11,7 +11,6 @@ import 'locale_initialization.dart'; import 'platform_view.dart'; import 'poppable_screen.dart'; import 'scenario.dart'; -import 'send_text_focus_semantics.dart'; import 'touches_scenario.dart'; typedef ScenarioFactory = Scenario Function(); // ignore: public_member_api_docs @@ -45,7 +44,6 @@ Map _scenarios = { 'platform_view_gesture_reject_after_touches_ended': () => PlatformViewForTouchIOSScenario(PlatformDispatcher.instance, 'platform view touch', id: _viewId++, accept: false, rejectUntilTouchesEnded: true), 'platform_view_scrolling_under_widget':()=>PlatformViewScrollingUnderWidget(PlatformDispatcher.instance, firstPlatformViewId: _viewId++, lastPlatformViewId: _viewId+=16), 'tap_status_bar': () => TouchesScenario(PlatformDispatcher.instance), - 'text_semantics_focus': () => SendTextFocusSemantics(PlatformDispatcher.instance), 'initial_route_reply': () => InitialRouteReply(PlatformDispatcher.instance), 'platform_view_with_continuous_texture': () => PlatformViewWithContinuousTexture(PlatformDispatcher.instance, 'Platform View', id: _viewId++), 'bogus_font_text': () => BogusFontText(PlatformDispatcher.instance), diff --git a/engine/src/flutter/testing/scenario_app/lib/src/send_text_focus_semantics.dart b/engine/src/flutter/testing/scenario_app/lib/src/send_text_focus_semantics.dart deleted file mode 100644 index 7ecc04b7d0..0000000000 --- a/engine/src/flutter/testing/scenario_app/lib/src/send_text_focus_semantics.dart +++ /dev/null @@ -1,143 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:typed_data'; -import 'dart:ui'; - -import 'package:vector_math/vector_math_64.dart'; - -import 'channel_util.dart'; -import 'scenario.dart'; - -/// A scenario that sends back messages when touches are received. -class SendTextFocusSemantics extends Scenario { - /// Constructor for `SendTextFocusScemantics`. - SendTextFocusSemantics(PlatformDispatcher dispatcher) : super(dispatcher); - - @override - void onBeginFrame(Duration duration) { - // Doesn't matter what we draw. Just paint white. - final SceneBuilder builder = SceneBuilder(); - final PictureRecorder recorder = PictureRecorder(); - final Canvas canvas = Canvas(recorder); - - canvas.drawRect( - Rect.fromLTWH(0, 0, window.physicalSize.width, window.physicalSize.height), - Paint()..color = const Color.fromARGB(255, 255, 255, 255), - ); - final Picture picture = recorder.endRecording(); - - builder.addPicture( - Offset.zero, - picture, - ); - final Scene scene = builder.build(); - window.render(scene); - scene.dispose(); - - // On the first frame, also pretend that it drew a text field. Send the - // corresponding semantics tree comprised of 1 node for the text field. - window.updateSemantics((SemanticsUpdateBuilder() - ..updateNode( - id: 0, - // SemanticsFlag.isTextField. - flags: 16, - // SemanticsAction.tap. - actions: 1, - rect: const Rect.fromLTRB(0.0, 0.0, 414.0, 48.0), - label: 'flutter textfield', - labelAttributes: [], - textDirection: TextDirection.ltr, - textSelectionBase: -1, - textSelectionExtent: -1, - platformViewId: -1, - maxValueLength: -1, - currentValueLength: 0, - scrollChildren: 0, - scrollIndex: 0, - scrollPosition: 0.0, - scrollExtentMax: 0.0, - scrollExtentMin: 0.0, - transform: Matrix4.identity().storage, - elevation: 0.0, - thickness: 0.0, - hint: '', - hintAttributes: [], - value: '', - valueAttributes: [], - increasedValue: '', - increasedValueAttributes: [], - decreasedValue: '', - decreasedValueAttributes: [], - tooltip: '', - childrenInTraversalOrder: Int32List(0), - childrenInHitTestOrder: Int32List(0), - additionalActions: Int32List(0), - )).build() - ); - } - - // We don't really care about the touch itself. It's just a way for the - // XCUITest to communicate timing to the mock framework. - @override - void onPointerDataPacket(PointerDataPacket packet) { - // This mimics the framework which shows the FlutterTextInputView before - // updating the TextInputSemanticsObject. - sendJsonMethodCall( - dispatcher: dispatcher, - channel: 'flutter/textinput', - method: 'TextInput.setClient', - arguments: [ - 1, - // The arguments are text field configurations. It doesn't really matter - // since we're just testing text field accessibility here. - { 'obscureText': false }, - ] - ); - - sendJsonMethodCall( - dispatcher: dispatcher, - channel: 'flutter/textinput', - method: 'TextInput.show', - ); - - window.updateSemantics((SemanticsUpdateBuilder() - ..updateNode( - id: 0, - // SemanticsFlag.isTextField and SemanticsFlag.isFocused. - flags: 48, - actions: 18433, - rect: const Rect.fromLTRB(0.0, 0.0, 414.0, 48.0), - label: 'focused flutter textfield', - labelAttributes: [], - textDirection: TextDirection.ltr, - textSelectionBase: 0, - textSelectionExtent: 0, - platformViewId: -1, - maxValueLength: -1, - currentValueLength: 0, - scrollChildren: 0, - scrollIndex: 0, - scrollPosition: 0.0, - scrollExtentMax: 0.0, - scrollExtentMin: 0.0, - transform: Matrix4.identity().storage, - elevation: 0.0, - thickness: 0.0, - hint: '', - hintAttributes: [], - value: '', - valueAttributes: [], - increasedValue: '', - increasedValueAttributes: [], - decreasedValue: '', - decreasedValueAttributes: [], - tooltip: '', - childrenInTraversalOrder: Int32List(0), - childrenInHitTestOrder: Int32List(0), - additionalActions: Int32List(0), - )).build() - ); - } -}