[kupu-checkins] r34071 - kupu/trunk/kupu/tests

duncan at codespeak.net duncan at codespeak.net
Thu Nov 2 18:54:42 CET 2006


Author: duncan
Date: Thu Nov  2 18:54:36 2006
New Revision: 34071

Modified:
   kupu/trunk/kupu/tests/run_tests.html
   kupu/trunk/kupu/tests/test_kupubasetools.js
   kupu/trunk/kupu/tests/test_kupuhelpers.js
   kupu/trunk/kupu/tests/test_kupuinit.js
   kupu/trunk/kupu/tests/test_plone.js
Log:
Tests now give green bar on Firefox, IE and Opera, but in IE and Opera they warn that some tests have been bypassed (and will indicate failure if any of the bypassed tests pass).


Modified: kupu/trunk/kupu/tests/run_tests.html
==============================================================================
--- kupu/trunk/kupu/tests/run_tests.html	(original)
+++ kupu/trunk/kupu/tests/run_tests.html	Thu Nov  2 18:54:36 2006
@@ -56,7 +56,8 @@
         };
 
         var body = getFromSelector('body');
-        var testsuite = new TestSuite(new HTMLReporter(body, true));
+        var reporter = new HTMLReporter(body, true);
+        var testsuite = new TestSuite(reporter);
         testsuite.registerTest(KupuHelpersTestCase);
         testsuite.registerTest(KupuEditorTestCase);
         testsuite.registerTest(KupuSelectionTestCase);
@@ -72,8 +73,12 @@
 
         iframe.contentWindow.document.designMode = 'off';
         iframe.style.display = 'none';
+        for (var i = 0; i < skipped_tests.length; i++) {
+            reporter.debug("Expected failure on "+skipped_tests[i]);
+        }
     };
 
+    var skipped_tests = [];
     // Mark a specific test as failing under Opera. When Opera is
     // fixed (or the test rewritten to cope with it) the flagged test
     // will then fail.
@@ -82,7 +87,27 @@
         if (navigator.userAgent.toLowerCase().indexOf("opera") == -1) {
             return; // Browser is not opera.
         }
-        self.debug('Invert test '+fname+'for broken browser');
+        //self.debug('Invert test '+fname+'for broken browser');
+        function test() {
+            try {
+                fn.call(self);
+            } catch(e) {
+                // The function threw an exception, which is what we
+                // expect.
+                return
+            };
+            self.assert(false, 'expected test '+fname+' to fail, but it passed!');
+        };
+        self[fname] = test;
+        skipped_tests.push(fname);
+    }
+    // To demonstrate fairness, mark a specific test as failing under IE.
+    function ie_is_broken(self, fname) {
+        var fn = self[fname];
+        if (!_SARISSA_IS_IE) {
+            return; // Browser is not opera.
+        }
+        //self.debug('Invert test '+fname+'for broken browser');
         function test() {
             try {
                 fn.call(self);
@@ -94,6 +119,7 @@
             self.assert(false, 'expected test '+fname+' to fail, but it passed!');
         };
         self[fname] = test;
+        skipped_tests.push(fname);
     }
 //]]>
 </script>

Modified: kupu/trunk/kupu/tests/test_kupubasetools.js
==============================================================================
--- kupu/trunk/kupu/tests/test_kupubasetools.js	(original)
+++ kupu/trunk/kupu/tests/test_kupubasetools.js	Thu Nov  2 18:54:36 2006
@@ -129,6 +129,7 @@
         this.updateStateTest('<p>foo</p><div class="other">baz</div>',
             1, 7, 'oobaz', 0, "Mixed styles");
     }
+    opera_is_broken(this, 'test_updateState7');
 
     this.test_setTextStyle = function() {
         this.body.innerHTML = '<p>foo</p><p>bar</p><p>baz</p>';
@@ -213,6 +214,7 @@
         this.ui.setTextStyle('td|te st');
         this.assertEquals(this._cleanHtml(this.body.innerHTML), withcellstyle);
     };
+    opera_is_broken(this, 'test_setTextStyle_ParaStyleThenCellStyle_SingleTableCell');
 
     this.test_setTextStyle_TableHeaderThenParaStyle_SingleTableCell = function() {
         //Apply a table header style to a cell, then a paragraph style
@@ -247,32 +249,34 @@
         this.ui.setTextStyle('h1|te st');
         this.assertEquals(this._cleanHtml(this.body.innerHTML), expected);
     };
+    opera_is_broken(this, 'test_setTextStyle_ParaStyle_AdjacentCells');
 
     this.test_setTextStyle_SetCellStyle_Column = function() {
         //Apply a table cell (td) style, *with class*, on a column of cells --
         //only available with Mozilla
         data = '<table><tbody><tr><td>foo</td><td>foz</td></tr><tr><td>bar</td><td>baz</td></tr></tbody></table>'; 
         expected = '<table><tbody><tr><td class="te st">foo</td><td>foz</td></tr><tr><td class="te st">bar</td><td>baz</td></tr></tbody></table>'
-        if (!_SARISSA_IS_IE) {
-            this.body.innerHTML = data; 
-            this._selectTableCells(new Array(0,2),'foo\tbar');
-            this.ui.setTextStyle('td|te st');
-            this.assertEquals(this._cleanHtml(this.body.innerHTML), expected);
-        };                        
+
+        this.body.innerHTML = data; 
+        this._selectTableCells(new Array(0,2),'foo\tbar');
+        this.ui.setTextStyle('td|te st');
+        this.assertEquals(this._cleanHtml(this.body.innerHTML), expected);
     };
-    
+    opera_is_broken(this, 'test_setTextStyle_SetCellStyle_Column');
+    ie_is_broken(this, 'test_setTextStyle_SetCellStyle_Column');
+
     this.test_setTextStyle_ParaStyle_Column = function() {
         //Apply a paragraph style, *with class*, on a column of cells -- only
         //available with Mozilla
         data = '<table><tbody><tr><td>foo</td><td>foz</td></tr><tr><td>bar</td><td>baz</td></tr></tbody></table>';
         expected = '<table><tbody><tr><td><h1 class="te st">foo</h1></td><td>foz</td></tr><tr><td><h1 class="te st">bar</h1></td><td>baz</td></tr></tbody></table>'
-        if (!_SARISSA_IS_IE) {
-            this.body.innerHTML = data;
-            this._selectTableCells(new Array(0,2),'foo\tbar');
-            this.ui.setTextStyle('h1|te st');
-            this.assertEquals(this._cleanHtml(this.body.innerHTML), expected);
-        };                        
+        this.body.innerHTML = data;
+        this._selectTableCells(new Array(0,2),'foo\tbar');
+        this.ui.setTextStyle('h1|te st');
+        this.assertEquals(this._cleanHtml(this.body.innerHTML), expected);
     };
+    opera_is_broken(this, 'test_setTextStyle_ParaStyle_Column');
+    ie_is_broken(this, 'test_setTextStyle_ParaStyle_Column');
 
     this.test_setTextStyleReplacingDiv = function() {
         this.body.innerHTML = '<p>foo</p><div>bar</div><p>baz</p>';

Modified: kupu/trunk/kupu/tests/test_kupuhelpers.js
==============================================================================
--- kupu/trunk/kupu/tests/test_kupuhelpers.js	(original)
+++ kupu/trunk/kupu/tests/test_kupuhelpers.js	Thu Nov  2 18:54:36 2006
@@ -259,6 +259,7 @@
         node = this.doc.getElementsByTagName('img')[0];
         this.assertEquals(this.selection.parentElement(), node);
     };
+    opera_is_broken(this, 'testParentElementImg');
 
     this.testParentElementImgSpecial = function() {
         this.body.innerHTML = '<p>foo <a><img/></a></p>';
@@ -268,6 +269,7 @@
         foo = this.selection.parentElement();
         this.assertEquals(this.selection.parentElement(), node);
     };
+    opera_is_broken(this, 'testParentElementImgSpecial');
 
     this.testParentElementMixed = function() {
         this.body.innerHTML = '<p>foo <b>bar</b><img><img> baz</p>';
@@ -300,6 +302,7 @@
         selection.selectNodeContents(this.body.firstChild.childNodes[1]);
         this.assertEquals(selection.toString(), 'bar');
     };
+    opera_is_broken(this, 'testToString');
 };
 
 KupuSelectionTestCase.prototype = new SelectionTestCase;

Modified: kupu/trunk/kupu/tests/test_kupuinit.js
==============================================================================
--- kupu/trunk/kupu/tests/test_kupuinit.js	(original)
+++ kupu/trunk/kupu/tests/test_kupuinit.js	Thu Nov  2 18:54:36 2006
@@ -84,6 +84,7 @@
         var boldchecker = this._makeBoldchecker();
         this.assertEquals(boldchecker(selNode, null, this.editor), false);
     };
+    opera_is_broken(this, 'testBoldcheckerMixed');
 
     this.testBoldcheckerBoldLeftOuter = function() {
         this.body.innerHTML = '<p>foo <b>bar</b></p>';
@@ -93,6 +94,7 @@
         var boldchecker = this._makeBoldchecker();
         this.assertEquals(boldchecker(selNode, null, this.editor), true);
     };
+    opera_is_broken(this, 'testBoldcheckerBoldLeftOuter');
 
     this.testBoldcheckerBoldInner = function() {
         this.body.innerHTML = '<p>foo <b>bar</b></p>';
@@ -102,6 +104,7 @@
         var boldchecker = this._makeBoldchecker();
         this.assertEquals(boldchecker(selNode, null, this.editor), true);
     };
+    opera_is_broken(this, 'testBoldcheckerBoldInner');
 
     this.testBoldcheckerExecCommand = function() {
         this.body.innerHTML = '<p>foo bar</p>';
@@ -115,7 +118,6 @@
 
     this.testBoldcheckerExecCommandCollapsed = function() {
         // XXX: the feature seems to work, but test is broken on IE
-        if (_SARISSA_IS_IE) return;
         this.body.innerHTML = '<p>foo bar</p>';
         // select                   ||
         this._setSelection(3, null, 3, null, '');
@@ -124,9 +126,10 @@
         var boldchecker = this._makeBoldchecker();
         this.assertEquals(boldchecker(selNode, null, this.editor), true);
     };
-
+    opera_is_broken(this, 'testBoldcheckerExecCommandCollapsed');
+    ie_is_broken(this, 'testBoldcheckerExecCommandCollapsed');
+    
     this.testBoldcheckerExecCommandNoCSS = function() {
-        if (_SARISSA_IS_IE) return;
         this.editor.getDocument().execCommand('styleWithCSS', null, false);
 
         this.body.innerHTML = '<p>foo bar</p>';
@@ -139,6 +142,7 @@
 
         this.editor.getDocument().execCommand('styleWithCSS', null, true);
     };
+    ie_is_broken(this, 'testBoldcheckerExecCommandNoCSS');
 
     this.testBoldcheckerStrong = function() {
         this.body.innerHTML = '<p>foo <strong>bar</strong></p>';
@@ -158,6 +162,7 @@
         var boldchecker = this._makeBoldchecker();
         this.assertEquals(boldchecker(selNode, null, this.editor), true);
     };
+    opera_is_broken(this, 'testBoldcheckerStyle');
 
     this.testItalicscheckerItalics = function() {
         this.body.innerHTML = '<p>foo <i>bar</i></p>';

Modified: kupu/trunk/kupu/tests/test_plone.js
==============================================================================
--- kupu/trunk/kupu/tests/test_plone.js	(original)
+++ kupu/trunk/kupu/tests/test_plone.js	Thu Nov  2 18:54:36 2006
@@ -105,6 +105,7 @@
         this.ui.setTextStyle('h2');
         this.assertEquals(this._cleanHtml(this.body.innerHTML), expected);
     }
+    opera_is_broken(this, 'testSetTextStyle');
 
     this.testSetTextStyleTable = function() {
         var data = '<table><tbody><tr><td>test</td></tr></tbody></table>';
@@ -123,6 +124,7 @@
         this.ui.setTextStyle('td');
         this.assertEquals(this._cleanHtml(this.body.innerHTML), expected);
     }
+    opera_is_broken(this, 'testSetTextStyleTable');
 
     this.testSetTextSpanStyle = function() {
         var data = '<p>some text</p><p>some more</p>';


More information about the kupu-checkins mailing list