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
2bada609
Unverified
Commit
2bada609
authored
Apr 08, 2021
by
Jonah Williams
Committed by
GitHub
Apr 08, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] add timeline ANR integration test (#79991)
parent
ac770423
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
132 additions
and
1 deletion
+132
-1
basic_project.dart
...tools/test/integration.shard/test_data/basic_project.dart
+44
-0
test_driver.dart
...ges/flutter_tools/test/integration.shard/test_driver.dart
+5
-1
timeline_test.dart
...s/flutter_tools/test/integration.shard/timeline_test.dart
+83
-0
No files found.
packages/flutter_tools/test/integration.shard/test_data/basic_project.dart
View file @
2bada609
...
@@ -55,6 +55,50 @@ class BasicProject extends Project {
...
@@ -55,6 +55,50 @@ class BasicProject extends Project {
int
get
topLevelFunctionBreakpointLine
=>
lineContaining
(
main
,
'// TOP LEVEL BREAKPOINT'
);
int
get
topLevelFunctionBreakpointLine
=>
lineContaining
(
main
,
'// TOP LEVEL BREAKPOINT'
);
}
}
class
BasicProjectWithTimelineTraces
extends
Project
{
@override
final
String
pubspec
=
'''
name: test
environment:
sdk: ">=2.12.0-0 <3.0.0"
dependencies:
flutter:
sdk: flutter
'''
;
@override
final
String
main
=
r''
'
import '
dart:
async
';
import '
dart:
developer
';
import '
package:
flutter
/
material
.
dart
';
Future<void> main() async {
while (true) {
runApp(new MyApp());
await Future.delayed(const Duration(milliseconds: 50));
Timeline.instantSync('
main
');
}
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
topLevelFunction();
return new MaterialApp( // BUILD BREAKPOINT
title: '
Flutter
Demo
',
home: new Container(),
);
}
}
topLevelFunction() {
print("topLevelFunction"); // TOP LEVEL BREAKPOINT
}
'''
;
}
class
BasicProjectWithFlutterGen
extends
Project
{
class
BasicProjectWithFlutterGen
extends
Project
{
@override
@override
final
String
generatedFile
=
'''
final
String
generatedFile
=
'''
...
...
packages/flutter_tools/test/integration.shard/test_driver.dart
View file @
2bada609
...
@@ -843,7 +843,11 @@ class SourcePosition {
...
@@ -843,7 +843,11 @@ class SourcePosition {
Future
<
Isolate
>
waitForExtension
(
VmService
vmService
,
String
extension
)
async
{
Future
<
Isolate
>
waitForExtension
(
VmService
vmService
,
String
extension
)
async
{
final
Completer
<
void
>
completer
=
Completer
<
void
>();
final
Completer
<
void
>
completer
=
Completer
<
void
>();
await
vmService
.
streamListen
(
EventStreams
.
kExtension
);
try
{
await
vmService
.
streamListen
(
EventStreams
.
kExtension
);
}
on
RPCError
{
// Do nothing, already subscribed.
}
vmService
.
onExtensionEvent
.
listen
((
Event
event
)
{
vmService
.
onExtensionEvent
.
listen
((
Event
event
)
{
if
(
event
.
json
[
'extensionKind'
]
==
'Flutter.FrameworkInitialization'
)
{
if
(
event
.
json
[
'extensionKind'
]
==
'Flutter.FrameworkInitialization'
)
{
completer
.
complete
();
completer
.
complete
();
...
...
packages/flutter_tools/test/integration.shard/timeline_test.dart
0 → 100644
View file @
2bada609
// 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.
// @dart = 2.8
import
'dart:async'
;
import
'package:file/file.dart'
;
import
'package:vm_service/vm_service.dart'
;
import
'package:vm_service/vm_service_io.dart'
;
import
'../src/common.dart'
;
import
'test_data/basic_project.dart'
;
import
'test_driver.dart'
;
import
'test_utils.dart'
;
void
main
(
)
{
Directory
tempDir
;
FlutterRunTestDriver
flutter
;
VmService
vmService
;
setUp
(()
async
{
tempDir
=
createResolvedTempDirectorySync
(
'vmservice_integration_test.'
);
final
BasicProjectWithTimelineTraces
project
=
BasicProjectWithTimelineTraces
();
await
project
.
setUpIn
(
tempDir
);
flutter
=
FlutterRunTestDriver
(
tempDir
);
await
flutter
.
run
(
withDebugger:
true
);
final
int
port
=
flutter
.
vmServicePort
;
vmService
=
await
vmServiceConnectUri
(
'ws://localhost:
$port
/ws'
);
});
tearDown
(()
async
{
await
flutter
?.
stop
();
tryToDelete
(
tempDir
);
});
// Regression test for https://github.com/flutter/flutter/issues/79498
testWithoutContext
(
'Can connect to the timeline without getting ANR from the application'
,
()
async
{
final
Timer
timer
=
Timer
(
const
Duration
(
minutes:
5
),
()
{
print
(
'Warning: test isolate is still active after 5 minutes. This is likely an '
'app-not-responding error and not a flake. See https://github.com/flutter/flutter/issues/79498 '
'for the bug this test is attempting to exercise.'
);
});
// Subscribe to all available streams.
await
Future
.
wait
(<
Future
<
void
>>[
vmService
.
streamListen
(
EventStreams
.
kVM
),
vmService
.
streamListen
(
EventStreams
.
kIsolate
),
vmService
.
streamListen
(
EventStreams
.
kDebug
),
vmService
.
streamListen
(
EventStreams
.
kGC
),
vmService
.
streamListen
(
EventStreams
.
kExtension
),
vmService
.
streamListen
(
EventStreams
.
kTimeline
),
vmService
.
streamListen
(
EventStreams
.
kLogging
),
vmService
.
streamListen
(
EventStreams
.
kService
),
vmService
.
streamListen
(
EventStreams
.
kHeapSnapshot
),
vmService
.
streamListen
(
EventStreams
.
kStdout
),
vmService
.
streamListen
(
EventStreams
.
kStderr
),
]);
// Verify that the app can be interacted with by querying the brightness
// for 30 seconds. Once this time has elapsed, wait for any pending requests and
// exit. If the app stops responding, the requests made will hang.
bool
interactionCompleted
=
false
;
Timer
(
const
Duration
(
seconds:
30
),
()
{
interactionCompleted
=
true
;
});
final
Isolate
isolate
=
await
waitForExtension
(
vmService
,
'ext.flutter.brightnessOverride'
);
while
(!
interactionCompleted
)
{
final
Response
response
=
await
vmService
.
callServiceExtension
(
'ext.flutter.brightnessOverride'
,
isolateId:
isolate
.
id
,
);
expect
(
response
.
json
[
'value'
],
'Brightness.light'
);
}
timer
.
cancel
();
});
}
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