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
757b5365
Unverified
Commit
757b5365
authored
Jul 18, 2019
by
Jonah Williams
Committed by
GitHub
Jul 18, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add missing test case for Usage (#36379)
parent
1957c663
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
0 deletions
+44
-0
analytics_test.dart
...ages/flutter_tools/test/general.shard/analytics_test.dart
+44
-0
No files found.
packages/flutter_tools/test/general.shard/analytics_test.dart
View file @
757b5365
...
...
@@ -3,7 +3,9 @@
// found in the LICENSE file.
import
'package:args/command_runner.dart'
;
import
'package:flutter_tools/src/base/config.dart'
;
import
'package:flutter_tools/src/base/time.dart'
;
import
'package:flutter_tools/src/features.dart'
;
import
'package:mockito/mockito.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
...
...
@@ -22,6 +24,7 @@ import '../src/context.dart';
void
main
(
)
{
group
(
'analytics'
,
()
{
Directory
tempDir
;
MockFlutterConfig
mockFlutterConfig
;
setUpAll
(()
{
Cache
.
disableLocking
();
...
...
@@ -30,6 +33,7 @@ void main() {
setUp
(()
{
Cache
.
flutterRoot
=
'../..'
;
tempDir
=
fs
.
systemTempDirectory
.
createTempSync
(
'flutter_tools_analytics_test.'
);
mockFlutterConfig
=
MockFlutterConfig
();
});
tearDown
(()
{
...
...
@@ -78,6 +82,44 @@ void main() {
FlutterVersion:
()
=>
FlutterVersion
(
const
SystemClock
()),
Usage:
()
=>
Usage
(
configDirOverride:
tempDir
.
path
),
});
testUsingContext
(
'Usage records one feature in experiment setting'
,
()
async
{
when
<
bool
>(
mockFlutterConfig
.
getValue
(
flutterWebFeature
.
configSetting
))
.
thenReturn
(
true
);
final
Usage
usage
=
Usage
();
usage
.
suppressAnalytics
=
false
;
usage
.
enabled
=
true
;
final
Future
<
Map
<
String
,
dynamic
>>
data
=
usage
.
onSend
.
first
;
usage
.
sendCommand
(
'test'
);
expect
(
await
data
,
containsPair
(
enabledFlutterFeatures
,
'enable-web'
));
},
overrides:
<
Type
,
Generator
>{
FlutterVersion:
()
=>
FlutterVersion
(
const
SystemClock
()),
Usage:
()
=>
Usage
(
configDirOverride:
tempDir
.
path
),
Config:
()
=>
mockFlutterConfig
,
});
testUsingContext
(
'Usage records multiple features in experiment setting'
,
()
async
{
when
<
bool
>(
mockFlutterConfig
.
getValue
(
flutterWebFeature
.
configSetting
))
.
thenReturn
(
true
);
when
<
bool
>(
mockFlutterConfig
.
getValue
(
flutterLinuxDesktopFeature
.
configSetting
))
.
thenReturn
(
true
);
when
<
bool
>(
mockFlutterConfig
.
getValue
(
flutterMacOSDesktopFeature
.
configSetting
))
.
thenReturn
(
true
);
final
Usage
usage
=
Usage
();
usage
.
suppressAnalytics
=
false
;
usage
.
enabled
=
true
;
final
Future
<
Map
<
String
,
dynamic
>>
data
=
usage
.
onSend
.
first
;
usage
.
sendCommand
(
'test'
);
expect
(
await
data
,
containsPair
(
enabledFlutterFeatures
,
'enable-web,enable-linux-desktop,enable-macos-desktop'
));
},
overrides:
<
Type
,
Generator
>{
FlutterVersion:
()
=>
FlutterVersion
(
const
SystemClock
()),
Usage:
()
=>
Usage
(
configDirOverride:
tempDir
.
path
),
Config:
()
=>
mockFlutterConfig
,
});
});
group
(
'analytics with mocks'
,
()
{
...
...
@@ -195,3 +237,5 @@ void main() {
class
MockUsage
extends
Mock
implements
Usage
{}
class
MockDoctor
extends
Mock
implements
Doctor
{}
class
MockFlutterConfig
extends
Mock
implements
Config
{}
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