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
2994d356
Unverified
Commit
2994d356
authored
Dec 12, 2018
by
Danny Tuppeny
Committed by
GitHub
Dec 12, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add some a basic debug stepping tests (#24515)
parent
cc23a7b4
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
125 additions
and
0 deletions
+125
-0
debugger_stepping_test.dart
...lutter_tools/test/integration/debugger_stepping_test.dart
+51
-0
stepping_project.dart
...er_tools/test/integration/test_data/stepping_project.dart
+57
-0
test_driver.dart
packages/flutter_tools/test/integration/test_driver.dart
+17
-0
No files found.
packages/flutter_tools/test/integration/debugger_stepping_test.dart
0 → 100644
View file @
2994d356
// Copyright 2018 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:file/file.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'../src/common.dart'
;
import
'test_data/stepping_project.dart'
;
import
'test_driver.dart'
;
import
'test_utils.dart'
;
void
main
(
)
{
group
(
'debugger'
,
()
{
Directory
tempDir
;
final
SteppingProject
_project
=
SteppingProject
();
FlutterRunTestDriver
_flutter
;
setUp
(()
async
{
tempDir
=
createResolvedTempDirectorySync
();
await
_project
.
setUpIn
(
tempDir
);
_flutter
=
FlutterRunTestDriver
(
tempDir
);
});
tearDown
(()
async
{
await
_flutter
.
stop
();
tryToDelete
(
tempDir
);
});
test
(
'can step over statements'
,
()
async
{
await
_flutter
.
run
(
withDebugger:
true
);
// Stop at the initial breakpoint that the expected steps are based on.
await
_flutter
.
breakAt
(
_project
.
breakpointUri
,
_project
.
breakpointLine
,
restart:
true
);
// Issue 5 steps, ensuring that we end up on the annotated lines each time.
for
(
int
i
=
1
;
i
<=
_project
.
numberOfSteps
;
i
++)
{
await
_flutter
.
stepOverOrOverAsyncSuspension
();
final
SourcePosition
location
=
await
_flutter
.
getSourceLocation
();
final
int
actualLine
=
location
.
line
;
// Get the line we're expected to stop at by searching for the comment
// within the source code.
final
int
expectedLine
=
_project
.
lineForStep
(
i
);
expect
(
actualLine
,
equals
(
expectedLine
),
reason:
'After
$i
steps, debugger should stop at
$expectedLine
but stopped at
$actualLine
'
);
}
});
},
timeout:
const
Timeout
.
factor
(
3
));
}
packages/flutter_tools/test/integration/test_data/stepping_project.dart
0 → 100644
View file @
2994d356
// Copyright 2018 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
'project.dart'
;
class
SteppingProject
extends
Project
{
@override
final
String
pubspec
=
'''
name: test
dependencies:
flutter:
sdk: flutter
'''
;
@override
final
String
main
=
r''
'
import '
dart:
async
';
import '
package:
flutter
/
material
.
dart
';
void main() => runApp(new MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
doAsyncStuff();
super.initState();
}
Future<void> doAsyncStuff() async {
print("test"); // BREAKPOINT
await new Future.value(true); // STEP 1
await new Future.microtask(() => true); // STEP 2 // STEP 3
await new Future.delayed(const Duration(milliseconds: 1)); // STEP 4 // STEP 5
print("done!"); // STEP 6
}
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: '
Flutter
Demo
',
home: new Container(),
);
}
}
'''
;
int
lineForStep
(
int
i
)
=>
lineContaining
(
main
,
'// STEP
$i
'
);
final
int
numberOfSteps
=
6
;
}
packages/flutter_tools/test/integration/test_driver.dart
View file @
2994d356
...
@@ -163,8 +163,17 @@ abstract class FlutterTestDriver {
...
@@ -163,8 +163,17 @@ abstract class FlutterTestDriver {
message:
'Isolate did not pause'
);
message:
'Isolate did not pause'
);
}
}
Future
<
bool
>
isAtAsyncSuspension
()
async
{
final
Isolate
isolate
=
await
_getFlutterIsolate
();
return
isolate
.
pauseEvent
.
atAsyncSuspension
==
true
;
}
Future
<
Isolate
>
resume
({
bool
wait
=
true
})
=>
_resume
(
wait:
wait
);
Future
<
Isolate
>
resume
({
bool
wait
=
true
})
=>
_resume
(
wait:
wait
);
Future
<
Isolate
>
stepOver
({
bool
wait
=
true
})
=>
_resume
(
step:
StepOption
.
kOver
,
wait:
wait
);
Future
<
Isolate
>
stepOver
({
bool
wait
=
true
})
=>
_resume
(
step:
StepOption
.
kOver
,
wait:
wait
);
Future
<
Isolate
>
stepOverAsync
({
bool
wait
=
true
})
=>
_resume
(
step:
StepOption
.
kOverAsyncSuspension
,
wait:
wait
);
Future
<
Isolate
>
stepOverOrOverAsyncSuspension
({
bool
wait
=
true
})
async
{
return
(
await
isAtAsyncSuspension
())
?
stepOverAsync
(
wait:
wait
)
:
stepOver
(
wait:
wait
);
}
Future
<
Isolate
>
stepInto
({
bool
wait
=
true
})
=>
_resume
(
step:
StepOption
.
kInto
,
wait:
wait
);
Future
<
Isolate
>
stepInto
({
bool
wait
=
true
})
=>
_resume
(
step:
StepOption
.
kInto
,
wait:
wait
);
Future
<
Isolate
>
stepOut
({
bool
wait
=
true
})
=>
_resume
(
step:
StepOption
.
kOut
,
wait:
wait
);
Future
<
Isolate
>
stepOut
({
bool
wait
=
true
})
=>
_resume
(
step:
StepOption
.
kOut
,
wait:
wait
);
...
@@ -366,6 +375,14 @@ class FlutterRunTestDriver extends FlutterTestDriver {
...
@@ -366,6 +375,14 @@ class FlutterRunTestDriver extends FlutterTestDriver {
_vmService
.
streamListen
(
'Debug'
),
_vmService
.
streamListen
(
'Debug'
),
]);
]);
// On hot restarts, the isolate ID we have for the Flutter thread will
// exit so we need to invalidate our cached ID.
_vmService
.
onIsolateEvent
.
listen
((
Event
event
)
{
if
(
event
.
kind
==
EventKind
.
kIsolateExit
&&
event
.
isolate
.
id
==
_flutterIsolateId
)
{
_flutterIsolateId
=
null
;
}
});
// Because we start paused, resume so the app is in a "running" state as
// Because we start paused, resume so the app is in a "running" state as
// expected by tests. Tests will reload/restart as required if they need
// expected by tests. Tests will reload/restart as required if they need
// to hit breakpoints, etc.
// to hit breakpoints, etc.
...
...
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