[prev in list] [next in list] [prev in thread] [next in thread] 

List:       selenium-commits
Subject:    [Selenium-commits] [608] trunk/code/javascript: Generating assert,
From:       dkemp () codehaus ! org
Date:       2005-08-07 7:57:11
Message-ID: 20050807075711.18094.qmail () codehaus ! org
[Download RAW message or body]

[Attachment #2 (text/html)]

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><style type="text/css"><!--
body {background:#ffffff;font-family:Verdana,Helvetica,Arial,sans-serif;}
h3 {margin:15px 0;padding:0;line-height:0;}
#msg {margin: 0 0 2em 0;}
#msg dl, #msg ul, #msg pre {padding:1em;border:1px dashed black;margin: 10px 0 30px \
0;} #msg dl {background:#ccccff;}
#msg pre {background:#ffffcc;}
#msg ul {background:#cc99ff;list-style:none;}
#msg dt {font-weight:bold;float:left;width: 6em;}
#msg dt:after { content:':';}
#patch h4 {padding: 0 \
10px;line-height:1.5em;margin:0;background:#ccffff;border-bottom:1px solid \
black;margin:0 0 10px 0;} #patch .propset h4, #patch .binary h4 {margin: 0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {background:#eeeeee;padding: 0 0 10px 0;}
#patch .propset .diff, #patch .binary .diff  {padding: 10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary \
{border:1px solid black;margin:10px 0;} #patch .add {background:#ddffdd;}
#patch .rem {background:#ffdddd;}
#patch .lines, .info {color:#888888;background:#ffffff;}
--></style>
<title>[608] trunk/code/javascript: Generating assert, assertNot, verify, and \
verifyNot from getters.</title> </head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd>608</dd>
<dt>Author</dt> <dd>dkemp</dd>
<dt>Date</dt> <dd>2005-08-07 03:57:10 -0400 (Sun, 07 Aug 2005)</dd>
</dl>

<h3>Log Message</h3>
<pre>Generating assert, assertNot, verify, and verifyNot from getters.  Replaced \
assertValue with getValue.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkcodejavascripthtmlutilsjs">trunk/code/javascript/htmlutils.js</a></li>
 <li><a href="#trunkcodejavascriptseleniumapijs">trunk/code/javascript/selenium-api.js</a></li>
 <li><a href="#trunkcodejavascriptseleniumcommandhandlersjs">trunk/code/javascript/selenium-commandhandlers.js</a></li>
 <li><a href="#trunkcodejavascripttestsTestFailingAsserthtml">trunk/code/javascript/tests/TestFailingAssert.html</a></li>
 <li><a href="#trunkcodejavascripttestsTestFailingVerificationshtml">trunk/code/javascript/tests/TestFailingVerifications.html</a></li>
 <li><a href="#trunkcodejavascripttestsTestVerificationshtml">trunk/code/javascript/tests/TestVerifications.html</a></li>
 <li><a href="#trunkcodejavascripttestsbrowserbotcommandfactorytestshtml">trunk/code/javascript/tests/browserbot/command-factory-tests.html</a></li>
 <li><a href="#trunkcodejavascripttestsbrowserbotseleniumapitestshtml">trunk/code/javascript/tests/browserbot/selenium-api-tests.html</a></li>
 </ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkcodejavascripthtmlutilsjs"></a>
<div class="modfile"><h4>Modified: trunk/code/javascript/htmlutils.js (607 => \
608)</h4> <pre class="diff">
<span class="info">--- trunk/code/javascript/htmlutils.js	2005-07-30 07:17:49 UTC \
                (rev 607)
+++ trunk/code/javascript/htmlutils.js	2005-08-07 07:57:10 UTC (rev 608)
</span><span class="lines">@@ -209,3 +209,78 @@
</span><span class="cx">     return &quot;^&quot; + re + &quot;$&quot;;
 };
 
</span><span class="add">+var Assert = {
+
+    fail: function(message) {
+        throw new AssertionFailedError(message);
+    },
+
+    /*
+     * Assert.equals(comment?, expected, actual)
+     */
+    equals: function() {
+        if (arguments.length == 2) {
+            var comment = &quot;&quot;;
+            var expected = arguments[0];
+            var actual = arguments[1];
+        } else {
+            var comment = arguments[0] + &quot; &quot;;
+            var expected = arguments[1];
+            var actual = arguments[2];
+        }
+        if (expected === actual) {
+            return;
+        }
+        Assert.fail(comment + 
+                    &quot;Expected '&quot; + expected + 
+                    &quot;' but was '&quot; + actual + &quot;'&quot;);
+    },
+
+    /*
+     * Assert.matches(comment?, pattern, actual)
+     */
+    matches: function() {
+        if (arguments.length == 2) {
+            var comment = &quot;&quot;;
+            var pattern = arguments[0];
+            var actual = arguments[1];
+        } else {
+            var comment = arguments[0] + &quot;; &quot;;
+            var pattern = arguments[1];
+            var actual = arguments[2];
+        }
+        if (PatternMatcher.matches(pattern, actual)) {
+            return;
+        }
+        Assert.fail(comment + 
+                    &quot;Actual value '&quot; + actual + 
+                    &quot;' did not match '&quot; + pattern + &quot;'&quot;);
+    },
+    
+    /*
+     * Assert.notMtches(comment?, pattern, actual)
+     */
+    notMatches: function() {
+        if (arguments.length == 2) {
+            var comment = &quot;&quot;;
+            var pattern = arguments[0];
+            var actual = arguments[1];
+        } else {
+            var comment = arguments[0] + &quot;; &quot;;
+            var pattern = arguments[1];
+            var actual = arguments[2];
+        }
+        if (!PatternMatcher.matches(pattern, actual)) {
+            return;
+        }
+        Assert.fail(comment + 
+                    &quot;Actual value '&quot; + actual + 
+                    &quot;' did match '&quot; + pattern + &quot;'&quot;);
+    }
+    
+};
+
+function AssertionFailedError(message) {
+    this.isAssertionFailedError = true;
+    this.failureMessage = message;
+}
</span></pre></div>
<a id="trunkcodejavascriptseleniumapijs"></a>
<div class="modfile"><h4>Modified: trunk/code/javascript/selenium-api.js (607 => \
608)</h4> <pre class="diff">
<span class="info">--- trunk/code/javascript/selenium-api.js	2005-07-30 07:17:49 UTC \
                (rev 607)
+++ trunk/code/javascript/selenium-api.js	2005-08-07 07:57:10 UTC (rev 608)
</span><span class="lines">@@ -182,14 +182,15 @@
</span><span class="cx">     Assert.matches(expectedTitle, this.page().title());
 };
 
</span><span class="add">+
</span><span class="cx"> /*
</span><span class="rem">- * Verify the value of a form element.
</span><span class="add">+ * Get the (trimmed) value of a form element.
+ * This is used to generate assertValue, verifyValue, ...
</span><span class="cx">  */
</span><span class="rem">-Selenium.prototype.assertValue = function(locator, \
                expectedValue) {
-    var element = this.page().findElement(locator);
-    var actualValue = getInputValue(element);
-    Assert.matches(expectedValue, actualValue.trim());
-};
</span><span class="add">+Selenium.prototype.getValue = function(locator) {
+	var element = this.page().findElement(locator)
+	return getInputValue(element).trim();
+}
</span><span class="cx"> 
 /*
  * Verifies that the text of the located element matches the expected content.
</span><span class="lines">@@ -536,62 +537,7 @@
</span><span class="cx">     return stringResult;
 };
 
</span><span class="rem">-var Assert = {
</span><span class="cx"> 
</span><span class="rem">-    fail: function(message) {
-        throw new AssertionFailedError(message);
-    },
-
-    /*
-     * Assert.equals(comment?, expected, actual)
-     */
-    equals: function() {
-        if (arguments.length == 2) {
-            var comment = &quot;&quot;;
-            var expected = arguments[0];
-            var actual = arguments[1];
-        } else {
-            var comment = arguments[0] + &quot; &quot;;
-            var expected = arguments[1];
-            var actual = arguments[2];
-        }
-        if (expected === actual) {
-            return;
-        }
-        Assert.fail(comment + 
-                    &quot;Expected '&quot; + expected + 
-                    &quot;' but was '&quot; + actual + &quot;'&quot;);
-    },
-
-    /*
-     * Assert.matches(comment?, pattern, actual)
-     */
-    matches: function() {
-        if (arguments.length == 2) {
-            var comment = &quot;&quot;;
-            var pattern = arguments[0];
-            var actual = arguments[1];
-        } else {
-            var comment = arguments[0] + &quot;; &quot;;
-            var pattern = arguments[1];
-            var actual = arguments[2];
-        }
-        if (PatternMatcher.matches(pattern, actual)) {
-            return;
-        }
-        Assert.fail(comment + 
-                    &quot;Actual value '&quot; + actual + 
-                    &quot;' did not match '&quot; + pattern + &quot;'&quot;);
-    }
-    
-};
-
-function AssertionFailedError(message) {
-    this.isAssertionFailedError = true;
-    this.failureMessage = message;
-}
-
-
</span><span class="cx"> /**
  *  Factory for creating &quot;Option Locators&quot;.
  *  An OptionLocator is an object for dealing with Select options (e.g. for
</span></pre></div>
<a id="trunkcodejavascriptseleniumcommandhandlersjs"></a>
<div class="modfile"><h4>Modified: trunk/code/javascript/selenium-commandhandlers.js \
(607 => 608)</h4> <pre class="diff">
<span class="info">--- trunk/code/javascript/selenium-commandhandlers.js	2005-07-30 \
                07:17:49 UTC (rev 607)
+++ trunk/code/javascript/selenium-commandhandlers.js	2005-08-07 07:57:10 UTC (rev \
608) </span><span class="lines">@@ -35,7 +35,17 @@
</span><span class="cx">         var handler = new AssertHandler(assertion, \
haltOnFailure);  this.asserts[name] = handler;
     };
</span><span class="add">+    
+    this.registerAssertUsingAccessor = function(name, accessor, haltOnFailure) {
+    	var handler = new AssertUsingAccessorHandler(accessor, haltOnFailure);
+    	this.asserts[name] = handler;
+    }
</span><span class="cx"> 
</span><span class="add">+    this.registerNegativeAssertUsingAccessor = \
function(name, accessor, haltOnFailure) { +    	var handler = new \
NegativeAssertUsingAccessorHandler(accessor, haltOnFailure); +    	this.asserts[name] \
= handler; +    }
+
</span><span class="cx">     this.getCommandHandler = function(name) {
         return this.actions[name] || this.accessors[name] || this.asserts[name] || \
null;  };
</span><span class="lines">@@ -80,14 +90,27 @@
</span><span class="cx">         }
     };
 
</span><span class="add">+    // Methods of the form getFoo(target) result in \
commands: +    // getFoo, assertFoo, verifyFoo, assertNotFoo, verifyNotFoo
</span><span class="cx">     var registerAllAccessors = function(commandObject) {
         for (var functionName in commandObject) {
</span><span class="rem">-            if (/^get[A-Z].+$/.exec(functionName) != null) \
{ </span><span class="add">+            var match = \
/^get([A-Z].+)$/.exec(functionName); +            if (match != null) {
</span><span class="cx">                 var accessor = commandObject[functionName];
</span><span class="add">+                var baseName = match[1];
</span><span class="cx">                 self.registerAccessor(functionName, \
accessor); </span><span class="add">+                // Register an assert with the \
&quot;assert&quot; prefix, and halt on failure. +                \
self.registerAssertUsingAccessor(&quot;assert&quot; + baseName, accessor, true); +    \
// Register a verify with the &quot;verify&quot; prefix, and do not halt on failure. \
+                self.registerAssertUsingAccessor(&quot;verify&quot; + baseName, \
accessor, false); +                // Register an assertNot with the \
&quot;assertNot&quot; prefix, and halt on failure. +                \
self.registerNegativeAssertUsingAccessor(&quot;assertNot&quot;+baseName, accessor, \
true); +                // Register a verifyNot with the &quot;verifyNot&quot; \
prefix, and do not halt on failure. +                \
self.registerNegativeAssertUsingAccessor(&quot;verifyNot&quot;+baseName, accessor, \
false); </span><span class="cx">             }
         }
     };
</span><span class="add">+    
</span><span class="cx"> }
 
 
</span><span class="lines">@@ -136,14 +159,19 @@
</span><span class="cx">     return result;
 };
 
</span><span class="rem">-function AssertHandler(assertion, haltOnFailure) {
</span><span class="add">+/**
+ * Abstract handler for assertions and verifications.
+ * Subclasses need to override executeAssertion() which in turn
+ * should throw an AssertFailedError if the assertion is to fail. 
+ */
+function AbstractAssertHandler(assertion, haltOnFailure) {
</span><span class="cx">     CommandHandler.call(this, &quot;assert&quot;, \
haltOnFailure || false, assertion);  }
</span><span class="rem">-AssertHandler.prototype = new CommandHandler;
-AssertHandler.prototype.execute = function(seleniumApi, command) {
</span><span class="add">+AbstractAssertHandler.prototype = new CommandHandler;
+AbstractAssertHandler.prototype.execute = function(seleniumApi, command) {
</span><span class="cx">     var result = new CommandResult();
     try {
</span><span class="rem">-        var processState = this.executor.call(seleniumApi, \
command.target, command.value); </span><span class="add">+        \
this.executeAssertion(seleniumApi, command); </span><span class="cx">         \
result.passed = true;  } catch (e) {
         // If this is not a AssertionFailedError, or we should haltOnFailure, \
rethrow. </span><span class="lines">@@ -152,8 +180,6 @@
</span><span class="cx">         }
         if (this.haltOnFailure) {
             var error = new SeleniumCommandError(e.failureMessage);
</span><span class="rem">-            // TODO: Surely this next line is redundant???
-            error.message = e.failureMessage;
</span><span class="cx">             throw error;
         }
         result.failed = true;
</span><span class="lines">@@ -162,6 +188,43 @@
</span><span class="cx">     return result;
 };
 
</span><span class="add">+/**
+ * Simple assertion handler whose command is expected to do the actual assertion.
+ */
+function AssertHandler(assertion, haltOnFailure) {
+    CommandHandler.call(this, &quot;assert&quot;, haltOnFailure || false, \
assertion); +};
+AssertHandler.prototype = new AbstractAssertHandler;
+AssertHandler.prototype.executeAssertion = function(seleniumApi, command) {
+        this.executor.call(seleniumApi, command.target, command.value);
+};
+
+/**
+ * Assertion handler whose command is expected to be an accessor (i.e. getFoo()).
+ * that succeeds if the value returned by the accessor matches the command value. 
+ */
+function AssertUsingAccessorHandler(accessor, haltOnFailure) {
+    CommandHandler.call(this, &quot;assert&quot;, haltOnFailure || false, accessor);
+};
+AssertUsingAccessorHandler.prototype = new AbstractAssertHandler;
+AssertUsingAccessorHandler.prototype.executeAssertion = function(seleniumApi, \
command) { +        var actualValue = this.executor.call(seleniumApi, \
command.target); +        Assert.matches(command.value, actualValue);
+};
+
+/**
+ * Assertion handler whose command is expected to be an accessor (i.e. getFoo()),
+ * that fails if the value returned by the accessor matches the command value.
+ */
+function NegativeAssertUsingAccessorHandler(accessor, haltOnFailure) {
+    CommandHandler.call(this, &quot;assert&quot;, haltOnFailure || false, accessor);
+};
+NegativeAssertUsingAccessorHandler.prototype = new AbstractAssertHandler;
+NegativeAssertUsingAccessorHandler.prototype.executeAssertion = \
function(seleniumApi, command) { +        var actualValue = \
this.executor.call(seleniumApi, command.target); +        \
Assert.notMatches(command.value, actualValue); +};
+
</span><span class="cx"> function CommandResult(processState) {
     this.processState = processState;
     this.result = &quot;OK&quot;;
</span></pre></div>
<a id="trunkcodejavascripttestsTestFailingAsserthtml"></a>
<div class="modfile"><h4>Modified: trunk/code/javascript/tests/TestFailingAssert.html \
(607 => 608)</h4> <pre class="diff">
<span class="info">--- trunk/code/javascript/tests/TestFailingAssert.html	2005-07-30 \
                07:17:49 UTC (rev 607)
+++ trunk/code/javascript/tests/TestFailingAssert.html	2005-08-07 07:57:10 UTC (rev \
608) </span><span class="lines">@@ -43,6 +43,16 @@
</span><span class="cx">       &lt;td&gt;theText&lt;/td&gt;
       &lt;td&gt;not the text value&lt;/td&gt;
     &lt;/tr&gt;
</span><span class="add">+    &lt;tr&gt;
+      &lt;td&gt;assertErrorOnNext&lt;/td&gt;
+      &lt;td&gt;Actual value 'the text value' did match 'the text value'&lt;/td&gt;
+      &lt;td/&gt;
+    &lt;/tr&gt;
+    &lt;tr&gt;
+      &lt;td&gt;assertNotValue&lt;/td&gt;
+      &lt;td&gt;theText&lt;/td&gt;
+      &lt;td&gt;the text value&lt;/td&gt;
+    &lt;/tr&gt;
</span><span class="cx">   &lt;/tbody&gt;
 &lt;/table&gt;
 &lt;/body&gt;
</span></pre></div>
<a id="trunkcodejavascripttestsTestFailingVerificationshtml"></a>
<div class="modfile"><h4>Modified: \
trunk/code/javascript/tests/TestFailingVerifications.html (607 => 608)</h4> <pre \
class="diff"> <span class="info">--- \
trunk/code/javascript/tests/TestFailingVerifications.html	2005-07-30 07:17:49 UTC \
                (rev 607)
+++ trunk/code/javascript/tests/TestFailingVerifications.html	2005-08-07 07:57:10 UTC \
(rev 608) </span><span class="lines">@@ -54,6 +54,16 @@
</span><span class="cx">     &lt;/tr&gt;
     &lt;tr&gt;
       &lt;td&gt;assertFailureOnNext&lt;/td&gt;
</span><span class="add">+      &lt;td&gt;Actual value 'the text value' did match \
'the text value'&lt;/td&gt; +      &lt;td/&gt;
+    &lt;/tr&gt;
+    &lt;tr&gt;
+      &lt;td&gt;verifyNotValue&lt;/td&gt;
+      &lt;td&gt;theText&lt;/td&gt;
+      &lt;td&gt;the text value&lt;/td&gt;
+    &lt;/tr&gt;
+    &lt;tr&gt;
+      &lt;td&gt;assertFailureOnNext&lt;/td&gt;
</span><span class="cx">       &lt;td&gt;Actual value 'the hidden value' did not \
match 'not the hidden value'&lt;/td&gt;  &lt;td/&gt;
     &lt;/tr&gt;
</span></pre></div>
<a id="trunkcodejavascripttestsTestVerificationshtml"></a>
<div class="modfile"><h4>Modified: trunk/code/javascript/tests/TestVerifications.html \
(607 => 608)</h4> <pre class="diff">
<span class="info">--- trunk/code/javascript/tests/TestVerifications.html	2005-07-30 \
                07:17:49 UTC (rev 607)
+++ trunk/code/javascript/tests/TestVerifications.html	2005-08-07 07:57:10 UTC (rev \
608) </span><span class="lines">@@ -50,6 +50,11 @@
</span><span class="cx">       &lt;td&gt;the text value&lt;/td&gt;
     &lt;/tr&gt;
     &lt;tr&gt;
</span><span class="add">+      &lt;td&gt;verifyNotValue&lt;/td&gt;
+      &lt;td&gt;theText&lt;/td&gt;
+      &lt;td&gt;not the text value&lt;/td&gt;
+    &lt;/tr&gt;
+    &lt;tr&gt;
</span><span class="cx">       &lt;td&gt;verifyValue&lt;/td&gt;
       &lt;td&gt;theHidden&lt;/td&gt;
       &lt;td&gt;the hidden value&lt;/td&gt;
</span></pre></div>
<a id="trunkcodejavascripttestsbrowserbotcommandfactorytestshtml"></a>
<div class="modfile"><h4>Modified: \
trunk/code/javascript/tests/browserbot/command-factory-tests.html (607 => 608)</h4> \
<pre class="diff"> <span class="info">--- \
trunk/code/javascript/tests/browserbot/command-factory-tests.html	2005-07-30 07:17:49 \
                UTC (rev 607)
+++ trunk/code/javascript/tests/browserbot/command-factory-tests.html	2005-08-07 \
07:57:10 UTC (rev 608) </span><span class="lines">@@ -65,7 +65,7 @@
</span><span class="cx">         assertEquals(&quot;accessorFunction&quot;, \
myAccessor.executor);  assertEquals(&quot;accessor&quot;, myAccessor.type);
     }
</span><span class="rem">-
</span><span class="add">+    
</span><span class="cx">     function \
                testAllMethodsWithGetPrefixAreRegisteredAsAccessorsByRegisterAll() {
         var actionSet = {getOne: &quot;get1&quot;, getTwo: &quot;get2&quot;, \
getdontGet: &quot;another&quot;};  var factory = new CommandHandlerFactory();
</span><span class="lines">@@ -77,7 +77,77 @@
</span><span class="cx">         assertEquals(&quot;get1&quot;, \
                factory.getCommandHandler(&quot;getOne&quot;).executor);
         assertEquals(&quot;get2&quot;, \
factory.getCommandHandler(&quot;getTwo&quot;).executor);  }
</span><span class="add">+    
+    function testAllMethodsWithGetPrefixAreRegisteredAsAssertsByRegisterAll() {
+        var actionSet = {getOne: function(target) {return target + \
&quot;foo&quot;;}, getTwo: &quot;get2&quot;, getdontGet: &quot;another&quot;}; +      \
var factory = new CommandHandlerFactory(); +        factory.registerAll(actionSet);
</span><span class="cx"> 
</span><span class="add">+        \
assertNull(factory.getCommandHandler(&quot;assertdontGet&quot;)); +        \
assertNull(factory.getCommandHandler(&quot;notEvenClose&quot;)); +
+        var myAssert = factory.getCommandHandler(&quot;assertOne&quot;);
+        assertEquals(CommandHandler, myAssert.constructor);
+        assertNotNull(myAssert.executor);
+        assertEquals(&quot;assert&quot;, myAssert.type);
+        assertTrue(myAssert.haltOnFailure);
+        
+        myAssert.executor(&quot;blah&quot;, &quot;blahfoo&quot;);
+    }
+    
+    function testAllMethodsWithGetPrefixAreRegisteredAsVerifiesByRegisterAll() {
+        var actionSet = {getOne: function(target) {return target + \
&quot;foo&quot;;}, getTwo: &quot;get2&quot;, getdontGet: &quot;another&quot;}; +      \
var factory = new CommandHandlerFactory(); +        factory.registerAll(actionSet);
+
+        var myAssert = factory.getCommandHandler(&quot;verifyOne&quot;);
+        assertEquals(CommandHandler, myAssert.constructor);
+        assertNotNull(myAssert.executor);
+        assertEquals(&quot;assert&quot;, myAssert.type);
+        assertFalse(myAssert.haltOnFailure);
+        
+        myAssert.executor(&quot;blah&quot;, &quot;blahfoo&quot;);
+    }
+    
+    function testAllMethodsWithGetPrefixAreRegisteredAsAssertNotsByRegisterAll() {
+        var actionSet = {getOne: function(target) {return target + \
&quot;foo&quot;;}, getTwo: &quot;get2&quot;, getdontGet: &quot;another&quot;}; +      \
var factory = new CommandHandlerFactory(); +        factory.registerAll(actionSet);
+
+        var myAssert = factory.getCommandHandler(&quot;assertNotOne&quot;);
+        assertEquals(CommandHandler, myAssert.constructor);
+        assertNotNull(myAssert.executor);
+        assertEquals(&quot;assert&quot;, myAssert.type);
+        assertTrue(myAssert.haltOnFailure);
+        try {
+	        myAssert.executor(&quot;blah&quot;, &quot;blahfoo&quot;);
+	        fail(&quot;Should have thrown an exception&quot;);
+	    }
+	    catch (e) {
+	    	// Expected.
+	    }
+    }
+    
+    function testAllMethodsWithGetPrefixAreRegisteredAsVerifyNotsByRegisterAll() {
+        var actionSet = {getOne: function(target) {return target + \
&quot;foo&quot;;}, getTwo: &quot;get2&quot;, getdontGet: &quot;another&quot;}; +      \
var factory = new CommandHandlerFactory(); +        factory.registerAll(actionSet);
+
+        var myAssert = factory.getCommandHandler(&quot;verifyNotOne&quot;);
+        assertEquals(CommandHandler, myAssert.constructor);
+        assertNotNull(myAssert.executor);
+        assertEquals(&quot;assert&quot;, myAssert.type);
+        assertFalse(myAssert.haltOnFailure);
+        try {
+	        myAssert.executor(&quot;blah&quot;, &quot;blahfoo&quot;);
+	        fail(&quot;Should have thrown an exception&quot;);
+	    }
+	    catch (e) {
+	    	// Expected.
+	    }
+    }
+    
+
</span><span class="cx">     function testHaltOnFailureDefaultsToFalseForAsserts() {
         var factory = new CommandHandlerFactory();
         factory.registerAssert(&quot;doHalt&quot;, &quot;assertFunction&quot;, \
true); </span></pre></div>
<a id="trunkcodejavascripttestsbrowserbotseleniumapitestshtml"></a>
<div class="modfile"><h4>Modified: \
trunk/code/javascript/tests/browserbot/selenium-api-tests.html (607 => 608)</h4> <pre \
class="diff"> <span class="info">--- \
trunk/code/javascript/tests/browserbot/selenium-api-tests.html	2005-07-30 07:17:49 \
                UTC (rev 607)
+++ trunk/code/javascript/tests/browserbot/selenium-api-tests.html	2005-08-07 \
07:57:10 UTC (rev 608) </span><span class="lines">@@ -133,49 +133,27 @@
</span><span class="cx">     verifyMocks();
 }
 
</span><span class="rem">-function testVerifyValueOfTextInputSuccess() {
</span><span class="add">+function testGetValueOfText() {
</span><span class="cx">     var mockTextControl = Object();
     mockTextControl.type = &quot;TEXT&quot;;
     mockTextControl.value = &quot;the value&quot;;
     mockPageBot.expects(&quot;findElement&quot;, \
&quot;id&quot;).returns(mockTextControl);  
</span><span class="rem">-    selenium.assertValue(&quot;id&quot;, &quot;the \
value&quot;); </span><span class="add">+    assertEquals(&quot;the value&quot;, \
selenium.getValue(&quot;id&quot;)); </span><span class="cx">     verifyMocks();
 }
 
</span><span class="rem">-function testVerifyValueOfTextInputFailure() {
-    var mockTextControl = Object();
-    mockTextControl.type = &quot;TEXT&quot;;
-    mockTextControl.value = &quot;the value&quot;;
-    mockPageBot.expects(&quot;findElement&quot;, \
                &quot;id&quot;).returns(mockTextControl);
-
-    assertCallFails(&quot;Verify value should have failed&quot;,
-                    function() { selenium.assertValue(&quot;id&quot;, &quot;a \
                different value&quot;); });
-    verifyMocks();
-}
-
-function testVerifyValueOfCheckboxSuccess() {
</span><span class="add">+function testGetValueOfCheckbox() {
</span><span class="cx">     var mockControl = Object();
     mockControl.type = &quot;CHECKBOX&quot;;
     mockControl.value = &quot;the value&quot;;
     mockControl.checked = true;
     mockPageBot.expects(&quot;findElement&quot;, \
&quot;id&quot;).returns(mockControl);  
</span><span class="rem">-    selenium.assertValue(&quot;id&quot;, &quot;on&quot;);
</span><span class="add">+    assertEquals(&quot;on&quot;, \
selenium.getValue(&quot;id&quot;)); </span><span class="cx">     verifyMocks();
 }
 
</span><span class="rem">-function testVerifyValueOfCheckboxFailure() {
-    var mockControl = Object();
-    mockControl.type = &quot;CHECKBOX&quot;;
-    mockControl.value = &quot;the value&quot;;
-    mockControl.checked = false;
-    mockPageBot.expects(&quot;findElement&quot;, \
                &quot;id&quot;).returns(mockControl);
-    assertCallFails(&quot;Verify value should have failed&quot;,
-                    function() {selenium.assertValue(&quot;id&quot;, &quot;the \
                value&quot;);});
-    verifyMocks();
-}
-
</span><span class="cx"> function testVerifyTextSuccess() {
     var mockElement = new Object();
     mockElement.textContent = &quot; foo &quot;;
</span>
</pre>
</div>
</div>

</body>
</html>



_______________________________________________
Selenium-commits mailing list
Selenium-commits@lists.public.thoughtworks.org
http://lists.public.thoughtworks.org/mailman/listinfo/selenium-commits


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic