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
14aa4d0a
Unverified
Commit
14aa4d0a
authored
Jul 23, 2019
by
Jonah Williams
Committed by
GitHub
Jul 23, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix analytics reporting test (#36556)
parent
ebdc2cf7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
16 deletions
+22
-16
usage.dart
packages/flutter_tools/lib/src/reporting/usage.dart
+7
-1
analytics_test.dart
...ages/flutter_tools/test/general.shard/analytics_test.dart
+15
-15
No files found.
packages/flutter_tools/lib/src/reporting/usage.dart
View file @
14aa4d0a
...
...
@@ -156,7 +156,6 @@ class Usage {
...?
parameters
,
_kLocalTimeParameter:
systemClock
.
now
().
toString
(),
};
_analytics
.
sendScreenView
(
command
,
parameters:
paramsWithLocalTime
);
}
...
...
@@ -253,11 +252,13 @@ class LogToFileAnalytics extends AnalyticsMock {
super
(
true
);
final
File
logFile
;
final
Map
<
String
,
String
>
_sessionValues
=
<
String
,
String
>{};
@override
Future
<
void
>
sendScreenView
(
String
viewName
,
{
Map
<
String
,
String
>
parameters
})
{
parameters
??=
<
String
,
String
>{};
parameters
[
'viewName'
]
=
viewName
;
parameters
.
addAll
(
_sessionValues
);
logFile
.
writeAsStringSync
(
'screenView
$parameters
\n
'
,
mode:
FileMode
.
append
);
return
Future
<
void
>.
value
(
null
);
}
...
...
@@ -271,4 +272,9 @@ class LogToFileAnalytics extends AnalyticsMock {
logFile
.
writeAsStringSync
(
'event
$parameters
\n
'
,
mode:
FileMode
.
append
);
return
Future
<
void
>.
value
(
null
);
}
@override
void
setSessionValue
(
String
param
,
dynamic
value
)
{
_sessionValues
[
param
]
=
value
.
toString
();
}
}
packages/flutter_tools/test/general.shard/analytics_test.dart
View file @
14aa4d0a
...
...
@@ -4,20 +4,22 @@
import
'package:args/command_runner.dart'
;
import
'package:file/memory.dart'
;
import
'package:mockito/mockito.dart'
;
import
'package:flutter_tools/src/base/config.dart'
;
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:flutter_tools/src/base/time.dart'
;
import
'package:flutter_tools/src/features.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/io.dart'
;
import
'package:flutter_tools/src/base/time.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/commands/build.dart'
;
import
'package:flutter_tools/src/commands/config.dart'
;
import
'package:flutter_tools/src/commands/doctor.dart'
;
import
'package:flutter_tools/src/doctor.dart'
;
import
'package:flutter_tools/src/features.dart'
;
import
'package:flutter_tools/src/reporting/usage.dart'
;
import
'package:flutter_tools/src/runner/flutter_command.dart'
;
import
'package:flutter_tools/src/version.dart'
;
import
'package:mockito/mockito.dart'
;
import
'package:platform/platform.dart'
;
import
'../src/common.dart'
;
...
...
@@ -90,17 +92,16 @@ void main() {
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'
));
expect
(
fs
.
file
(
'test'
).
readAsStringSync
(),
contains
(
'
$enabledFlutterFeatures
:
enable-web'
));
},
overrides:
<
Type
,
Generator
>{
FlutterVersion:
()
=>
FlutterVersion
(
const
SystemClock
()),
Usage:
()
=>
Usage
(
configDirOverride:
tempDir
.
path
),
Config:
()
=>
mockFlutterConfig
,
Platform:
()
=>
FakePlatform
(
environment:
<
String
,
String
>{
'FLUTTER_ANALYTICS_LOG_FILE'
:
'test'
,
}),
FileSystem:
()
=>
MemoryFileSystem
(),
});
testUsingContext
(
'Usage records multiple features in experiment setting'
,
()
async
{
...
...
@@ -111,17 +112,16 @@ void main() {
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'
));
expect
(
fs
.
file
(
'test'
).
readAsStringSync
(),
contains
(
'
$enabledFlutterFeatures
:
enable-web,enable-linux-desktop,enable-macos-desktop'
));
},
overrides:
<
Type
,
Generator
>{
FlutterVersion:
()
=>
FlutterVersion
(
const
SystemClock
()),
Usage:
()
=>
Usage
(
configDirOverride:
tempDir
.
path
),
Config:
()
=>
mockFlutterConfig
,
Platform:
()
=>
FakePlatform
(
environment:
<
String
,
String
>{
'FLUTTER_ANALYTICS_LOG_FILE'
:
'test'
,
}),
FileSystem:
()
=>
MemoryFileSystem
(),
});
});
...
...
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