-
-
Notifications
You must be signed in to change notification settings - Fork 344
/
Copy pathRNSentryOnDrawReporter+Test.mm
49 lines (39 loc) · 1.1 KB
/
RNSentryOnDrawReporter+Test.mm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#import "RNSentryOnDrawReporter+Test.h"
@interface MockedListener : NSObject <RNSentryFramesTrackerListenerProtocol>
@property (strong, nonatomic) RNSentryEmitNewFrameEvent emitNewFrameEvent;
- (instancetype)initWithMockedListener:(RNSentryEmitNewFrameEvent)emitNewFrameEvent;
@end
@implementation MockedListener
- (instancetype)initWithMockedListener:(RNSentryEmitNewFrameEvent)emitNewFrameEvent
{
self = [super init];
if (self) {
_emitNewFrameEvent = [emitNewFrameEvent copy];
}
return self;
}
- (void)startListening
{
self.emitNewFrameEvent(@([[NSDate date] timeIntervalSince1970]));
}
- (void)framesTrackerHasNewFrame:(nonnull NSDate *)newFrameDate
{
NSLog(@"Not implemented in the test mock");
}
@end
@implementation
RNSentryOnDrawReporterView (Testing)
+ (instancetype)createWithMockedListener
{
return [[self alloc] initWithMockedListener];
}
- (instancetype)initWithMockedListener
{
self = [super init];
if (self) {
self.framesListener =
[[MockedListener alloc] initWithMockedListener:[self createEmitNewFrameEvent]];
}
return self;
}
@end