-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/set locale #467
Merged
Merged
Feature/set locale #467
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1075,6 +1075,45 @@ - (void) test_set_device_id_after_start | |
XCTAssertTrue([[LPAPIConfig sharedConfig].deviceId isEqualToString:deviceId]); | ||
} | ||
|
||
/** | ||
* Tests setting the user locale after Leanplum start | ||
*/ | ||
- (void) test_set_locale | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can simplify the test to: - (void) test_set_locale
{
NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:@"ab_CD"];
XCTestExpectation *request_expectation =
[self expectationWithDescription:@"request_expectation"];
[LPRequestSender validate_request_args_dictionary:^(NSDictionary *args) {
XCTAssertTrue([args[LP_KEY_LOCALE] isEqualToString:[locale localeIdentifier]]);
XCTAssertFalse([args[LP_KEY_LOCALE] isEqualToString:[[NSLocale currentLocale] localeIdentifier]]);
[request_expectation fulfill];
}];
[Leanplum setLocale:locale];
[self waitForExpectations:@[request_expectation] timeout:1.0];
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tests has been updated |
||
{ | ||
NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:@"ab_CD"]; | ||
|
||
[HTTPStubs stubRequestsPassingTest:^BOOL(NSURLRequest * _Nonnull request) { | ||
return [request.URL.host isEqualToString:API_HOST]; | ||
} withStubResponse:^HTTPStubsResponse * _Nonnull(NSURLRequest * _Nonnull request) { | ||
NSString *response_file = OHPathForFile(@"simple_start_response.json", self.class); | ||
return [HTTPStubsResponse responseWithFileAtPath:response_file statusCode:200 | ||
headers:@{@"Content-Type":@"application/json"}]; | ||
}]; | ||
|
||
[LPRequestSender validate_request:^BOOL(NSString *method, NSString *apiMethod, | ||
NSDictionary *params) { | ||
XCTAssertEqualObjects(apiMethod, @"start"); | ||
return YES; | ||
}]; | ||
|
||
XCTAssertTrue([LeanplumHelper start_production_test]); | ||
|
||
dispatch_semaphore_t semaphor = dispatch_semaphore_create(0); | ||
[Leanplum onStartResponse:^(BOOL success) { | ||
XCTAssertTrue(success); | ||
[Leanplum setLocale:locale]; | ||
dispatch_semaphore_signal(semaphor); | ||
}]; | ||
long timedOut = dispatch_semaphore_wait(semaphor, [LeanplumHelper default_dispatch_time]); | ||
XCTAssertTrue(timedOut == 0); | ||
XCTAssertTrue([Leanplum hasStarted]); | ||
|
||
[LPRequestSender validate_request_args_dictionary:^(NSDictionary *args) { | ||
XCTAssertTrue([args[LP_KEY_LOCALE] isEqualToString:[locale localeIdentifier]]); | ||
XCTAssertFalse([args[LP_KEY_LOCALE] isEqualToString:[[NSLocale currentLocale] localeIdentifier]]); | ||
}]; | ||
} | ||
|
||
/** | ||
* Tests track with events of same type , priority and countdown. | ||
*/ | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the use case - would this be called before starting Leanplum or at some point after it started?
If it has started, the locale in the start API call will be the system one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea was for calling it after Leanplum is started, in order to simplify a bit complex variations of starting.
If you think it is better to move it to start, and/or to add some stored property for overriding the system's locale, so the start would take that one, I'm ok with it as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improved in a way that
setLocale
now can be called both before and after Leanplum is started