Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 173084 Details for
Bug 318455
Create Tests for TestUtil.js
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Fix
TestUtilTest.txt (text/plain), 30.04 KB, created by
Tim Buschtoens
on 2010-06-30 08:47:58 EDT
(
hide
)
Description:
Fix
Filename:
MIME Type:
Creator:
Tim Buschtoens
Created:
2010-06-30 08:47:58 EDT
Size:
30.04 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.rap.rwt.q07.jstest >Index: index.html >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.rwt.test/org.eclipse.rap.rwt.q07.jstest/index.html,v >retrieving revision 1.13 >diff -u -r1.13 index.html >--- index.html 27 Apr 2010 08:46:10 -0000 1.13 >+++ index.html 30 Jun 2010 12:42:06 -0000 >@@ -20,6 +20,7 @@ > <script src="./js/resource/Includes.js" type="text/javascript"></script> > > <!-- Tests --> >+ <script src="./js/org/eclipse/rwt/test/tests/TestUtilTest.js" type="text/javascript"></script> > <script src="./js/org/eclipse/rwt/test/tests/AnimationTest.js" type="text/javascript"></script> > <script src="./js/org/eclipse/rwt/test/tests/ASyncKeyEventUtilTest.js" type="text/javascript"></script> > <script src="./js/org/eclipse/rwt/test/tests/GCTest.js" type="text/javascript"></script> >Index: js/org/eclipse/rwt/test/TestRunner.js >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.rwt.test/org.eclipse.rap.rwt.q07.jstest/js/org/eclipse/rwt/test/TestRunner.js,v >retrieving revision 1.7 >diff -u -r1.7 TestRunner.js >--- js/org/eclipse/rwt/test/TestRunner.js 29 Apr 2010 15:50:58 -0000 1.7 >+++ js/org/eclipse/rwt/test/TestRunner.js 30 Jun 2010 12:42:06 -0000 >@@ -16,7 +16,7 @@ > this.base( arguments ); > qx.log.Logger.ROOT_LOGGER.setMinLevel( qx.log.Logger.LEVEL_ERROR ); > this._FREEZEONFAIL = true; >- this._NOTRYCATCH = false; // set to true for better debugging in IE >+ this._NOTRYCATCH = false; > this._FULLSCREEN = true; > this._presenter = org.eclipse.rwt.test.Presenter.getInstance(); > this._presenter.setFullScreen( this._FULLSCREEN ); >@@ -101,6 +101,7 @@ > for ( this._currentFunction in testFunctions ){ > this._asserts = 0; > testFunctions[ this._currentFunction ].call( obj ); >+ this._cleanUp(); > this.info( this._currentFunction + " - OK ", true ); > } > } else { >@@ -110,6 +111,7 @@ > for ( this._currentFunction in testFunctions ){ > this._asserts = 0; > testFunctions[ this._currentFunction ].call( obj ); >+ this._cleanUp(); > this.info( this._currentFunction + " - OK ", true ); > } > } catch( e ) { >@@ -133,6 +135,13 @@ > this.info( "Tests done.", false ); > }, > >+ _cleanUp : function() { >+ org.eclipse.rwt.test.fixture.TestUtil.clearRequestLog(); >+ org.eclipse.rwt.test.fixture.TestUtil.clearTimerOnceLog(); >+ org.eclipse.rwt.test.fixture.TestUtil.restoreAppearance(); >+ qx.ui.core.Widget.flushGlobalQueues(); >+ }, >+ > // called by Asserts.js > processAssert : function( assertType, expected, value, isFailed, message ) { > if( isFailed ) { >@@ -141,11 +150,11 @@ > var errorMessage = 'Assert "' > + ( message ? message : this._asserts + 1 ) > + '", type "' >- + assertType >+ + assertType > + '" failed : Expected "' >- + expected >+ + this._getObjectSummary( expected ) > + '" but found "' >- + value >+ + this._getObjectSummary( value ) > + '"'; > var error = { > "assert" : true, >@@ -165,6 +174,22 @@ > } > }, > >+ _getObjectSummary : function( value ) { >+ var result = value; >+ if( value instanceof Array ) { >+ result = value.join(); >+ } else if( value instanceof Object >+ && !( value instanceof qx.core.Object ) ) >+ { >+ var arr = []; >+ for( var key in value ) { >+ arr.push( " " + key + " : " + value[ key ] ); >+ } >+ result = "{" + arr.join() + " }"; >+ } >+ return result; >+ }, >+ > _criticalFail : function( msg ) { > this._presenter.log( "Critical error: " + msg, false ); > this._presenter.log( "Testrunner aborted." , false ); >Index: js/org/eclipse/rwt/test/fixture/TestUtil.js >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.rwt.test/org.eclipse.rap.rwt.q07.jstest/js/org/eclipse/rwt/test/fixture/TestUtil.js,v >retrieving revision 1.11 >diff -u -r1.11 TestUtil.js >--- js/org/eclipse/rwt/test/fixture/TestUtil.js 12 Apr 2010 12:31:14 -0000 1.11 >+++ js/org/eclipse/rwt/test/fixture/TestUtil.js 30 Jun 2010 12:42:06 -0000 >@@ -18,35 +18,53 @@ > > getElementBounds : function( node ) { > var style = node.style; >- if( style.cssText.indexOf( "%" ) != -1 ) { >- throw( "getElementBounds does not support '%'!" ); >- } > var result = { >- top : parseInt( style.top ), >- left : parseInt( style.left ), >- width : parseInt( style.width ), >- height : parseInt( style.height ) >+ top : this._parseLength( style.top ), >+ left : this._parseLength( style.left ), >+ width : this._parseLength( style.width ), >+ height : this._parseLength( style.height ) > }; > try { > var ps = node.parentNode.style; >- if( ps.cssText.indexOf( "%" ) != -1 ) { >- throw( "getElementBounds does not support '%'!" ); >- } >- result.right = parseInt( ps.width ) >- - parseInt( ps.borderLeftWidth || 0 ) >- - parseInt( ps.borderRightWidth || 0 ) >+ result.right = this._parseLength( ps.width ) >+ - this._parseLength( ps.borderLeftWidth || 0 ) >+ - this._parseLength( ps.borderRightWidth || 0 ) > - ( result.left + result.width ) >- result.bottom = parseInt( ps.height ) >- - parseInt( ps.borderTopWidth || 0 ) >- - parseInt( ps.borderBottomWidth || 0 ) >+ result.bottom = this._parseLength( ps.height ) >+ - this._parseLength( ps.borderTopWidth || 0 ) >+ - this._parseLength( ps.borderBottomWidth || 0 ) > - ( result.top + result.height ); > } catch( e ) { >- this.printStackTrace(); >- throw( " could not get bounds: no parentNode!" ); >+ throw( "Could not get bounds: no parentNode!" ); >+ } >+ return result; >+ }, >+ >+ _parseLength : function( value ) { >+ var result = value ? parseInt( value ) : 0; >+ if( result != 0 >+ && typeof value == "string" >+ && value.indexOf( "px" ) == -1 ) >+ { >+ throw "getElementBounds only supports \"px\" but found " + value; > } > return result; > }, > >+ getElementFont : function( element ) { >+ var font = element.style.font; >+ if( font == "" || typeof font != "string" ) { >+ var fontData = [ >+ element.style.fontSize, >+ element.style.fontStyle, >+ element.style.fontWeight, >+ element.style.fontFamily >+ ]; >+ font = fontData.join( " " ); >+ } >+ return font; >+ }, >+ > hasElementOpacity : function( node ) { > return node.style.cssText.search( /opacity/i ) != -1; > }, >@@ -61,12 +79,16 @@ > } else if( node.style.backgroundImage > && node.style.backgroundImage.indexOf( 'url(' ) != -1 ) > { >- result = node.style.backgroundImage.slice( 4, -1 ); >- } >+ result = node.style.backgroundImage.slice( 4, -1 ); >+ } > // Webkit re-writes the url in certain situations: > if( result.length > 0 && result == document.URL ) { > result = ""; > } >+ // Firefox writes quotation-marks into the URL >+ if( result[ 0 ] == "\"" && result[ result.length -1 ] == "\"" ) { >+ result = result.slice( 1, -1 ); >+ } > return result; > }, > >@@ -100,10 +122,6 @@ > ///////////////////////////// > // Event handling - DOM layer > >- click : function( widget ) { >- this.clickDOM( widget._getTargetNode() ); >- }, >- > clickDOM : function( node ) { > var left = qx.event.type.MouseEvent.buttons.left; > this.fakeMouseEventDOM( node, "mousedown", left ); >@@ -111,16 +129,23 @@ > this.fakeMouseEventDOM( node, "click", left ); > }, > >- rightClick : function( widget ) { >- var right = qx.event.type.MouseEvent.buttons.right; >- var node = widget._getTargetNode(); >- this.fakeMouseEventDOM( node, "mousedown", right ); >- this.fakeMouseEventDOM( node, "mouseup", right ); >- this.fakeMouseEventDOM( node, "click", right ); >- this.fakeMouseEventDOM( node, "contextmenu", right ); >+ shiftClickDOM : function( node ) { >+ var left = qx.event.type.MouseEvent.buttons.left; >+ var mod = qx.event.type.DomEvent.SHIFT_MASK; >+ this.fakeMouseEventDOM( node, "mousedown", left, 0, 0, mod ); >+ this.fakeMouseEventDOM( node, "mouseup", left, 0, 0, mod ); >+ this.fakeMouseEventDOM( node, "click", left, 0, 0, mod ); > }, >- >- fakeMouseEventDOM : function( node, type, button, left, top ) { >+ >+ ctrlClickDOM : function( node ) { >+ var left = qx.event.type.MouseEvent.buttons.left; >+ var mod = qx.event.type.DomEvent.CTRL_MASK; >+ this.fakeMouseEventDOM( node, "mousedown", left, 0, 0, mod ); >+ this.fakeMouseEventDOM( node, "mouseup", left, 0, 0, mod ); >+ this.fakeMouseEventDOM( node, "click", left, 0, 0, mod ); >+ }, >+ >+ fakeMouseEventDOM : function( node, type, button, left, top, mod ) { > if( typeof node == "undefined" ) { > throw( "Error in fakeMouseEventDOM: node not defined! " ); > } >@@ -130,6 +155,9 @@ > if( typeof top == "undefined" ) { > top = 0; > } >+ if( typeof mod == "undefined" ) { >+ mod = 0; >+ } > var clientX = left; > var clientY = top; > if( qx.core.Client.getEngine() == "mshtml" ) { >@@ -137,48 +165,122 @@ > clientY -= qx.bom.Viewport.getScrollTop(window); > } > var domEvent = { >+ "preventDefault" : function(){}, > "type" : type, > "target" : node, >+ "which" : 1, > "button" : button, > "pageX" : left, > "pageY" : top, > "clientX" : clientX, > "clientY" : clientY, > "screenX" : left, >- "screenY" : top >+ "screenY" : top, >+ "ctrlKey" : ( qx.event.type.DomEvent.CTRL_MASK & mod ) != 0, >+ "altKey" : ( qx.event.type.DomEvent.ALT_MASK & mod ) != 0, >+ "shiftKey" : ( qx.event.type.DomEvent.SHIFT_MASK & mod ) != 0 > } > qx.event.handler.EventHandler.getInstance().__onmouseevent( domEvent ); > }, > >+ fakeKeyEventDOM : function( node, eventType, stringOrKeyCode ) { >+ var charCode = null; >+ var keyCode = null; >+ var isChar = typeof stringOrKeyCode == "string"; >+ if( isChar ) { >+ charCode = stringOrKeyCode.charCodeAt( 0 ); >+ } else { >+ keyCode = stringOrKeyCode; >+ } >+ var domEvent = { >+ target : node, >+ type : eventType, >+ ctrlKey : false, >+ altKey : false, >+ shiftKey : false, >+ keyCode : keyCode, >+ charCode : charCode, >+ isChar: isChar, >+ pageX: 0, >+ pageY: 0, >+ preventDefault : function(){}, >+ stopPropagation : function(){} >+ }; >+ var handler = qx.event.handler.KeyEventHandler.getInstance(); >+ handler._idealKeyHandler( keyCode, charCode, eventType, domEvent ); >+ }, >+ > ///////////////////////////// > // Event handling - Qooxdoo >- >+ click : function( widget ) { >+ this.clickDOM( widget._getTargetNode() ); >+ }, >+ >+ doubleClick : function( widget ) { >+ var node = widget._getTargetNode(); >+ this.clickDOM( node ); >+ this.clickDOM( node ); >+ var left = qx.event.type.MouseEvent.buttons.left; >+ this.fakeMouseEventDOM( node, "dblclick", left ); >+ }, >+ >+ shiftClick : function( widget ) { >+ var node = widget._getTargetNode(); >+ this.shiftClickDOM( node ); >+ }, >+ >+ ctrlClick : function( widget ) { >+ var node = widget._getTargetNode(); >+ this.ctrlClickDOM( node ); >+ }, >+ >+ rightClick : function( widget ) { >+ var right = qx.event.type.MouseEvent.buttons.right; >+ var node = widget._getTargetNode(); >+ this.fakeMouseEventDOM( node, "mousedown", right ); >+ this.fakeMouseEventDOM( node, "mouseup", right ); >+ this.fakeMouseEventDOM( node, "click", right ); >+ this.fakeMouseEventDOM( node, "contextmenu", right ); >+ }, >+ > mouseOver : function( widget ) { > this.fakeMouseEvent( widget, "mouseover" ); > }, >- >+ > mouseMove : function( widget ) { > this.fakeMouseEvent( widget, "mousemove" ); > }, >- >+ > mouseOut : function( widget ) { > this.fakeMouseEvent( widget, "mouseout" ); > }, >- >+ > mouseFromTo : function( from, to ) { > this.mouseMove( from ); > this.mouseOut( from ); > this.mouseOver( to ); > this.mouseMove( to ); > }, >- >+ > fakeMouseClick : function( widget, left, top ) { > this.fakeMouseEvent( widget, "mousedown", left, top ); > this.fakeMouseEvent( widget, "mouseup", left, top ); > this.fakeMouseEvent( widget, "click", left, top ); > }, >- >+ >+ fakeWheel : function( widget, value ) { >+ var ev = this._createQxMouseEvent( widget, "mousewheel" ); >+ ev.getWheelDelta = function(){ return value; }; >+ widget.dispatchEvent( ev ); >+ }, >+ > fakeMouseEvent : function( widget, type, left, top ) { >+ var ev = this._createQxMouseEvent( widget, type, left, top ); >+ ev.setButton( qx.event.type.MouseEvent.C_BUTTON_LEFT ); >+ widget.dispatchEvent( ev ); >+ }, >+ >+ _createQxMouseEvent : function( widget, type, left, top ) { > if( !widget._isCreated ) { > throw( "Error in testUtil.fakeMouseEvent: widget is not created" ); > } >@@ -191,7 +293,9 @@ > clientX : left, > clientY : top, > pageX : left, >- pageY : top >+ pageY : top, >+ preventDefault : function(){}, >+ stopPropagation : function(){} > }; > var ev = new qx.event.type.MouseEvent( > type, >@@ -202,16 +306,16 @@ > null > ); > ev.setButton( qx.event.type.MouseEvent.C_BUTTON_LEFT ); >- widget.dispatchEvent( ev ); >+ return ev; > }, >- >+ > press : function( widget, key, checkActive ) { > this.fakeKeyEvent( widget, "keydown", key, checkActive ); > this.fakeKeyEvent( widget, "keypress", key, checkActive ); > this.fakeKeyEvent( widget, "keyinput", key, checkActive ); > this.fakeKeyEvent( widget, "keyup", key, checkActive ); > }, >- >+ > fakeKeyEvent : function( widget, type, key, checkActive ) { > if( !widget._isCreated ) { > throw( "Error in fakeKeyEvent: " + widget + " is not created" ); >@@ -236,34 +340,7 @@ > widget.warn( type + " not possible: " + widget.__dbKey + " not focused!" ); > } > }, >- >- fakeKeyEventDOM : function( node, eventType, stringOrKeyCode ) { >- var charCode = null; >- var keyCode = null; >- var isChar = typeof stringOrKeyCode == "string"; >- if( isChar ) { >- charCode = stringOrKeyCode.charCodeAt( 0 ); >- } else { >- keyCode = stringOrKeyCode; >- } >- var domEvent = { >- target : node, >- type : eventType, >- ctrlKey : false, >- altKey : false, >- shiftKey : false, >- keyCode : keyCode, >- charCode : charCode, >- isChar: isChar, >- pageX: 0, >- pageY: 0, >- preventDefault : function(){}, >- stopPropagation : function(){} >- }; >- var handler = qx.event.handler.KeyEventHandler.getInstance(); >- handler._idealKeyHandler( keyCode, charCode, eventType, domEvent ); >- }, >- >+ > //////////////// > // client-server > >@@ -275,15 +352,15 @@ > return ""; > } ); > }, >- >+ > getRequestLog : function() { > return this._requestLog; > }, >- >+ > getRequestsSend : function() { > return this._requestLog.length; > }, >- >+ > clearRequestLog : function() { > org.eclipse.swt.Request.getInstance().send(); > this._requestLog = []; >@@ -334,6 +411,47 @@ > timer._oninterval(); > }, > >+ ////////// >+ // Theming >+ >+ // assumes that the set appearance-theme does never change during tests >+ fakeAppearance : function( appearanceId, value ) { >+ var manager = qx.theme.manager.Appearance.getInstance(); >+ var themeName = manager.getAppearanceTheme().name; >+ var base = manager.getAppearanceTheme().appearances; >+ if( typeof this._appearanceBackups[ appearanceId ] == "undefined" ) { >+ if( base[ appearanceId ] ) { >+ this._appearanceBackups[ appearanceId ] = base[ appearanceId ]; >+ } else { >+ this._appearanceBackups[ appearanceId ] = false; >+ } >+ } >+ base[ appearanceId ] = value; >+ this._clearAppearanceCache(); >+ }, >+ >+ restoreAppearance : function() { >+ var manager = qx.theme.manager.Appearance.getInstance(); >+ var base = manager.getAppearanceTheme().appearances; >+ for( var appearanceId in this._appearanceBackups ) { >+ var value = this._appearanceBackups[ appearanceId ]; >+ if( value === false ) { >+ delete base[ appearanceId ]; >+ } else { >+ base[ appearanceId ] = value; >+ } >+ } >+ this._appearanceBackups = {}; >+ this._clearAppearanceCache(); >+ }, >+ >+ _appearanceBackups : {}, >+ >+ _clearAppearanceCache : function() { >+ var manager = qx.theme.manager.Appearance.getInstance() >+ manager.__cache[ manager.getAppearanceTheme().name ] = {}; >+ }, >+ > //////// > // Misc > >Index: js/org/eclipse/rwt/test/tests/TestUtilTest.js >=================================================================== >RCS file: js/org/eclipse/rwt/test/tests/TestUtilTest.js >diff -N js/org/eclipse/rwt/test/tests/TestUtilTest.js >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ js/org/eclipse/rwt/test/tests/TestUtilTest.js 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,319 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 EclipseSource and others. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0 which accompanies this distribution, >+ * and is available at http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * EclipseSource - initial API and implementation >+ ******************************************************************************/ >+ >+qx.Class.define( "org.eclipse.rwt.test.tests.TestUtilTest", { >+ >+ extend : qx.core.Object, >+ >+ members : { >+ >+ testGetElementBounds : function() { >+ var testUtil = org.eclipse.rwt.test.fixture.TestUtil; >+ var parent = document.createElement( "div" ); >+ var child = document.createElement( "div" ); >+ parent.style.width = "100px"; >+ parent.style.height = "200px"; >+ parent.appendChild( child ); >+ child.style.top = "20px"; >+ child.style.left = "30px"; >+ child.style.width = "50px"; >+ child.style.height = "70px"; >+ var bounds = testUtil.getElementBounds( child ); >+ var expected = { >+ "top" : 20, >+ "left" : 30, >+ "width" : 50, >+ "height" : 70, >+ "right" : 20, >+ "bottom" : 110 >+ }; >+ assertEquals( expected, bounds ); >+ }, >+ >+ testGetElementBoundsNoParent : function() { >+ var testUtil = org.eclipse.rwt.test.fixture.TestUtil; >+ var child = document.createElement( "div" ); >+ var log = []; >+ try { >+ testUtil.getElementBounds( child ); >+ } catch( ex ) { >+ log.push( ex ); >+ } >+ assertEquals( 1, log.length ); >+ }, >+ >+ testGetElementBoundsNoPercantageOnChild : function() { >+ var testUtil = org.eclipse.rwt.test.fixture.TestUtil; >+ var parent = document.createElement( "div" ); >+ var child = document.createElement( "div" ); >+ parent.style.width = "100%"; >+ parent.style.height = "200px"; >+ parent.appendChild( child ); >+ child.style.top = "20px"; >+ child.style.left = "30px"; >+ child.style.width = "50px"; >+ child.style.height = "70px"; >+ var log = []; >+ try { >+ testUtil.getElementBounds( child ); >+ } catch( ex ) { >+ log.push( ex ); >+ } >+ assertEquals( 1, log.length ); >+ }, >+ >+ testGetElementBoundsNoPercantageOnParent : function() { >+ var testUtil = org.eclipse.rwt.test.fixture.TestUtil; >+ var parent = document.createElement( "div" ); >+ var child = document.createElement( "div" ); >+ parent.style.width = "100px"; >+ parent.style.height = "200px"; >+ parent.appendChild( child ); >+ child.style.top = "20px"; >+ child.style.left = "30px"; >+ child.style.width = "100%"; >+ child.style.height = "70px"; >+ var log = []; >+ try { >+ testUtil.getElementBounds( child ); >+ } catch( ex ) { >+ log.push( ex ); >+ } >+ assertEquals( 1, log.length ); >+ }, >+ >+ testGetElementBoundsWidthImage : function() { >+ var testUtil = org.eclipse.rwt.test.fixture.TestUtil; >+ var parent = document.createElement( "div" ); >+ var child = document.createElement( "div" ); >+ parent.style.width = "100px"; >+ parent.style.height = "200px"; >+ parent.appendChild( child ); >+ child.style.top = "20px"; >+ child.style.left = "30px"; >+ child.style.width = "50px"; >+ child.style.height = "70px"; >+ child.style.backgroundRepeat = "no-repeat"; >+ child.style.backgroundPosition = "center"; >+ var bounds = testUtil.getElementBounds( child ); >+ var expected = { >+ "top" : 20, >+ "left" : 30, >+ "width" : 50, >+ "height" : 70, >+ "right" : 20, >+ "bottom" : 110 >+ }; >+ assertEquals( expected, bounds ); >+ }, >+ >+ testGetElementBoundsWidthBorder : function() { >+ var testUtil = org.eclipse.rwt.test.fixture.TestUtil; >+ var parent = document.createElement( "div" ); >+ var child = document.createElement( "div" ); >+ parent.style.width = "100px"; >+ parent.style.height = "200px"; >+ parent.style.border = "5px solid black"; >+ parent.appendChild( child ); >+ child.style.top = "20px"; >+ child.style.left = "30px"; >+ child.style.width = "50px"; >+ child.style.height = "70px"; >+ var bounds = testUtil.getElementBounds( child ); >+ var expected = { >+ "top" : 20, >+ "left" : 30, >+ "width" : 50, >+ "height" : 70, >+ "right" : 10, >+ "bottom" : 100 >+ }; >+ assertEquals( expected, bounds ); >+ }, >+ >+ testGetElementBoundsWidthDifferentEdges : function() { >+ var testUtil = org.eclipse.rwt.test.fixture.TestUtil; >+ var parent = document.createElement( "div" ); >+ var child = document.createElement( "div" ); >+ parent.style.width = "100px"; >+ parent.style.height = "200px"; >+ parent.style.borderWidth = "5px 4px 3px 2px"; >+ parent.appendChild( child ); >+ child.style.top = "20px"; >+ child.style.left = "30px"; >+ child.style.width = "50px"; >+ child.style.height = "70px"; >+ var bounds = testUtil.getElementBounds( child ); >+ var expected = { >+ "top" : 20, >+ "left" : 30, >+ "width" : 50, >+ "height" : 70, >+ "right" : 14, >+ "bottom" : 102 >+ }; >+ assertEquals( expected, bounds ); >+ }, >+ >+ testGetCssBackgroundImage : function() { >+ // TODO : test for IE-filter >+ var testUtil = org.eclipse.rwt.test.fixture.TestUtil; >+ var div = document.createElement( "div" ); >+ div.style.backgroundImage = "url( test.gif )"; >+ var result = testUtil.getCssBackgroundImage( div ); >+ assertEquals( result.length - 8, result.indexOf( "test.gif" ) ); >+ }, >+ >+ testFakeAppearance : function() { >+ var testUtil = org.eclipse.rwt.test.fixture.TestUtil; >+ var widget = new qx.ui.basic.Terminator(); >+ widget.setAppearance( "my-appearance" ); >+ testUtil.fakeAppearance( "my-appearance", { >+ style : function( states ) { >+ return { >+ backgroundImage : "my-appearance.gif" >+ }; >+ } >+ } ); >+ widget._renderAppearance(); >+ assertEquals( "my-appearance.gif", widget.getBackgroundImage() ); >+ widget.destroy(); >+ }, >+ >+ testOverwriteAppearance : function() { >+ var testUtil = org.eclipse.rwt.test.fixture.TestUtil; >+ var widget = new org.eclipse.rwt.widgets.Button( "push" ); >+ assertEquals( "push-button", widget.getAppearance() ); >+ testUtil.fakeAppearance( "push-button", { >+ style : function( states ) { >+ return { >+ backgroundImage : "my-appearance.gif" >+ }; >+ } >+ } ); >+ widget._renderAppearance(); >+ assertEquals( "my-appearance.gif", widget.getBackgroundImage() ); >+ widget.destroy(); >+ }, >+ >+ testDeleteFakeAppearance : function() { >+ var testUtil = org.eclipse.rwt.test.fixture.TestUtil; >+ testUtil.fakeAppearance( "my-appearance", { >+ style : function( states ) { >+ return { >+ backgroundImage : "my-appearance.gif" >+ }; >+ } >+ } ); >+ testUtil.restoreAppearance(); >+ var widget = new qx.ui.basic.Terminator(); >+ widget.setAppearance( "my-appearance" ); >+ widget._renderAppearance(); >+ assertNull( widget.getBackgroundImage() ); >+ widget.destroy(); >+ }, >+ >+ testRestoreAppearance : function() { >+ var testUtil = org.eclipse.rwt.test.fixture.TestUtil; >+ var widget = new org.eclipse.rwt.widgets.Button( "push" ); >+ assertEquals( "push-button", widget.getAppearance() ); >+ testUtil.fakeAppearance( "push-button", { >+ style : function( states ) { >+ return { >+ backgroundImage : "my-appearance.gif" >+ }; >+ } >+ } ); >+ widget._renderAppearance(); >+ testUtil.restoreAppearance(); >+ widget._renderAppearance(); >+ assertNull( widget.getBackgroundImage() ); >+ widget.destroy(); >+ }, >+ >+ testFakeWheel : function() { >+ var testUtil = org.eclipse.rwt.test.fixture.TestUtil; >+ var widget = new qx.ui.basic.Terminator(); >+ widget.addToDocument(); >+ testUtil.flush(); >+ var log = []; >+ widget.addEventListener( "mousewheel", function( evt ) { >+ log.push( evt.getWheelDelta() ); >+ } ); >+ testUtil.fakeWheel( widget, 2 ); >+ testUtil.fakeWheel( widget, -3 ); >+ assertEquals( [ 2, -3 ], log ); >+ widget.destroy(); >+ }, >+ >+ testFakeMouseEventDomModifier : function() { >+ var testUtil = org.eclipse.rwt.test.fixture.TestUtil; >+ var widget = new qx.ui.basic.Terminator(); >+ widget.addToDocument(); >+ testUtil.flush(); >+ var log = []; >+ widget.addEventListener( "mousedown", function( evt ) { >+ log.push( evt.getModifiers() ); >+ } ); >+ var node = widget._getTargetNode(); >+ var left = qx.event.type.MouseEvent.buttons.left; >+ testUtil.fakeMouseEventDOM( node, "mousedown", left, 0, 0, 0 ); >+ testUtil.fakeMouseEventDOM( node, "mousedown", left, 0, 0, 1 ); >+ testUtil.fakeMouseEventDOM( node, "mousedown", left, 0, 0, 2 ); >+ testUtil.fakeMouseEventDOM( node, "mousedown", left, 0, 0, 4 ); >+ testUtil.fakeMouseEventDOM( node, "mousedown", left, 0, 0, 7 ); >+ assertEquals( [ 0, 1, 2, 4, 7 ], log ); >+ widget.destroy(); >+ }, >+ >+ testGetElementFontShorthand : function() { >+ var testUtil = org.eclipse.rwt.test.fixture.TestUtil; >+ var el = document.createElement( "div" ); >+ el.style.font = "10px italic bold Arial"; >+ var font = testUtil.getElementFont( el ); >+ assertTrue( font.indexOf( "10px" ) != -1 ); >+ assertTrue( font.indexOf( "Arial" ) != -1 ); >+ assertTrue( font.indexOf( "italic" ) != -1 ); >+ assertTrue( font.indexOf( "bold" ) != -1 ); >+ }, >+ >+ testGetElementFontSingleProps : function() { >+ var testUtil = org.eclipse.rwt.test.fixture.TestUtil; >+ var el = document.createElement( "div" ); >+ el.style.font = "10px italic bold Arial"; >+ el.style.fontFamily = "Arial"; >+ el.style.fontSize = "10px"; >+ el.style.fontStyle = "italic"; >+ el.style.fontWeight = "bold"; >+ var font = testUtil.getElementFont( el ); >+ assertTrue( font.indexOf( "10px" ) != -1 ); >+ assertTrue( font.indexOf( "Arial" ) != -1 ); >+ assertTrue( font.indexOf( "italic" ) != -1 ); >+ assertTrue( font.indexOf( "bold" ) != -1 ); >+ }, >+ >+ testDoubleClick : function() { >+ var testUtil = org.eclipse.rwt.test.fixture.TestUtil; >+ var widget = new qx.ui.basic.Terminator(); >+ widget.addToDocument(); >+ testUtil.flush(); >+ var log = []; >+ widget.addEventListener( "click" , function() { log.push( "click" ); } ); >+ widget.addEventListener( "dblclick" , function() { >+ log.push( "dblclick" ); >+ } ); >+ testUtil.doubleClick( widget ); >+ assertEquals( [ "click", "click", "dblclick" ], log ); >+ widget.destroy(); >+ } >+ >+ } >+ >+} ); >\ No newline at end of file
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 318455
: 173084