Annotation of kupuMPIWG/tests/test_kupubasetools.js, revision 1.1.1.1

1.1       dwinter     1: /*****************************************************************************
                      2:  *
                      3:  * Copyright (c) 2003-2005 Kupu Contributors. All rights reserved.
                      4:  *
                      5:  * This software is distributed under the terms of the Kupu
                      6:  * License. See LICENSE.txt for license text. For a list of Kupu
                      7:  * Contributors see CREDITS.txt.
                      8:  *
                      9:  *****************************************************************************/
                     10: 
                     11: // $Id: test_kupubasetools.js 9984 2005-03-21 14:29:21Z yuppie $
                     12: 
                     13: function KupuUITestCase() {
                     14:     this.name = 'KupuUITestCase';
                     15:     SelectionTestCase.apply(this);
                     16:     this.base_setUp = this.setUp;
                     17: 
                     18:     this.setUp = function() {
                     19:         this.base_setUp();
                     20:         this.editor = new KupuEditor(this.kupudoc, {}, null);
                     21:         this.ui = new KupuUI('kupu-tb-styles');
                     22:         this.ui.editor = this.editor;
                     23:     };
                     24: 
                     25:     this.test_updateState = function() {
                     26:         this.body.innerHTML = '<p>foo</p><pre>bar</pre><p>baz</p>';
                     27:         var node = this.body.getElementsByTagName('pre')[0];
                     28:         this.ui.tsselect.selectedIndex = 0;
                     29:         this.assertEquals(this.ui.tsselect.selectedIndex, 0);
                     30:         this.ui.updateState(node);
                     31:         this.assertEquals(this.ui.tsselect.selectedIndex, 3);
                     32:     };
                     33: 
                     34:     this.test_setTextStyle = function() {
                     35:         this.body.innerHTML = '<p>foo</p><p>bar</p><p>baz</p>';
                     36:         // select                          |bar|
                     37:         this._setSelection(4, null, 7, null, 'bar');
                     38:         this.ui.setTextStyle('h1');
                     39:         this.assertEquals(this._cleanHtml(this.body.innerHTML),
                     40:                           '<p>foo</p><h1>bar</h1><p>baz</p>');
                     41:     };
                     42: 
                     43:     this.XXXtest_setTextStyleReplacingDiv = function() {
                     44:         this.body.innerHTML = '<p>foo</p><div>bar</div><p>baz</p>';
                     45:         // select                          |bar|
                     46:         this._setSelection(4, null, 7, null, 'bar');
                     47:         this.ui.setTextStyle('h1');
                     48:         this.assertEquals(this._cleanHtml(this.body.innerHTML),
                     49:                           '<p>foo</p><h1>bar</h1><p>baz</p>');
                     50:     };
                     51: };
                     52: 
                     53: KupuUITestCase.prototype = new SelectionTestCase;
                     54: 
                     55: function ImageToolTestCase() {
                     56:     this.name = 'KupuUITestCase';
                     57:     SelectionTestCase.apply(this);
                     58:     this.base_setUp = this.setUp;
                     59: 
                     60:     this.setUp = function() {
                     61:         this.base_setUp();
                     62:         this.editor = new KupuEditor(this.kupudoc, {}, new DummyLogger());
                     63:         this.editor._initialized = true;
                     64:         this.imagetool = new ImageTool();
                     65:         this.imagetool.editor = this.editor;
                     66:     };
                     67: 
                     68:     this.test_createImage = function() {
                     69:         this.body.innerHTML = '<p>foo bar baz</p>';
                     70:         // select                    |bar|
                     71:         this._setSelection(4, null, 7, null, 'bar');
                     72:         this.imagetool.createImage('bar.png');
                     73:         this.assertEquals(this._cleanHtml(this.body.innerHTML),
                     74:                           '<p>foo <img src="bar.png"> baz</p>');
                     75:     };
                     76: 
                     77:     this.test_createImageFull = function() {
                     78:         this.body.innerHTML = '<p>foo bar baz</p>';
                     79:         // select                    |bar|
                     80:         this._setSelection(4, null, 7, null, 'bar');
                     81:         this.imagetool.createImage('bar.png', 'spam', 'image-inline');
                     82:         var nodes = this.body.getElementsByTagName('img');
                     83:         this.assertEquals(nodes.length, 1);
                     84:         this.assertEquals(nodes[0].className, 'image-inline');
                     85:         this.assertEquals(nodes[0].alt, 'spam');
                     86:     };
                     87: };
                     88: 
                     89: ImageToolTestCase.prototype = new SelectionTestCase;

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>