diff --git a/KifTests/ChatTester.h b/KifTests/ChatTester.h new file mode 100644 index 000000000..93ec77140 --- /dev/null +++ b/KifTests/ChatTester.h @@ -0,0 +1,13 @@ +// +// ChatTester.h +// linphone +// +// Created by Guillaume on 17/01/2015. +// +// + +#import + +@interface ChatTester : KIFTestCase + +@end diff --git a/KifTests/ChatTester.m b/KifTests/ChatTester.m new file mode 100644 index 000000000..1d1e9cd60 --- /dev/null +++ b/KifTests/ChatTester.m @@ -0,0 +1,36 @@ +// +// ChatTester.m +// linphone +// +// Created by Guillaume on 17/01/2015. +// +// + +#import "ChatTester.h" +#import "KIFTestCase+LinphoneExtras.h" + +@implementation ChatTester + + +- (void)beforeAll { + [self switchToValidAccountIfNeeded]; + + [tester tapViewWithAccessibilityLabel:@"Chat"]; +} + +- (void)testSendMessageToMyself { + [tester enterText:[self accountUsername] intoViewWithAccessibilityLabel:@"Enter a address"]; + [tester tapViewWithAccessibilityLabel:@"New Discussion"]; + + [tester enterText:@"Hello" intoViewWithAccessibilityLabel:@"Message field"]; + + [tester tapViewWithAccessibilityLabel:@"Send"]; + + [tester waitForViewWithAccessibilityLabel:@"Outgoing message" value:@"Hello" traits:UIAccessibilityTraitStaticText]; + [tester waitForViewWithAccessibilityLabel:@"Incoming message" value:@"Hello" traits:UIAccessibilityTraitStaticText]; + + [tester waitForViewWithAccessibilityLabel:@"Message status" value:@"delivered" traits:UIAccessibilityTraitImage]; + +} + +@end diff --git a/KifTests/KIFTestCase+LinphoneExtras.h b/KifTests/KIFTestCase+LinphoneExtras.h new file mode 100644 index 000000000..ec45e82f3 --- /dev/null +++ b/KifTests/KIFTestCase+LinphoneExtras.h @@ -0,0 +1,18 @@ +// +// KIFTestCase+LinphoneExtras.h +// linphone +// +// Created by Guillaume on 17/01/2015. +// +// + +#import + +@interface KIFTestCase (LinphoneExtras) + +@property BOOL invalidAccountSet; + +- (void)switchToValidAccountIfNeeded; +- (NSString*)accountUsername; + +@end diff --git a/KifTests/KIFTestCase+LinphoneExtras.m b/KifTests/KIFTestCase+LinphoneExtras.m new file mode 100644 index 000000000..c428ce4cc --- /dev/null +++ b/KifTests/KIFTestCase+LinphoneExtras.m @@ -0,0 +1,54 @@ +// +// KIFTestCase+LinphoneExtras.m +// linphone +// +// Created by Guillaume on 17/01/2015. +// +// + +#import "KIFTestCase+LinphoneExtras.h" + +@implementation KIFTestCase (LinphoneExtras) + +static bool invalidAccount = true; + +- (void)setInvalidAccountSet:(BOOL)invalidAccountSet { + invalidAccount = invalidAccountSet; +} + +- (BOOL)invalidAccountSet { + return invalidAccount; +} + +- (NSString *)accountUsername { + return @"testios"; +} + +- (void)switchToValidAccountIfNeeded { + [UIView setAnimationsEnabled:false]; + + if( invalidAccount ){ + + [tester tapViewWithAccessibilityLabel:@"Settings"]; + [tester tapViewWithAccessibilityLabel:@"Run assistant"]; + [tester waitForTimeInterval:0.5]; + if( [tester tryFindingViewWithAccessibilityLabel:@"Launch Wizard" error:nil]){ + [tester tapViewWithAccessibilityLabel:@"Launch Wizard"]; + [tester waitForTimeInterval:0.5]; + } + + NSLog(@"Switching to a valid account"); + + [tester tapViewWithAccessibilityLabel:@"Start"]; + [tester tapViewWithAccessibilityLabel:@"Sign in linphone.org account"]; + + [tester enterText:@"testios" intoViewWithAccessibilityLabel:@"Username"]; + [tester enterText:@"testtest" intoViewWithAccessibilityLabel:@"Password"]; + + [tester tapViewWithAccessibilityLabel:@"Sign in"]; + + invalidAccount = false; + } +} + +@end diff --git a/KifTests/WizardTester.h b/KifTests/WizardTester.h new file mode 100644 index 000000000..34a3a371b --- /dev/null +++ b/KifTests/WizardTester.h @@ -0,0 +1,13 @@ + // +// WizardTester.h +// linphone +// +// Created by Guillaume on 17/01/2015. +// +// + +#import + +@interface WizardTester : KIFTestCase + +@end \ No newline at end of file diff --git a/KifTests/WizardTester.m b/KifTests/WizardTester.m index 5d9a71a11..00f8b3381 100644 --- a/KifTests/WizardTester.m +++ b/KifTests/WizardTester.m @@ -6,13 +6,10 @@ // // -#import -#import + +#import "WizardTester.h" #import - -@interface WizardTester : KIFTestCase - -@end +#import "KIFTestCase+LinphoneExtras.h" @implementation WizardTester @@ -21,30 +18,60 @@ [tester tapViewWithAccessibilityLabel:@"Settings"]; [tester tapViewWithAccessibilityLabel:@"Run assistant"]; - [tester waitForTimeInterval:2]; + [tester waitForTimeInterval:0.5]; if( [tester tryFindingViewWithAccessibilityLabel:@"Launch Wizard" error:nil]){ [tester tapViewWithAccessibilityLabel:@"Launch Wizard"]; - [tester waitForTimeInterval:1]; + [tester waitForTimeInterval:0.5]; } - - - // TODO: goto Wizard } - (void)afterEach{ - // TODO: goto Dialer [tester tapViewWithAccessibilityLabel:@"Dialer"]; } -- (void)testLinphoneLogin { +#pragma mark - State ++ (void)switchToValidAccountWithTester:(KIFTestCase*)testCase { +} + +#pragma mark - Utilities + +- (void)_linphoneLogin:(NSString*)username withPW:(NSString*)pw { [tester tapViewWithAccessibilityLabel:@"Start"]; [tester tapViewWithAccessibilityLabel:@"Sign in linphone.org account"]; - [tester enterText:@"testios" intoViewWithAccessibilityLabel:@"Username"]; - [tester enterText:@"testtest" intoViewWithAccessibilityLabel:@"Password"]; + [tester enterText:username intoViewWithAccessibilityLabel:@"Username"]; + [tester enterText:pw intoViewWithAccessibilityLabel:@"Password"]; [tester tapViewWithAccessibilityLabel:@"Sign in"]; +} + + + +- (void)_externalLoginWithProtocol:(NSString*)protocol { + + [self setInvalidAccountSet:true]; + [tester tapViewWithAccessibilityLabel:@"Start"]; + [tester tapViewWithAccessibilityLabel:@"Sign in SIP account"]; + + [tester enterText:@"testios" intoViewWithAccessibilityLabel:@"Username"]; + [tester enterText:@"testtest" intoViewWithAccessibilityLabel:@"Password"]; + [tester enterText:@"sip.linphone.org" intoViewWithAccessibilityLabel:@"Domain"]; + [tester tapViewWithAccessibilityLabel:protocol]; + + [tester tapViewWithAccessibilityLabel:@"Sign in"]; + + // check the registration state + UIView* regState = [tester waitForViewWithAccessibilityLabel:@"Registration state"]; + [tester waitForTimeInterval:1]; + [tester expectView:regState toContainText:@"Registered"]; +} + +#pragma mark - Tests + +- (void)testLinphoneLogin { + + [self _linphoneLogin:@"testios" withPW:@"testtest"]; // check the registration state UIView* regState = [tester waitForViewWithAccessibilityLabel:@"Registration state"]; @@ -53,5 +80,38 @@ } +- (void)testLinphoneLoginWithBadPassword { + [self _linphoneLogin:@"testios" withPW:@"badPass"]; + + [self setInvalidAccountSet:true]; + + UIView* alertViewText = [tester waitForViewWithAccessibilityLabel:@"Registration failure" traits:UIAccessibilityTraitStaticText]; + if( alertViewText ){ + UIView *reason = [tester waitForViewWithAccessibilityLabel:@"Forbidden" traits:UIAccessibilityTraitStaticText]; + if( reason == nil ){ [tester fail]; + } else { + [tester tapViewWithAccessibilityLabel:@"OK"]; // alertview + [tester tapViewWithAccessibilityLabel:@"Cancel"]; // cancel wizard + } + } else { + [tester fail]; + } +} + +- (void)testExternalLoginWithUDP { + [self _externalLoginWithProtocol:@"UDP"]; +} + +- (void)testExternalLoginWithTCP { + [self _externalLoginWithProtocol:@"TCP"]; +} + +- (void)testExternalLoginWithTLS { + [self _externalLoginWithProtocol:@"TLS"]; +} + + + + @end diff --git a/linphone.xcodeproj/project.pbxproj b/linphone.xcodeproj/project.pbxproj index 0414f7579..9ec8d4a98 100755 --- a/linphone.xcodeproj/project.pbxproj +++ b/linphone.xcodeproj/project.pbxproj @@ -697,6 +697,8 @@ F08F119D19C0A65B007D70C2 /* NSObject+DTRuntime.m in Sources */ = {isa = PBXBuildFile; fileRef = F08F119C19C0A65B007D70C2 /* NSObject+DTRuntime.m */; }; F08F11A019C0A6CB007D70C2 /* DTObjectBlockExecutor.m in Sources */ = {isa = PBXBuildFile; fileRef = F08F119F19C0A6CB007D70C2 /* DTObjectBlockExecutor.m */; }; F0938159188E629800A55DFA /* iTunesArtwork in Resources */ = {isa = PBXBuildFile; fileRef = F0938158188E629800A55DFA /* iTunesArtwork */; }; + F0A1CE081A6B056E001CA2BE /* ChatTester.m in Sources */ = {isa = PBXBuildFile; fileRef = F0A1CE071A6B056E001CA2BE /* ChatTester.m */; }; + F0A1CE0C1A6B08FA001CA2BE /* KIFTestCase+LinphoneExtras.m in Sources */ = {isa = PBXBuildFile; fileRef = F0A1CE0B1A6B08FA001CA2BE /* KIFTestCase+LinphoneExtras.m */; }; F0B4FB5D1A65550B00637027 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F0B4FB5C1A65550B00637027 /* Images.xcassets */; }; F0B89C2218DC89E30050B60E /* MediaPlayer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F0B89C2118DC89E30050B60E /* MediaPlayer.framework */; }; F0B89C2818DC973E0050B60E /* wizard_external_sip.rc in Resources */ = {isa = PBXBuildFile; fileRef = F0B89C2418DC973E0050B60E /* wizard_external_sip.rc */; }; @@ -1697,6 +1699,11 @@ F095485C1883F68800E8A69B /* ru */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ru; path = "ru.lproj/WizardViewController~ipad.strings"; sourceTree = ""; }; F095485D1883F6E700E8A69B /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/WizardViews.strings; sourceTree = ""; }; F095485E1883F6EA00E8A69B /* ru */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ru; path = ru.lproj/WizardViews.strings; sourceTree = ""; }; + F0A1CE061A6B056E001CA2BE /* ChatTester.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChatTester.h; sourceTree = ""; }; + F0A1CE071A6B056E001CA2BE /* ChatTester.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChatTester.m; sourceTree = ""; }; + F0A1CE091A6B05A4001CA2BE /* WizardTester.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WizardTester.h; sourceTree = ""; }; + F0A1CE0A1A6B08FA001CA2BE /* KIFTestCase+LinphoneExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "KIFTestCase+LinphoneExtras.h"; sourceTree = ""; }; + F0A1CE0B1A6B08FA001CA2BE /* KIFTestCase+LinphoneExtras.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "KIFTestCase+LinphoneExtras.m"; sourceTree = ""; }; F0AF06F01A24BA760086C9C1 /* ar */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ar; path = ar.lproj/AboutViewController.strings; sourceTree = ""; }; F0AF06F11A24BA760086C9C1 /* ar */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ar; path = ar.lproj/ChatRoomViewController.strings; sourceTree = ""; }; F0AF06F21A24BA760086C9C1 /* ar */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ar; path = ar.lproj/ChatViewController.strings; sourceTree = ""; }; @@ -3010,6 +3017,11 @@ children = ( F0F952021A6AEB1000254160 /* Supporting Files */, F0F952111A6AECD300254160 /* WizardTester.m */, + F0A1CE091A6B05A4001CA2BE /* WizardTester.h */, + F0A1CE061A6B056E001CA2BE /* ChatTester.h */, + F0A1CE071A6B056E001CA2BE /* ChatTester.m */, + F0A1CE0A1A6B08FA001CA2BE /* KIFTestCase+LinphoneExtras.h */, + F0A1CE0B1A6B08FA001CA2BE /* KIFTestCase+LinphoneExtras.m */, ); path = KifTests; sourceTree = ""; @@ -3981,6 +3993,8 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + F0A1CE081A6B056E001CA2BE /* ChatTester.m in Sources */, + F0A1CE0C1A6B08FA001CA2BE /* KIFTestCase+LinphoneExtras.m in Sources */, F0F952121A6AECD300254160 /* WizardTester.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0;