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
2eca1d30
Unverified
Commit
2eca1d30
authored
Jun 04, 2020
by
Jenn Magder
Committed by
GitHub
Jun 04, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use fake command in analytics test (#58544)
parent
b1d75fc9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
6 deletions
+23
-6
analytics_test.dart
...ages/flutter_tools/test/general.shard/analytics_test.dart
+23
-6
No files found.
packages/flutter_tools/test/general.shard/analytics_test.dart
View file @
2eca1d30
...
@@ -50,19 +50,23 @@ void main() {
...
@@ -50,19 +50,23 @@ void main() {
int
count
=
0
;
int
count
=
0
;
globals
.
flutterUsage
.
onSend
.
listen
((
Map
<
String
,
dynamic
>
data
)
=>
count
++);
globals
.
flutterUsage
.
onSend
.
listen
((
Map
<
String
,
dynamic
>
data
)
=>
count
++);
final
FlutterCommand
command
=
FakeFlutterCommand
();
final
CommandRunner
<
void
>
runner
=
createTestCommandRunner
(
command
);
globals
.
flutterUsage
.
enabled
=
false
;
globals
.
flutterUsage
.
enabled
=
false
;
await
createProject
(
tempDir
);
await
runner
.
run
(<
String
>[
'fake'
]
);
expect
(
count
,
0
);
expect
(
count
,
0
);
globals
.
flutterUsage
.
enabled
=
true
;
globals
.
flutterUsage
.
enabled
=
true
;
await
createProject
(
tempDir
);
await
runner
.
run
(<
String
>[
'fake'
]);
expect
(
count
,
globals
.
flutterUsage
.
isFirstRun
?
0
:
4
);
// LogToFileAnalytics isFirstRun is hardcoded to false
// so this usage will never act like the first run
// (which would not send usage).
expect
(
count
,
4
);
count
=
0
;
count
=
0
;
globals
.
flutterUsage
.
enabled
=
false
;
globals
.
flutterUsage
.
enabled
=
false
;
final
DoctorCommand
doctorCommand
=
DoctorCommand
();
await
runner
.
run
(<
String
>[
'fake'
]);
final
CommandRunner
<
void
>
runner
=
createTestCommandRunner
(
doctorCommand
);
await
runner
.
run
(<
String
>[
'doctor'
]);
expect
(
count
,
0
);
expect
(
count
,
0
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
...
@@ -363,6 +367,19 @@ Analytics throwingAnalyticsIOFactory(
...
@@ -363,6 +367,19 @@ Analytics throwingAnalyticsIOFactory(
throw
const
FileSystemException
(
'Could not create file'
);
throw
const
FileSystemException
(
'Could not create file'
);
}
}
class
FakeFlutterCommand
extends
FlutterCommand
{
@override
String
get
description
=>
'A fake command'
;
@override
String
get
name
=>
'fake'
;
@override
Future
<
FlutterCommandResult
>
runCommand
()
async
{
return
FlutterCommandResult
.
success
();
}
}
class
MockUsage
extends
Mock
implements
Usage
{}
class
MockUsage
extends
Mock
implements
Usage
{}
class
MockDoctor
extends
Mock
implements
Doctor
{}
class
MockDoctor
extends
Mock
implements
Doctor
{}
...
...
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