Javier Cicchelli 9bcdaa697b [Setup] Basic project structure (#1)
This PR contains all the work related to setting up this project as required to implement the [Assignment](https://repo.rock-n-code.com/rock-n-code/deep-linking-assignment/wiki/Assignment) on top, as intended.

To summarise this work:
- [x] created a new **Xcode** project;
- [x] cloned the `Wikipedia` app and inserted it into the **Xcode** project;
- [x] created the `Locations` app and also, its `Libraries` package;
- [x] created the `Shared` package to share dependencies between the apps;
- [x] added a `Makefile` file and implemented some **environment** and **help** commands.

Co-authored-by: Javier Cicchelli <javier@rock-n-code.com>
Reviewed-on: rock-n-code/deep-linking-assignment#1
2023-04-08 18:37:13 +00:00

102 lines
3.3 KiB
Objective-C

#import <XCTest/XCTest.h>
#import "WMFTaskGroup.h"
#import "WMFAsyncTestCase.h"
@interface WMFTaskGroupTests : XCTestCase
@end
@implementation WMFTaskGroupTests
- (void)setUp {
[super setUp];
}
- (void)tearDown {
[super tearDown];
}
- (void)testEmptyGroup {
WMFTaskGroup *group = [WMFTaskGroup new];
XCTestExpectation *expectation = [self expectationWithDescription:@"Wait for group"];
[group waitInBackgroundWithCompletion:^{
XCTAssertTrue(true);
[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:WMFDefaultExpectationTimeout
handler:^(NSError *_Nullable error) {
if (error) {
XCTFail();
}
}];
}
- (void)testSimple {
WMFTaskGroup *group = [WMFTaskGroup new];
[group enter];
[group enter];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[group leave];
});
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[group leave];
});
XCTestExpectation *expectation = [self expectationWithDescription:@"Wait for group"];
[group waitInBackgroundWithCompletion:^{
XCTAssertTrue(true);
[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:WMFDefaultExpectationTimeout
handler:^(NSError *_Nullable error) {
if (error) {
XCTFail();
}
}];
}
- (void)testHang {
WMFTaskGroup *group = [WMFTaskGroup new];
[group enter];
[group waitInBackgroundWithCompletion:^{
XCTFail();
}];
XCTestExpectation *expectation = [self expectationWithDescription:@"Wait for group"];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[expectation fulfill];
});
[self waitForExpectationsWithTimeout:WMFDefaultExpectationTimeout
handler:^(NSError *_Nullable error) {
XCTAssert(true);
}];
}
- (void)testOverLeave {
WMFTaskGroup *group = [WMFTaskGroup new];
[group enter];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[group leave];
});
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[group leave];
});
XCTestExpectation *expectation = [self expectationWithDescription:@"Wait for group"];
[group waitInBackgroundWithCompletion:^{
XCTAssertTrue(true);
}];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[expectation fulfill];
});
[self waitForExpectationsWithTimeout:10
handler:^(NSError *_Nullable error) {
if (error) {
XCTFail();
}
}];
}
@end