more tests
This commit is contained in:
parent
97992a66cc
commit
ead815ab65
@ -35,22 +35,6 @@
|
||||
landmarkType = "5">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
shouldBeEnabled = "No"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "FMC Planner 2Tests/FMC_Planner_2Tests.m"
|
||||
timestampString = "482591208.671376"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "26"
|
||||
endingLineNumber = "26"
|
||||
landmarkName = "-setUp"
|
||||
landmarkType = "5">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
@ -58,11 +42,11 @@
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "FMC Planner 2/DropboxV2ObjC.m"
|
||||
timestampString = "482597611.374247"
|
||||
timestampString = "482609979.426219"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "562"
|
||||
endingLineNumber = "562"
|
||||
startingLineNumber = "571"
|
||||
endingLineNumber = "571"
|
||||
landmarkName = "-setupDropboxWithHandler:presenter:"
|
||||
landmarkType = "5">
|
||||
</BreakpointContent>
|
||||
@ -74,11 +58,11 @@
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "FMC Planner 2/DropboxV2ObjC.m"
|
||||
timestampString = "482597611.374247"
|
||||
timestampString = "482609979.426219"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "568"
|
||||
endingLineNumber = "568"
|
||||
startingLineNumber = "577"
|
||||
endingLineNumber = "577"
|
||||
landmarkName = "-setupDropboxWithHandler:presenter:"
|
||||
landmarkType = "5">
|
||||
</BreakpointContent>
|
||||
@ -90,11 +74,11 @@
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "FMC Planner 2/DropboxV2ObjC.m"
|
||||
timestampString = "482597611.374247"
|
||||
timestampString = "482609979.426219"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "570"
|
||||
endingLineNumber = "570"
|
||||
startingLineNumber = "579"
|
||||
endingLineNumber = "579"
|
||||
landmarkName = "-setupDropboxWithHandler:presenter:"
|
||||
landmarkType = "5">
|
||||
</BreakpointContent>
|
||||
@ -106,11 +90,11 @@
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "FMC Planner 2/DropboxV2ObjC.m"
|
||||
timestampString = "482597611.374247"
|
||||
timestampString = "482609979.426219"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "589"
|
||||
endingLineNumber = "589"
|
||||
startingLineNumber = "598"
|
||||
endingLineNumber = "598"
|
||||
landmarkName = "-setupDropboxWithHandler:presenter:"
|
||||
landmarkType = "5">
|
||||
</BreakpointContent>
|
||||
@ -122,11 +106,11 @@
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "FMC Planner 2/DropboxV2ObjC.m"
|
||||
timestampString = "482597611.374247"
|
||||
timestampString = "482609979.426219"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "608"
|
||||
endingLineNumber = "608"
|
||||
startingLineNumber = "617"
|
||||
endingLineNumber = "617"
|
||||
landmarkName = "-setupDropboxWithHandler:presenter:"
|
||||
landmarkType = "5">
|
||||
</BreakpointContent>
|
||||
@ -138,11 +122,11 @@
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "FMC Planner 2/DropboxV2ObjC.m"
|
||||
timestampString = "482597611.374247"
|
||||
timestampString = "482609979.426219"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "627"
|
||||
endingLineNumber = "627"
|
||||
startingLineNumber = "636"
|
||||
endingLineNumber = "636"
|
||||
landmarkName = "-setupDropboxWithHandler:presenter:"
|
||||
landmarkType = "5">
|
||||
</BreakpointContent>
|
||||
|
||||
@ -32,12 +32,12 @@
|
||||
|
||||
- (void)downloadFromDropbox:(NSArray *)files
|
||||
presenter:(UIViewController *)presenter
|
||||
completion:(void (^)(void))handler;
|
||||
completion:(void (^)(BOOL success))handler;
|
||||
- (void)uploadToDropbox:(NSArray *)files
|
||||
presenter:(UIViewController *)presenter
|
||||
completion:(void (^)(void))handler;
|
||||
completion:(void (^)(BOOL success))handler;
|
||||
- (void)contentsOfPath:(NSString *)path
|
||||
completion:(void (^)(NSArray *data))handler
|
||||
completion:(void (^)(NSArray *data, BOOL success))handler
|
||||
presenter:(UIViewController *)presenter;
|
||||
- (void)createFolderAtPath:(NSString *)path
|
||||
presenter:(UIViewController *)presenter;
|
||||
|
||||
@ -21,6 +21,11 @@
|
||||
protocol:@"HTTP"
|
||||
realm:nil
|
||||
authenticationMethod:@"OAuth2"];
|
||||
NSDictionary *credentials =
|
||||
[[NSURLCredentialStorage sharedCredentialStorage]
|
||||
credentialsForProtectionSpace:self.kDropboxProtectionSpace];
|
||||
NSURLCredential *credential = [credentials.objectEnumerator nextObject];
|
||||
self.token = credential.password;
|
||||
return self;
|
||||
}
|
||||
|
||||
@ -156,7 +161,7 @@
|
||||
* @param completion executed after completion
|
||||
*/
|
||||
- (void)contentsOfPath:(NSString *)path
|
||||
completion:(void (^)(NSArray *data))handler
|
||||
completion:(void (^)(NSArray *data, BOOL success))handler
|
||||
presenter:(UIViewController *)presenter
|
||||
{
|
||||
|
||||
@ -250,9 +255,10 @@
|
||||
.topViewController];
|
||||
}
|
||||
}];
|
||||
handler(nil, NO);
|
||||
}
|
||||
else {
|
||||
handler(data2);
|
||||
handler(data2, YES);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -265,6 +271,7 @@
|
||||
.topViewController];
|
||||
|
||||
}];
|
||||
handler(nil, NO);
|
||||
}
|
||||
}];
|
||||
}
|
||||
@ -275,7 +282,7 @@
|
||||
*/
|
||||
- (void)downloadFromDropbox:(NSArray *)files
|
||||
presenter:(UIViewController *)presenter
|
||||
completion:(void (^)(void))handler
|
||||
completion:(void (^)(BOOL success))handler
|
||||
{
|
||||
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
|
||||
request.URL = [NSURL
|
||||
@ -320,6 +327,7 @@
|
||||
valueForKey:@"error_summary"] == nil) {
|
||||
[data writeToFile:[SharedDeclerations savePathForFile:string]
|
||||
atomically:YES];
|
||||
handler(YES);
|
||||
}
|
||||
else {
|
||||
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
|
||||
@ -361,6 +369,7 @@
|
||||
.topViewController];
|
||||
}
|
||||
}];
|
||||
handler(NO);
|
||||
}
|
||||
}
|
||||
else if (error != nil) {
|
||||
@ -370,11 +379,10 @@
|
||||
presentErrorAlert:error
|
||||
presenter:presenter.navigationController
|
||||
.topViewController];
|
||||
|
||||
}];
|
||||
handler(NO);
|
||||
}
|
||||
}
|
||||
handler();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -383,7 +391,7 @@
|
||||
*/
|
||||
- (void)uploadToDropbox:(NSArray *)files
|
||||
presenter:(UIViewController *)presenter
|
||||
completion:(void (^)(void))handler
|
||||
completion:(void (^)(BOOL success))handler
|
||||
{
|
||||
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
|
||||
request.URL =
|
||||
@ -434,6 +442,7 @@
|
||||
.topViewController];
|
||||
|
||||
}];
|
||||
handler(NO);
|
||||
}
|
||||
if ([[NSJSONSerialization JSONObjectWithData:data options:0 error:nil]
|
||||
valueForKey:@"error_summary"] != nil) {
|
||||
@ -475,9 +484,9 @@
|
||||
.topViewController];
|
||||
}
|
||||
}];
|
||||
handler(NO);
|
||||
}
|
||||
}
|
||||
handler();
|
||||
}
|
||||
|
||||
|
||||
@ -566,7 +575,7 @@
|
||||
[queue addOperationWithBlock:^{
|
||||
// Exports (PMDG format)
|
||||
[self contentsOfPath:nil
|
||||
completion:^(NSArray *data) {
|
||||
completion:^(NSArray *data, BOOL success) {
|
||||
BOOL exports = false;
|
||||
for (NSDictionary *dict in data) {
|
||||
if ([[dict valueForKey:@"name"]
|
||||
@ -585,7 +594,7 @@
|
||||
presenter:presenter];
|
||||
// NavData (3 files from QW Navigraph data
|
||||
[self contentsOfPath:nil
|
||||
completion:^(NSArray *data) {
|
||||
completion:^(NSArray *data, BOOL success) {
|
||||
BOOL exports = false;
|
||||
for (NSDictionary *dict in data) {
|
||||
if ([[dict valueForKey:@"name"]
|
||||
@ -604,7 +613,7 @@
|
||||
presenter:presenter.navigationController.topViewController];
|
||||
// Backups of Saves
|
||||
[self contentsOfPath:nil
|
||||
completion:^(NSArray *data) {
|
||||
completion:^(NSArray *data, BOOL success) {
|
||||
BOOL exports = false;
|
||||
for (NSDictionary *dict in data) {
|
||||
if ([[dict valueForKey:@"name"]
|
||||
@ -623,7 +632,7 @@
|
||||
presenter:presenter.navigationController.topViewController];
|
||||
// Old saves (FMC Planner + (or X?))
|
||||
[self contentsOfPath:nil
|
||||
completion:^(NSArray *data) {
|
||||
completion:^(NSArray *data, BOOL success) {
|
||||
BOOL exports = false;
|
||||
for (NSDictionary *dict in data) {
|
||||
if ([[dict valueForKey:@"name"]
|
||||
|
||||
@ -41,7 +41,7 @@
|
||||
if ([self.title isEqualToString:@"Download"]) {
|
||||
[dbClient
|
||||
contentsOfPath:@"SAVES"
|
||||
completion:^(NSArray *data) {
|
||||
completion:^(NSArray *data, BOOL success) {
|
||||
NSMutableArray *temp = [[NSMutableArray alloc] init];
|
||||
if (data != nil) {
|
||||
for (NSDictionary *dict in data) {
|
||||
@ -184,7 +184,7 @@
|
||||
[queue addOperationWithBlock:^{
|
||||
[dbClient downloadFromDropbox:_markList
|
||||
presenter:self
|
||||
completion:^{
|
||||
completion:^(BOOL success) {
|
||||
[[NSOperationQueue mainQueue]
|
||||
addOperationWithBlock:^{
|
||||
_sm.dbDownload.enabled = YES;
|
||||
@ -204,7 +204,7 @@
|
||||
[dbClient
|
||||
uploadToDropbox:_markList
|
||||
presenter:self
|
||||
completion:^{
|
||||
completion:^(BOOL success) {
|
||||
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
|
||||
_sm.dbUpload.enabled = YES;
|
||||
_sm.dbUpload.alpha = 1.0;
|
||||
|
||||
@ -29,11 +29,6 @@
|
||||
// Override point for customization after application launch.
|
||||
_dbClient = [[DropboxV2ObjC alloc] init];
|
||||
((AppDelegate *)[UIApplication sharedApplication].delegate).main = self;
|
||||
NSDictionary *credentials =
|
||||
[[NSURLCredentialStorage sharedCredentialStorage]
|
||||
credentialsForProtectionSpace:_dbClient.kDropboxProtectionSpace];
|
||||
NSURLCredential *credential = [credentials.objectEnumerator nextObject];
|
||||
_dbClient.token = credential.password;
|
||||
// Reset if user changed it
|
||||
[_dbClient setupDropboxWithHandler:^{
|
||||
}
|
||||
|
||||
@ -121,7 +121,7 @@
|
||||
[queue addOperationWithBlock:^{
|
||||
[dbClient
|
||||
contentsOfPath:@"NAVDATA"
|
||||
completion:^(NSArray *files) {
|
||||
completion:^(NSArray *files, BOOL success) {
|
||||
if (files != nil) {
|
||||
NSMutableArray *dlList = [[NSMutableArray alloc] init];
|
||||
for (NSDictionary *file in files) {
|
||||
@ -132,7 +132,7 @@
|
||||
[dbClient
|
||||
downloadFromDropbox:dlList
|
||||
presenter:self
|
||||
completion:^{
|
||||
completion:^(BOOL success) {
|
||||
[[NSOperationQueue mainQueue]
|
||||
addOperationWithBlock:^{
|
||||
_main.navDataActive = false;
|
||||
|
||||
@ -6,11 +6,14 @@
|
||||
// Copyright © 2016 Kilian Hofmann. All rights reserved.
|
||||
//
|
||||
|
||||
#import "DropboxV2ObjC.h"
|
||||
#import "NavDataParser.h"
|
||||
#import "SharedDeclerations.h"
|
||||
#import <XCTest/XCTest.h>
|
||||
|
||||
@interface FMC_Planner_2Tests : XCTestCase {
|
||||
NavDataParser *parser;
|
||||
DropboxV2ObjC *dbClient;
|
||||
}
|
||||
|
||||
@end
|
||||
@ -22,9 +25,8 @@
|
||||
[super setUp];
|
||||
// Put setup code here. This method is called before the invocation of each
|
||||
// test method in the class.
|
||||
if (parser == nil) {
|
||||
parser = [[NavDataParser alloc] init];
|
||||
}
|
||||
parser = [[NavDataParser alloc] init];
|
||||
dbClient = [[DropboxV2ObjC alloc] init];
|
||||
}
|
||||
|
||||
- (void)tearDown
|
||||
@ -47,6 +49,8 @@
|
||||
{
|
||||
XCTAssertTrue([parser findAirway:@"T104"].count > 0);
|
||||
XCTAssertTrue([parser findAirway:@"T104T"].count == 0);
|
||||
XCTAssertTrue(
|
||||
[[parser findAirway:@"DIRECT"].firstObject isEqualToString:@"OK"]);
|
||||
}
|
||||
|
||||
- (void)testWaypointOnAirway
|
||||
@ -68,4 +72,50 @@
|
||||
withStart:@"DKB"] == nil);
|
||||
}
|
||||
|
||||
- (void)testPathContent
|
||||
{
|
||||
[dbClient contentsOfPath:nil
|
||||
completion:^(NSArray *data, BOOL success) {
|
||||
if (success) {
|
||||
NSMutableArray *temp = [[NSMutableArray alloc] init];
|
||||
for (NSDictionary *dict in data) {
|
||||
[temp addObject:[dict valueForKey:@"name"]];
|
||||
}
|
||||
XCTAssertTrue([temp containsObject:@"TEST.txt"]);
|
||||
}
|
||||
}
|
||||
presenter:nil];
|
||||
}
|
||||
|
||||
- (void)testDownload
|
||||
{
|
||||
if ([[NSFileManager defaultManager]
|
||||
fileExistsAtPath:[SharedDeclerations
|
||||
savePathForFile:@"TEST.txt"]]) {
|
||||
[[NSFileManager defaultManager]
|
||||
removeItemAtPath:[SharedDeclerations savePathForFile:@"TEST.txt"]
|
||||
error:nil];
|
||||
}
|
||||
[dbClient downloadFromDropbox:@[ @"TEST.txt" ]
|
||||
presenter:nil
|
||||
completion:^(BOOL success) {
|
||||
if (success) {
|
||||
XCTAssertTrue([[NSFileManager defaultManager]
|
||||
fileExistsAtPath:
|
||||
[SharedDeclerations
|
||||
savePathForFile:@"TEST.txt"]]);
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)testUpload
|
||||
{
|
||||
[dbClient
|
||||
uploadToDropbox:@[ [SharedDeclerations savePathForFile:@"TEST.txt"] ]
|
||||
presenter:nil
|
||||
completion:^(BOOL success) {
|
||||
XCTAssertTrue(success);
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user