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 2013/01/08 01:10:40 UTC

[1/2] ios commit: Adding bool plugin result message, tests

Adding bool plugin result message, tests


Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/0618b461
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/0618b461
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/0618b461

Branch: refs/heads/master
Commit: 0618b461db60d9e0616160ff9c9b1acbb6e69ba1
Parents: c6a1dbe
Author: Kevin Hawkins <kh...@salesforce.com>
Authored: Sun Oct 21 20:49:01 2012 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Mon Jan 7 16:04:35 2013 -0800

----------------------------------------------------------------------
 CordovaLib/Classes/CDVPluginResult.h               |    1 +
 CordovaLib/Classes/CDVPluginResult.m               |    5 +++++
 .../CDVPluginResultJSONSerializationTests.m        |    9 +++++++++
 3 files changed, 15 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/0618b461/CordovaLib/Classes/CDVPluginResult.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVPluginResult.h b/CordovaLib/Classes/CDVPluginResult.h
index 6dd7d45..061e30d 100644
--- a/CordovaLib/Classes/CDVPluginResult.h
+++ b/CordovaLib/Classes/CDVPluginResult.h
@@ -44,6 +44,7 @@ typedef enum {
 + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsArray:(NSArray*)theMessage;
 + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsInt:(int)theMessage;
 + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsDouble:(double)theMessage;
++ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsBool:(BOOL)theMessage;
 + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsDictionary:(NSDictionary*)theMessage;
 + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageToErrorObject:(int)errorCode;
 

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/0618b461/CordovaLib/Classes/CDVPluginResult.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVPluginResult.m b/CordovaLib/Classes/CDVPluginResult.m
index 5343dce..8939ac9 100644
--- a/CordovaLib/Classes/CDVPluginResult.m
+++ b/CordovaLib/Classes/CDVPluginResult.m
@@ -88,6 +88,11 @@ static NSArray* org_apache_cordova_CommandStatusMsgs;
     return [[self alloc] initWithStatus:statusOrdinal message:[NSNumber numberWithDouble:theMessage]];
 }
 
++ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsBool:(BOOL)theMessage
+{
+    return [[self alloc] initWithStatus:statusOrdinal message:[NSNumber numberWithBool:theMessage]];
+}
+
 + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsDictionary:(NSDictionary*)theMessage
 {
     return [[self alloc] initWithStatus:statusOrdinal message:theMessage];

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/0618b461/CordovaLibTests/CDVPluginResultJSONSerializationTests.m
----------------------------------------------------------------------
diff --git a/CordovaLibTests/CDVPluginResultJSONSerializationTests.m b/CordovaLibTests/CDVPluginResultJSONSerializationTests.m
index f02ff71..c5f1b2b 100644
--- a/CordovaLibTests/CDVPluginResultJSONSerializationTests.m
+++ b/CordovaLibTests/CDVPluginResultJSONSerializationTests.m
@@ -46,6 +46,15 @@
     STAssertTrue([[NSNumber numberWithDouble:5.5] isEqual:message], nil);
 }
 
+- (void)testSerializingMessageAsBool
+{
+    CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:YES];
+    NSDictionary *dic = [[result toJSONString] cdvjk_objectFromJSONString];
+    NSNumber *message = [dic objectForKey:@"message"];
+    
+    STAssertTrue([[NSNumber numberWithBool:YES] isEqual:message], nil);
+}
+
 - (void)testSerializingMessageAsArray
 {
     NSArray* testValues = [NSArray arrayWithObjects: