File tree Expand file tree Collapse file tree 4 files changed +14
-13
lines changed
Tests/Unit-Tests/NewRelicAgentTests/Uncategorized Expand file tree Collapse file tree 4 files changed +14
-13
lines changed Original file line number Diff line number Diff line change @@ -94,7 +94,7 @@ - (void)start {
94
94
#endif
95
95
}
96
96
97
- - (void )createDurationMetric {
97
+ - (BOOL )createDurationMetric {
98
98
99
99
// Based on whether or not we've saved a boot timestamp and whether or not the app has been launched this boot we can determine whether or not this is a warm start.
100
100
NSDate *previousBootTime = [[NSUserDefaults standardUserDefaults ] objectForKey: systemBootTimestampKey];
@@ -114,16 +114,16 @@ - (void)createDurationMetric {
114
114
if ([self isPrewarmAvailable ] && isPrewarmLaunch) {
115
115
NRLOG_AGENT_INFO (@" New Relic: Skipping App Start Time because iOS prewarmed this launch." );
116
116
117
- return ;
117
+ return false ;
118
118
}
119
119
if (self.isWarmLaunch ) {
120
120
NRLOG_AGENT_INFO (@" New Relic: Skipping App Start Time because matching boot times." );
121
- return ;
121
+ return false ;
122
122
}
123
123
124
124
// If the app was running in the background. Skip recording this launch.
125
125
if (self.wasInBackground ) {
126
- return ;
126
+ return false ;
127
127
}
128
128
129
129
// App Launch Time: Cold is time between now and when process started.
@@ -132,10 +132,11 @@ - (void)createDurationMetric {
132
132
// Skip recording obviously wrong extra long app launch durations.
133
133
if (calculatedAppLaunchDuration >= maxAppLaunchDuration) {
134
134
NRLOG_AGENT_INFO (@" New Relic: Skipping app start time metric since %f > allowed." , calculatedAppLaunchDuration);
135
- return ;
135
+ return false ;
136
136
}
137
137
138
138
self.appLaunchDuration = calculatedAppLaunchDuration;
139
+ return true ;
139
140
}
140
141
141
142
- (BOOL )isPrewarmAvailable {
Original file line number Diff line number Diff line change 25
25
+ (void ) stop ;
26
26
27
27
+ (void ) synchronousDequeue ;
28
+ + (void ) synchronousDequeueWithCompletion : (void (^)(BOOL ))completion ;
28
29
@end
Original file line number Diff line number Diff line change @@ -207,7 +207,7 @@ - (void) testRemoteLogLevels {
207
207
@" additionalAttribute2" : @" attribute2"
208
208
}];
209
209
210
- [self waitForExpectationsWithTimeout: 5 handler: nil ];
210
+ [self waitForExpectationsWithTimeout: 30 handler: nil ];
211
211
212
212
NSError * error;
213
213
NSData * logData = [NRLogger logFileData: &error];
@@ -290,7 +290,7 @@ - (void) testLocalLogLevels {
290
290
@" additionalAttribute2" : @" attribute2"
291
291
}];
292
292
293
- [self waitForExpectationsWithTimeout: 5 handler: nil ];
293
+ [self waitForExpectationsWithTimeout: 30 handler: nil ];
294
294
295
295
NSError * error;
296
296
NSData * logData = [NRLogger logFileData: &error];
@@ -365,7 +365,7 @@ - (void) testAutoCollectedLogs {
365
365
os_log_error (customLog, " This is an error os_log message.\n " );
366
366
os_log_fault (customLog, " This is a fault os_log message.\n " );
367
367
368
- [self waitForExpectationsWithTimeout: 5 handler: nil ];
368
+ [self waitForExpectationsWithTimeout: 30 handler: nil ];
369
369
370
370
[NRAutoLogCollector restoreStandardOutputAndError ];
371
371
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ + (void) clear;
19
19
@end
20
20
21
21
@interface NRMAStartTimer ()
22
- - (void )createDurationMetric ;
22
+ - (BOOL )createDurationMetric ;
23
23
@end
24
24
25
25
@implementation NRMAStartTimerTests
@@ -46,14 +46,13 @@ - (void) tearDown {
46
46
-(void )test {
47
47
[[NSUserDefaults standardUserDefaults ] removeObjectForKey: @" systemBootTimestamp" ];
48
48
49
- [[NRMAStartTimer sharedInstance ] createDurationMetric ];
50
-
49
+ BOOL success = [[NRMAStartTimer sharedInstance ] createDurationMetric ];
50
+ XCTSkipIf (!success, @" Failed to create duration metric" );
51
+
51
52
[NRMASupportMetricHelper processDeferredMetrics ];
52
53
53
54
[NRMATaskQueue synchronousDequeue ];
54
55
55
- sleep (1 );
56
-
57
56
NRMANamedValueMeasurement* measurement = ((NRMANamedValueMeasurement*)helper.result );
58
57
59
58
XCTAssertTrue ([measurement.name isEqualToString: NRMA_METRIC_APP_LAUNCH_COLD], @" %@ does not equal AppLaunch/Cold" , measurement.name );
You can’t perform that action at this time.
0 commit comments