Skip to content

Commit

Permalink
Merge branch 'release/2.0.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
Enuviel committed Nov 23, 2017
2 parents 8dc858b + 54c5544 commit 616b9a6
Show file tree
Hide file tree
Showing 27 changed files with 406 additions and 106 deletions.
2 changes: 1 addition & 1 deletion .slather.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ workspace: Example/Leanplum-SDK.xcworkspace
scheme: Leanplum-SDK-Example
source_directory: Leanplum-SDK/
output_directory: coverage-report
binary_file: /DerivedData/Build/Products/Debug-iphonesimulator/Leanplum-SDK_Example.app/PlugIns/Leanplum-SDK_Tests.xctest/Frameworks/Leanplum.framework/Leanplum
binary_file: DerivedData/Build/Products/Debug-iphonesimulator/Leanplum-SDK_Example.app/PlugIns/Leanplum-SDK_Tests.xctest/Frameworks/Leanplum.framework/Leanplum
ignore:
- Leanplum-SDK/Classes/Vendor/**
67 changes: 47 additions & 20 deletions Example/Leanplum-SDK.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
{
"idiom" : "tv",
"scale" : "1x"
},
{
"idiom" : "tv",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
{
"idiom" : "tv",
"scale" : "1x"
},
{
"idiom" : "tv",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
{
"idiom" : "tv",
"scale" : "1x"
},
{
"idiom" : "tv",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
{
"idiom" : "tv",
"scale" : "1x"
},
{
"idiom" : "tv",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
{
"idiom" : "tv",
"scale" : "1x"
},
{
"idiom" : "tv",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
{
"idiom" : "tv",
"scale" : "1x"
},
{
"idiom" : "tv",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
{
"idiom" : "tv",
"scale" : "1x"
},
{
"idiom" : "tv",
"scale" : "2x"
}
],
"info" : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
{
"idiom" : "tv",
"scale" : "1x"
},
{
"idiom" : "tv",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
{
"images" : [
{
"orientation" : "landscape",
"idiom" : "tv",
"extent" : "full-screen",
"minimum-system-version" : "11.0",
"scale" : "2x"
},
{
"orientation" : "landscape",
"idiom" : "tv",
Expand All @@ -12,4 +19,4 @@
"version" : 1,
"author" : "xcode"
}
}
}
4 changes: 2 additions & 2 deletions Example/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ target 'Leanplum-SDK_Example' do
end

target 'Leanplum-tvOS-SDK_Example' do
platform :tvos, '8.0'
platform :tvos, '9.0'

pod 'Leanplum-tvOS-SDK', :path => '../'
pod 'Leanplum-tvOS-SDK-source', :path => '../'
end
6 changes: 3 additions & 3 deletions Example/Tests/Classes/MessagesTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ - (void) test_no_priorities

NSDictionary *messageConfigs = [LPJSON JSONFromString:jsonString];
[self runInAppMessagePrioritizationTest:messageConfigs
withExpectedMessageIds:[NSSet setWithObjects:@"1", @"2", @"3", nil]];
withExpectedMessageIds:[NSSet setWithObjects:@"1", nil]];
}

- (void) test_different_priorities
Expand Down Expand Up @@ -189,14 +189,14 @@ - (void) test_tied_priorities

NSDictionary *messageConfigs = [LPJSON JSONFromString:jsonString];
[self runInAppMessagePrioritizationTest:messageConfigs
withExpectedMessageIds:[NSSet setWithObjects:@"1", @"3", nil]];
withExpectedMessageIds:[NSSet setWithObjects:@"1", nil]];

// Testing three messages with the same priority.
jsonString = [LeanplumHelper retrieve_string_from_file:@"TiedPriorities2"
ofType:@"json"];
messageConfigs = [LPJSON JSONFromString:jsonString];
[self runInAppMessagePrioritizationTest:messageConfigs
withExpectedMessageIds:[NSSet setWithObjects:@"1", @"2" ,@"3", nil]];
withExpectedMessageIds:[NSSet setWithObjects:@"1", nil]];
}

- (void) test_different_priorities_with_missing_values
Expand Down
69 changes: 69 additions & 0 deletions Example/Tests/Classes/NewsfeedTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -374,4 +374,73 @@ - (void)test_disableFetching
XCTAssertTrue(timedOut == 0);
}

- (void)test_onForceContentUpdate {
XCTAssertTrue([LeanplumHelper start_development_test]);

// FCU without sync
id<OHHTTPStubsDescriptor> stub = [OHHTTPStubs stubRequestsPassingTest:
^BOOL(NSURLRequest * _Nonnull request) {
return [request.URL.host isEqualToString:API_HOST];
} withStubResponse:^OHHTTPStubsResponse * _Nonnull(NSURLRequest *request) {
NSString *response_file = OHPathForFile(@"variables_response.json",
self.class);
return [OHHTTPStubsResponse responseWithFileAtPath:response_file
statusCode:200
headers:@{@"Content-Type":@"application/json"}];
}];

XCTestExpectation *responseExpectation1 = [self expectationWithDescription:@"response1"];
[[Leanplum inbox] onForceContentUpdate:^void(BOOL success){
XCTAssertTrue(success);
[responseExpectation1 fulfill];
}];

[Leanplum forceContentUpdate:nil];
[self waitForExpectationsWithTimeout:2 handler:nil];
[OHHTTPStubs removeStub:stub];
[[Leanplum inbox] reset];

// FCU with sync
stub = [OHHTTPStubs stubRequestsPassingTest:^BOOL(NSURLRequest * _Nonnull request) {
return [request.URL.host isEqualToString:API_HOST];
} withStubResponse:^OHHTTPStubsResponse * _Nonnull(NSURLRequest *request) {
NSString *response_file = OHPathForFile(@"variables_with_newsfeed_response.json",
self.class);
return [OHHTTPStubsResponse responseWithFileAtPath:response_file
statusCode:200
headers:@{@"Content-Type":@"application/json"}];
}];

XCTestExpectation *responseExpectation2 = [self expectationWithDescription:@"response2"];
[[Leanplum inbox] onForceContentUpdate:^void(BOOL success){
XCTAssertTrue(success);
[responseExpectation2 fulfill];
}];

[Leanplum forceContentUpdate:nil];
[self waitForExpectationsWithTimeout:2 handler:nil];
[OHHTTPStubs removeStub:stub];
[[Leanplum inbox] reset];

// FCU without internet connection
stub = [OHHTTPStubs stubRequestsPassingTest:^BOOL(NSURLRequest *request) {
return [request.URL.host isEqualToString:API_HOST];;
} withStubResponse:^OHHTTPStubsResponse * _Nonnull(NSURLRequest * _Nonnull request) {
NSError *error = [NSError errorWithDomain:NSURLErrorDomain
code:NSURLErrorBadServerResponse userInfo:nil];
return [OHHTTPStubsResponse responseWithError:error];
}];

XCTestExpectation *responseExpectation3 = [self expectationWithDescription:@"response3"];
[[Leanplum inbox] onForceContentUpdate:^void(BOOL success){
XCTAssertFalse(success);
[responseExpectation3 fulfill];
}];

[Leanplum forceContentUpdate:nil];
[self waitForExpectationsWithTimeout:2 handler:nil];
[OHHTTPStubs removeStub:stub];
[[Leanplum inbox] reset];
}

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"response": [{
"success": true
}, {
"success": true
}, {
"vars": {

},
"interfaceRules": [

],
"variants": [

],
"regions": {

},
"syncNewsfeed": true,
"success": true,
"messages": {

},
"interfaceEvents": [

]
}]
}
2 changes: 1 addition & 1 deletion Leanplum-SDK/Classes/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#define IS_NOOP ((!IS_SUPPORTED_IOS_VERSION) || IS_JAILBROKEN || [LPConstantsState sharedState].isTestMode || [LPConstantsState sharedState].isInPermanentFailureState)
#define RETURN_IF_NOOP if (IS_NOOP) return

#define LEANPLUM_SDK_VERSION @"2.0.3"
#define LEANPLUM_SDK_VERSION @"2.0.4"
#define LEANPLUM_CLIENT @"ios"

// Can upload up to 100 files or 50 MB per request.
Expand Down
8 changes: 8 additions & 0 deletions Leanplum-SDK/Classes/LPInbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
* This block is used when you define a callback.
*/
typedef void (^LeanplumInboxChangedBlock)(void);
typedef void (^LeanplumInboxSyncedBlock)(BOOL success);

@interface LPInbox : NSObject

Expand Down Expand Up @@ -150,6 +151,13 @@ typedef void (^LeanplumInboxChangedBlock)(void);
*/
- (void)onChanged:(LeanplumInboxChangedBlock)block;

/**
* Block to call when forceContentUpdate was called.
* Returns true if syncing was successful.
* Note: use onChanged: for UI.
*/
- (void)onForceContentUpdate:(LeanplumInboxSyncedBlock)block;

/**
@{
* Adds a responder to be executed when an event happens.
Expand Down

0 comments on commit 616b9a6

Please sign in to comment.