Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Furnadjiev2017-02-10 09:05:19 +0000
committerIvan Furnadjiev2017-02-10 09:05:19 +0000
commit4e2055f7395396ce5b0915840b4d48d62aa2198a (patch)
tree51cad09b181f980c7db74083689790eec52cefb2
parent413be3831164594d6dba55695a5cfe41bdbedb29 (diff)
downloadorg.eclipse.rap-4e2055f7395396ce5b0915840b4d48d62aa2198a.tar.gz
org.eclipse.rap-4e2055f7395396ce5b0915840b4d48d62aa2198a.tar.xz
org.eclipse.rap-4e2055f7395396ce5b0915840b4d48d62aa2198a.zip
Add JS tests for custom variant inheritance in Grid
-rw-r--r--tests/org.eclipse.rap.rwt.jstest/js/org/eclipse/rwt/test/tests/GridColumnTest.js54
-rw-r--r--tests/org.eclipse.rap.rwt.jstest/js/org/eclipse/rwt/test/tests/GridRowTest.js54
-rw-r--r--tests/org.eclipse.rap.rwt.jstest/js/org/eclipse/rwt/test/tests/GridTest.js27
3 files changed, 117 insertions, 18 deletions
diff --git a/tests/org.eclipse.rap.rwt.jstest/js/org/eclipse/rwt/test/tests/GridColumnTest.js b/tests/org.eclipse.rap.rwt.jstest/js/org/eclipse/rwt/test/tests/GridColumnTest.js
index c1f3e471d8..8bf54fb4be 100644
--- a/tests/org.eclipse.rap.rwt.jstest/js/org/eclipse/rwt/test/tests/GridColumnTest.js
+++ b/tests/org.eclipse.rap.rwt.jstest/js/org/eclipse/rwt/test/tests/GridColumnTest.js
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2016 EclipseSource and others.
+ * Copyright (c) 2011, 2017 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
@@ -524,6 +524,29 @@ rwt.qx.Class.define( "org.eclipse.rwt.test.tests.GridColumnTest", {
tree.destroy();
},
+ testCustomVariant_isInheritFromGrid : function() {
+ var tree = this._createTreeByProtocol( "w3", "w2", [] );
+ var column = this._createColumnByProtocol( "w4", "w3", [] );
+
+ tree.setCustomVariant( "variant_blue" );
+
+ assertEquals( "variant_blue", column.getCustomVariant() );
+ column.dispose();
+ tree.destroy();
+ },
+
+ testCustomVariant_canBeOverridden : function() {
+ var tree = this._createTreeByProtocol( "w3", "w2", [] );
+ var column = this._createColumnByProtocol( "w4", "w3", [] );
+
+ tree.setCustomVariant( "variant_blue" );
+ column.setCustomVariant( "variant_red" );
+
+ assertEquals( "variant_red", column.getCustomVariant() );
+ column.dispose();
+ tree.destroy();
+ },
+
testSetHtmlAttribute : function() {
var tree = this._createTreeByProtocol( "w3", "w2", [] );
var column = this._createColumnByProtocol( "w4", "w3", [] );
@@ -583,6 +606,28 @@ rwt.qx.Class.define( "org.eclipse.rwt.test.tests.GridColumnTest", {
tree.destroy();
},
+ testRenderSortIndicator_withCustomVariant : function() {
+ var tree = this._createTreeByProtocol( "w3", "w2", [] );
+ var column = this._createColumnByProtocol( "w4", "w3", [] );
+ TestUtil.fakeAppearance( "tree-column-sort-indicator", {
+ style : function( states ) {
+ return {
+ "backgroundImage" : [ states.variant_foo ? "foo.gif" : "bar.gif", 10, 15 ]
+ };
+ }
+ } );
+
+ tree.setCustomVariant( "variant_foo" );
+ TestUtil.protocolSet( "w3", { "sortColumn" : "w4", "sortDirection" : "up" } );
+ TestUtil.flush();
+
+ var label = this._getColumnLabel( tree, column );
+ assertEquals( "foo.gif", label.getCellContent( 2 ) );
+ assertEquals( [ 10, 15 ], label.getCellDimension( 2 ) );
+ column.dispose();
+ tree.destroy();
+ },
+
testRenderFooterLabelState : function() {
var tree = this._createTreeByProtocol( "w3", "w2", [] );
tree.setFooterVisible( true );
@@ -1907,6 +1952,7 @@ describe( "GridHeader", function() {
columnOrder[ i ] = column;
}
grid.getColumnOrder.andReturn( columnOrder );
+ grid.getRenderConfig.andReturn( {} );
} );
afterEach( function(){
@@ -1920,7 +1966,8 @@ describe( "GridHeader", function() {
beforeEach( function(){
header = new GridHeader( {
- "appearance" : "table"
+ "appearance" : "table",
+ "config" : {}
} );
label = header._getLabelByColumn( columns[ 0 ] );
} );
@@ -1949,7 +1996,8 @@ describe( "GridHeader", function() {
beforeEach( function(){
footer = new GridHeader( {
"appearance" : "table",
- "footer" : true
+ "footer" : true,
+ "config" : {}
} );
label = footer._getLabelByColumn( columns[ 0 ] );
} );
diff --git a/tests/org.eclipse.rap.rwt.jstest/js/org/eclipse/rwt/test/tests/GridRowTest.js b/tests/org.eclipse.rap.rwt.jstest/js/org/eclipse/rwt/test/tests/GridRowTest.js
index 077d04e992..ab11167d29 100644
--- a/tests/org.eclipse.rap.rwt.jstest/js/org/eclipse/rwt/test/tests/GridRowTest.js
+++ b/tests/org.eclipse.rap.rwt.jstest/js/org/eclipse/rwt/test/tests/GridRowTest.js
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2015 EclipseSource and others.
+ * Copyright (c) 2010, 2017 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
@@ -3435,20 +3435,36 @@ rwt.qx.Class.define( "org.eclipse.rwt.test.tests.GridRowTest", {
assertEquals( 12, parseInt( nodes[ 0 ].style.height, 10 ) );
},
- /////////
- // Helper
+ testCustomVariantIsRespectedForCellPadding : function() {
+ tree = new rwt.widgets.Grid( {
+ "appearance": "tree",
+ "indentionWidth" : 10
+ } );
+ tree.setCustomVariant( "variant_big" );
+ var item = new rwt.widgets.GridItem( tree.getRootItem() );
+ item.setTexts( [ "Test" ] );
+ tree.setItemMetrics( 0, 0, 15, 0, 10, 10, 40 );
+ this._setCellPadding( 3, "variant_big", 9 );
+
+ var layout = this._getRowLayout( tree, item );
+
+ assertEquals( 9, layout.cellPadding );
+ },
- _createRow : function( tree, isTable ) {
- var result = new rwt.widgets.base.GridRow( tree );
- if( isTable ) {
- result.setAppearance( "table-row" );
- } else {
- result.setAppearance( "tree-row" );
- }
- row = result;
- row.setWidth( 400 );
- this._addToDom( row );
- },
+ /////////
+ // Helper
+
+ _createRow : function( tree, isTable ) {
+ var result = new rwt.widgets.base.GridRow( tree );
+ if( isTable ) {
+ result.setAppearance( "table-row" );
+ } else {
+ result.setAppearance( "tree-row" );
+ }
+ row = result;
+ row.setWidth( 400 );
+ this._addToDom( row );
+ },
_addToDom : function( widget ) {
rwt.util.RWTQuery( document.body ).append( widget.$el );
@@ -3665,6 +3681,16 @@ rwt.qx.Class.define( "org.eclipse.rwt.test.tests.GridRowTest", {
} );
},
+ _setCellPadding : function( value, customVariant, customValue ) {
+ TestUtil.fakeAppearance( "tree-cell", {
+ style : function( state ) {
+ return {
+ "padding" : state[ customVariant ] ? customValue : value
+ };
+ }
+ } );
+ },
+
_getOverlayElement : function( row ) {
return row.$overlay.get( 0 );
},
diff --git a/tests/org.eclipse.rap.rwt.jstest/js/org/eclipse/rwt/test/tests/GridTest.js b/tests/org.eclipse.rap.rwt.jstest/js/org/eclipse/rwt/test/tests/GridTest.js
index d436760884..63642e68be 100644
--- a/tests/org.eclipse.rap.rwt.jstest/js/org/eclipse/rwt/test/tests/GridTest.js
+++ b/tests/org.eclipse.rap.rwt.jstest/js/org/eclipse/rwt/test/tests/GridTest.js
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2015 EclipseSource and others.
+ * Copyright (c) 2010, 2017 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
@@ -5078,6 +5078,31 @@ rwt.qx.Class.define( "org.eclipse.rwt.test.tests.GridTest", {
widget.destroy();
},
+ testItemCustomVariant_isInheritFromGrid : function() {
+ var tree = this._createDefaultTree();
+ this._fillTree( tree, 1, 1 );
+
+ tree.setCustomVariant( "variant_foo" );
+
+ assertEquals( "variant_foo", tree.getRootItem().getVariant() );
+ assertEquals( "variant_foo", tree.getRootItem().getChild( 0 ).getVariant() );
+ assertEquals( "variant_foo", tree.getRootItem().getChild( 0 ).getChild( 0 ).getVariant() );
+ tree.destroy();
+ },
+
+ testItemCustomVariant_canBeOverridden : function() {
+ var tree = this._createDefaultTree();
+ this._fillTree( tree, 1, 1 );
+
+ tree.setCustomVariant( "variant_foo" );
+ tree.getRootItem().getChild( 0 ).setVariant( "variant_bar" );
+
+ assertEquals( "variant_foo", tree.getRootItem().getVariant() );
+ assertEquals( "variant_bar", tree.getRootItem().getChild( 0 ).getVariant() );
+ assertEquals( "variant_foo", tree.getRootItem().getChild( 0 ).getChild( 0 ).getVariant() );
+ tree.destroy();
+ },
+
/////////
// helper

Back to the top