Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
47bad772
Unverified
Commit
47bad772
authored
Jan 05, 2021
by
Jia Hao
Committed by
GitHub
Jan 05, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support flutter_test_config for `flutter test` on web platforms (#72488)
parent
ba91a69f
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
46 additions
and
2 deletions
+46
-2
_goldens_io.dart
packages/flutter/test/_goldens_io.dart
+5
-0
_goldens_web.dart
packages/flutter/test/_goldens_web.dart
+8
-0
flutter_test_config.dart
packages/flutter/test/flutter_test_config.dart
+2
-1
web_test_compiler.dart
packages/flutter_tools/lib/src/test/web_test_compiler.dart
+2
-0
bootstrap.dart
packages/flutter_tools/lib/src/web/bootstrap.dart
+6
-1
bootstrap_test.dart
.../flutter_tools/test/general.shard/web/bootstrap_test.dart
+23
-0
No files found.
packages/flutter/test/_goldens_io.dart
0 → 100644
View file @
47bad772
// Copyright 2014 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.
export
'package:flutter_goldens/flutter_goldens.dart'
show
testExecutable
;
packages/flutter/test/_goldens_web.dart
0 → 100644
View file @
47bad772
// Copyright 2014 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:async'
;
// package:flutter_goldens is not used as part of the test process for web.
Future
<
void
>
testExecutable
(
FutureOr
<
void
>
testMain
())
async
=>
testMain
();
packages/flutter/test/flutter_test_config.dart
View file @
47bad772
...
...
@@ -2,4 +2,5 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
export
'package:flutter_goldens/flutter_goldens.dart'
show
testExecutable
;
export
'_goldens_io.dart'
if
(
dart
.
library
.
html
)
'_goldens_web.dart'
show
testExecutable
;
packages/flutter_tools/lib/src/test/web_test_compiler.dart
View file @
47bad772
...
...
@@ -18,6 +18,7 @@ import '../compile.dart';
import
'../dart/language_version.dart'
;
import
'../web/bootstrap.dart'
;
import
'../web/memory_fs.dart'
;
import
'test_config.dart'
;
/// A web compiler for the test runner.
class
WebTestCompiler
{
...
...
@@ -79,6 +80,7 @@ class WebTestCompiler {
..
writeAsStringSync
(
generateTestEntrypoint
(
relativeTestPath:
relativeTestSegments
.
join
(
'/'
),
absolutePath:
testFilePath
,
testConfigPath:
findTestConfigFile
(
_fileSystem
.
file
(
testFilePath
))?.
path
,
languageVersion:
languageVersion
,
));
generatedFiles
.
add
(
generatedFile
);
...
...
packages/flutter_tools/lib/src/web/bootstrap.dart
View file @
47bad772
...
...
@@ -102,6 +102,7 @@ define("$bootstrapModule", ["$entrypoint", "dart_sdk"], function(app, dart_sdk)
String generateTestEntrypoint({
@required String relativeTestPath,
@required String absolutePath,
@required String testConfigPath,
@required LanguageVersion languageVersion,
}) {
return '''
...
...
@@ -110,6 +111,7 @@ String generateTestEntrypoint({
import
'dart:ui'
as
ui
;
import
'dart:html'
;
import
'dart:js'
;
$
{
testConfigPath
!=
null
?
"import '
${Uri.file(testConfigPath)}
' as test_config;"
:
""
}
import
'package:stream_channel/stream_channel.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:test_api/src/backend/stack_trace_formatter.dart'
;
// ignore: implementation_imports
...
...
@@ -122,7 +124,10 @@ String generateTestEntrypoint({
webGoldenComparator
=
DefaultWebGoldenComparator
(
Uri
.
parse
(
'
$absolutePath
'
));
(
ui
.
window
as
dynamic
).
debugOverrideDevicePixelRatio
(
3.0
);
(
ui
.
window
as
dynamic
).
webOnlyDebugPhysicalSizeOverride
=
const
ui
.
Size
(
2400
,
1800
);
internalBootstrapBrowserTest
(()
=>
test
.
main
);
internalBootstrapBrowserTest
(()
{
return
$
{
testConfigPath
!=
null
?
"() => test_config.testExecutable(test.main)"
:
"test.main"
};
});
}
void
internalBootstrapBrowserTest
(
Function
getMain
())
{
...
...
packages/flutter_tools/test/general.shard/web/bootstrap_test.dart
View file @
47bad772
...
...
@@ -3,6 +3,7 @@
// found in the LICENSE file.
import
'package:flutter_tools/src/web/bootstrap.dart'
;
import
'package:package_config/package_config.dart'
;
import
'../../src/common.dart'
;
...
...
@@ -70,4 +71,26 @@ void main() {
expect
(
result
,
contains
(
'el.setAttribute("data-main",
\'
foo.dart.js
\'
);'
));
});
test
(
'generateTestEntrypoint does not generate test config wrappers when testConfigPath is not passed'
,
()
{
final
String
result
=
generateTestEntrypoint
(
relativeTestPath:
'relative_path.dart'
,
absolutePath:
'absolute_path.dart'
,
testConfigPath:
null
,
languageVersion:
LanguageVersion
(
2
,
8
),
);
expect
(
result
,
isNot
(
contains
(
'test_config.testExecutable'
)));
});
test
(
'generateTestEntrypoint generates test config wrappers when testConfigPath is passed'
,
()
{
final
String
result
=
generateTestEntrypoint
(
relativeTestPath:
'relative_path.dart'
,
absolutePath:
'absolute_path.dart'
,
testConfigPath:
'test_config_path.dart'
,
languageVersion:
LanguageVersion
(
2
,
8
),
);
expect
(
result
,
contains
(
'test_config.testExecutable'
));
});
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment