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
5e2d3e95
Commit
5e2d3e95
authored
Mar 07, 2017
by
Yegor
Committed by
GitHub
Mar 07, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up crash reporting code (#8602)
parent
24eeddc0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
21 deletions
+14
-21
crash_reporting.dart
packages/flutter_tools/lib/src/crash_reporting.dart
+8
-11
crash_reporting_test.dart
packages/flutter_tools/test/crash_reporting_test.dart
+6
-10
No files found.
packages/flutter_tools/lib/src/crash_reporting.dart
View file @
5e2d3e95
...
...
@@ -37,19 +37,20 @@ String _kStackTraceFileField = 'DartError';
/// it must be supplied in the request.
String
_kStackTraceFilename
=
'stacktrace_file'
;
/// We only send crash reports in testing mode.
///
/// See [enterTestingMode] and [exitTestingMode].
bool
_testing
=
false
;
/// Sends crash reports to Google.
class
CrashReportSender
{
static
final
Uri
_
defaultB
aseUri
=
new
Uri
(
static
final
Uri
_
b
aseUri
=
new
Uri
(
scheme:
'https'
,
host:
_kCrashServerHost
,
port:
443
,
path:
_kCrashEndpointPath
,
);
static
Uri
_baseUri
=
_defaultBaseUri
;
static
CrashReportSender
_instance
;
CrashReportSender
.
_
(
this
.
_client
);
...
...
@@ -128,19 +129,15 @@ class CrashReportSender {
}
}
/// Overrides [CrashReportSender._baseUri] for testing and enables testing
/// mode.
/// Enables testing mode.
@visibleForTesting
void
overrideBaseCrashUrlForTesting
(
Uri
uri
)
{
CrashReportSender
.
_baseUri
=
uri
;
void
enterTestingMode
(
)
{
_testing
=
true
;
}
/// Resets [CrashReportSender._baseUri] back to the original value and disables
/// test mode.
/// Disables testing mode.
@visibleForTesting
void
resetBaseCrashUrlForTesting
(
)
{
CrashReportSender
.
_baseUri
=
CrashReportSender
.
_defaultBaseUri
;
void
exitTestingMode
(
)
{
_testing
=
false
;
}
...
...
packages/flutter_tools/test/crash_reporting_test.dart
View file @
5e2d3e95
...
...
@@ -15,26 +15,22 @@ import 'package:flutter_tools/executable.dart' as tools;
import
'package:flutter_tools/src/base/context.dart'
;
import
'package:flutter_tools/src/base/io.dart'
;
import
'package:flutter_tools/src/base/logger.dart'
;
import
'package:flutter_tools/src/base/os.dart'
as
os
;
import
'package:flutter_tools/src/crash_reporting.dart'
;
import
'package:flutter_tools/src/runner/flutter_command.dart'
;
import
'src/context.dart'
;
void
main
(
)
{
group
(
'crash reporting'
,
()
{
int
testPort
;
setUp
(()
async
{
tools
.
crashFileSystem
=
new
MemoryFileSystem
();
setExitFunctionForTests
((
_
)
{
});
testPort
=
await
os
.
findAvailablePort
();
overrideBaseCrashUrlForTesting
(
Uri
.
parse
(
'http://localhost:
$testPort
/test-path'
));
enterTestingMode
();
});
tearDown
(()
{
tools
.
crashFileSystem
=
new
LocalFileSystem
();
restoreExitFunction
();
resetBaseCrashUrlForTesting
();
exitTestingMode
();
});
testUsingContext
(
'should send crash reports'
,
()
async
{
...
...
@@ -62,10 +58,10 @@ void main() {
// Verify that we sent the crash report.
expect
(
method
,
'POST'
);
expect
(
uri
,
new
Uri
(
scheme:
'http'
,
host:
'
localhost
'
,
port:
testPort
,
path:
'/
test-path
'
,
scheme:
'http
s
'
,
host:
'
clients2.google.com
'
,
port:
443
,
path:
'/
cr/staging_report
'
,
queryParameters:
<
String
,
String
>{
'product'
:
'Flutter_Tools'
,
'version'
:
'test-version'
,
...
...
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