Skip to content

Commit 9b5742c

Browse files
authored
Implement some stubbed methods, update umbrella header, add missing test (#2214)
* Add missing test * Implement some stubbed methods, update the umbrella header
1 parent a33e17d commit 9b5742c

File tree

5 files changed

+57
-6
lines changed

5 files changed

+57
-6
lines changed

GoogleDataLogger/GoogleDataLogger/Classes/GDLRegistrar.m

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
#import "GDLRegistrar.h"
1818

19+
#import "GDLRegistrar_Private.h"
20+
1921
@implementation GDLRegistrar
2022

2123
+ (instancetype)sharedInstance {
@@ -27,13 +29,22 @@ + (instancetype)sharedInstance {
2729
return sharedInstance;
2830
}
2931

32+
- (instancetype)init {
33+
self = [super init];
34+
if (self) {
35+
_logTargetToPrioritizer = [[NSMutableDictionary alloc] init];
36+
_logTargetToBackend = [[NSMutableDictionary alloc] init];
37+
}
38+
return self;
39+
}
40+
3041
- (void)registerBackend:(id<GDLLogBackend>)backend forLogTarget:(NSInteger)logTarget {
31-
// TODO
42+
self.logTargetToBackend[@(logTarget)] = backend;
3243
}
3344

3445
- (void)registerLogPrioritizer:(id<GDLLogPrioritizer>)prioritizer
3546
forLogTarget:(NSInteger)logTarget {
36-
// TODO
47+
self.logTargetToPrioritizer[@(logTarget)] = prioritizer;
3748
}
3849

3950
@end

GoogleDataLogger/GoogleDataLogger/Classes/Private/GDLRegistrar_Private.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
@interface GDLRegistrar ()
2020

2121
/** A map of logTargets to backend implementations. */
22-
@property(nonatomic) NSDictionary<NSNumber *, id<GDLLogBackend>> *logTargetToBackend;
22+
@property(nonatomic) NSMutableDictionary<NSNumber *, id<GDLLogBackend>> *logTargetToBackend;
2323

2424
/** A map of logTargets to prioritizer implementations. */
25-
@property(nonatomic) NSDictionary<NSNumber *, id<GDLLogPrioritizer>> *logTargetToPrioritizer;
25+
@property(nonatomic) NSMutableDictionary<NSNumber *, id<GDLLogPrioritizer>> *logTargetToPrioritizer;
2626

2727
@end

GoogleDataLogger/GoogleDataLogger/Classes/Public/GDLLogBackend.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@
1616

1717
#import <Foundation/Foundation.h>
1818

19+
NS_ASSUME_NONNULL_BEGIN
20+
1921
/** A convenient typedef to define the block to be called upon completion of an upload to the
2022
* backend.
2123
*/
22-
typedef void (^GDLBackendCompletionBlock)(NSSet<NSURL *> *successfulUploads,
23-
NSSet<NSURL *> *unsuccessfulUploads);
24+
typedef void (^GDLBackendCompletionBlock)(NSSet<NSURL *> *_Nullable successfulUploads,
25+
NSSet<NSURL *> *_Nullable unsuccessfulUploads);
2426

2527
/** This protocol defines the common interface for logging backend implementations. */
2628
@protocol GDLLogBackend <NSObject>
@@ -37,3 +39,5 @@ typedef void (^GDLBackendCompletionBlock)(NSSet<NSURL *> *successfulUploads,
3739
- (void)uploadLogs:(NSSet<NSURL *> *)logFiles onComplete:(GDLBackendCompletionBlock)onComplete;
3840

3941
@end
42+
43+
NS_ASSUME_NONNULL_END

GoogleDataLogger/GoogleDataLogger/Classes/Public/GoogleDataLogger.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
* limitations under the License.
1515
*/
1616

17+
#import "GDLLogBackend.h"
1718
#import "GDLLogEvent.h"
19+
#import "GDLLogPrioritizer.h"
20+
#import "GDLLogProto.h"
1821
#import "GDLLogTransformer.h"
1922
#import "GDLLogger.h"
23+
#import "GDLRegistrar.h"

GoogleDataLogger/Tests/GDLClockTest.m

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright 2018 Google
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#import <XCTest/XCTest.h>
18+
19+
#import "GDLClock.h"
20+
21+
@interface GDLClockTest : XCTestCase
22+
23+
@end
24+
25+
@implementation GDLClockTest
26+
27+
/** Tests the default initializer. */
28+
- (void)testInit {
29+
XCTAssertNotNil([[GDLClockTest alloc] init]);
30+
}
31+
32+
@end

0 commit comments

Comments
 (0)