-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding iOS unit test for XMPPAutoTime
- Loading branch information
1 parent
0a3b7f4
commit 2037d10
Showing
16 changed files
with
1,509 additions
and
6 deletions.
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
3 changes: 1 addition & 2 deletions
3
Xcode/Testing/AutoTimeTest/Desktop/AutoTimeTest/AutoTimeTest/AutoTimeTestAppDelegate.h
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
638 changes: 638 additions & 0 deletions
638
Xcode/Testing/AutoTimeTest/Mobile/AutoTimeTest/AutoTimeTest.xcodeproj/project.pbxproj
Large diffs are not rendered by default.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
...t/Mobile/AutoTimeTest/AutoTimeTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
38 changes: 38 additions & 0 deletions
38
Xcode/Testing/AutoTimeTest/Mobile/AutoTimeTest/AutoTimeTest/AutoTimeTest-Info.plist
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>en</string> | ||
<key>CFBundleDisplayName</key> | ||
<string>${PRODUCT_NAME}</string> | ||
<key>CFBundleExecutable</key> | ||
<string>${EXECUTABLE_NAME}</string> | ||
<key>CFBundleIconFile</key> | ||
<string></string> | ||
<key>CFBundleIdentifier</key> | ||
<string>com.deusty.oss.${PRODUCT_NAME:rfc1034identifier}</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>${PRODUCT_NAME}</string> | ||
<key>CFBundlePackageType</key> | ||
<string>APPL</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>1.0</string> | ||
<key>CFBundleSignature</key> | ||
<string>????</string> | ||
<key>CFBundleVersion</key> | ||
<string>1.0</string> | ||
<key>LSRequiresIPhoneOS</key> | ||
<true/> | ||
<key>NSMainNibFile</key> | ||
<string>MainWindow</string> | ||
<key>UISupportedInterfaceOrientations</key> | ||
<array> | ||
<string>UIInterfaceOrientationPortrait</string> | ||
<string>UIInterfaceOrientationLandscapeLeft</string> | ||
<string>UIInterfaceOrientationLandscapeRight</string> | ||
</array> | ||
</dict> | ||
</plist> |
14 changes: 14 additions & 0 deletions
14
Xcode/Testing/AutoTimeTest/Mobile/AutoTimeTest/AutoTimeTest/AutoTimeTest-Prefix.pch
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// | ||
// Prefix header for all source files of the 'AutoTimeTest' target in the 'AutoTimeTest' project | ||
// | ||
|
||
#import <Availability.h> | ||
|
||
#ifndef __IPHONE_3_0 | ||
#warning "This project uses features only available in iPhone SDK 3.0 and later." | ||
#endif | ||
|
||
#ifdef __OBJC__ | ||
#import <UIKit/UIKit.h> | ||
#import <Foundation/Foundation.h> | ||
#endif |
16 changes: 16 additions & 0 deletions
16
Xcode/Testing/AutoTimeTest/Mobile/AutoTimeTest/AutoTimeTest/AutoTimeTestAppDelegate.h
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#import <UIKit/UIKit.h> | ||
#import "XMPPFramework.h" | ||
|
||
@class AutoTimeTestViewController; | ||
|
||
|
||
@interface AutoTimeTestAppDelegate : NSObject <UIApplicationDelegate> | ||
{ | ||
XMPPStream *xmppStream; | ||
XMPPAutoTime *xmppAutoTime; | ||
} | ||
|
||
@property (nonatomic, retain) IBOutlet UIWindow *window; | ||
@property (nonatomic, retain) IBOutlet AutoTimeTestViewController *viewController; | ||
|
||
@end |
113 changes: 113 additions & 0 deletions
113
Xcode/Testing/AutoTimeTest/Mobile/AutoTimeTest/AutoTimeTest/AutoTimeTestAppDelegate.m
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 |
---|---|---|
@@ -0,0 +1,113 @@ | ||
#import "AutoTimeTestAppDelegate.h" | ||
#import "AutoTimeTestViewController.h" | ||
#import "DDLog.h" | ||
#import "DDTTYLogger.h" | ||
|
||
// Log levels: off, error, warn, info, verbose | ||
static const int ddLogLevel = LOG_LEVEL_VERBOSE; | ||
|
||
#define MY_JID @"" // <--- ENTER A JID HERE (e.g. user@gmail.com) | ||
#define MY_PASSWORD @"" // <--- ENTER PASSWORD HERE | ||
|
||
|
||
@implementation AutoTimeTestAppDelegate | ||
|
||
@synthesize window = _window; | ||
@synthesize viewController = _viewController; | ||
|
||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions | ||
{ | ||
[DDLog addLogger:[DDTTYLogger sharedInstance]]; | ||
|
||
DDLogVerbose(@"%@: %@", [self class], THIS_METHOD); | ||
|
||
xmppStream = [[XMPPStream alloc] init]; | ||
|
||
// xmppStream.hostName = @""; | ||
xmppStream.myJID = [XMPPJID jidWithString:MY_JID]; | ||
|
||
xmppAutoTime = [[XMPPAutoTime alloc] init]; | ||
xmppAutoTime.recalibrationInterval = 60; | ||
xmppAutoTime.targetJID = nil; | ||
|
||
[xmppAutoTime activate:xmppStream]; | ||
|
||
[xmppStream addDelegate:self delegateQueue:dispatch_get_main_queue()]; | ||
[xmppAutoTime addDelegate:self delegateQueue:dispatch_get_main_queue()]; | ||
|
||
NSError *error = nil; | ||
|
||
if (![xmppStream connect:&error]) | ||
{ | ||
DDLogError(@"%@: Error connecting: %@", [self class], error); | ||
} | ||
|
||
self.window.rootViewController = self.viewController; | ||
[self.window makeKeyAndVisible]; | ||
return YES; | ||
} | ||
|
||
- (void)goOnline:(NSTimer *)aTimer | ||
{ | ||
DDLogVerbose(@"%@: %@", [self class], THIS_METHOD); | ||
|
||
[xmppStream sendElement:[XMPPPresence presence]]; | ||
} | ||
|
||
- (void)goOffline:(NSTimer *)aTimer | ||
{ | ||
DDLogVerbose(@"%@: %@", [self class], THIS_METHOD); | ||
|
||
[xmppStream sendElement:[XMPPPresence presenceWithType:@"unavailable"]]; | ||
} | ||
|
||
- (void)changeAutoTimeInterval:(NSTimer *)aTimer | ||
{ | ||
DDLogVerbose(@"%@: %@", [self class], THIS_METHOD); | ||
|
||
xmppAutoTime.recalibrationInterval = 30; | ||
} | ||
|
||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
|
||
- (void)xmppStreamDidConnect:(XMPPStream *)sender | ||
{ | ||
DDLogVerbose(@"%@: %@", [self class], THIS_METHOD); | ||
|
||
NSError *error = nil; | ||
|
||
if (![xmppStream authenticateWithPassword:MY_PASSWORD error:&error]) | ||
{ | ||
DDLogError(@"%@: Error authenticating: %@", [self class], error); | ||
} | ||
} | ||
|
||
- (void)xmppStreamDidAuthenticate:(XMPPStream *)sender | ||
{ | ||
DDLogVerbose(@"%@: %@", [self class], THIS_METHOD); | ||
|
||
[NSTimer scheduledTimerWithTimeInterval:130 | ||
target:self | ||
selector:@selector(changeAutoTimeInterval:) | ||
userInfo:nil | ||
repeats:NO]; | ||
} | ||
|
||
- (void)xmppStream:(XMPPStream *)sender didNotAuthenticate:(NSXMLElement *)error | ||
{ | ||
DDLogVerbose(@"%@: %@", [self class], THIS_METHOD); | ||
} | ||
|
||
- (void)xmppStreamDidDisconnect:(XMPPStream *)sender withError:(NSError *)error | ||
{ | ||
DDLogVerbose(@"%@: %@ %@", [self class], THIS_METHOD, error); | ||
} | ||
|
||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
|
||
- (void)xmppAutoTime:(XMPPAutoTime *)sender didUpdateTimeDifference:(NSTimeInterval)timeDifference | ||
{ | ||
DDLogVerbose(@"%@: %@ %f <<<<<<<============", [self class], THIS_METHOD, timeDifference); | ||
} | ||
|
||
@end |
13 changes: 13 additions & 0 deletions
13
Xcode/Testing/AutoTimeTest/Mobile/AutoTimeTest/AutoTimeTest/AutoTimeTestViewController.h
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
// AutoTimeTestViewController.h | ||
// AutoTimeTest | ||
// | ||
// Created by Robbie Hanson on 9/1/11. | ||
// Copyright 2011 __MyCompanyName__. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface AutoTimeTestViewController : UIViewController | ||
|
||
@end |
44 changes: 44 additions & 0 deletions
44
Xcode/Testing/AutoTimeTest/Mobile/AutoTimeTest/AutoTimeTest/AutoTimeTestViewController.m
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// | ||
// AutoTimeTestViewController.m | ||
// AutoTimeTest | ||
// | ||
// Created by Robbie Hanson on 9/1/11. | ||
// Copyright 2011 __MyCompanyName__. All rights reserved. | ||
// | ||
|
||
#import "AutoTimeTestViewController.h" | ||
|
||
@implementation AutoTimeTestViewController | ||
|
||
- (void)didReceiveMemoryWarning | ||
{ | ||
// Releases the view if it doesn't have a superview. | ||
[super didReceiveMemoryWarning]; | ||
|
||
// Release any cached data, images, etc that aren't in use. | ||
} | ||
|
||
#pragma mark - View lifecycle | ||
|
||
/* | ||
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib. | ||
- (void)viewDidLoad | ||
{ | ||
[super viewDidLoad]; | ||
} | ||
*/ | ||
|
||
- (void)viewDidUnload | ||
{ | ||
[super viewDidUnload]; | ||
// Release any retained subviews of the main view. | ||
// e.g. self.myOutlet = nil; | ||
} | ||
|
||
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation | ||
{ | ||
// Return YES for supported orientations | ||
return (interfaceOrientation == UIInterfaceOrientationPortrait); | ||
} | ||
|
||
@end |
Oops, something went wrong.