Repository: cordova-osx
Updated Branches:
  refs/heads/master aa1384542 -> 15081af1e


CB-9918 CDVInvokedUrlCommand.argumentAtIndex returns WebUndefined instead of nil


Project: http://git-wip-us.apache.org/repos/asf/cordova-osx/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-osx/commit/4c4bd0f8
Tree: http://git-wip-us.apache.org/repos/asf/cordova-osx/tree/4c4bd0f8
Diff: http://git-wip-us.apache.org/repos/asf/cordova-osx/diff/4c4bd0f8

Branch: refs/heads/master
Commit: 4c4bd0f8a52e5f2f2a3b9cfb8efb431ef82ff16f
Parents: aa13845
Author: Tobias Bocanegra <[email protected]>
Authored: Fri Jun 24 22:13:51 2016 -0700
Committer: Tobias Bocanegra <[email protected]>
Committed: Fri Jun 24 22:13:51 2016 -0700

----------------------------------------------------------------------
 .../Classes/Commands/CDVInvokedUrlCommand.m     |  3 +-
 .../CordovaLibTests/CDVInvokedUrlCommandTests.m | 53 ++++++++++++++++++++
 .../CordovaLibTests.xcodeproj/project.pbxproj   |  4 ++
 3 files changed, 59 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/4c4bd0f8/CordovaLib/CordovaLib/Classes/Commands/CDVInvokedUrlCommand.m
----------------------------------------------------------------------
diff --git a/CordovaLib/CordovaLib/Classes/Commands/CDVInvokedUrlCommand.m 
b/CordovaLib/CordovaLib/Classes/Commands/CDVInvokedUrlCommand.m
index 6210abb..c92964a 100644
--- a/CordovaLib/CordovaLib/Classes/Commands/CDVInvokedUrlCommand.m
+++ b/CordovaLib/CordovaLib/Classes/Commands/CDVInvokedUrlCommand.m
@@ -17,6 +17,7 @@
  under the License.
  */
 
+#import <WebKit/WebKit.h>
 #import "CDVInvokedUrlCommand.h"
 
 @implementation CDVInvokedUrlCommand
@@ -96,7 +97,7 @@
         return defaultValue;
     }
     id ret = _arguments[index];
-    if (ret == [NSNull null]) {
+    if (ret == [NSNull null] || ret == [WebUndefined undefined]) {
         ret = defaultValue;
     }
     if ((aClass != nil) && ![ret isKindOfClass:aClass]) {

http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/4c4bd0f8/tests/CordovaLibTests/CDVInvokedUrlCommandTests.m
----------------------------------------------------------------------
diff --git a/tests/CordovaLibTests/CDVInvokedUrlCommandTests.m 
b/tests/CordovaLibTests/CDVInvokedUrlCommandTests.m
new file mode 100644
index 0000000..efa9260
--- /dev/null
+++ b/tests/CordovaLibTests/CDVInvokedUrlCommandTests.m
@@ -0,0 +1,53 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+
+#import <XCTest/XCTest.h>
+#import <WebKit/WebKit.h>
+
+#import <Cordova/CDVInvokedUrlCommand.h>
+
+@interface CDVInvokedUrlCommandTests : XCTestCase
+@end
+
+@implementation CDVInvokedUrlCommandTests
+
+- (void) testInitWithNoArgs {
+    NSArray* jsonArr = @[@"callbackId", @"className", @"methodName", [NSArray 
array]];
+    CDVInvokedUrlCommand* command = [CDVInvokedUrlCommand 
commandFromJson:jsonArr];
+
+    XCTAssertEqual(@"callbackId", command.callbackId);
+    XCTAssertEqual(@"className", command.cmdClassName);
+    XCTAssertEqual(@"methodName", command.methodName);
+    XCTAssertEqual([NSArray array], command.arguments);
+}
+
+- (void) testArgumentAtIndex {
+    NSArray* arguments = @[[NSNull null], [WebUndefined undefined]];
+    NSArray* jsonArr = @[[NSNull null], @"className", @"methodName", 
arguments];
+    CDVInvokedUrlCommand* command = [CDVInvokedUrlCommand 
commandFromJson:jsonArr];
+
+    XCTAssertNil([command argumentAtIndex:0], @"NSNull to nil");
+    XCTAssertNil([command argumentAtIndex:1], @"WebUndefined to nil");
+    XCTAssertNil([command argumentAtIndex:100], @"Invalid index to nil");
+    XCTAssertEqual(@"default", [command argumentAtIndex:0 
withDefault:@"default"], @"NSNull to default");
+    XCTAssertEqual(@"default", [command argumentAtIndex:1 
withDefault:@"default"], @"WebUndefined to default");
+    XCTAssertEqual(@"default", [command argumentAtIndex:100 
withDefault:@"default"], @"Invalid index to default");
+}
+
+@end

http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/4c4bd0f8/tests/CordovaLibTests/CordovaLibTests.xcodeproj/project.pbxproj
----------------------------------------------------------------------
diff --git a/tests/CordovaLibTests/CordovaLibTests.xcodeproj/project.pbxproj 
b/tests/CordovaLibTests/CordovaLibTests.xcodeproj/project.pbxproj
index 1e62650..259f75d 100644
--- a/tests/CordovaLibTests/CordovaLibTests.xcodeproj/project.pbxproj
+++ b/tests/CordovaLibTests/CordovaLibTests.xcodeproj/project.pbxproj
@@ -22,6 +22,7 @@
                70DAA9221908E80C00AF3749 /* www in Resources */ = {isa = 
PBXBuildFile; fileRef = 70DAA9201908E80C00AF3749 /* www */; };
                70DAA9231908E80C00AF3749 /* config.xml in Resources */ = {isa = 
PBXBuildFile; fileRef = 70DAA9211908E80C00AF3749 /* config.xml */; };
                70DAA9251908E82600AF3749 /* WebKit.framework in Frameworks */ = 
{isa = PBXBuildFile; fileRef = 70DAA9241908E82600AF3749 /* WebKit.framework */; 
};
+               70E770111D1DDE41009EE98C /* CDVInvokedUrlCommandTests.m in 
Sources */ = {isa = PBXBuildFile; fileRef = CC6A0F936C0B9238F1E8FD60 /* 
CDVInvokedUrlCommandTests.m */; };
                CC6A0B0363F2D72B476E94F2 /* TestPlugin.m in Sources */ = {isa = 
PBXBuildFile; fileRef = CC6A04A9E370B440AFF78213 /* TestPlugin.m */; };
                CC6A0B56B7165F2929A4F2EF /* CDVPluginsTests.m in Sources */ = 
{isa = PBXBuildFile; fileRef = CC6A07C34FC25839C2500136 /* CDVPluginsTests.m 
*/; };
 /* End PBXBuildFile section */
@@ -74,6 +75,7 @@
                CC6A04A9E370B440AFF78213 /* TestPlugin.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path 
= TestPlugin.m; sourceTree = "<group>"; };
                CC6A07C34FC25839C2500136 /* CDVPluginsTests.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path 
= CDVPluginsTests.m; sourceTree = "<group>"; };
                CC6A0D7BC56F51517A3FADE7 /* TestPlugin.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
TestPlugin.h; sourceTree = "<group>"; };
+               CC6A0F936C0B9238F1E8FD60 /* CDVInvokedUrlCommandTests.m */ = 
{isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = 
sourcecode.c.objc; path = CDVInvokedUrlCommandTests.m; sourceTree = "<group>"; 
};
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
@@ -156,6 +158,7 @@
                                70718D7F190A4201002ADC5F /* CDVBase64Tests.m */,
                                70DAA8E61908E05900AF3749 /* CDVStartPageTests.m 
*/,
                                CC6A07C34FC25839C2500136 /* CDVPluginsTests.m 
*/,
+                               CC6A0F936C0B9238F1E8FD60 /* 
CDVInvokedUrlCommandTests.m */,
                                CC6A0D7BC56F51517A3FADE7 /* TestPlugin.h */,
                                CC6A04A9E370B440AFF78213 /* TestPlugin.m */,
                        );
@@ -343,6 +346,7 @@
                                70718D80190A4201002ADC5F /* CDVBase64Tests.m in 
Sources */,
                                70DAA8E71908E05900AF3749 /* CDVStartPageTests.m 
in Sources */,
                                CC6A0B56B7165F2929A4F2EF /* CDVPluginsTests.m 
in Sources */,
+                               70E770111D1DDE41009EE98C /* 
CDVInvokedUrlCommandTests.m in Sources */,
                                CC6A0B0363F2D72B476E94F2 /* TestPlugin.m in 
Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to