Skip to content
This repository
Browse code

account.plist used to specify mail account data

Instead of hardcoding it. Excluded from the repository via .gitignore. Also adding TestData to the project, compiled into the Test bundle.

Pushing the iOS deployment target down to 4.3, and ensuring that all projects have the same value there.
  • Loading branch information...
commit d3bf550e1d29feff9f97f7e4caf7495ab88dd2d5 1 parent 9c6c77e
Scott Nonnenberg authored December 20, 2012
1  .gitignore
@@ -4,3 +4,4 @@ xcuserdata
4 4
 .DS_Store
5 5
 include/
6 6
 .idea
  7
+TestData/account.plist
10  MailCore.xcodeproj/project.pbxproj
@@ -117,6 +117,7 @@
117 117
 		F8EC5B0514C37F60006AF4D3 /* CTMIME_HtmlPart.m in Sources */ = {isa = PBXBuildFile; fileRef = F8EC5B0214C37F60006AF4D3 /* CTMIME_HtmlPart.m */; };
118 118
 		F8EC5B0514C37F60006AF4D5 /* CTConnectedTest.m in Sources */ = {isa = PBXBuildFile; fileRef = F8EC5B0514C37F60006AF4D4 /* CTConnectedTest.m */; };
119 119
 		F8EC5B0514C37F60006AF4D8 /* CTCoreFolderTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F8EC5B0514C37F60006AF4D7 /* CTCoreFolderTests.m */; };
  120
+		F9FC3A731683FC07004B2D1E /* TestData in Resources */ = {isa = PBXBuildFile; fileRef = F9FC3A721683FC07004B2D1E /* TestData */; };
120 121
 /* End PBXBuildFile section */
121 122
 
122 123
 /* Begin PBXContainerItemProxy section */
@@ -298,6 +299,7 @@
298 299
 		F8EC5B0514C37F60006AF4D6 /* CTConnectedTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CTConnectedTest.h; path = Tests/CTConnectedTest.h; sourceTree = "<group>"; };
299 300
 		F8EC5B0514C37F60006AF4D7 /* CTCoreFolderTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CTCoreFolderTests.m; path = Tests/CTCoreFolderTests.m; sourceTree = "<group>"; };
300 301
 		F8EC5B0514C37F60006AF4D9 /* CTCoreFolderTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CTCoreFolderTests.h; path = Tests/CTCoreFolderTests.h; sourceTree = "<group>"; };
  302
+		F9FC3A721683FC07004B2D1E /* TestData */ = {isa = PBXFileReference; lastKnownFileType = folder; path = TestData; sourceTree = "<group>"; };
301 303
 /* End PBXFileReference section */
302 304
 
303 305
 /* Begin PBXFrameworksBuildPhase section */
@@ -359,6 +361,7 @@
359 361
 				F888632D158102F50088CF38 /* Cyrus SASL.xcodeproj */,
360 362
 				F890D38D10CEECD50039817C /* libetpan.xcodeproj */,
361 363
 				F85A18AF09C7D8F200305C06 /* Tests */,
  364
+				F9FC3A721683FC07004B2D1E /* TestData */,
362 365
 				08FB77AEFE84172EC02AAC07 /* Classes */,
363 366
 				32C88DFF0371C24200C91783 /* Other Sources */,
364 367
 				089C1665FE841158C02AAC07 /* Resources */,
@@ -784,6 +787,7 @@
784 787
 			buildActionMask = 2147483647;
785 788
 			files = (
786 789
 				F8DFCF5615801A5000C01975 /* InfoPlist.strings in Resources */,
  790
+				F9FC3A731683FC07004B2D1E /* TestData in Resources */,
787 791
 			);
788 792
 			runOnlyForDeploymentPostprocessing = 0;
789 793
 		};
@@ -1033,6 +1037,7 @@
1033 1037
 				GCC_WARN_ABOUT_RETURN_TYPE = YES;
1034 1038
 				GCC_WARN_UNUSED_VARIABLE = YES;
1035 1039
 				HEADER_SEARCH_PATHS = "libetpan/build-mac/include/**";
  1040
+				IPHONEOS_DEPLOYMENT_TARGET = 4.3;
1036 1041
 				LIBRARY_SEARCH_PATHS = "";
1037 1042
 				SDKROOT = macosx;
1038 1043
 			};
@@ -1049,6 +1054,7 @@
1049 1054
 				GCC_WARN_ABOUT_RETURN_TYPE = YES;
1050 1055
 				GCC_WARN_UNUSED_VARIABLE = YES;
1051 1056
 				HEADER_SEARCH_PATHS = "libetpan/build-mac/include/**";
  1057
+				IPHONEOS_DEPLOYMENT_TARGET = 4.3;
1052 1058
 				LIBRARY_SEARCH_PATHS = "";
1053 1059
 				SDKROOT = macosx;
1054 1060
 			};
@@ -1111,7 +1117,7 @@
1111 1117
 				GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
1112 1118
 				GCC_WARN_UNINITIALIZED_AUTOS = YES;
1113 1119
 				INFOPLIST_FILE = "Tests/Tests-Info.plist";
1114  
-				IPHONEOS_DEPLOYMENT_TARGET = 5.1;
  1120
+				IPHONEOS_DEPLOYMENT_TARGET = 4.3;
1115 1121
 				LIBRARY_SEARCH_PATHS = (
1116 1122
 					"$(inherited)",
1117 1123
 					"\"$(SRCROOT)/iOSPorts/ports/security/cyrus-sasl/build/Debug-iphoneos\"",
@@ -1138,7 +1144,7 @@
1138 1144
 				GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
1139 1145
 				GCC_WARN_UNINITIALIZED_AUTOS = YES;
1140 1146
 				INFOPLIST_FILE = "Tests/Tests-Info.plist";
1141  
-				IPHONEOS_DEPLOYMENT_TARGET = 5.1;
  1147
+				IPHONEOS_DEPLOYMENT_TARGET = 4.3;
1142 1148
 				LIBRARY_SEARCH_PATHS = (
1143 1149
 					"$(inherited)",
1144 1150
 					"\"$(SRCROOT)/iOSPorts/ports/security/cyrus-sasl/build/Debug-iphoneos\"",
1  Tests/CTConnectedTest.h
@@ -38,4 +38,5 @@
38 38
 @interface CTConnectedTest : SenTestCase
39 39
 @property (nonatomic, strong) CTCoreAccount *account;
40 40
 @property (nonatomic, strong) CTCoreFolder  *folder;
  41
+@property (nonatomic, strong) NSDictionary  *credentials;
41 42
 @end
57  Tests/CTConnectedTest.m
@@ -35,15 +35,41 @@
35 35
 
36 36
 @implementation CTConnectedTest {
37 37
 }
38  
-@synthesize account, folder;
39  
-NSString *SERVER = @"imap.gmail.com";
40  
-NSString *USERNAME = @"mailcoretests@gmail.com";
41  
-NSString *PASSWORD = @"MailCoreRockz";
  38
+@synthesize account, folder, credentials;
  39
+
  40
+/* Create a TestData/account.plist file to make these tests work. Start with this:
  41
+
  42
+ <?xml version="1.0" encoding="UTF-8"?>
  43
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  44
+ <plist version="1.0">
  45
+ <dict>
  46
+ <key>username</key>
  47
+ <string>username</string>
  48
+ <key>password</key>
  49
+ <string>password</string>
  50
+ <key>server</key>
  51
+ <string>server</string>
  52
+ <key>port</key>
  53
+ <integer>993</integer>
  54
+ <key>path</key>
  55
+ <string>MailCoreTests</string>
  56
+ </dict>
  57
+ </plist>
  58
+
  59
+ Because account.plist is included in the .gitignore file, your credentials won't be added
  60
+ to source control.
  61
+
  62
+ */
42 63
 
43 64
 - (void)setUp {
  65
+    NSString *filePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"TestData/account" ofType:@"plist"];
  66
+    self.credentials = [NSDictionary dictionaryWithContentsOfFile:filePath];
  67
+
  68
+    STAssertNotNil(self.credentials, @"These tests will fail anyway if they can't connect");
  69
+
44 70
     self.account = [[CTCoreAccount alloc] init];
45 71
     [self connect];
46  
-    self.folder = [self.account folderWithPath:@"Test"];
  72
+    self.folder = [self.account folderWithPath:[self.credentials valueForKey:@"path"]];
47 73
     [self.folder connect];
48 74
 }
49 75
 
@@ -60,12 +86,27 @@ - (void)dealloc {
60 86
 }
61 87
 
62 88
 - (void)connect {
63  
-    [self.account connectToServer:SERVER port:993 connectionType:CTConnectionTypeTLS authType:CTImapAuthTypePlain
64  
-             login:USERNAME password:PASSWORD];
  89
+    NSString *server = [self.credentials valueForKey:@"server"];
  90
+    int port = [[self.credentials objectForKey:@"port"] intValue];
  91
+    NSString *username = [self.credentials valueForKey:@"username"];
  92
+    NSString *password = [self.credentials valueForKey:@"password"];
  93
+
  94
+    STAssertFalse([server isEqualToString:@"server"], @"You need to provide your own account info");
  95
+    STAssertFalse([username isEqualToString:@"username"], @"You need to provide your own account info");
  96
+    STAssertFalse([password isEqualToString:@"password"], @"You need to provide your own account info");
  97
+    /* Once you've provided your own account info, create a folder with six messages in it.
  98
+     The path key in the account.plist should point to this directory, and you're ready! */
  99
+
  100
+    BOOL success = [self.account connectToServer:server port:port connectionType:CTConnectionTypeTLS authType:CTImapAuthTypePlain login:username password:password];
  101
+
  102
+    STAssertTrue(success, @"should successfully connect to email account");
  103
+    if (!success) {
  104
+        NSLog(@"!!!!!!! Can't connect to account !!!!!!! Error: %@", [[self.account lastError] localizedDescription]);
  105
+    }
65 106
 }
66 107
 
67 108
 - (void)disconnect {
68 109
     [self.folder disconnect];
69 110
     [self.account disconnect];
70 111
 }
71  
-@end
  112
+@end

0 notes on commit d3bf550

Please sign in to comment.
Something went wrong with that request. Please try again.