-
Notifications
You must be signed in to change notification settings - Fork 235
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Functions for logging into File in SDK and TestBed App. Added U…
…I Test Cases.
- Loading branch information
1 parent
57b574f
commit e681c6f
Showing
39 changed files
with
2,646 additions
and
101 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
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
106 changes: 106 additions & 0 deletions
106
Branch-TestBed/Branch-TestBed-UITests/UITestCase0OpenNInstall.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,106 @@ | ||
// | ||
// UITestOpenNInstall.m | ||
// Branch-TestBed-UITests | ||
// | ||
// Created by Nidhi on 3/10/21. | ||
// Copyright © 2021 Branch, Inc. All rights reserved. | ||
// | ||
|
||
#import "UITestCaseTestBed.h" | ||
#import <Foundation/Foundation.h> | ||
|
||
@interface UITestCase0OpenNInstall : UITestCaseTestBed | ||
|
||
@end | ||
|
||
@implementation UITestCase0OpenNInstall | ||
|
||
- (void)setUp { | ||
[super setUp]; | ||
} | ||
|
||
- (void)tearDown { | ||
} | ||
/* | ||
* Test Case : | ||
* 1.1 First initSession call results in API call to /v1/install or /v1/open | ||
* 1.2 Subsequent initSession calls result in API call to /v1/open | ||
*/ | ||
- (void)test0Install { | ||
|
||
// Launch App and Disable Tracking | ||
XCUIApplication *app = [[XCUIApplication alloc] init]; | ||
[app launch]; | ||
[self disableTracking:FALSE]; | ||
|
||
// Press Button "Load Logs for Last Command" and copy logs | ||
XCUIElementQuery *tablesQuery = app.tables; | ||
[tablesQuery.staticTexts[@"Load Logs for Last Command"] tap]; | ||
XCUIElement *deeplinkdataTextView = app.textViews[@"DeepLinkData"]; | ||
[deeplinkdataTextView tap]; | ||
NSString *prevLogResults = app.textViews[@"DeepLinkData"].value; | ||
|
||
// Parse logs | ||
NSString *url; | ||
NSDictionary *json; | ||
NSString *status; | ||
NSDictionary *dataJson; | ||
[self parseURL:&url andJSON:&json andStatus:&status andDataJSON:&dataJson FromLogs:prevLogResults]; | ||
|
||
// Check url contains /v1/install | ||
XCTAssertNotNil(url); | ||
XCTAssertNotNil(json); | ||
XCTAssertTrue([url containsString:@"/v1/install"]); | ||
|
||
// Get and Assert device_fingerprint_id & identity_id | ||
NSNumber *device_fingerprint_id = [dataJson objectForKey:@"device_fingerprint_id"]; | ||
NSNumber *identity_id = [dataJson objectForKey:@"identity_id"]; | ||
XCTAssertNotNil(identity_id); | ||
XCTAssertNotNil(device_fingerprint_id); | ||
|
||
//Re-launch App | ||
[app.navigationBars[@"Branch-TestBed"].buttons[@"Branch-TestBed"] tap]; | ||
[app terminate]; | ||
[app launch]; | ||
|
||
// Load logs and assert - | ||
// - URL contains /v1/open | ||
// - device_fingerprint_id is the same as returned above | ||
// - identity_id is the same as returned above | ||
[tablesQuery/*@START_MENU_TOKEN@*/.staticTexts[@"Load Logs for Last Command"]/*[[".cells",".buttons[@\"Load Logs for Last Command\"].staticTexts[@\"Load Logs for Last Command\"]",".staticTexts[@\"Load Logs for Last Command\"]"],[[[-1,2],[-1,1],[-1,0,1]],[[-1,2],[-1,1]]],[0]]@END_MENU_TOKEN@*/ tap]; | ||
deeplinkdataTextView = app.textViews[@"DeepLinkData"]; | ||
[deeplinkdataTextView tap]; | ||
prevLogResults = app.textViews[@"DeepLinkData"].value; | ||
[self parseURL:&url andJSON:&json andStatus:&status andDataJSON:&dataJson FromLogs:prevLogResults]; | ||
|
||
XCTAssertTrue([url containsString:@"/v1/open"]); | ||
|
||
XCTAssertNotNil([json valueForKey:@"identity_id"]); | ||
NSNumber *newID = [NSNumber numberWithInteger: [[json objectForKey:@"identity_id"] integerValue]] ; | ||
XCTAssertTrue([newID isEqualToNumber:identity_id]); | ||
|
||
XCTAssertNotNil([json valueForKey:@"device_fingerprint_id"]); | ||
NSNumber *newFPID = [NSNumber numberWithInteger: [[json objectForKey:@"device_fingerprint_id"] integerValue]] ; | ||
XCTAssertTrue([newFPID isEqualToNumber:device_fingerprint_id]); | ||
XCTAssertTrue([status containsString:@"200"]); | ||
} | ||
|
||
/* | ||
When a link is clicked with the app installed, it opens the app | ||
- the call to /v1/open should include information about the link clicked | ||
- the response from /v1/open should include deep link data inside the `data` object | ||
*/ | ||
- (void) testOpenAppFromWebPage | ||
{ | ||
[self clickLinkInWebPage:@"TestWebPage.html"]; | ||
|
||
XCUIApplication *app = [[XCUIApplication alloc] init]; | ||
if ([ app waitForExistenceWithTimeout:15] != NO) { | ||
NSString *deepLinkData = app.textViews[@"DeepLinkData"].value; | ||
XCTAssertTrue([deepLinkData containsString:self.deeplinkDataToCheck]); | ||
} else { | ||
XCTFail("Application not launched"); | ||
} | ||
} | ||
|
||
@end |
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,145 @@ | ||
// | ||
// UITestCaseMisc.m | ||
// Branch-TestBed-UITests | ||
// | ||
// Created by Nidhi on 2/26/21. | ||
// Copyright © 2021 Branch, Inc. All rights reserved. | ||
// | ||
|
||
#import "UITestCaseTestBed.h" | ||
#import "Branch.h" | ||
#import "BranchEvent.h" | ||
|
||
@interface UITestCaseMisc : UITestCaseTestBed | ||
|
||
@end | ||
|
||
@implementation UITestCaseMisc | ||
|
||
- (void)setUp { | ||
[super setUp]; | ||
} | ||
|
||
- (void)tearDown { | ||
} | ||
|
||
- (void)testShareLink { | ||
|
||
// Tap on 'Creat Branch Link' and then 'Share Link' | ||
XCUIApplication *app = [[XCUIApplication alloc] init]; | ||
[app launch]; | ||
[self disableTracking:FALSE]; | ||
XCUIElementQuery *tablesQuery = app.tables; | ||
[tablesQuery/*@START_MENU_TOKEN@*/.staticTexts[@"Create Branch Link"]/*[[".cells",".buttons[@\"Create Branch Link\"].staticTexts[@\"Create Branch Link\"]",".staticTexts[@\"Create Branch Link\"]"],[[[-1,2],[-1,1],[-1,0,1]],[[-1,2],[-1,1]]],[0]]@END_MENU_TOKEN@*/ tap]; | ||
[tablesQuery.staticTexts[@"Share Link"] tap]; | ||
sleep(3); | ||
|
||
// Copy Link | ||
[[[[app/*@START_MENU_TOKEN@*/.collectionViews/*[[".otherElements[@\"ActivityListView\"].collectionViews",".collectionViews"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.buttons[@"Copy"].otherElements containingType:XCUIElementTypeImage identifier:@"copy"] childrenMatchingType:XCUIElementTypeOther].element childrenMatchingType:XCUIElementTypeOther].element tap]; | ||
sleep(3); | ||
|
||
// Assert Link is copied in Pasteboard | ||
NSString *pasteboardString = [UIPasteboard generalPasteboard].string; | ||
if ([pasteboardString containsString:@"Shared through 'Pasteboard'"] != YES) { | ||
XCTFail("Link not copied"); | ||
} | ||
} | ||
|
||
- (void)testCreateAndOpenURL { | ||
|
||
XCUIApplication *app = [[XCUIApplication alloc] init]; | ||
[app launch]; | ||
[self disableTracking:FALSE]; | ||
|
||
//Tap "Create Branch Link" and assert text Field "Branch Link" shows link | ||
XCUIElementQuery *tablesQuery = app.tables; | ||
[tablesQuery.staticTexts[@"Create Branch Link"] tap]; | ||
XCUIElement *branchLinkTextField = tablesQuery.textFields[@"Branch Link"]; | ||
NSString *shortURL = branchLinkTextField.value; | ||
XCTAssertNotNil(shortURL); | ||
|
||
// Tap "Open Branch Link" and assert deep link data | ||
[tablesQuery.buttons[@"Open Branch Link"] tap]; | ||
sleep(1); | ||
NSString *deepLinkData = app.textViews[@"DeepLinkData"].value; | ||
self.deeplinkDataToCheck = @"This text was embedded as data in a Branch link with the following characteristics:\n\ncanonicalUrl: https://dev.branch.io/getting-started/deep-link-routing/guide/ios/\n title: Content Title\n contentDescription: My Content Description\n imageUrl: https://pbs.twimg.com/profile_images/658759610220703744/IO1HUADP.png\n"; | ||
NSLog(@"%@" , self.deeplinkDataToCheck); | ||
XCTAssertTrue([deepLinkData containsString:self.deeplinkDataToCheck]); | ||
|
||
} | ||
|
||
- (void)testReferringParams | ||
{ | ||
// Launch App, disable tracking and logout | ||
XCUIApplication *app = [[XCUIApplication alloc] init]; | ||
[app launch]; | ||
[self disableTracking:FALSE]; | ||
XCUIElementQuery *tablesQuery = app.tables; | ||
[tablesQuery/*@START_MENU_TOKEN@*/.staticTexts[@"SimulateLogout"]/*[[".cells",".buttons[@\"SimulateLogout\"].staticTexts[@\"SimulateLogout\"]",".staticTexts[@\"SimulateLogout\"]"],[[[-1,2],[-1,1],[-1,0,1]],[[-1,2],[-1,1]]],[0]]@END_MENU_TOKEN@*/ tap]; | ||
[app.alerts[@"Logout succeeded"].scrollViews.otherElements.buttons[@"OK"] tap]; | ||
|
||
// Tap 'View FirstReferringParams' and copy params | ||
XCUIElement *branchTestbedButton = app.navigationBars[@"Branch-TestBed"].buttons[@"Branch-TestBed"]; | ||
XCUIElement *viewFirstreferringparamsStaticText = tablesQuery.staticTexts[@"View FirstReferringParams"]; | ||
[viewFirstreferringparamsStaticText tap]; | ||
NSString *viewFirstreferringString = app.textViews[@"DeepLinkData"].value; | ||
XCTAssertTrue([viewFirstreferringString containsString:@"{\n}"]); | ||
[branchTestbedButton tap]; | ||
|
||
// Tap 'View LatestReferringParams' and copy params | ||
XCUIElement *viewLatestreferringparamsStaticText = tablesQuery.staticTexts[@"View LatestReferringParams"]; | ||
[viewLatestreferringparamsStaticText tap]; | ||
NSString *viewLatesttreferringString = app.textViews[@"DeepLinkData"].value; | ||
XCTAssertTrue([viewLatesttreferringString containsString:@"{\n}"]); | ||
[branchTestbedButton tap]; | ||
|
||
// Tap "Set User ID" and then Tap 'View FirstReferringParams' & 'View LatestReferringParams' and copy params again | ||
[tablesQuery.buttons[@"Set User ID"] tap]; | ||
[branchTestbedButton tap]; | ||
sleep(1); | ||
[viewFirstreferringparamsStaticText tap]; | ||
viewFirstreferringString = app.textViews[@"DeepLinkData"].value; | ||
[branchTestbedButton tap]; | ||
[viewLatestreferringparamsStaticText tap]; | ||
viewLatesttreferringString = app.textViews[@"DeepLinkData"].value; | ||
[branchTestbedButton tap]; | ||
|
||
// Re-launch app. | ||
[app terminate]; | ||
[app launch]; | ||
|
||
// Tap on 'View FirstReferringParams' & 'View LatestReferringParams' again and check viewFirstreferringparamsStaticText is still same and viewLatestreferringparamsStaticText shows latest paramms. | ||
[viewFirstreferringparamsStaticText tap]; | ||
NSString *viewFirstreferringStringNew = app.textViews[@"DeepLinkData"].value; | ||
[branchTestbedButton tap]; | ||
XCTAssertTrue([viewFirstreferringString isEqualToString:viewFirstreferringStringNew]); | ||
[viewLatestreferringparamsStaticText tap]; | ||
viewLatesttreferringString = app.textViews[@"DeepLinkData"].value; | ||
[branchTestbedButton tap]; | ||
|
||
NSString *viewLatesttreferringStringNew =@"{\n \"+clicked_branch_link\" = 0;\n \"+is_first_session\" = 0;\n}"; | ||
|
||
XCTAssertTrue([viewLatesttreferringString isEqualToString:viewLatesttreferringStringNew]); | ||
|
||
} | ||
|
||
- (void)testFBParams | ||
{ | ||
XCUIApplication *app = [[XCUIApplication alloc] init]; | ||
[app launch]; | ||
[self disableTracking:FALSE]; | ||
|
||
XCUIElementQuery *tablesQuery = [[XCUIApplication alloc] init].tables; | ||
[tablesQuery/*@START_MENU_TOKEN@*/.buttons[@"Set FB Params"]/*[[".cells.buttons[@\"Set FB Params\"]",".buttons[@\"Set FB Params\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/ tap]; | ||
setFBParams = TRUE; | ||
checkFBParams = TRUE; | ||
[self sendEvent:BranchStandardEventAddToCart]; | ||
XCUIElement *branchTestbedButton = app.navigationBars[@"Branch-TestBed"].buttons[@"Branch-TestBed"]; | ||
[branchTestbedButton tap]; | ||
[tablesQuery/*@START_MENU_TOKEN@*/.buttons[@"Clear FB Params"]/*[[".cells.buttons[@\"Clear FB Params\"]",".buttons[@\"Clear FB Params\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/ tap]; | ||
setFBParams = FALSE; | ||
[self sendEvent:BranchStandardEventAddToCart]; | ||
checkFBParams = FALSE; | ||
} | ||
|
||
@end |
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,39 @@ | ||
// | ||
// UITestCaseSafari.m | ||
// Branch-TestBed-UITests | ||
// | ||
// Created by Nidhi on 3/25/21. | ||
// Copyright © 2021 Branch, Inc. All rights reserved. | ||
// | ||
|
||
#import "UITestCaseTestBed.h" | ||
|
||
@interface UITestCaseSafari : UITestCaseTestBed | ||
|
||
@end | ||
|
||
@implementation UITestCaseSafari | ||
|
||
- (void)setUp { | ||
self.continueAfterFailure = NO; | ||
[super setUp]; | ||
//[[[XCUIApplication alloc] init] launch]; | ||
} | ||
|
||
- (void)tearDown { | ||
} | ||
|
||
- (void)testOpenURL { | ||
//[self OpenLinkInWebPage:@"TestWebPage.html"]; | ||
} | ||
|
||
- (void)testOpenURLInNewWindow { | ||
|
||
} | ||
|
||
- (void)testClickURL { | ||
|
||
} | ||
|
||
|
||
@end |
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,31 @@ | ||
// | ||
// UITestCaseTestBed.h | ||
// Branch-TestBed-UITests | ||
// | ||
// Created by Nidhi on 3/7/21. | ||
// Copyright © 2021 Branch, Inc. All rights reserved. | ||
// | ||
|
||
#ifndef UITestCaseTestBed_h | ||
#define UITestCaseTestBed_h | ||
|
||
#import <XCTest/XCTest.h> | ||
|
||
extern BOOL setIdentity; | ||
extern BOOL checkIdentity; | ||
extern BOOL setFBParams; | ||
extern BOOL checkFBParams; | ||
|
||
@interface UITestCaseTestBed : XCTestCase | ||
|
||
@property NSString *deeplinkDataToCheck; | ||
|
||
- (void)sendEvent:(NSString*)eventName; | ||
-(void)parseURL:(NSString **)url andJSON:(NSDictionary **)json FromLogs:(NSString*)logs; | ||
-(void)parseURL:(NSString **)url andJSON:(NSDictionary **)json andStatus:(NSString**)status andDataJSON:(NSDictionary **)dataJson FromLogs:(NSString*)logs; | ||
- (void)clickLinkInWebPage:(NSString*)webPage; | ||
//- (void)OpenLinkInWebPage:(NSString*)webPage; | ||
- (void)disableTracking:(BOOL)disable; | ||
@end | ||
|
||
#endif /* UITestCaseTestBed_h */ |
Oops, something went wrong.