Skip to content

Commit 6ca2bfe

Browse files
authored
Center Popup + Interstitial + PushAsktoAsk snapshot test (#346)
1 parent 4baeadf commit 6ca2bfe

File tree

8 files changed

+262
-19
lines changed

8 files changed

+262
-19
lines changed

Example/Leanplum-SDK.xcodeproj/project.pbxproj

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,12 @@
101101
9CD04D941F8EE7E30033AB4A /* variables_with_newsfeed_response.json in Resources */ = {isa = PBXBuildFile; fileRef = 9CD04D931F8EB6190033AB4A /* variables_with_newsfeed_response.json */; };
102102
9CD04D951F8EE7E30033AB4A /* variables_with_newsfeed_response.json in Resources */ = {isa = PBXBuildFile; fileRef = 9CD04D931F8EB6190033AB4A /* variables_with_newsfeed_response.json */; };
103103
A84527FD215C3035001FA20D /* LPRequestTest.m in Sources */ = {isa = PBXBuildFile; fileRef = A84527FC215C3035001FA20D /* LPRequestTest.m */; };
104-
A86C8CF42405E271003F5E4E /* LPAlertMessageSnapshotTest.m in Sources */ = {isa = PBXBuildFile; fileRef = A86C8CF32405E271003F5E4E /* LPAlertMessageSnapshotTest.m */; };
105104
A86C8CF624072814003F5E4E /* LPOpenUrlMessageTemplateTest.m in Sources */ = {isa = PBXBuildFile; fileRef = A86C8CF524072814003F5E4E /* LPOpenUrlMessageTemplateTest.m */; };
106-
A86C8CF924084263003F5E4E /* LPConfirmMessageSnapshotTest.m in Sources */ = {isa = PBXBuildFile; fileRef = A86C8CF724084236003F5E4E /* LPConfirmMessageSnapshotTest.m */; };
105+
A86C8D00240844C7003F5E4E /* LPPushAskToAskMessageSnapshotTest.m in Sources */ = {isa = PBXBuildFile; fileRef = A86C8CFA240844C6003F5E4E /* LPPushAskToAskMessageSnapshotTest.m */; };
106+
A86C8D02240844C7003F5E4E /* LPConfirmMessageSnapshotTest.m in Sources */ = {isa = PBXBuildFile; fileRef = A86C8CFB240844C6003F5E4E /* LPConfirmMessageSnapshotTest.m */; };
107+
A86C8D04240844C7003F5E4E /* LPCenterPopupMessageSnapshotTest.m in Sources */ = {isa = PBXBuildFile; fileRef = A86C8CFC240844C7003F5E4E /* LPCenterPopupMessageSnapshotTest.m */; };
108+
A86C8D06240844C7003F5E4E /* LPInterstitialMessageSnapshotTest.m in Sources */ = {isa = PBXBuildFile; fileRef = A86C8CFD240844C7003F5E4E /* LPInterstitialMessageSnapshotTest.m */; };
109+
A86C8D08240844C7003F5E4E /* LPAlertMessageSnapshotTest.m in Sources */ = {isa = PBXBuildFile; fileRef = A86C8CFE240844C7003F5E4E /* LPAlertMessageSnapshotTest.m */; };
107110
A8CB8A36227276A400E1001D /* LeanplumRequestTest.m in Sources */ = {isa = PBXBuildFile; fileRef = A8CB8A35227276A400E1001D /* LeanplumRequestTest.m */; };
108111
A8EEA1AB20E44B0B00FF9A4D /* start_with_variant_debug_info_response.json in Resources */ = {isa = PBXBuildFile; fileRef = A8EEA1AA20E44B0A00FF9A4D /* start_with_variant_debug_info_response.json */; };
109112
A8EEA1AC20E44B0B00FF9A4D /* start_with_variant_debug_info_response.json in Resources */ = {isa = PBXBuildFile; fileRef = A8EEA1AA20E44B0A00FF9A4D /* start_with_variant_debug_info_response.json */; };
@@ -211,9 +214,12 @@
211214
9CD04D931F8EB6190033AB4A /* variables_with_newsfeed_response.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = variables_with_newsfeed_response.json; sourceTree = "<group>"; };
212215
A54ACCFCB36AE8C874708A7F /* libPods-Leanplum-SDK_Example-Leanplum-SDK_Tests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Leanplum-SDK_Example-Leanplum-SDK_Tests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
213216
A84527FC215C3035001FA20D /* LPRequestTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LPRequestTest.m; sourceTree = "<group>"; };
214-
A86C8CF32405E271003F5E4E /* LPAlertMessageSnapshotTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LPAlertMessageSnapshotTest.m; sourceTree = "<group>"; };
215217
A86C8CF524072814003F5E4E /* LPOpenUrlMessageTemplateTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LPOpenUrlMessageTemplateTest.m; sourceTree = "<group>"; };
216-
A86C8CF724084236003F5E4E /* LPConfirmMessageSnapshotTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LPConfirmMessageSnapshotTest.m; sourceTree = "<group>"; };
218+
A86C8CFA240844C6003F5E4E /* LPPushAskToAskMessageSnapshotTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LPPushAskToAskMessageSnapshotTest.m; sourceTree = "<group>"; };
219+
A86C8CFB240844C6003F5E4E /* LPConfirmMessageSnapshotTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LPConfirmMessageSnapshotTest.m; sourceTree = "<group>"; };
220+
A86C8CFC240844C7003F5E4E /* LPCenterPopupMessageSnapshotTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LPCenterPopupMessageSnapshotTest.m; sourceTree = "<group>"; };
221+
A86C8CFD240844C7003F5E4E /* LPInterstitialMessageSnapshotTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LPInterstitialMessageSnapshotTest.m; sourceTree = "<group>"; };
222+
A86C8CFE240844C7003F5E4E /* LPAlertMessageSnapshotTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LPAlertMessageSnapshotTest.m; sourceTree = "<group>"; };
217223
A8CB8A35227276A400E1001D /* LeanplumRequestTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LeanplumRequestTest.m; sourceTree = "<group>"; };
218224
A8EEA1AA20E44B0A00FF9A4D /* start_with_variant_debug_info_response.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = start_with_variant_debug_info_response.json; sourceTree = "<group>"; };
219225
A8F5D58623F3483E00313C98 /* LPBaseInterstitialMessageTemplateTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LPBaseInterstitialMessageTemplateTest.m; sourceTree = "<group>"; };
@@ -483,8 +489,11 @@
483489
A86C8CF22405E23E003F5E4E /* Snapshot Tests */ = {
484490
isa = PBXGroup;
485491
children = (
486-
A86C8CF32405E271003F5E4E /* LPAlertMessageSnapshotTest.m */,
487-
A86C8CF724084236003F5E4E /* LPConfirmMessageSnapshotTest.m */,
492+
A86C8CFE240844C7003F5E4E /* LPAlertMessageSnapshotTest.m */,
493+
A86C8CFC240844C7003F5E4E /* LPCenterPopupMessageSnapshotTest.m */,
494+
A86C8CFB240844C6003F5E4E /* LPConfirmMessageSnapshotTest.m */,
495+
A86C8CFD240844C7003F5E4E /* LPInterstitialMessageSnapshotTest.m */,
496+
A86C8CFA240844C6003F5E4E /* LPPushAskToAskMessageSnapshotTest.m */,
488497
);
489498
path = "Snapshot Tests";
490499
sourceTree = "<group>";
@@ -781,19 +790,22 @@
781790
isa = PBXSourcesBuildPhase;
782791
buildActionMask = 2147483647;
783792
files = (
793+
A86C8D06240844C7003F5E4E /* LPInterstitialMessageSnapshotTest.m in Sources */,
784794
65D4AB49224CA963009BA5F3 /* LPActionContextTest.m in Sources */,
785795
07E5C8B31F052B7800A4B092 /* LPFileManagerTest.m in Sources */,
786796
A8CB8A36227276A400E1001D /* LeanplumRequestTest.m in Sources */,
797+
A86C8D08240844C7003F5E4E /* LPAlertMessageSnapshotTest.m in Sources */,
787798
07E5C8B81F052B7800A4B092 /* MessagesTest.m in Sources */,
799+
A86C8D00240844C7003F5E4E /* LPPushAskToAskMessageSnapshotTest.m in Sources */,
788800
07E5C8BD1F052B7800A4B092 /* LeanplumHelper.m in Sources */,
789801
07E5C8B21F052B7800A4B092 /* LPNetworkOperation+Category.m in Sources */,
790802
65E53E982148786C00A05040 /* LPCountAggregatorTest.m in Sources */,
791803
07E5C8B91F052B7800A4B092 /* LPMessageTemplatesClassTest.m in Sources */,
792-
A86C8CF924084263003F5E4E /* LPConfirmMessageSnapshotTest.m in Sources */,
804+
A86C8D02240844C7003F5E4E /* LPConfirmMessageSnapshotTest.m in Sources */,
793805
A8F5D58A23F34AD400313C98 /* LPBasePushMessageTemplateTest.m in Sources */,
794806
07E5C8B11F052B7800A4B092 /* LPNetworkEngine+Category.m in Sources */,
795807
07E5C8B61F052B7800A4B092 /* LeanplumTest.m in Sources */,
796-
A86C8CF42405E271003F5E4E /* LPAlertMessageSnapshotTest.m in Sources */,
808+
A86C8D04240844C7003F5E4E /* LPCenterPopupMessageSnapshotTest.m in Sources */,
797809
65E189C6216BDB82005E6B93 /* LPRequestFactoryTest.m in Sources */,
798810
07E5C8AD1F052B7800A4B092 /* LPEventDataManagerTest.m in Sources */,
799811
65E189C421643631005E6B93 /* LPRequestSenderTest.m in Sources */,
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
//
2+
// LPAlertMessageSnapshotTest.m
3+
// Leanplum-SDK_Tests
4+
//
5+
// Created by Mayank Sanganeria on 2/25/20.
6+
// Copyright © 2020 Leanplum. All rights reserved.
7+
//
8+
9+
#import <XCTest/XCTest.h>
10+
#import <FBSnapshotTestCase/FBSnapshotTestCase.h>
11+
#import <Leanplum/LPCenterPopupMessageTemplate.h>
12+
#import <OCMock.h>
13+
14+
@interface LPCenterPopupMessageTemplate()
15+
16+
@property (nonatomic, strong) UIView *popupGroup;
17+
- (void)setupPopupView;
18+
19+
@end
20+
21+
@interface LPActionContext(UnitTest)
22+
23+
+ (LPActionContext *)actionContextWithName:(NSString *)name
24+
args:(NSDictionary *)args
25+
messageId:(NSString *)messageId;
26+
27+
@end
28+
29+
@interface LPCenterPopupMessageSnapshotTest : FBSnapshotTestCase
30+
31+
@end
32+
33+
@implementation LPCenterPopupMessageSnapshotTest
34+
35+
- (void)setUp {
36+
[super setUp];
37+
//self.recordMode = YES;
38+
}
39+
40+
- (void)tearDown {
41+
[super tearDown];
42+
}
43+
44+
- (void)testView {
45+
LPCenterPopupMessageTemplate *template = [[LPCenterPopupMessageTemplate alloc] init];
46+
LPActionContext *context = [LPActionContext actionContextWithName:LPMT_CENTER_POPUP_NAME args:@{
47+
LPMT_ARG_TITLE_TEXT:APP_NAME,
48+
LPMT_ARG_TITLE_COLOR:[UIColor redColor],
49+
LPMT_ARG_MESSAGE_TEXT:LPMT_DEFAULT_POPUP_MESSAGE,
50+
LPMT_ARG_MESSAGE_COLOR:[UIColor blackColor],
51+
LPMT_ARG_BACKGROUND_COLOR:[UIColor whiteColor],
52+
LPMT_ARG_ACCEPT_BUTTON_TEXT:LPMT_DEFAULT_OK_BUTTON_TEXT,
53+
LPMT_ARG_ACCEPT_BUTTON_BACKGROUND_COLOR:[UIColor whiteColor],
54+
LPMT_ARG_ACCEPT_BUTTON_TEXT_COLOR:[UIColor blackColor],
55+
LPMT_ARG_LAYOUT_WIDTH:@(LPMT_DEFAULT_CENTER_POPUP_WIDTH),
56+
LPMT_ARG_LAYOUT_HEIGHT:@(LPMT_DEFAULT_CENTER_POPUP_HEIGHT),
57+
}
58+
messageId:0];
59+
id contextMock = OCMPartialMock(context);
60+
OCMStub([contextMock stringNamed:LPMT_ARG_TITLE_TEXT]).andReturn(APP_NAME);
61+
OCMStub([contextMock colorNamed:LPMT_ARG_TITLE_COLOR]).andReturn([UIColor blackColor]);
62+
OCMStub([contextMock stringNamed:LPMT_ARG_MESSAGE_TEXT]).andReturn(LPMT_DEFAULT_POPUP_MESSAGE);
63+
OCMStub([contextMock colorNamed:LPMT_ARG_MESSAGE_COLOR]).andReturn([UIColor blackColor]);
64+
OCMStub([contextMock colorNamed:LPMT_ARG_BACKGROUND_COLOR]).andReturn([UIColor whiteColor]);
65+
OCMStub([contextMock stringNamed:LPMT_ARG_ACCEPT_BUTTON_TEXT]).andReturn(LPMT_DEFAULT_OK_BUTTON_TEXT);
66+
OCMStub([contextMock colorNamed:LPMT_ARG_ACCEPT_BUTTON_BACKGROUND_COLOR]).andReturn([UIColor whiteColor]);
67+
OCMStub([contextMock colorNamed:LPMT_ARG_ACCEPT_BUTTON_TEXT_COLOR]).andReturn([UIColor blackColor]);
68+
OCMStub([contextMock numberNamed:LPMT_ARG_LAYOUT_WIDTH]).andReturn(@(LPMT_DEFAULT_CENTER_POPUP_WIDTH));
69+
OCMStub([contextMock numberNamed:LPMT_ARG_LAYOUT_HEIGHT]).andReturn(@(LPMT_DEFAULT_CENTER_POPUP_HEIGHT));
70+
71+
template.contexts = [@[contextMock] mutableCopy];
72+
[template setupPopupView];
73+
FBSnapshotVerifyView(template.popupGroup, nil);
74+
}
75+
76+
@end
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
//
2+
// LPAlertMessageSnapshotTest.m
3+
// Leanplum-SDK_Tests
4+
//
5+
// Created by Mayank Sanganeria on 2/25/20.
6+
// Copyright © 2020 Leanplum. All rights reserved.
7+
//
8+
9+
#import <XCTest/XCTest.h>
10+
#import <FBSnapshotTestCase/FBSnapshotTestCase.h>
11+
#import <Leanplum/LPInterstitialMessageTemplate.h>
12+
#import <OCMock.h>
13+
14+
@interface LPInterstitialMessageTemplate()
15+
16+
@property (nonatomic, strong) UIView *popupGroup;
17+
- (void)setupPopupView;
18+
19+
@end
20+
21+
@interface LPActionContext(UnitTest)
22+
23+
+ (LPActionContext *)actionContextWithName:(NSString *)name
24+
args:(NSDictionary *)args
25+
messageId:(NSString *)messageId;
26+
27+
@end
28+
29+
@interface LPInterstitialMessageSnapshotTest : FBSnapshotTestCase
30+
31+
@end
32+
33+
@implementation LPInterstitialMessageSnapshotTest
34+
35+
- (void)setUp {
36+
[super setUp];
37+
//self.recordMode = YES;
38+
}
39+
40+
- (void)tearDown {
41+
[super tearDown];
42+
}
43+
44+
- (void)testView {
45+
LPInterstitialMessageTemplate *template = [[LPInterstitialMessageTemplate alloc] init];
46+
LPActionContext *context = [LPActionContext actionContextWithName:LPMT_INTERSTITIAL_NAME args:@{
47+
LPMT_ARG_TITLE_TEXT:APP_NAME,
48+
LPMT_ARG_TITLE_COLOR:[UIColor blackColor],
49+
LPMT_ARG_MESSAGE_TEXT:LPMT_DEFAULT_INTERSTITIAL_MESSAGE,
50+
LPMT_ARG_MESSAGE_COLOR:[UIColor blackColor],
51+
LPMT_ARG_BACKGROUND_COLOR:[UIColor whiteColor],
52+
LPMT_ARG_ACCEPT_BUTTON_TEXT:LPMT_DEFAULT_OK_BUTTON_TEXT,
53+
LPMT_ARG_ACCEPT_BUTTON_BACKGROUND_COLOR:[UIColor whiteColor],
54+
LPMT_ARG_ACCEPT_BUTTON_TEXT_COLOR:[UIColor blackColor],
55+
} messageId:0];
56+
id contextMock = OCMPartialMock(context);
57+
OCMStub([contextMock stringNamed:LPMT_ARG_TITLE_TEXT]).andReturn(APP_NAME);
58+
OCMStub([contextMock colorNamed:LPMT_ARG_TITLE_COLOR]).andReturn([UIColor blackColor]);
59+
OCMStub([contextMock stringNamed:LPMT_ARG_MESSAGE_TEXT]).andReturn(LPMT_DEFAULT_INTERSTITIAL_MESSAGE);
60+
OCMStub([contextMock colorNamed:LPMT_ARG_MESSAGE_COLOR]).andReturn([UIColor blackColor]);
61+
OCMStub([contextMock colorNamed:LPMT_ARG_BACKGROUND_COLOR]).andReturn([UIColor whiteColor]);
62+
OCMStub([contextMock stringNamed:LPMT_ARG_ACCEPT_BUTTON_TEXT]).andReturn(LPMT_DEFAULT_OK_BUTTON_TEXT);
63+
OCMStub([contextMock colorNamed:LPMT_ARG_ACCEPT_BUTTON_BACKGROUND_COLOR]).andReturn([UIColor whiteColor]);
64+
OCMStub([contextMock colorNamed:LPMT_ARG_ACCEPT_BUTTON_TEXT_COLOR]).andReturn([UIColor blackColor]);
65+
66+
template.contexts = [@[contextMock] mutableCopy];
67+
[template setupPopupView];
68+
FBSnapshotVerifyView(template.popupGroup, nil);
69+
}
70+
71+
@end
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
//
2+
// LPAlertMessageSnapshotTest.m
3+
// Leanplum-SDK_Tests
4+
//
5+
// Created by Mayank Sanganeria on 2/25/20.
6+
// Copyright © 2020 Leanplum. All rights reserved.
7+
//
8+
9+
#import <XCTest/XCTest.h>
10+
#import <FBSnapshotTestCase/FBSnapshotTestCase.h>
11+
#import <Leanplum/LPPushAsktoAskMessageTemplate.h>
12+
#import <OCMock.h>
13+
14+
@interface LPPushAsktoAskMessageTemplate()
15+
16+
@property (nonatomic, strong) UIView *popupGroup;
17+
- (void)setupPopupView;
18+
19+
@end
20+
21+
@interface LPActionContext(UnitTest)
22+
23+
+ (LPActionContext *)actionContextWithName:(NSString *)name
24+
args:(NSDictionary *)args
25+
messageId:(NSString *)messageId;
26+
27+
@end
28+
29+
@interface LPPushAskToAskMessageSnapshotTest : FBSnapshotTestCase
30+
31+
@end
32+
33+
@implementation LPPushAskToAskMessageSnapshotTest
34+
35+
- (void)setUp {
36+
[super setUp];
37+
//self.recordMode = YES;
38+
}
39+
40+
- (void)tearDown {
41+
[super tearDown];
42+
}
43+
44+
- (void)testView {
45+
LPPushAsktoAskMessageTemplate *template = [[LPPushAsktoAskMessageTemplate alloc] init];
46+
47+
LPActionContext *context = [LPActionContext actionContextWithName:LPMT_PUSH_ASK_TO_ASK args:@{
48+
LPMT_ARG_TITLE_TEXT:APP_NAME,
49+
LPMT_ARG_TITLE_COLOR:[UIColor blackColor],
50+
LPMT_ARG_MESSAGE_TEXT:LPMT_DEFAULT_ASK_TO_ASK_MESSAGE,
51+
LPMT_ARG_MESSAGE_COLOR:[UIColor blackColor],
52+
LPMT_ARG_BACKGROUND_COLOR:[UIColor colorWithWhite:LIGHT_GRAY alpha:1.0],
53+
LPMT_ARG_ACCEPT_BUTTON_TEXT:LPMT_DEFAULT_OK_BUTTON_TEXT,
54+
LPMT_ARG_ACCEPT_BUTTON_BACKGROUND_COLOR:[UIColor colorWithWhite:LIGHT_GRAY alpha:1.0],
55+
LPMT_ARG_ACCEPT_BUTTON_TEXT_COLOR:[UIColor blackColor],
56+
LPMT_ARG_CANCEL_BUTTON_TEXT:LPMT_DEFAULT_LATER_BUTTON_TEXT,
57+
LPMT_ARG_CANCEL_BUTTON_BACKGROUND_COLOR:[UIColor colorWithWhite:LIGHT_GRAY alpha:1.0],
58+
LPMT_ARG_CANCEL_BUTTON_TEXT_COLOR:[UIColor grayColor],
59+
LPMT_ARG_LAYOUT_WIDTH:@(LPMT_DEFAULT_CENTER_POPUP_WIDTH),
60+
LPMT_ARG_LAYOUT_HEIGHT:@(LPMT_DEFAULT_CENTER_POPUP_HEIGHT)
61+
} messageId:0];
62+
id contextMock = OCMPartialMock(context);
63+
OCMStub([contextMock stringNamed:LPMT_ARG_TITLE_TEXT]).andReturn(APP_NAME);
64+
OCMStub([contextMock colorNamed:LPMT_ARG_TITLE_COLOR]).andReturn([UIColor blackColor]);
65+
OCMStub([contextMock stringNamed:LPMT_ARG_MESSAGE_TEXT]).andReturn(LPMT_DEFAULT_ASK_TO_ASK_MESSAGE);
66+
OCMStub([contextMock colorNamed:LPMT_ARG_MESSAGE_COLOR]).andReturn([UIColor blackColor]);
67+
OCMStub([contextMock colorNamed:LPMT_ARG_BACKGROUND_COLOR]).andReturn([UIColor colorWithWhite:LIGHT_GRAY alpha:1.0]);
68+
OCMStub([contextMock stringNamed:LPMT_ARG_ACCEPT_BUTTON_TEXT]).andReturn(LPMT_DEFAULT_OK_BUTTON_TEXT);
69+
OCMStub([contextMock colorNamed:LPMT_ARG_ACCEPT_BUTTON_BACKGROUND_COLOR]).andReturn([UIColor colorWithWhite:LIGHT_GRAY alpha:1.0]);
70+
OCMStub([contextMock colorNamed:LPMT_ARG_ACCEPT_BUTTON_TEXT_COLOR]).andReturn([UIColor blackColor]);
71+
OCMStub([contextMock stringNamed:LPMT_ARG_CANCEL_BUTTON_TEXT]).andReturn(LPMT_DEFAULT_LATER_BUTTON_TEXT);
72+
OCMStub([contextMock colorNamed:LPMT_ARG_CANCEL_BUTTON_BACKGROUND_COLOR]).andReturn([UIColor colorWithWhite:LIGHT_GRAY alpha:1.0]);
73+
OCMStub([contextMock colorNamed:LPMT_ARG_CANCEL_BUTTON_TEXT_COLOR]).andReturn([UIColor grayColor]);
74+
OCMStub([contextMock numberNamed:LPMT_ARG_LAYOUT_WIDTH]).andReturn(@(LPMT_DEFAULT_CENTER_POPUP_WIDTH));
75+
OCMStub([contextMock numberNamed:LPMT_ARG_LAYOUT_HEIGHT]).andReturn(@(LPMT_DEFAULT_CENTER_POPUP_HEIGHT));
76+
77+
template.contexts = [@[contextMock] mutableCopy];
78+
[template setupPopupView];
79+
FBSnapshotVerifyView(template.popupGroup, nil);
80+
}
81+
82+
@end
34.2 KB
Loading
30.7 KB
Loading
41 KB
Loading

Leanplum-SDK/Classes/MessageTemplates/LPBaseInterstitialMessageTemplate.m

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,20 @@ - (void)showPopup
8585
});
8686
return;
8787
}
88+
[self setupPopupView];
89+
[self.popupGroup setAlpha:0.0];
90+
[[UIApplication sharedApplication].keyWindow addSubview:self.popupGroup];
91+
[UIView animateWithDuration:LPMT_POPUP_ANIMATION_LENGTH animations:^{
92+
[self->_popupGroup setAlpha:0.5];
93+
}];
94+
95+
[[NSNotificationCenter defaultCenter] addObserver:self
96+
selector:@selector(orientationDidChange:)
97+
name:UIDeviceOrientationDidChangeNotification
98+
object:nil];
99+
}
88100

101+
- (void)setupPopupView {
89102
LPActionContext *context = self.contexts.lastObject;
90103
BOOL isFullscreen = [context.actionName isEqualToString:LPMT_INTERSTITIAL_NAME];
91104
BOOL isWeb = [context.actionName isEqualToString:LPMT_WEB_INTERSTITIAL_NAME] ||
@@ -136,17 +149,6 @@ - (void)showPopup
136149

137150
[self refreshPopupContent];
138151
[self updatePopupLayout];
139-
140-
[self.popupGroup setAlpha:0.0];
141-
[[UIApplication sharedApplication].keyWindow addSubview:self.popupGroup];
142-
[UIView animateWithDuration:LPMT_POPUP_ANIMATION_LENGTH animations:^{
143-
[self->_popupGroup setAlpha:1.0];
144-
}];
145-
146-
[[NSNotificationCenter defaultCenter] addObserver:self
147-
selector:@selector(orientationDidChange:)
148-
name:UIDeviceOrientationDidChangeNotification
149-
object:nil];
150152
}
151153

152154
- (void)removeAllViewsFrom:(UIView *)view

0 commit comments

Comments
 (0)