File tree 2 files changed +13
-2
lines changed
packages/firebase_performance/firebase_performance
2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change 3
3
// found in the LICENSE file.
4
4
5
5
import 'package:firebase_core/firebase_core.dart' ;
6
- import 'package:flutter_test/flutter_test.dart' ;
7
6
import 'package:firebase_performance/firebase_performance.dart' ;
8
7
import 'package:flutter/foundation.dart' show kIsWeb;
8
+ import 'package:flutter_test/flutter_test.dart' ;
9
9
import 'package:integration_test/integration_test.dart' ;
10
10
11
11
import 'firebase_options.dart' ;
@@ -46,10 +46,10 @@ void main() {
46
46
47
47
setUpAll (() async {
48
48
performance = FirebasePerformance .instance;
49
- await performance.setPerformanceCollectionEnabled (true );
50
49
});
51
50
52
51
setUp (() async {
52
+ await performance.setPerformanceCollectionEnabled (true );
53
53
testTrace = performance.newTrace ('test-trace' );
54
54
});
55
55
@@ -58,6 +58,12 @@ void main() {
58
58
await testTrace.stop ();
59
59
});
60
60
61
+ test ('starting trace with performance collection disabled' , () async {
62
+ await performance.setPerformanceCollectionEnabled (false );
63
+ await testTrace.start ();
64
+ await testTrace.stop ();
65
+ });
66
+
61
67
test ("starting Trace twice shouldn't throw an error" , () async {
62
68
await testTrace.start ();
63
69
await testTrace.start ();
Original file line number Diff line number Diff line change @@ -130,6 +130,11 @@ - (void)traceStart:(id)arguments withMethodCallResult:(FLTFirebaseMethodCallResu
130
130
NSString *name = arguments[@" name" ];
131
131
132
132
FIRTrace *trace = [FIRPerformance startTraceWithName: name];
133
+ if (trace == nil ) {
134
+ // Performance collection is disabled
135
+ result.success (nil );
136
+ return ;
137
+ }
133
138
_traceHandle = [NSNumber numberWithInt: [_traceHandle intValue ] + 1 ];
134
139
[_traces setObject: trace forKey: _traceHandle];
135
140
You can’t perform that action at this time.
0 commit comments