17
17
#import " FirebasePerformance/Sources/Configurations/FPRConfigurations+Private.h"
18
18
#import " FirebasePerformance/Sources/FPRClient+Private.h"
19
19
#import " FirebasePerformance/Sources/FPRClient.h"
20
+ #import " FirebasePerformance/Sources/FPRNanoPbUtils.h"
20
21
#import " FirebasePerformance/Sources/Loggers/FPRGDTLogger.h"
21
22
#import " FirebasePerformance/Sources/Loggers/FPRGDTLogger_Private.h"
22
23
29
30
#import < OCMock/OCMock.h>
30
31
#import " SharedTestUtilities/GDTCORTransportFake.h"
31
32
33
+ NSString *const kFPRMockInstallationId = @" mockId" ;
34
+
32
35
@interface FPRClientTest : FPRTestCase
33
36
34
37
/* * Configuration which can be assigned as a fake object for event dispatch control. */
@@ -47,7 +50,7 @@ - (void)setUp {
47
50
// Arrange installations object.
48
51
FPRFakeInstallations *installations = [FPRFakeInstallations installations ];
49
52
self.client = [[FPRClient alloc ] init ];
50
- installations.identifier = @" mockId " ;
53
+ installations.identifier = kFPRMockInstallationId ;
51
54
self.client .installations = (FIRInstallations *)installations;
52
55
53
56
// Arrange remote config object.
@@ -73,6 +76,9 @@ - (void)testLogAndProcessEventsForTrace {
73
76
// Act on event logging call.
74
77
[self .client processAndLogEvent: perfMetric];
75
78
79
+ firebase_perf_v1_PerfMetric expectedMetric = perfMetric;
80
+ expectedMetric.application_info .app_instance_id = FPREncodeString (kFPRMockInstallationId );
81
+
76
82
// Wait for async job to execute event logging.
77
83
dispatch_group_wait (self.client .eventsQueueGroup , DISPATCH_TIME_FOREVER);
78
84
@@ -82,8 +88,10 @@ - (void)testLogAndProcessEventsForTrace {
82
88
(GDTCORTransportFake *)self.client .gdtLogger .gdtfllTransport ;
83
89
XCTAssertEqual (fakeGdtTransport.logEvents .count , 1 );
84
90
GDTCOREvent *event = fakeGdtTransport.logEvents .firstObject ;
91
+ XCTAssertNotNil (
92
+ FPRDecodeString ([(FPRGDTEvent *)event.dataObject metric ].application_info .app_instance_id ));
85
93
XCTAssertEqualObjects ([event.dataObject transportBytes ],
86
- [[FPRGDTEvent gdtEventForPerfMetric: perfMetric ] transportBytes ]);
94
+ [[FPRGDTEvent gdtEventForPerfMetric: expectedMetric ] transportBytes ]);
87
95
});
88
96
}
89
97
@@ -96,6 +104,9 @@ - (void)testLogAndProcessEventsForNetworkTrace {
96
104
// Act on event logging call.
97
105
[self .client processAndLogEvent: perfMetric];
98
106
107
+ firebase_perf_v1_PerfMetric expectedMetric = perfMetric;
108
+ expectedMetric.application_info .app_instance_id = FPREncodeString (kFPRMockInstallationId );
109
+
99
110
// Wait for async job to execute event logging.
100
111
dispatch_group_wait (self.client .eventsQueueGroup , DISPATCH_TIME_FOREVER);
101
112
@@ -105,8 +116,10 @@ - (void)testLogAndProcessEventsForNetworkTrace {
105
116
(GDTCORTransportFake *)self.client .gdtLogger .gdtfllTransport ;
106
117
XCTAssertEqual (fakeGdtTransport.logEvents .count , 1 );
107
118
GDTCOREvent *event = fakeGdtTransport.logEvents .firstObject ;
119
+ XCTAssertNotNil (
120
+ FPRDecodeString ([(FPRGDTEvent *)event.dataObject metric ].application_info .app_instance_id ));
108
121
XCTAssertEqualObjects ([event.dataObject transportBytes ],
109
- [[FPRGDTEvent gdtEventForPerfMetric: perfMetric ] transportBytes ]);
122
+ [[FPRGDTEvent gdtEventForPerfMetric: expectedMetric ] transportBytes ]);
110
123
});
111
124
}
112
125
@@ -118,6 +131,9 @@ - (void)testLogAndProcessEventsForGauge {
118
131
// Act on event logging call.
119
132
[self .client processAndLogEvent: perfMetric];
120
133
134
+ firebase_perf_v1_PerfMetric expectedMetric = perfMetric;
135
+ expectedMetric.application_info .app_instance_id = FPREncodeString (kFPRMockInstallationId );
136
+
121
137
// Wait for async job to execute event logging.
122
138
dispatch_group_wait (self.client .eventsQueueGroup , DISPATCH_TIME_FOREVER);
123
139
@@ -127,8 +143,10 @@ - (void)testLogAndProcessEventsForGauge {
127
143
(GDTCORTransportFake *)self.client .gdtLogger .gdtfllTransport ;
128
144
XCTAssertEqual (fakeGdtTransport.logEvents .count , 1 );
129
145
GDTCOREvent *event = fakeGdtTransport.logEvents .firstObject ;
146
+ XCTAssertNotNil (
147
+ FPRDecodeString ([(FPRGDTEvent *)event.dataObject metric ].application_info .app_instance_id ));
130
148
XCTAssertEqualObjects ([event.dataObject transportBytes ],
131
- [[FPRGDTEvent gdtEventForPerfMetric: perfMetric ] transportBytes ]);
149
+ [[FPRGDTEvent gdtEventForPerfMetric: expectedMetric ] transportBytes ]);
132
150
});
133
151
}
134
152
0 commit comments