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
d208ce2d
Unverified
Commit
d208ce2d
authored
Jul 30, 2019
by
Zachary Anderson
Committed by
GitHub
Jul 30, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tool] Usage refactor cleanup (#37186)
parent
a9aea962
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
78 additions
and
8 deletions
+78
-8
doctor.dart
packages/flutter_tools/lib/src/doctor.dart
+10
-0
events.dart
packages/flutter_tools/lib/src/reporting/events.dart
+20
-5
doctor_test.dart
...lutter_tools/test/general.shard/commands/doctor_test.dart
+16
-0
resident_runner_test.dart
...lutter_tools/test/general.shard/resident_runner_test.dart
+32
-3
No files found.
packages/flutter_tools/lib/src/doctor.dart
View file @
d208ce2d
...
...
@@ -334,6 +334,15 @@ class GroupedValidator extends DoctorValidator {
final
List
<
DoctorValidator
>
subValidators
;
List
<
ValidationResult
>
_subResults
;
/// Subvalidator results.
///
/// To avoid losing information when results are merged, the subresults are
/// cached on this field when they are available. The results are in the same
/// order as the subvalidator list.
List
<
ValidationResult
>
get
subResults
=>
_subResults
;
@override
String
get
slowWarning
=>
_currentSlowWarning
;
String
_currentSlowWarning
=
'Initializing...'
;
...
...
@@ -356,6 +365,7 @@ class GroupedValidator extends DoctorValidator {
ValidationResult
_mergeValidationResults
(
List
<
ValidationResult
>
results
)
{
assert
(
results
.
isNotEmpty
,
'Validation results should not be empty'
);
_subResults
=
results
;
ValidationType
mergedType
=
results
[
0
].
type
;
final
List
<
ValidationMessage
>
mergedMessages
=
<
ValidationMessage
>[];
String
statusInfo
;
...
...
packages/flutter_tools/lib/src/reporting/events.dart
View file @
d208ce2d
...
...
@@ -90,12 +90,27 @@ class HotEvent extends UsageEvent {
/// An event that reports the result of a [DoctorValidator]
class
DoctorResultEvent
extends
UsageEvent
{
DoctorResultEvent
({
@required
DoctorValidator
validator
,
@required
ValidationResult
result
})
:
super
(
'doctorResult.
${validator.runtimeType
.toString()
}
'
,
@required
this
.
validator
,
@required
this
.
result
,
})
:
super
(
'doctorResult.
${validator.runtimeType}
'
,
result
.
typeStr
);
// TODO(zra): Override send() to detect a GroupedValidator and send separate
// events for each sub-validator.
final
DoctorValidator
validator
;
final
ValidationResult
result
;
@override
void
send
()
{
if
(
validator
is
!
GroupedValidator
)
{
flutterUsage
.
sendEvent
(
category
,
parameter
);
return
;
}
final
GroupedValidator
group
=
validator
;
for
(
int
i
=
0
;
i
<
group
.
subValidators
.
length
;
i
++)
{
final
DoctorValidator
v
=
group
.
subValidators
[
i
];
final
ValidationResult
r
=
group
.
subResults
[
i
];
DoctorResultEvent
(
validator:
v
,
result:
r
).
send
();
}
}
}
/// An event that reports success or failure of a pub get.
...
...
packages/flutter_tools/test/general.shard/commands/doctor_test.dart
View file @
d208ce2d
...
...
@@ -276,6 +276,22 @@ void main() {
Platform:
_kNoColorOutputPlatform
,
Usage:
()
=>
mockUsage
,
});
testUsingContext
(
'events for grouped validators are properly decomposed'
,
()
async
{
await
FakeGroupedDoctor
().
diagnose
(
verbose:
false
);
expect
(
verify
(
mockUsage
.
sendEvent
(
'doctorResult.PassingGroupedValidator'
,
captureAny
)).
captured
,
<
dynamic
>[
'installed'
,
'installed'
,
'installed'
],
);
expect
(
verify
(
mockUsage
.
sendEvent
(
'doctorResult.MissingGroupedValidator'
,
captureAny
)).
captured
,
<
dynamic
>[
'missing'
],
);
},
overrides:
<
Type
,
Generator
>{
Platform:
_kNoColorOutputPlatform
,
Usage:
()
=>
mockUsage
,
});
});
group
(
'doctor with fake validators'
,
()
{
...
...
packages/flutter_tools/test/general.shard/resident_runner_test.dart
View file @
d208ce2d
...
...
@@ -52,6 +52,7 @@ void main() {
// DevFS Mocks
when
(
mockDevFS
.
lastCompiled
).
thenReturn
(
DateTime
(
2000
));
when
(
mockDevFS
.
sources
).
thenReturn
(<
Uri
>[]);
when
(
mockDevFS
.
baseUri
).
thenReturn
(
Uri
());
when
(
mockDevFS
.
destroy
()).
thenAnswer
((
Invocation
invocation
)
async
{
});
when
(
mockDevFS
.
assetPathsToEvict
).
thenReturn
(<
String
>{});
// FlutterDevice Mocks.
...
...
@@ -80,6 +81,7 @@ void main() {
]);
when
(
mockFlutterDevice
.
device
).
thenReturn
(
mockDevice
);
when
(
mockFlutterView
.
uiIsolate
).
thenReturn
(
mockIsolate
);
when
(
mockFlutterView
.
runFromSource
(
any
,
any
,
any
)).
thenAnswer
((
Invocation
invocation
)
async
{});
when
(
mockFlutterDevice
.
stopEchoingDeviceLog
()).
thenAnswer
((
Invocation
invocation
)
async
{
});
when
(
mockFlutterDevice
.
observatoryUris
).
thenReturn
(<
Uri
>[
testUri
,
...
...
@@ -189,9 +191,6 @@ void main() {
Usage:
()
=>
MockUsage
(),
}));
// Need one for hot restart as well.
test
(
'ResidentRunner can send target platform to analytics from hot reload'
,
()
=>
testbed
.
run
(()
async
{
when
(
mockDevice
.
sdkNameAndVersion
).
thenAnswer
((
Invocation
invocation
)
async
{
return
'Example'
;
...
...
@@ -221,6 +220,36 @@ void main() {
Usage:
()
=>
MockUsage
(),
}));
test
(
'ResidentRunner can send target platform to analytics from full restart'
,
()
=>
testbed
.
run
(()
async
{
when
(
mockDevice
.
sdkNameAndVersion
).
thenAnswer
((
Invocation
invocation
)
async
{
return
'Example'
;
});
when
(
mockDevice
.
targetPlatform
).
thenAnswer
((
Invocation
invocation
)
async
{
return
TargetPlatform
.
android_arm
;
});
when
(
mockDevice
.
isLocalEmulator
).
thenAnswer
((
Invocation
invocation
)
async
{
return
false
;
});
when
(
mockDevice
.
supportsHotRestart
).
thenReturn
(
true
);
final
Completer
<
DebugConnectionInfo
>
onConnectionInfo
=
Completer
<
DebugConnectionInfo
>.
sync
();
final
Completer
<
void
>
onAppStart
=
Completer
<
void
>.
sync
();
unawaited
(
residentRunner
.
attach
(
appStartedCompleter:
onAppStart
,
connectionInfoCompleter:
onConnectionInfo
,
));
final
OperationResult
result
=
await
residentRunner
.
restart
(
fullRestart:
true
);
expect
(
result
.
fatal
,
false
);
expect
(
result
.
code
,
0
);
expect
(
verify
(
flutterUsage
.
sendEvent
(
'hot'
,
'restart'
,
parameters:
captureAnyNamed
(
'parameters'
))).
captured
[
0
],
containsPair
(
cdKey
(
CustomDimensions
.
hotEventTargetPlatform
),
getNameForTargetPlatform
(
TargetPlatform
.
android_arm
))
);
},
overrides:
<
Type
,
Generator
>{
Usage:
()
=>
MockUsage
(),
}));
test
(
'ResidentRunner Can handle an RPC exception from hot restart'
,
()
=>
testbed
.
run
(()
async
{
when
(
mockDevice
.
sdkNameAndVersion
).
thenAnswer
((
Invocation
invocation
)
async
{
return
'Example'
;
...
...
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