-
Notifications
You must be signed in to change notification settings - Fork 130
Expand file tree
/
Copy pathXCTestResourceUtils.m
More file actions
82 lines (68 loc) · 2.5 KB
/
XCTestResourceUtils.m
File metadata and controls
82 lines (68 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
////////////////////////////////////////////////////////////////////////////////
//
// JASPER BLUES
// Copyright 2012 Jasper Blues
// All Rights Reserved.
//
// NOTICE: Jasper Blues permits you to use, modify, and distribute this file
// in accordance with the terms of the license agreement accompanying it.
//
////////////////////////////////////////////////////////////////////////////////
#import "XCTestResourceUtils.h"
NSString *XCTestResourcePath(void)
{
NSString *home = NSHomeDirectory();
NSString *path = [home stringByAppendingString:@"/xcode-editor-test-results"];
return path;
}
NSString *XCSample1FolderPath(void)
{
return [XCTestResourcePath() stringByAppendingString:@"/expanz-iOS-SDK"];
}
NSString *XCSample1XcodeProjectPath(void)
{
return [XCSample1FolderPath() stringByAppendingString:@"/expanz-iOS-SDK.xcodeproj"];
}
NSString *XCBox2dSampleContainingFolderPath(void)
{
return [XCTestResourcePath() stringByAppendingString:@"/HelloBoxy"];
}
NSString *XCBox2dSampleProjectPath(void)
{
return [XCBox2dSampleContainingFolderPath() stringByAppendingString:@"/HelloBoxy.xcodeproj"];
}
NSString *XCMasterDetailContainerFolderPath(void)
{
return [XCTestResourcePath() stringByAppendingString:@"/ProjectToEdit"];
}
NSString *XCMasterDetailProjectPath(void)
{
return [XCMasterDetailContainerFolderPath() stringByAppendingString:@"/ProjectToEdit.xcodeproj"];
}
NSString *XCPathRelativeToProjectRootFolderPath(void)
{
return [XCTestResourcePath() stringByAppendingString:@"/PathRelativeToProjectRoot"];
}
NSString *XCPathRelativeToProjectRootProjectPath(void)
{
return [XCPathRelativeToProjectRootFolderPath() stringByAppendingString:@"/PathRelativeToProjectRoot.xcodeproj"];
}
NSString *NSStringWithXCTestResource(NSString *resourceName)
{
NSString *filePath = [XCTestResourcePath() stringByAppendingPathComponent:resourceName];
NSError *error = nil;
NSString *contents = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:&error];
if (!contents) {
[NSException raise:NSInvalidArgumentException format:@"No test resource named '%@'", filePath];
}
return contents;
}
NSData *NSDataWithXCTestResource(NSString *resourceName)
{
NSString *filePath = [XCTestResourcePath() stringByAppendingPathComponent:resourceName];
NSData *data = [NSData dataWithContentsOfFile:filePath];
if (!data) {
[NSException raise:NSInvalidArgumentException format:@"Expected data at path '%@'", filePath];
}
return data;
}