forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove currentLocale prepend on iOS (flutter#18379)
- Loading branch information
Showing
6 changed files
with
112 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
testing/scenario_app/ios/Scenarios/ScenariosUITests/LocalizationInitializationTest.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// 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 <Flutter/Flutter.h> | ||
#import <XCTest/XCTest.h> | ||
|
||
FLUTTER_ASSERT_ARC | ||
|
||
@interface LocalizationInitializationTest : XCTestCase | ||
@property(nonatomic, strong) XCUIApplication* application; | ||
@end | ||
|
||
@implementation LocalizationInitializationTest | ||
|
||
- (void)setUp { | ||
[super setUp]; | ||
self.continueAfterFailure = NO; | ||
|
||
self.application = [[XCUIApplication alloc] init]; | ||
self.application.launchArguments = @[ @"--locale-initialization" ]; | ||
[self.application launch]; | ||
} | ||
|
||
- (void)testNoLocalePrepend { | ||
NSTimeInterval timeout = 10.0; | ||
|
||
XCUIElement* textInputSemanticsObject = | ||
[self.application.textFields matchingIdentifier:@"[en]"].element; | ||
|
||
// The locales recieved by dart:ui are exposed onBeginFrame via semantics label. | ||
// There should only be one locale, as we have removed the locale prepend on iOS. | ||
XCTAssertTrue([textInputSemanticsObject waitForExistenceWithTimeout:timeout]); | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// 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 'dart:typed_data'; | ||
import 'dart:ui'; | ||
|
||
import 'package:vector_math/vector_math_64.dart'; | ||
|
||
import 'scenario.dart'; | ||
|
||
/// Sends the recieved locale data back as semantics information. | ||
class LocaleInitialization extends Scenario { | ||
/// Constructor | ||
LocaleInitialization(Window window) | ||
: assert(window != null), | ||
super(window); | ||
|
||
@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, pretend that it drew a text field. Send the | ||
// corresponding semantics tree comprised of 1 node with the locale data | ||
// as the label. | ||
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: window.locales.toString(), | ||
textDirection: TextDirection.ltr, | ||
textSelectionBase: -1, | ||
textSelectionExtent: -1, | ||
platformViewId: -1, | ||
maxValueLength: -1, | ||
currentValueLength: 0, | ||
scrollChildren: 0, | ||
scrollIndex: 0, | ||
transform: Matrix4.identity().storage, | ||
elevation: 0.0, | ||
thickness: 0.0, | ||
childrenInTraversalOrder: Int32List(0), | ||
childrenInHitTestOrder: Int32List(0), | ||
additionalActions: Int32List(0), | ||
)).build() | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters