Skip to content

Commit f233d5b

Browse files
authored
[Cleanup] Follow-up to #10259 (#10262)
* [Cleanup] Follow-up to 10259 * [skip ci] Resolve TODO In an effort to resolve this TODO, I marked the protocol as @optional to clean up some of the duplicate test code. While it cleaned up the test code, it did clutter up the actual usage of the API so I decided against doing so.
1 parent 11313da commit f233d5b

File tree

12 files changed

+45
-245
lines changed

12 files changed

+45
-245
lines changed

FirebaseAppCheck/Tests/Unit/Core/FIRAppCheckAPIServiceTests.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
@interface FIRHeartbeatLoggerFake : NSObject <FIRHeartbeatLoggerProtocol>
4242
@property(nonatomic, copy, nullable) FIRHeartbeatsPayload * (^onFlushHeartbeatsIntoPayloadHandler)
4343
(void);
44-
@property(nonatomic, copy, nullable) FIRHeartbeatInfoCode (^onHeartbeatCodeForTodayHandler)(void);
44+
@property(nonatomic, copy, nullable) FIRDailyHeartbeatCode (^onHeartbeatCodeForTodayHandler)(void);
4545
@end
4646

4747
@implementation FIRHeartbeatLoggerFake
@@ -54,12 +54,12 @@ - (nonnull FIRHeartbeatsPayload *)flushHeartbeatsIntoPayload {
5454
}
5555
}
5656

57-
- (FIRHeartbeatInfoCode)heartbeatCodeForToday {
57+
- (FIRDailyHeartbeatCode)heartbeatCodeForToday {
5858
// This API should not be used by the below tests because the AppCheck SDK
5959
// uses only the V2 heartbeat API (`flushHeartbeatsIntoPayload`) for getting
6060
// heartbeats.
6161
[self doesNotRecognizeSelector:_cmd];
62-
return FIRHeartbeatInfoCodeNone;
62+
return FIRDailyHeartbeatCodeNone;
6363
}
6464

6565
- (void)log {

FirebaseAuth/Tests/Unit/FIRAuthBackendRPCImplementationTests.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ - (void)postWithRequest:(id<FIRAuthRPCRequest>)request
147147
@interface FIRFakeHeartbeatLogger : NSObject <FIRHeartbeatLoggerProtocol>
148148
@property(nonatomic, copy, nullable) FIRHeartbeatsPayload * (^onFlushHeartbeatsIntoPayloadHandler)
149149
(void);
150-
@property(nonatomic, copy, nullable) FIRHeartbeatInfoCode (^onHeartbeatCodeForTodayHandler)(void);
150+
@property(nonatomic, copy, nullable) FIRDailyHeartbeatCode (^onHeartbeatCodeForTodayHandler)(void);
151151
@end
152152

153153
@implementation FIRFakeHeartbeatLogger
@@ -160,12 +160,12 @@ - (nonnull FIRHeartbeatsPayload *)flushHeartbeatsIntoPayload {
160160
}
161161
}
162162

163-
- (FIRHeartbeatInfoCode)heartbeatCodeForToday {
163+
- (FIRDailyHeartbeatCode)heartbeatCodeForToday {
164164
// This API should not be used by the below tests because the Auth
165165
// SDK uses only the V2 heartbeat API (`flushHeartbeatsIntoPayload`) for
166166
// getting heartbeats.
167167
[self doesNotRecognizeSelector:_cmd];
168-
return FIRHeartbeatInfoCodeNone;
168+
return FIRDailyHeartbeatCodeNone;
169169
}
170170

171171
- (void)log {

FirebaseCore/Extension/FIRHeartbeatInfo.h

Lines changed: 0 additions & 41 deletions
This file was deleted.

FirebaseCore/Extension/FIRHeartbeatLogger.h

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,22 @@
1414

1515
#import <Foundation/Foundation.h>
1616

17-
// TODO(ncooke3): Remove in future PR when `FIRHeartbeatInfo` symbol is removed.
18-
#import "FIRHeartbeatInfo.h"
19-
2017
NS_ASSUME_NONNULL_BEGIN
2118

2219
#ifndef FIREBASE_BUILD_CMAKE
2320
@class FIRHeartbeatsPayload;
2421
#endif // FIREBASE_BUILD_CMAKE
2522

26-
// TODO(ncooke3): Consider annotating protocol API as `@optional`. (#9568)
23+
/// Enum representing different daily heartbeat codes.
24+
/// This enum is only used by clients using platform logging V1. This is because
25+
/// the V1 payload only supports a single daily heartbeat.
26+
typedef NS_ENUM(NSInteger, FIRDailyHeartbeatCode) {
27+
/// Represents the absence of a daily heartbeat.
28+
FIRDailyHeartbeatCodeNone = 0,
29+
/// Represents the presence of a daily heartbeat.
30+
FIRDailyHeartbeatCodeSome = 2,
31+
};
32+
2733
@protocol FIRHeartbeatLoggerProtocol <NSObject>
2834

2935
/// Asynchronously logs a heartbeat.
@@ -35,7 +41,7 @@ NS_ASSUME_NONNULL_BEGIN
3541
#endif // FIREBASE_BUILD_CMAKE
3642

3743
/// Gets the heartbeat code for today.
38-
- (FIRHeartbeatInfoCode)heartbeatCodeForToday;
44+
- (FIRDailyHeartbeatCode)heartbeatCodeForToday;
3945

4046
@end
4147

@@ -77,7 +83,7 @@ NSString *_Nullable FIRHeaderValueFromHeartbeatsPayload(FIRHeartbeatsPayload *he
7783
///
7884
/// @note This API is thread-safe.
7985
/// @return Heartbeat code indicating whether or not there is an unsent global heartbeat.
80-
- (FIRHeartbeatInfoCode)heartbeatCodeForToday;
86+
- (FIRDailyHeartbeatCode)heartbeatCodeForToday;
8187

8288
@end
8389

FirebaseCore/Extension/FirebaseCoreInternal.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#import "FIRComponentContainer.h"
2020
#import "FIRComponentType.h"
2121
#import "FIRDependency.h"
22-
#import "FIRHeartbeatInfo.h"
2322
#import "FIRHeartbeatLogger.h"
2423
#import "FIRLibrary.h"
2524
#import "FIRLogger.h"

FirebaseCore/Sources/FIRHeartbeatInfo.m

Lines changed: 0 additions & 72 deletions
This file was deleted.

FirebaseCore/Sources/FIRHeartbeatLogger.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,17 @@ - (FIRHeartbeatsPayload *)flushHeartbeatsIntoPayload {
7676
}
7777
#endif // FIREBASE_BUILD_CMAKE
7878

79-
- (FIRHeartbeatInfoCode)heartbeatCodeForToday {
79+
- (FIRDailyHeartbeatCode)heartbeatCodeForToday {
8080
#ifndef FIREBASE_BUILD_CMAKE
8181
FIRHeartbeatsPayload *todaysHeartbeatPayload = [_heartbeatController flushHeartbeatFromToday];
8282

8383
if ([todaysHeartbeatPayload isEmpty]) {
84-
return FIRHeartbeatInfoCodeNone;
84+
return FIRDailyHeartbeatCodeNone;
8585
} else {
86-
return FIRHeartbeatInfoCodeGlobal;
86+
return FIRDailyHeartbeatCodeSome;
8787
}
8888
#else
89-
return FIRHeartbeatInfoCodeNone;
89+
return FIRDailyHeartbeatCodeNone;
9090
#endif // FIREBASE_BUILD_CMAKE
9191
}
9292

FirebaseCore/Tests/Unit/FIRHeartbeatInfoTest.m

Lines changed: 0 additions & 91 deletions
This file was deleted.

FirebaseCore/Tests/Unit/FIRHeartbeatLoggerTests.m

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,23 +91,23 @@ - (void)testDoNotLogMoreThanOnceToday_AfterFlushing {
9191
[self assertHeartbeatsPayloadIsEmpty:secondHeartbeatsPayload];
9292
}
9393

94-
- (void)testFlushing_UsingV1API_WhenHeartbeatsAreStored_ReturnsFIRHeartbeatInfoCodeGlobal {
94+
- (void)testFlushing_UsingV1API_WhenHeartbeatsAreStored_ReturnsFIRDailyHeartbeatCodeSome {
9595
// Given
9696
FIRHeartbeatLogger *heartbeatLogger = self.heartbeatLogger;
9797
// When
9898
[heartbeatLogger log];
99-
FIRHeartbeatInfoCode heartbeatInfoCode = [heartbeatLogger heartbeatCodeForToday];
99+
FIRDailyHeartbeatCode heartbeatInfoCode = [heartbeatLogger heartbeatCodeForToday];
100100
// Then
101-
XCTAssertEqual(heartbeatInfoCode, FIRHeartbeatInfoCodeGlobal);
101+
XCTAssertEqual(heartbeatInfoCode, FIRDailyHeartbeatCodeSome);
102102
}
103103

104-
- (void)testFlushing_UsingV1API_WhenNoHeartbeatsAreStored_ReturnsFIRHeartbeatInfoCodeNone {
104+
- (void)testFlushing_UsingV1API_WhenNoHeartbeatsAreStored_ReturnsFIRDailyHeartbeatCodeNone {
105105
// Given
106106
FIRHeartbeatLogger *heartbeatLogger = self.heartbeatLogger;
107107
// When
108-
FIRHeartbeatInfoCode heartbeatInfoCode = [heartbeatLogger heartbeatCodeForToday];
108+
FIRDailyHeartbeatCode heartbeatInfoCode = [heartbeatLogger heartbeatCodeForToday];
109109
// Then
110-
XCTAssertEqual(heartbeatInfoCode, FIRHeartbeatInfoCodeNone);
110+
XCTAssertEqual(heartbeatInfoCode, FIRDailyHeartbeatCodeNone);
111111
}
112112

113113
- (void)testFlushing_UsingV2API_WhenHeartbeatsAreStored_ReturnsNonEmptyPayload {
@@ -139,10 +139,10 @@ - (void)testLogAndFlushUsingV1API_AndThenFlushAgainUsingV2API_FlushesHeartbeatIn
139139
FIRHeartbeatLogger *heartbeatLogger = self.heartbeatLogger;
140140
[heartbeatLogger log];
141141
// When
142-
FIRHeartbeatInfoCode heartbeatInfoCode = [heartbeatLogger heartbeatCodeForToday];
142+
FIRDailyHeartbeatCode heartbeatInfoCode = [heartbeatLogger heartbeatCodeForToday];
143143
FIRHeartbeatsPayload *heartbeatsPayload = [heartbeatLogger flushHeartbeatsIntoPayload];
144144
// Then
145-
XCTAssertEqual(heartbeatInfoCode, FIRHeartbeatInfoCodeGlobal);
145+
XCTAssertEqual(heartbeatInfoCode, FIRDailyHeartbeatCodeSome);
146146
[self assertHeartbeatsPayloadIsEmpty:heartbeatsPayload];
147147
}
148148

@@ -153,14 +153,14 @@ - (void)testLogAndFlushUsingV2API_AndThenFlushAgainUsingV1API_FlushesHeartbeatIn
153153
[heartbeatLogger log];
154154
// When
155155
FIRHeartbeatsPayload *heartbeatsPayload = [heartbeatLogger flushHeartbeatsIntoPayload];
156-
FIRHeartbeatInfoCode heartbeatInfoCode = [heartbeatLogger heartbeatCodeForToday];
156+
FIRDailyHeartbeatCode heartbeatInfoCode = [heartbeatLogger heartbeatCodeForToday];
157157
// Then
158158
[self assertEncodedPayloadHeader:FIRHeaderValueFromHeartbeatsPayload(heartbeatsPayload)
159159
isEqualToPayloadJSON:@{
160160
@"version" : @2,
161161
@"heartbeats" : @[ @{@"agent" : @"dummy_agent", @"dates" : @[ expectedDate ]} ]
162162
}];
163-
XCTAssertEqual(heartbeatInfoCode, FIRHeartbeatInfoCodeNone);
163+
XCTAssertEqual(heartbeatInfoCode, FIRDailyHeartbeatCodeNone);
164164
}
165165

166166
- (void)testHeartbeatLoggersWithSameIDShareTheSameStorage {

0 commit comments

Comments
 (0)