Skip to content

Commit 0dd0c2e

Browse files
authored
[platform_view]Send platform message when platform view is focused (#105050)
1 parent 94e3184 commit 0dd0c2e

File tree

15 files changed

+522
-57
lines changed

15 files changed

+522
-57
lines changed

.ci.yaml

+11
Original file line numberDiff line numberDiff line change
@@ -3657,6 +3657,17 @@ targets:
36573657
- bin/**
36583658
- .ci.yaml
36593659

3660+
- name: Mac native_platform_view_ui_tests_ios
3661+
bringup: true
3662+
recipe: devicelab/devicelab_drone
3663+
presubmit: false
3664+
timeout: 60
3665+
properties:
3666+
tags: >
3667+
["devicelab", "hostonly"]
3668+
task_name: native_platform_view_ui_tests_ios
3669+
scheduler: luci
3670+
36603671
- name: Mac run_release_test_macos
36613672
recipe: devicelab/devicelab_drone
36623673
timeout: 60

TESTOWNERS

+1-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@
195195
/dev/devicelab/bin/tasks/module_custom_host_app_name_test.dart @zanderso @flutter/tool
196196
/dev/devicelab/bin/tasks/module_host_with_custom_build_test.dart @zanderso @flutter/tool
197197
/dev/devicelab/bin/tasks/module_test.dart @zanderso @flutter/tool
198-
/dev/devicelab/bin/tasks/native_ui_tests_ios.dart @jmagman @flutter/engine
198+
/dev/devicelab/bin/tasks/native_platform_view_ui_tests_ios.dart @hellohuanlin @flutter/ios
199199
/dev/devicelab/bin/tasks/native_ui_tests_macos.dart @cbracken @flutter/desktop
200200
/dev/devicelab/bin/tasks/plugin_test.dart @stuartmorgan @flutter/plugin
201201
/dev/devicelab/bin/tasks/plugin_test_ios.dart @jmagman @flutter/ios
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Copyright 2014 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import 'package:flutter_devicelab/framework/devices.dart';
6+
import 'package:flutter_devicelab/framework/framework.dart';
7+
import 'package:flutter_devicelab/framework/ios.dart';
8+
import 'package:flutter_devicelab/framework/task_result.dart';
9+
import 'package:flutter_devicelab/framework/utils.dart';
10+
import 'package:path/path.dart' as path;
11+
12+
Future<void> main() async {
13+
await task(() async {
14+
final String projectDirectory = '${flutterDirectory.path}/dev/integration_tests/ios_platform_view_tests';
15+
16+
await inDirectory(projectDirectory, () async {
17+
section('Build clean');
18+
19+
await flutter('clean');
20+
21+
section('Build platform view app');
22+
23+
await flutter(
24+
'build',
25+
options: <String>[
26+
'ios',
27+
'-v',
28+
'--release',
29+
'--config-only',
30+
],
31+
);
32+
});
33+
34+
section('Run platform view XCUITests');
35+
36+
final Device device = await devices.workingDevice;
37+
if (!await runXcodeTests(
38+
platformDirectory: path.join(projectDirectory, 'ios'),
39+
destination: 'id=${device.deviceId}',
40+
testName: 'native_platform_view_ui_tests_ios',
41+
)) {
42+
return TaskResult.failure('Platform view XCUITests failed');
43+
}
44+
45+
return TaskResult.success(null);
46+
});
47+
}

dev/devicelab/lib/tasks/integration_tests.dart

+3
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ TaskFunction createIOSPlatformViewTests() {
8383
return DriverTest(
8484
'${flutterDirectory.path}/dev/integration_tests/ios_platform_view_tests',
8585
'lib/main.dart',
86+
extraOptions: <String>[
87+
'--dart-define=ENABLE_DRIVER_EXTENSION=true',
88+
],
8689
);
8790
}
8891

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Copyright 2014 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
@import XCTest;
6+
7+
@interface XCUIElement(KeyboardFocus)
8+
@property (nonatomic, readonly) BOOL flt_hasKeyboardFocus;
9+
@end
10+
11+
@implementation XCUIElement(KeyboardFocus)
12+
- (BOOL)flt_hasKeyboardFocus {
13+
return [[self valueForKey:@"hasKeyboardFocus"] boolValue];
14+
}
15+
@end
16+
17+
@interface PlatformViewUITests : XCTestCase
18+
@property (strong) XCUIApplication *app;
19+
@end
20+
21+
@implementation PlatformViewUITests
22+
23+
- (void)setUp {
24+
self.continueAfterFailure = NO;
25+
26+
self.app = [[XCUIApplication alloc] init];
27+
[self.app launch];
28+
}
29+
- (void)testPlatformViewFocus {
30+
31+
XCUIElement *entranceButton = self.app.buttons[@"platform view focus test"];
32+
XCTAssertTrue([entranceButton waitForExistenceWithTimeout:1]);
33+
[entranceButton tap];
34+
35+
XCUIElement *platformView = self.app.textFields[@"platform_view[0]"];
36+
XCTAssertTrue([platformView waitForExistenceWithTimeout:1]);
37+
XCUIElement *flutterTextField = self.app.textFields[@"Flutter Text Field"];
38+
XCTAssertTrue([flutterTextField waitForExistenceWithTimeout:1]);
39+
40+
[flutterTextField tap];
41+
XCTAssertTrue([self.app.windows.element waitForExistenceWithTimeout:1]);
42+
XCTAssertFalse(platformView.flt_hasKeyboardFocus);
43+
XCTAssertTrue(flutterTextField.flt_hasKeyboardFocus);
44+
45+
// Tapping on platformView should unfocus the previously focused flutterTextField
46+
[platformView tap];
47+
XCTAssertTrue(platformView.flt_hasKeyboardFocus);
48+
XCTAssertFalse(flutterTextField.flt_hasKeyboardFocus);
49+
}
50+
51+
@end

0 commit comments

Comments
 (0)