Title: [92513] trunk
Revision
92513
Author
[email protected]
Date
2011-08-05 14:07:50 -0700 (Fri, 05 Aug 2011)

Log Message

Future proof an Objective-C test
https://bugs.webkit.org/show_bug.cgi?id=65788

Tools: 

Reviewed by Dan Bernstein.

Add isObjectInstanceOf to ObjCController.

* DumpRenderTree/mac/ObjCController.m:
(+[ObjCController isSelectorExcludedFromWebScript:]):
(+[ObjCController webScriptNameForSelector:]):
(-[ObjCController isObject:instanceOf:]):

LayoutTests: 

Don't check explicitly for class names; just check that the objects are instances of the right classes.

* platform/mac/fast/dom/wrapper-classes-objc-expected.txt:
* platform/mac/fast/dom/wrapper-classes-objc.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (92512 => 92513)


--- trunk/LayoutTests/ChangeLog	2011-08-05 21:00:39 UTC (rev 92512)
+++ trunk/LayoutTests/ChangeLog	2011-08-05 21:07:50 UTC (rev 92513)
@@ -1,5 +1,15 @@
 2011-08-05  Anders Carlsson  <[email protected]>
 
+        Future proof an Objective-C test
+        https://bugs.webkit.org/show_bug.cgi?id=65788
+
+        Don't check explicitly for class names; just check that the objects are instances of the right classes.
+
+        * platform/mac/fast/dom/wrapper-classes-objc-expected.txt:
+        * platform/mac/fast/dom/wrapper-classes-objc.html:
+
+2011-08-05  Anders Carlsson  <[email protected]>
+
         Add a Lion specific test for fast/repaint/canvas-putImageData.html
 
         * platform/mac-snowleopard/fast/repaint: Added.

Modified: trunk/LayoutTests/platform/mac/fast/dom/wrapper-classes-objc-expected.txt (92512 => 92513)


--- trunk/LayoutTests/platform/mac/fast/dom/wrapper-classes-objc-expected.txt	2011-08-05 21:00:39 UTC (rev 92512)
+++ trunk/LayoutTests/platform/mac/fast/dom/wrapper-classes-objc-expected.txt	2011-08-05 21:07:50 UTC (rev 92513)
@@ -175,15 +175,15 @@
 
 _javascript_ types
 
-PASS objCWrapperClass(null) is 'nil'
-PASS objCWrapperClass(undefined) is 'WebUndefined'
-PASS objCWrapperClass(0) is 'NSCFNumber'
-PASS objCWrapperClass(1) is 'NSCFNumber'
-PASS objCWrapperClass(false) is 'NSCFBoolean'
-PASS objCWrapperClass(true) is 'NSCFBoolean'
-PASS objCWrapperClass('') is 'NSCFString'
-PASS objCWrapperClass({ }) is 'WebScriptObject'
-PASS objCWrapperClass([ ]) is 'WebScriptObject'
+PASS objCWrapperIsInstanceOf(null, 'nil') is true
+PASS objCWrapperIsInstanceOf(undefined, 'WebUndefined') is true
+PASS objCWrapperIsInstanceOf(0, 'NSNumber') is true
+PASS objCWrapperIsInstanceOf(1, 'NSNumber') is true
+PASS objCWrapperIsInstanceOf(false, 'NSNumber') is true
+PASS objCWrapperIsInstanceOf(true, 'NSNumber') is true
+PASS objCWrapperIsInstanceOf('', 'NSString') is true
+PASS objCWrapperIsInstanceOf({ }, 'WebScriptObject') is true
+PASS objCWrapperIsInstanceOf([ ], 'WebScriptObject') is true
 PASS objCObjectOfClass('NSNull') is null
 PASS typeof objCObjectOfClass('') is 'undefined'
 PASS typeof objCObjectOfClass('WebUndefined') is 'undefined'

Modified: trunk/LayoutTests/platform/mac/fast/dom/wrapper-classes-objc.html (92512 => 92513)


--- trunk/LayoutTests/platform/mac/fast/dom/wrapper-classes-objc.html	2011-08-05 21:00:39 UTC (rev 92512)
+++ trunk/LayoutTests/platform/mac/fast/dom/wrapper-classes-objc.html	2011-08-05 21:07:50 UTC (rev 92513)
@@ -17,6 +17,13 @@
 if (window.layoutTestController)
     layoutTestController.waitUntilDone();
 
+function objCWrapperIsInstanceOf(node, className)
+{
+    if (!window.objCController)
+        return "only works under DumpRenderTree";
+    return !!objCController.isObjectInstanceOf(node, className);
+}
+
 function objCWrapperClass(node)
 {
     if (!window.objCController)
@@ -265,15 +272,15 @@
     debug('_javascript_ types');
     debug('');
 
-    shouldBe("objCWrapperClass(null)", "'nil'");
-    shouldBe("objCWrapperClass(undefined)", "'WebUndefined'");
-    shouldBe("objCWrapperClass(0)", "'NSCFNumber'");
-    shouldBe("objCWrapperClass(1)", "'NSCFNumber'");
-    shouldBe("objCWrapperClass(false)", "'NSCFBoolean'");
-    shouldBe("objCWrapperClass(true)", "'NSCFBoolean'");
-    shouldBe("objCWrapperClass('')", "'NSCFString'");
-    shouldBe("objCWrapperClass({ })", "'WebScriptObject'");
-    shouldBe("objCWrapperClass([ ])", "'WebScriptObject'");
+    shouldBeTrue("objCWrapperIsInstanceOf(null, 'nil')");
+    shouldBeTrue("objCWrapperIsInstanceOf(undefined, 'WebUndefined')");
+    shouldBeTrue("objCWrapperIsInstanceOf(0, 'NSNumber')");
+    shouldBeTrue("objCWrapperIsInstanceOf(1, 'NSNumber')");
+    shouldBeTrue("objCWrapperIsInstanceOf(false, 'NSNumber')");
+    shouldBeTrue("objCWrapperIsInstanceOf(true, 'NSNumber')");
+    shouldBeTrue("objCWrapperIsInstanceOf('', 'NSString')");
+    shouldBeTrue("objCWrapperIsInstanceOf({ }, 'WebScriptObject')");
+    shouldBeTrue("objCWrapperIsInstanceOf([ ], 'WebScriptObject')");
 
     shouldBe("objCObjectOfClass('NSNull')", "null"); // can't test with typeof because typeof null is 'object'
     shouldBe("typeof objCObjectOfClass('')", "'undefined'");

Modified: trunk/Tools/ChangeLog (92512 => 92513)


--- trunk/Tools/ChangeLog	2011-08-05 21:00:39 UTC (rev 92512)
+++ trunk/Tools/ChangeLog	2011-08-05 21:07:50 UTC (rev 92513)
@@ -1,3 +1,17 @@
+2011-08-05  Anders Carlsson  <[email protected]>
+
+        Future proof an Objective-C test
+        https://bugs.webkit.org/show_bug.cgi?id=65788
+
+        Reviewed by Dan Bernstein.
+
+        Add isObjectInstanceOf to ObjCController.
+
+        * DumpRenderTree/mac/ObjCController.m:
+        (+[ObjCController isSelectorExcludedFromWebScript:]):
+        (+[ObjCController webScriptNameForSelector:]):
+        (-[ObjCController isObject:instanceOf:]):
+
 2011-08-05  Adam Barth  <[email protected]>
 
         trac.js needs unittests

Modified: trunk/Tools/DumpRenderTree/mac/ObjCController.m (92512 => 92513)


--- trunk/Tools/DumpRenderTree/mac/ObjCController.m	2011-08-05 21:00:39 UTC (rev 92512)
+++ trunk/Tools/DumpRenderTree/mac/ObjCController.m	2011-08-05 21:07:50 UTC (rev 92513)
@@ -66,6 +66,7 @@
 {
     if (0
             || aSelector == @selector(classNameOf:)
+            || aSelector == @selector(isObject:instanceOf:)
             || aSelector == @selector(objectOfClass:)
             || aSelector == @selector(arrayOfString)
             || aSelector == @selector(identityIsEqual::)
@@ -87,6 +88,8 @@
 {
     if (aSelector == @selector(classNameOf:))
         return @"className";
+    if (aSelector == @selector(isObject:instanceOf:))
+        return @"isObjectInstanceOf";
     if (aSelector == @selector(objectOfClass:))
         return @"objectOfClass";
     if (aSelector == @selector(arrayOfString))
@@ -113,6 +116,14 @@
     return nil;
 }
 
+- (BOOL)isObject:(id)object instanceOf:(NSString *)aClass
+{
+    if (!object)
+        return [aClass isEqualToString:@"nil"];
+
+    return [object isKindOfClass:NSClassFromString(aClass)];
+}
+            
 - (NSString *)classNameOf:(id)object
 {
     if (!object)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to