-
Notifications
You must be signed in to change notification settings - Fork 3k
[cocoapods test jam] Add application tests #128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,6 @@ | ||
| language: objective-c | ||
| before_script: | ||
| - brew update | ||
| - brew upgrade xctool || true | ||
| script: | ||
| - xctool -project WebViewJavascriptBridge.xcodeproj -scheme WebViewJavascriptBridge -configuration Release -sdk iphonesimulator test |
This file contains hidden or 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
Large diffs are not rendered by default.
Oops, something went wrong.
110 changes: 110 additions & 0 deletions
110
WebViewJavascriptBridge.xcodeproj/xcshareddata/xcschemes/WebViewJavascriptBridge.xcscheme
This file contains hidden or 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,110 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <Scheme | ||
| LastUpgradeVersion = "0630" | ||
| version = "1.3"> | ||
| <BuildAction | ||
| parallelizeBuildables = "YES" | ||
| buildImplicitDependencies = "YES"> | ||
| <BuildActionEntries> | ||
| <BuildActionEntry | ||
| buildForTesting = "YES" | ||
| buildForRunning = "YES" | ||
| buildForProfiling = "YES" | ||
| buildForArchiving = "YES" | ||
| buildForAnalyzing = "YES"> | ||
| <BuildableReference | ||
| BuildableIdentifier = "primary" | ||
| BlueprintIdentifier = "3D0FE4691AE2886400BB4104" | ||
| BuildableName = "libWebViewJavascriptBridge.a" | ||
| BlueprintName = "WebViewJavascriptBridge" | ||
| ReferencedContainer = "container:WebViewJavascriptBridge.xcodeproj"> | ||
| </BuildableReference> | ||
| </BuildActionEntry> | ||
| <BuildActionEntry | ||
| buildForTesting = "YES" | ||
| buildForRunning = "YES" | ||
| buildForProfiling = "NO" | ||
| buildForArchiving = "NO" | ||
| buildForAnalyzing = "YES"> | ||
| <BuildableReference | ||
| BuildableIdentifier = "primary" | ||
| BlueprintIdentifier = "3D0FE4741AE2886500BB4104" | ||
| BuildableName = "WebViewJavascriptBridgeTests.xctest" | ||
| BlueprintName = "WebViewJavascriptBridgeTests" | ||
| ReferencedContainer = "container:WebViewJavascriptBridge.xcodeproj"> | ||
| </BuildableReference> | ||
| </BuildActionEntry> | ||
| </BuildActionEntries> | ||
| </BuildAction> | ||
| <TestAction | ||
| selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
| selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
| shouldUseLaunchSchemeArgsEnv = "YES" | ||
| buildConfiguration = "Debug"> | ||
| <Testables> | ||
| <TestableReference | ||
| skipped = "NO"> | ||
| <BuildableReference | ||
| BuildableIdentifier = "primary" | ||
| BlueprintIdentifier = "3D0FE4741AE2886500BB4104" | ||
| BuildableName = "WebViewJavascriptBridgeTests.xctest" | ||
| BlueprintName = "WebViewJavascriptBridgeTests" | ||
| ReferencedContainer = "container:WebViewJavascriptBridge.xcodeproj"> | ||
| </BuildableReference> | ||
| </TestableReference> | ||
| </Testables> | ||
| <MacroExpansion> | ||
| <BuildableReference | ||
| BuildableIdentifier = "primary" | ||
| BlueprintIdentifier = "3D0FE4691AE2886400BB4104" | ||
| BuildableName = "libWebViewJavascriptBridge.a" | ||
| BlueprintName = "WebViewJavascriptBridge" | ||
| ReferencedContainer = "container:WebViewJavascriptBridge.xcodeproj"> | ||
| </BuildableReference> | ||
| </MacroExpansion> | ||
| </TestAction> | ||
| <LaunchAction | ||
| selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
| selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
| launchStyle = "0" | ||
| useCustomWorkingDirectory = "NO" | ||
| buildConfiguration = "Debug" | ||
| ignoresPersistentStateOnLaunch = "NO" | ||
| debugDocumentVersioning = "YES" | ||
| allowLocationSimulation = "YES"> | ||
| <MacroExpansion> | ||
| <BuildableReference | ||
| BuildableIdentifier = "primary" | ||
| BlueprintIdentifier = "3D0FE4691AE2886400BB4104" | ||
| BuildableName = "libWebViewJavascriptBridge.a" | ||
| BlueprintName = "WebViewJavascriptBridge" | ||
| ReferencedContainer = "container:WebViewJavascriptBridge.xcodeproj"> | ||
| </BuildableReference> | ||
| </MacroExpansion> | ||
| <AdditionalOptions> | ||
| </AdditionalOptions> | ||
| </LaunchAction> | ||
| <ProfileAction | ||
| shouldUseLaunchSchemeArgsEnv = "YES" | ||
| savedToolIdentifier = "" | ||
| useCustomWorkingDirectory = "NO" | ||
| buildConfiguration = "Release" | ||
| debugDocumentVersioning = "YES"> | ||
| <MacroExpansion> | ||
| <BuildableReference | ||
| BuildableIdentifier = "primary" | ||
| BlueprintIdentifier = "3D0FE4691AE2886400BB4104" | ||
| BuildableName = "libWebViewJavascriptBridge.a" | ||
| BlueprintName = "WebViewJavascriptBridge" | ||
| ReferencedContainer = "container:WebViewJavascriptBridge.xcodeproj"> | ||
| </BuildableReference> | ||
| </MacroExpansion> | ||
| </ProfileAction> | ||
| <AnalyzeAction | ||
| buildConfiguration = "Debug"> | ||
| </AnalyzeAction> | ||
| <ArchiveAction | ||
| buildConfiguration = "Release" | ||
| revealArchiveInOrganizer = "YES"> | ||
| </ArchiveAction> | ||
| </Scheme> |
This file contains hidden or 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 hidden or 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 @@ | ||
| // | ||
| // AppDelegate.h | ||
| // WebViewJavascriptBridgeTestHost | ||
| // | ||
| // Created by Pieter De Baets on 18/04/2015. | ||
| // Copyright (c) 2015 marcuswestin. All rights reserved. | ||
| // | ||
|
|
||
| #import <UIKit/UIKit.h> | ||
|
|
||
| @interface AppDelegate : UIResponder <UIApplicationDelegate> | ||
|
|
||
| @property (strong, nonatomic) UIWindow *window; | ||
|
|
||
| @end | ||
|
|
This file contains hidden or 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,43 @@ | ||
| // | ||
| // AppDelegate.m | ||
| // WebViewJavascriptBridgeTestHost | ||
| // | ||
| // Created by Pieter De Baets on 18/04/2015. | ||
| // Copyright (c) 2015 marcuswestin. All rights reserved. | ||
| // | ||
|
|
||
| #import "AppDelegate.h" | ||
|
|
||
| @implementation AppDelegate | ||
|
|
||
| - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { | ||
| self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; | ||
| self.window.rootViewController = [UIViewController new]; | ||
| [self.window makeKeyAndVisible]; | ||
|
|
||
| return YES; | ||
| } | ||
|
|
||
| - (void)applicationWillResignActive:(UIApplication *)application { | ||
| // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. | ||
| // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. | ||
| } | ||
|
|
||
| - (void)applicationDidEnterBackground:(UIApplication *)application { | ||
| // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. | ||
| // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. | ||
| } | ||
|
|
||
| - (void)applicationWillEnterForeground:(UIApplication *)application { | ||
| // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. | ||
| } | ||
|
|
||
| - (void)applicationDidBecomeActive:(UIApplication *)application { | ||
| // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. | ||
| } | ||
|
|
||
| - (void)applicationWillTerminate:(UIApplication *)application { | ||
| // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. | ||
| } | ||
|
|
||
| @end |
This file contains hidden or 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,34 @@ | ||
| <?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>CFBundleExecutable</key> | ||
| <string>$(EXECUTABLE_NAME)</string> | ||
| <key>CFBundleIdentifier</key> | ||
| <string>in.marcuswestin.$(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</string> | ||
| <key>LSRequiresIPhoneOS</key> | ||
| <true/> | ||
| <key>UIRequiredDeviceCapabilities</key> | ||
| <array> | ||
| <string>armv7</string> | ||
| </array> | ||
| <key>UISupportedInterfaceOrientations</key> | ||
| <array> | ||
| <string>UIInterfaceOrientationPortrait</string> | ||
| </array> | ||
| </dict> | ||
| </plist> |
This file contains hidden or 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 @@ | ||
| // | ||
| // main.m | ||
| // WebViewJavascriptBridgeTestHost | ||
| // | ||
| // Created by Pieter De Baets on 18/04/2015. | ||
| // Copyright (c) 2015 marcuswestin. All rights reserved. | ||
| // | ||
|
|
||
| #import <UIKit/UIKit.h> | ||
| #import "AppDelegate.h" | ||
|
|
||
| int main(int argc, char * argv[]) { | ||
| @autoreleasepool { | ||
| return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); | ||
| } | ||
| } |
This file contains hidden or 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,108 @@ | ||
| // | ||
| // BridgeTests.m | ||
| // WebViewJavascriptBridge | ||
| // | ||
| // Created by Pieter De Baets on 18/04/2015. | ||
| // Copyright (c) 2015 marcuswestin. All rights reserved. | ||
| // | ||
|
|
||
| #import <XCTest/XCTest.h> | ||
|
|
||
| #import "WebViewJavascriptBridge.h" | ||
| #import "AppDelegate.h" | ||
|
|
||
| static NSString *const echoHandler = @"echoHandler"; | ||
| static const WVJBHandler nullHandler = ^(id data, WVJBResponseCallback callback) {}; | ||
|
|
||
| @interface BridgeTests : XCTestCase | ||
|
|
||
| @end | ||
|
|
||
| @implementation BridgeTests { | ||
| UIWebView *_webView; | ||
| } | ||
|
|
||
| - (void)setUp | ||
| { | ||
| [super setUp]; | ||
|
|
||
| UIViewController *rootVC = [[(AppDelegate *)[[UIApplication sharedApplication] delegate] window] rootViewController]; | ||
| _webView = [[UIWebView alloc] initWithFrame:rootVC.view.bounds]; | ||
| [rootVC.view addSubview:_webView]; | ||
| } | ||
|
|
||
| - (void)tearDown | ||
| { | ||
| [super tearDown]; | ||
| [_webView removeFromSuperview]; | ||
| } | ||
|
|
||
| static void loadEchoSample(UIWebView *webView) | ||
| { | ||
| NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"echo" withExtension:@"html"]]; | ||
| [webView loadRequest:request]; | ||
| } | ||
|
|
||
| - (void)testInitialization | ||
| { | ||
| XCTestExpectation *startup = [self expectationWithDescription:@"Startup completed"]; | ||
| WebViewJavascriptBridge *bridge = [WebViewJavascriptBridge bridgeForWebView:_webView handler:^(id data, WVJBResponseCallback responseCallback) { | ||
| XCTAssertEqualObjects(data, @"Hello world"); | ||
| [startup fulfill]; | ||
| }]; | ||
| XCTAssertNotNil(bridge); | ||
|
|
||
| loadEchoSample(_webView); | ||
| [self waitForExpectationsWithTimeout:10 handler:NULL]; | ||
| } | ||
|
|
||
| - (void)testResponseHandler | ||
| { | ||
| WebViewJavascriptBridge *bridge = [WebViewJavascriptBridge bridgeForWebView:_webView handler:nullHandler]; | ||
|
|
||
| XCTestExpectation *callbackInvoked = [self expectationWithDescription:@"Callback invoked"]; | ||
| [bridge send:@"testResponseHandler" responseCallback:^(id responseData) { | ||
| XCTAssertEqualObjects(responseData, @"testResponseHandler"); | ||
| [callbackInvoked fulfill]; | ||
| }]; | ||
|
|
||
| loadEchoSample(_webView); | ||
| [self waitForExpectationsWithTimeout:10 handler:NULL]; | ||
| } | ||
|
|
||
| - (void)testEchoHandler | ||
| { | ||
| WebViewJavascriptBridge *bridge = [WebViewJavascriptBridge bridgeForWebView:_webView handler:nullHandler]; | ||
|
|
||
| XCTestExpectation *callbackInvocked = [self expectationWithDescription:@"Callback invoked"]; | ||
| [bridge callHandler:echoHandler data:@"testEchoHandler" responseCallback:^(id responseData) { | ||
| XCTAssertEqualObjects(responseData, @"testEchoHandler"); | ||
| [callbackInvocked fulfill]; | ||
| }]; | ||
|
|
||
| loadEchoSample(_webView); | ||
| [self waitForExpectationsWithTimeout:10 handler:NULL]; | ||
| } | ||
|
|
||
| - (void)testObjectEncoding | ||
| { | ||
| WebViewJavascriptBridge *bridge = [WebViewJavascriptBridge bridgeForWebView:_webView handler:nullHandler]; | ||
|
|
||
| void (^echoObject)(id) = ^void(id object) { | ||
| XCTestExpectation *callbackInvocked = [self expectationWithDescription:@"Callback invoked"]; | ||
| [bridge callHandler:echoHandler data:object responseCallback:^(id responseData) { | ||
| XCTAssertEqualObjects(responseData, object); | ||
| [callbackInvocked fulfill]; | ||
| }]; | ||
| }; | ||
|
|
||
| echoObject(@"A string sent over the wire"); | ||
| echoObject(@"A string with '\"'/\\"); | ||
| echoObject(@[ @1, @2, @3 ]); | ||
| echoObject(@{ @"a" : @1, @"b" : @2 }); | ||
|
|
||
| loadEchoSample(_webView); | ||
| [self waitForExpectationsWithTimeout:10 handler:NULL]; | ||
| } | ||
|
|
||
| @end |
This file contains hidden or 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,24 @@ | ||
| <?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>CFBundleExecutable</key> | ||
| <string>$(EXECUTABLE_NAME)</string> | ||
| <key>CFBundleIdentifier</key> | ||
| <string>in.marcuswestin.WebViewJavascriptBridge.$(PRODUCT_NAME:rfc1034identifier)</string> | ||
| <key>CFBundleInfoDictionaryVersion</key> | ||
| <string>6.0</string> | ||
| <key>CFBundleName</key> | ||
| <string>$(PRODUCT_NAME)</string> | ||
| <key>CFBundlePackageType</key> | ||
| <string>BNDL</string> | ||
| <key>CFBundleShortVersionString</key> | ||
| <string>1.0</string> | ||
| <key>CFBundleSignature</key> | ||
| <string>????</string> | ||
| <key>CFBundleVersion</key> | ||
| <string>1</string> | ||
| </dict> | ||
| </plist> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would remove this check. In an app that I'm writing, we've pulled the js file from our application bundle and are loading it on our server. This would result in runtime errors in my application while debugging/developing locally.