Skip to content

Commit

Permalink
Move more of the tests in the engine to package:test (flutter#55083)
Browse files Browse the repository at this point in the history
Partial work towards flutter/flutter#133569.
  • Loading branch information
matanlurey authored Sep 10, 2024
1 parent 5882da8 commit 58e3f19
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 33 deletions.
2 changes: 1 addition & 1 deletion testing/benchmark/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ dependencies:
path: any

dev_dependencies:
litetest: any
test: any
2 changes: 1 addition & 1 deletion testing/benchmark/test/parse_and_send_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

import 'dart:io';

import 'package:litetest/litetest.dart';
import 'package:metrics_center/metrics_center.dart';
import 'package:path/path.dart' as p;
import 'package:test/test.dart';

import '../bin/parse_and_send.dart' as pas;

Expand Down
2 changes: 1 addition & 1 deletion testing/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,7 @@ def build_dart_host_test_list(build_dir):
(os.path.join('flutter', 'testing', 'scenario_app'), []),
(
os.path.join('flutter', 'tools', 'api_check'),
[os.path.join(BUILDROOT_DIR, 'flutter')],
[],
),
(os.path.join('flutter', 'tools', 'build_bucket_golden_scraper'), []),
(os.path.join('flutter', 'tools', 'clang_tidy'), []),
Expand Down
8 changes: 2 additions & 6 deletions tools/api_check/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,8 @@ resolution: workspace

dependencies:
analyzer: any
_fe_analyzer_shared: any
pub_semver: any

dev_dependencies:
async_helper: any
expect: any
litetest: any
engine_repo_tools: any
path: any
smith: any
test: any
63 changes: 39 additions & 24 deletions tools/api_check/test/apicheck_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:io';

import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/visitor.dart';
import 'package:apicheck/apicheck.dart';
import 'package:litetest/litetest.dart';
import 'package:engine_repo_tools/engine_repo_tools.dart';
import 'package:path/path.dart' as path;
import 'package:test/test.dart';

void main(List<String> arguments) {
if (arguments.isEmpty) {
print('usage: dart bin/apicheck.dart path/to/engine/src/flutter');
exit(1);
}

final String flutterRoot = arguments[0];
void main() {
final String flutterRoot = Engine.findWithin().flutterDir.path;

checkApiConsistency(flutterRoot);
checkNativeApi(flutterRoot);
Expand Down Expand Up @@ -45,12 +39,14 @@ void checkApiConsistency(String flutterRoot) {
);
// C values: kFlutterAccessibilityFeatureFooBar = 1 << N,
final List<String> embedderEnumValues = getCppEnumValues(
sourcePath: path.join(flutterRoot, 'shell', 'platform', 'embedder', 'embedder.h'),
sourcePath:
path.join(flutterRoot, 'shell', 'platform', 'embedder', 'embedder.h'),
enumName: 'FlutterAccessibilityFeature',
);
// C++ values: kFooBar = 1 << N,
final List<String> internalEnumValues = getCppEnumClassValues(
sourcePath: path.join(flutterRoot, 'lib','ui', 'window', 'platform_configuration.h'),
sourcePath: path.join(
flutterRoot, 'lib', 'ui', 'window', 'platform_configuration.h'),
enumName: 'AccessibilityFeatureFlag',
);
// Java values: FOO_BAR(1 << N).
Expand All @@ -72,17 +68,20 @@ void checkApiConsistency(String flutterRoot) {
className: 'SemanticsAction',
);
final List<String> webuiFields = getDartClassFields(
sourcePath: path.join(flutterRoot, 'lib', 'web_ui', 'lib', 'semantics.dart'),
sourcePath:
path.join(flutterRoot, 'lib', 'web_ui', 'lib', 'semantics.dart'),
className: 'SemanticsAction',
);
// C values: kFlutterSemanticsActionFooBar = 1 << N.
final List<String> embedderEnumValues = getCppEnumValues(
sourcePath: path.join(flutterRoot, 'shell', 'platform', 'embedder', 'embedder.h'),
sourcePath:
path.join(flutterRoot, 'shell', 'platform', 'embedder', 'embedder.h'),
enumName: 'FlutterSemanticsAction',
);
// C++ values: kFooBar = 1 << N.
final List<String> internalEnumValues = getCppEnumClassValues(
sourcePath: path.join(flutterRoot, 'lib', 'ui', 'semantics', 'semantics_node.h'),
sourcePath:
path.join(flutterRoot, 'lib', 'ui', 'semantics', 'semantics_node.h'),
enumName: 'SemanticsAction',
);
// Java values: FOO_BAR(1 << N).
Expand All @@ -101,22 +100,34 @@ void checkApiConsistency(String flutterRoot) {
test('AppLifecycleState enums match', () {
// Dart values: _kFooBarIndex = 1 << N.
final List<String> uiFields = getDartClassFields(
sourcePath: path.join(flutterRoot, 'lib', 'ui', 'platform_dispatcher.dart'),
sourcePath:
path.join(flutterRoot, 'lib', 'ui', 'platform_dispatcher.dart'),
className: 'AppLifecycleState',
);
final List<String> webuiFields = getDartClassFields(
sourcePath: path.join(flutterRoot, 'lib', 'web_ui', 'lib', 'platform_dispatcher.dart'),
sourcePath: path.join(
flutterRoot, 'lib', 'web_ui', 'lib', 'platform_dispatcher.dart'),
className: 'AppLifecycleState',
);
// C++ values: kFooBar = 1 << N.
final List<String> internalEnumValues = getCppEnumClassValues(
sourcePath: path.join(flutterRoot, 'shell', 'platform', 'common', 'app_lifecycle_state.h'),
sourcePath: path.join(
flutterRoot, 'shell', 'platform', 'common', 'app_lifecycle_state.h'),
enumName: 'AppLifecycleState',
);
// Java values: FOO_BAR(1 << N).
final List<String> javaEnumValues = getJavaEnumValues(
sourcePath: path.join(flutterRoot, 'shell', 'platform', 'android', 'io',
'flutter', 'embedding', 'engine', 'systemchannels', 'LifecycleChannel.java'),
sourcePath: path.join(
flutterRoot,
'shell',
'platform',
'android',
'io',
'flutter',
'embedding',
'engine',
'systemchannels',
'LifecycleChannel.java'),
enumName: 'AppLifecycleState',
).map(allCapsToCamelCase).toList();

Expand All @@ -137,12 +148,14 @@ void checkApiConsistency(String flutterRoot) {
);
// C values: kFlutterSemanticsFlagFooBar = 1 << N.
final List<String> embedderEnumValues = getCppEnumValues(
sourcePath: path.join(flutterRoot, 'shell', 'platform', 'embedder', 'embedder.h'),
sourcePath:
path.join(flutterRoot, 'shell', 'platform', 'embedder', 'embedder.h'),
enumName: 'FlutterSemanticsFlag',
);
// C++ values: kFooBar = 1 << N.
final List<String> internalEnumValues = getCppEnumClassValues(
sourcePath: path.join(flutterRoot, 'lib', 'ui', 'semantics', 'semantics_node.h'),
sourcePath:
path.join(flutterRoot, 'lib', 'ui', 'semantics', 'semantics_node.h'),
enumName: 'SemanticsFlags',
);
// Java values: FOO_BAR(1 << N).
Expand Down Expand Up @@ -185,15 +198,17 @@ class NativeFunctionVisitor extends RecursiveAstVisitor<void> {

@override
void visitNativeFunctionBody(NativeFunctionBody node) {
final MethodDeclaration? method = node.thisOrAncestorOfType<MethodDeclaration>();
final MethodDeclaration? method =
node.thisOrAncestorOfType<MethodDeclaration>();
if (method != null) {
if (method.parameters != null) {
check(method.toString(), method.parameters!);
}
return;
}

final FunctionDeclaration? func = node.thisOrAncestorOfType<FunctionDeclaration>();
final FunctionDeclaration? func =
node.thisOrAncestorOfType<FunctionDeclaration>();
if (func != null) {
final FunctionExpression funcExpr = func.functionExpression;
if (funcExpr.parameters != null) {
Expand Down

0 comments on commit 58e3f19

Please sign in to comment.