You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sh...@apache.org on 2014/10/18 00:16:01 UTC
[2/2] ios commit: CB-7813 - Added unit test
CB-7813 - Added unit test
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/d72a48ac
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/d72a48ac
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/d72a48ac
Branch: refs/heads/master
Commit: d72a48acd0b9455ece519419f0cbc538a8af808c
Parents: 5de0f3f
Author: Shazron Abdullah <sh...@apache.org>
Authored: Fri Oct 17 15:15:43 2014 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Fri Oct 17 15:15:43 2014 -0700
----------------------------------------------------------------------
tests/CordovaLibTests/CDVWebViewDelegateTests.m | 35 ++++++++++++++++++++
1 file changed, 35 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/d72a48ac/tests/CordovaLibTests/CDVWebViewDelegateTests.m
----------------------------------------------------------------------
diff --git a/tests/CordovaLibTests/CDVWebViewDelegateTests.m b/tests/CordovaLibTests/CDVWebViewDelegateTests.m
index 7edd189..3413638 100644
--- a/tests/CordovaLibTests/CDVWebViewDelegateTests.m
+++ b/tests/CordovaLibTests/CDVWebViewDelegateTests.m
@@ -21,6 +21,27 @@
#import <Cordova/CDVWebViewDelegate.h>
+@interface CDVWebViewDelegate2 : CDVWebViewDelegate {}
+
+- (void)setState:(NSInteger)state;
+- (NSInteger)state;
+
+@end
+
+@implementation CDVWebViewDelegate2
+
+- (void)setState:(NSInteger)state
+{
+ _state = state;
+}
+
+- (NSInteger)state
+{
+ return _state;
+}
+
+@end
+
@interface CDVWebViewDelegate ()
// expose private interface
@@ -43,6 +64,20 @@
[super tearDown];
}
+- (void)testFailLoadStateCancelled
+{
+ NSInteger initialState = 1; // STATE_WAITING_FOR_LOAD_START;
+ NSInteger expectedState = 5; // STATE_CANCELLED;
+ NSError* errorCancelled = [NSError errorWithDomain:NSCocoaErrorDomain code:NSURLErrorCancelled userInfo:nil];
+
+ CDVWebViewDelegate2* wvd = [[CDVWebViewDelegate2 alloc] initWithDelegate:nil]; // not really testing delegate handling
+
+ wvd.state = initialState;
+ [wvd webView:nil didFailLoadWithError:errorCancelled];
+
+ XCTAssertTrue(wvd.state == expectedState, @"If the load error was through an iframe redirect (NSURLErrorCancelled), the state should be STATE_CANCELLED");
+}
+
- (void)testShouldLoadRequest
{
CDVWebViewDelegate* wvd = [[CDVWebViewDelegate alloc] initWithDelegate:nil]; // not really testing delegate handling
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org