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
11660159
Unverified
Commit
11660159
authored
Jul 16, 2019
by
chunhtai
Committed by
GitHub
Jul 16, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable widget load assets in its own package in test (#35991)
parent
a8c4da22
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
43 additions
and
7 deletions
+43
-7
package_assets_expectation.txt
...tomated_tests/flutter_test/package_assets_expectation.txt
+1
-0
package_assets_test.dart
dev/automated_tests/flutter_test/package_assets_test.dart
+20
-0
test.png
dev/automated_tests/icon/test.png
+0
-0
pubspec.yaml
dev/automated_tests/pubspec.yaml
+2
-1
binding.dart
packages/flutter_test/lib/src/binding.dart
+14
-6
flutter_platform.dart
packages/flutter_tools/lib/src/test/flutter_platform.dart
+1
-0
test_test.dart
.../flutter_tools/test/general.shard/commands/test_test.dart
+5
-0
No files found.
dev/automated_tests/flutter_test/package_assets_expectation.txt
0 → 100644
View file @
11660159
[0-9]+:[0-9]+ [+]1: All tests passed!
dev/automated_tests/flutter_test/package_assets_test.dart
0 → 100644
View file @
11660159
// Copyright 2019 The Chromium 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
'package:flutter/widgets.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
testWidgets
(
'Rendering Error'
,
(
WidgetTester
tester
)
async
{
// Assets can load with its package name.
await
tester
.
pumpWidget
(
Image
.
asset
(
'icon/test.png'
,
width:
54
,
height:
54
,
fit:
BoxFit
.
none
,
package:
'flutter_automated_tests'
),
);
});
}
dev/automated_tests/icon/test.png
0 → 100644
View file @
11660159
This diff was suppressed by a .gitattributes entry.
dev/automated_tests/pubspec.yaml
View file @
11660159
...
...
@@ -64,5 +64,6 @@ dependencies:
flutter
:
uses-material-design
:
true
assets
:
-
icon/
# PUBSPEC CHECKSUM: 4625
packages/flutter_test/lib/src/binding.dart
View file @
11660159
...
...
@@ -811,15 +811,23 @@ class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
final
String
assetFolderPath
=
Platform
.
environment
[
'UNIT_TEST_ASSETS'
];
_ensureInitialized
(
assetFolderPath
);
final
String
prefix
=
'packages/
${Platform.environment['APP_NAME']}
/'
;
if
(
_allowedAssetKeys
.
isNotEmpty
)
{
defaultBinaryMessenger
.
setMockMessageHandler
(
'flutter/assets'
,
(
ByteData
message
)
{
final
String
key
=
utf8
.
decode
(
message
.
buffer
.
asUint8List
());
if
(
_allowedAssetKeys
.
contains
(
key
))
{
final
File
asset
=
File
(
path
.
join
(
assetFolderPath
,
key
));
final
Uint8List
encoded
=
Uint8List
.
fromList
(
asset
.
readAsBytesSync
());
return
Future
<
ByteData
>.
value
(
encoded
.
buffer
.
asByteData
());
String
key
=
utf8
.
decode
(
message
.
buffer
.
asUint8List
());
if
(!
_allowedAssetKeys
.
contains
(
key
))
{
// For tests in package, it will load assets with its own package prefix.
// In this case, we do a best-effort look up.
if
(!
key
.
startsWith
(
prefix
))
return
null
;
key
=
key
.
replaceFirst
(
prefix
,
''
);
if
(!
_allowedAssetKeys
.
contains
(
key
))
return
null
;
}
return
null
;
final
File
asset
=
File
(
path
.
join
(
assetFolderPath
,
key
));
final
Uint8List
encoded
=
Uint8List
.
fromList
(
asset
.
readAsBytesSync
());
return
Future
<
ByteData
>.
value
(
encoded
.
buffer
.
asByteData
());
});
}
}
...
...
packages/flutter_tools/lib/src/test/flutter_platform.dart
View file @
11660159
...
...
@@ -866,6 +866,7 @@ class FlutterPlatform extends PlatformPlugin {
'FLUTTER_TEST'
:
flutterTest
,
'FONTCONFIG_FILE'
:
_fontConfigFile
.
path
,
'SERVER_PORT'
:
serverPort
.
toString
(),
'APP_NAME'
:
flutterProject
?.
manifest
?.
appName
??
''
,
};
if
(
buildTestAssets
)
{
environment
[
'UNIT_TEST_ASSETS'
]
=
fs
.
path
.
join
(
...
...
packages/flutter_tools/test/general.shard/commands/test_test.dart
View file @
11660159
...
...
@@ -65,6 +65,11 @@ void main() {
return
_testFile
(
'print_user_created_ancestor_no_flag'
,
automatedTestsDirectory
,
flutterTestDirectory
);
},
skip:
io
.
Platform
.
isWindows
);
// TODO(chunhtai): Dart on Windows has trouble with unicode characters in output (#35425).
testUsingContext
(
'can load assets within its own package'
,
()
async
{
Cache
.
flutterRoot
=
'../..'
;
return
_testFile
(
'package_assets'
,
automatedTestsDirectory
,
flutterTestDirectory
,
exitCode:
isZero
);
},
skip:
io
.
Platform
.
isWindows
);
testUsingContext
(
'run a test when its name matches a regexp'
,
()
async
{
Cache
.
flutterRoot
=
'../..'
;
final
ProcessResult
result
=
await
_runFlutterTest
(
'filtering'
,
automatedTestsDirectory
,
flutterTestDirectory
,
...
...
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