From 43cd5d53b5b85b7bfa751e3d7a554de6b69ae31f Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Mon, 1 Aug 2011 10:01:45 +0000 Subject: [PATCH] #7337 Tests for column alignment, headers+header mode, column icons and generated columns svn changeset:20050/svn branch:6.7 --- .../components/AbstractComponentTest.java | 34 +- .../components/AbstractComponentTestCase.java | 3 + .../table/TableColumnAlignment.html | 305 +++++++++++++++++ .../tests/components/table/TableColumnHeaders | 244 ++++++++++++++ .../components/table/TableColumnIcons.html | 185 +++++++++++ .../table/TableGeneratedColumns.html | 223 +++++++++++++ .../vaadin/tests/components/table/Tables.java | 306 ++++++++++++++++-- 7 files changed, 1269 insertions(+), 31 deletions(-) create mode 100644 tests/src/com/vaadin/tests/components/table/TableColumnAlignment.html create mode 100644 tests/src/com/vaadin/tests/components/table/TableColumnHeaders create mode 100644 tests/src/com/vaadin/tests/components/table/TableColumnIcons.html create mode 100644 tests/src/com/vaadin/tests/components/table/TableGeneratedColumns.html diff --git a/tests/src/com/vaadin/tests/components/AbstractComponentTest.java b/tests/src/com/vaadin/tests/components/AbstractComponentTest.java index b00ca3025b..8344ed216a 100644 --- a/tests/src/com/vaadin/tests/components/AbstractComponentTest.java +++ b/tests/src/com/vaadin/tests/components/AbstractComponentTest.java @@ -57,6 +57,7 @@ public abstract class AbstractComponentTest * Maps the category name to a menu item */ private Map categoryToMenuItem = new HashMap(); + private Map menuItemToCategory = new HashMap(); // Logging private Log log; @@ -362,15 +363,16 @@ public abstract class AbstractComponentTest } /** - * Creates category "category" in parent category "parentCategory". Each - * category name must be globally unique. + * Creates category named "category" with id "categoryId" in parent category + * "parentCategory". Each categoryId must be globally unique. * * @param category + * @param categoryId * @param parentCategory * @return */ protected MenuItem createCategory(String category, String parentCategory) { - if (categoryToMenuItem.containsKey(category)) { + if (hasCategory(category)) { return categoryToMenuItem.get(category); } MenuItem item; @@ -380,9 +382,35 @@ public abstract class AbstractComponentTest item = getCategoryMenuItem(parentCategory).addItem(category, null); } categoryToMenuItem.put(category, item); + menuItemToCategory.put(item, category); return item; } + protected boolean hasCategory(String categoryId) { + return categoryToMenuItem.containsKey(categoryId); + } + + protected void removeCategory(String categoryId) { + if (!hasCategory(categoryId)) { + throw new IllegalArgumentException("Category '" + categoryId + + "' does not exist"); + } + + MenuItem item = getCategoryMenuItem(categoryId); + Object[] children = item.getChildren().toArray(); + for (Object child : children) { + if (menuItemToCategory.containsKey(child)) { + removeCategory(menuItemToCategory.get(child)); + } + } + // Detach from parent + item.getParent().removeChild(item); + // Clean mappings + categoryToMenuItem.remove(categoryId); + menuItemToCategory.remove(item); + + } + private MenuBar.Command menuBooleanCommand( final com.vaadin.tests.components.ComponentTestCase.Command booleanCommand, final Object data) { diff --git a/tests/src/com/vaadin/tests/components/AbstractComponentTestCase.java b/tests/src/com/vaadin/tests/components/AbstractComponentTestCase.java index 982ab02834..1b04198da0 100644 --- a/tests/src/com/vaadin/tests/components/AbstractComponentTestCase.java +++ b/tests/src/com/vaadin/tests/components/AbstractComponentTestCase.java @@ -15,6 +15,9 @@ import com.vaadin.ui.Layout.SpacingHandler; public abstract class AbstractComponentTestCase extends TestBase { + protected static final ThemeResource ICON_16_HELP_PNG_CACHEABLE = cacheableThemeResource("../runo/icons/16/help.png"); + protected static final ThemeResource ICON_16_FOLDER_PNG_CACHEABLE = cacheableThemeResource("../runo/icons/16/folder.png"); + protected static final ThemeResource ICON_16_ERROR_PNG_CACHEABLE = cacheableThemeResource("../runo/icons/16/error.png"); protected static final ThemeResource ICON_16_USER_PNG_CACHEABLE = cacheableThemeResource("../runo/icons/16/user.png"); protected static final ThemeResource ICON_16_USER_PNG_UNCACHEABLE = uncacheableThemeResource("../runo/icons/16/user.png"); protected static final ThemeResource ICON_32_ATTENTION_PNG_CACHEABLE = cacheableThemeResource("../runo/icons/32/attention.png"); diff --git a/tests/src/com/vaadin/tests/components/table/TableColumnAlignment.html b/tests/src/com/vaadin/tests/components/table/TableColumnAlignment.html new file mode 100644 index 0000000000..49bb86dbce --- /dev/null +++ b/tests/src/com/vaadin/tests/components/table/TableColumnAlignment.html @@ -0,0 +1,305 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
New Test
open/run/com.vaadin.tests.components.table.Tables?restartApplication
mouseClickvaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item022,8
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item737,12
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[1]/VMenuBar[0]#item185,10
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[2]/VMenuBar[0]#item273,6
mouseClickvaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item023,7
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item953,4
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[1]/VMenuBar[0]#item061,3
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[2]/VMenuBar[0]#item241,13
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[3]/VMenuBar[0]#item246,0
mouseClickvaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item024,9
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item941,3
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[1]/VMenuBar[0]#item124,1
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[2]/VMenuBar[0]#item251,8
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[3]/VMenuBar[0]#item132,11
mouseClickvaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item034,4
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item942,6
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[1]/VMenuBar[0]#item237,11
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[2]/VMenuBar[0]#item250,14
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[3]/VMenuBar[0]#item015,6
mouseClickvaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item013,10
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item942,3
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[1]/VMenuBar[0]#item342,9
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[2]/VMenuBar[0]#item232,14
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[3]/VMenuBar[0]#item236,4
mouseClickvaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item048,21
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item946,14
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[1]/VMenuBar[0]#item435,4
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[2]/VMenuBar[0]#item243,5
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[3]/VMenuBar[0]#item124,11
screenCapturealigned-1r-2c-3l-4r-5c
mouseClickvaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item035,4
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item937,3
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[1]/VMenuBar[0]#item050,6
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[2]/VMenuBar[0]#item260,6
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[3]/VMenuBar[0]#item038,12
mouseClickvaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item039,8
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item956,4
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[1]/VMenuBar[0]#item144,1
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[2]/VMenuBar[0]#item253,10
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[3]/VMenuBar[0]#item030,11
mouseClickvaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item049,9
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item944,6
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[1]/VMenuBar[0]#item244,4
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[2]/VMenuBar[0]#item236,13
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[3]/VMenuBar[0]#item054,6
mouseClickvaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item032,6
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item933,4
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[1]/VMenuBar[0]#item353,7
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[2]/VMenuBar[0]#item248,6
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[3]/VMenuBar[0]#item028,5
mouseClickvaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item029,10
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item934,12
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[1]/VMenuBar[0]#item436,1
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[2]/VMenuBar[0]#item234,3
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[3]/VMenuBar[0]#item031,8
screenCapturealigned-all-left
+ + diff --git a/tests/src/com/vaadin/tests/components/table/TableColumnHeaders b/tests/src/com/vaadin/tests/components/table/TableColumnHeaders new file mode 100644 index 0000000000..9f4e6cb8da --- /dev/null +++ b/tests/src/com/vaadin/tests/components/table/TableColumnHeaders @@ -0,0 +1,244 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
New Test
open/run/com.vaadin.tests.components.table.Tables?restartApplication
mouseClickvaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item063,19
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item554,5
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[1]/VMenuBar[0]#item043,3
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[2]/VMenuBar[0]#item317,3
mouseClickvaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item051,14
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item939,2
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[1]/VMenuBar[0]#item051,1
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[2]/VMenuBar[0]#item552,12
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[3]/VMenuBar[0]#item246,2
assertTextvaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]A nice column
mouseClickvaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item054,12
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item958,8
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[1]/VMenuBar[0]#item146,0
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[2]/VMenuBar[0]#item522,4
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[3]/VMenuBar[0]#item131,11
assertTextvaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]/domChild[2]A
mouseClickvaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item024,1
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item651,9
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[1]/VMenuBar[0]#item050,1
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[2]/VMenuBar[0]#item272,11
assertTextvaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]Property 1
assertTextvaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]/domChild[2]Property 2
assertTextvaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]/domChild[2]Property 3
mouseClickvaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item022,9
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item643,7
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[1]/VMenuBar[0]#item034,3
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[2]/VMenuBar[0]#item048,12
assertTextvaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]A nice column
assertTextvaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]/domChild[2]A
assertTextvaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]/domChild[2]
mouseClickvaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item049,13
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item644,10
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[1]/VMenuBar[0]#item072,5
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[2]/VMenuBar[0]#item340,10
assertNotVisiblevaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]A nice column


A


Property 3
mouseClickvaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item039,11
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item639,10
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[1]/VMenuBar[0]#item051,5
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[2]/VMenuBar[0]#item173,11
assertVisiblevaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]A nice column


A


Property 3
assertTextvaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]A nice column
assertTextvaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]/domChild[2]A
assertTextvaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]/domChild[2]Property 3
+ + diff --git a/tests/src/com/vaadin/tests/components/table/TableColumnIcons.html b/tests/src/com/vaadin/tests/components/table/TableColumnIcons.html new file mode 100644 index 0000000000..81b8be89fa --- /dev/null +++ b/tests/src/com/vaadin/tests/components/table/TableColumnIcons.html @@ -0,0 +1,185 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
New Test
open/run/com.vaadin.tests.components.table.Tables?restartApplication
mouseClickvaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item019,4
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item931,10
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[1]/VMenuBar[0]#item048,8
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[2]/VMenuBar[0]#item445,7
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[3]/VMenuBar[0]#item138,14
assertElementPresentvaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]/domChild[0]
mouseClickvaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item02,10
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item924,5
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[1]/VMenuBar[0]#item449,6
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[2]/VMenuBar[0]#item429,10
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[3]/VMenuBar[0]#item351,7
assertElementPresentvaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[4]/domChild[2]/domChild[0]
mouseClickvaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item020,12
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item945,14
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[1]/VMenuBar[0]#item936,2
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[2]/VMenuBar[0]#item446,14
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[3]/VMenuBar[0]#item472,10
assertElementPresentvaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[9]/domChild[2]/domChild[0]
screenCaptureicons-on-properties-1-5-10
mouseClickvaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item021,1
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item942,14
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[1]/VMenuBar[0]#item017,6
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[2]/VMenuBar[0]#item452,12
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[3]/VMenuBar[0]#item027,9
mouseClickvaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item045,10
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item953,2
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[1]/VMenuBar[0]#item945,1
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[2]/VMenuBar[0]#item441,5
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[3]/VMenuBar[0]#item013,5
assertElementNotPresentvaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[9]/domChild[2]/domChild[0]
assertElementNotPresentvaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]/domChild[0]
screenCaptureicon-on-5
+ + diff --git a/tests/src/com/vaadin/tests/components/table/TableGeneratedColumns.html b/tests/src/com/vaadin/tests/components/table/TableGeneratedColumns.html new file mode 100644 index 0000000000..19326e9f12 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/table/TableGeneratedColumns.html @@ -0,0 +1,223 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
New Test
open/run/com.vaadin.tests.components.table.Tables?restartApplication
mouseClickvaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item123,10
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item058,13
mouseClickvaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item044,2
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item241,5
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[1]/VMenuBar[0]#item036,4
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[2]/VMenuBar[0]#item853,17
mouseClickvaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item031,10
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item536,11
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[1]/VMenuBar[0]#item086,8
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[2]/VMenuBar[0]#item222,7
mouseClickvaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item027,8
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item837,8
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[1]/VMenuBar[0]#item477,10
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[2]/VMenuBar[0]#item245,10
mouseClickvaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]/domChild[0]1,11
dragAndDropvaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]/domChild[0]-100,0
screenCapturebutton-100%-after-column-resize
mouseClickvaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item045,21
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item830,2
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[1]/VMenuBar[0]#item4109,7
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[2]/VMenuBar[0]#item371,10
screenCapturebutton-and-label
open/run/com.vaadin.tests.components.table.Tables
screenCapturebutton-and-label-after-reload
mouseClickvaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item017,10
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item948,11
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[1]/VMenuBar[0]#item239,10
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[2]/VMenuBar[0]#item253,13
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[3]/VMenuBar[0]#item216,6
mouseClickvaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item017,10
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item948,11
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[1]/VMenuBar[0]#item339,10
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[2]/VMenuBar[0]#item253,13
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[3]/VMenuBar[0]#item216,6
screenCapturelabel-aligned-right
dragAndDropvaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]-20,0
dragAndDropvaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]20,0
screenCapturelabel-aligned-right
+ + diff --git a/tests/src/com/vaadin/tests/components/table/Tables.java b/tests/src/com/vaadin/tests/components/table/Tables.java index dc11022027..f663fbb48b 100644 --- a/tests/src/com/vaadin/tests/components/table/Tables.java +++ b/tests/src/com/vaadin/tests/components/table/Tables.java @@ -8,9 +8,14 @@ import java.util.List; import com.vaadin.event.Action; import com.vaadin.event.Action.Handler; import com.vaadin.event.ItemClickEvent.ItemClickListener; +import com.vaadin.terminal.Resource; import com.vaadin.tests.components.select.AbstractSelectTestCase; import com.vaadin.ui.AbstractSelect.MultiSelectMode; +import com.vaadin.ui.Button; +import com.vaadin.ui.Component; +import com.vaadin.ui.Label; import com.vaadin.ui.Table; +import com.vaadin.ui.Table.ColumnGenerator; import com.vaadin.ui.Table.ColumnResizeEvent; import com.vaadin.ui.Table.ColumnResizeListener; import com.vaadin.ui.Table.FooterClickEvent; @@ -25,7 +30,7 @@ public class Tables extends AbstractSelectTestCase protected static final String CATEGORY_ROWS = "Rows"; private static final String CATEGORY_HEADER = "Header"; private static final String CATEGORY_FOOTER = "Footer"; - private static final String CATEGORY_VISIBLE_COLUMNS = "Visible columns"; + private static final String CATEGORY_COLUMNS = "Columns"; @Override protected Class getTestClass() { @@ -33,7 +38,15 @@ public class Tables extends AbstractSelectTestCase } /* COMMANDS */ - private Command visibleColumnCommand = new Command() { + private Command columnAlignmentCommand = new Command() { + + public void execute(T c, String alignment, Object propertyId) { + c.setColumnAlignment(propertyId, alignment); + } + + }; + + private Command columnVisibleCommand = new Command() { public void execute(Table c, Boolean visible, Object propertyId) { List visibleColumns = new ArrayList(Arrays.asList(c .getVisibleColumns())); @@ -50,6 +63,14 @@ public class Tables extends AbstractSelectTestCase } }; + private Command columnCollapsed = new Command() { + + public void execute(T c, Boolean collapsed, Object propertyId) { + c.setColumnCollapsed(propertyId, collapsed); + + } + }; + protected Command columnResizeListenerCommand = new Command() { public void execute(Table c, Boolean value, Object data) { @@ -107,16 +128,10 @@ public class Tables extends AbstractSelectTestCase } }; - public class Alignments { - - } + protected Command alignColumnLeftCommand = new Command() { - protected Command columnAlignmentCommand = new Command() { - - public void execute(T c, Alignments value, Object data) { - // TODO - // for (Object propertyId : c.getContainerPropertyIds()) { - // } + public void execute(T c, Object propertyId, Object data) { + c.setColumnAlignment(propertyId, (String) data); } }; @@ -140,6 +155,110 @@ public class Tables extends AbstractSelectTestCase } } }; + private Command columnWidthCommand = new Command() { + + public void execute(T c, Integer width, Object propertyId) { + c.setColumnWidth(propertyId, width); + + } + }; + + private Command columnIconCommand = new Command() { + + public void execute(T c, Resource icon, Object propertyId) { + c.setColumnIcon(propertyId, icon); + + } + }; + private Command columnHeaderModeCommand = new Command() { + + public void execute(T c, Integer columnHeaderMode, Object data) { + c.setColumnHeaderMode(columnHeaderMode); + + } + }; + private Command columnHeaderCommand = new Command() { + + public void execute(T c, String header, Object propertyId) { + c.setColumnHeader(propertyId, header); + + } + }; + private Command columnExpandRatioCommand = new Command() { + + public void execute(T c, Float expandRatio, Object propertyId) { + c.setColumnExpandRatio(propertyId, expandRatio); + } + }; + + private class GeneratedColumn { + private Class type; + private String width; + + public GeneratedColumn(Class type, String width) { + super(); + this.type = type; + this.width = width; + } + } + + String generatedColumnId = "Generated "; + int generatedColumnNextNr = 1; + + private Command addGeneratedColumnCommand = new Command() { + + public void execute(T c, final GeneratedColumn col, Object data) { + while (c.getColumnGenerator(generatedColumnId + + generatedColumnNextNr) != null) { + generatedColumnNextNr++; + } + + c.addGeneratedColumn(generatedColumnId + generatedColumnNextNr, + new ColumnGenerator() { + + public Component generateCell(Table source, + Object itemId, Object columnId) { + if (col.type == Button.class) { + Button b = new Button(); + b.setCaption(itemId + "/" + columnId); + b.setWidth(col.width); + return b; + } else if (col.type == Label.class) { + Label l = new Label(); + l.setValue(itemId + "/" + columnId); + l.setWidth(col.width); + return l; + } + + return null; + } + }); + generatedColumnNextNr++; + createColumnOptions(false); + + } + }; + private Command removeGeneratedColumnsCommand = new Command() { + + public void execute(T c, Object value, Object data) { + for (int i = 0; i < generatedColumnNextNr; i++) { + String columnId = generatedColumnId + i; + if (c.getColumnGenerator(columnId) != null) { + c.removeGeneratedColumn(columnId); + } + + } + createColumnOptions(false); + + } + }; + private Command setSortEnabledCommand = new Command() { + + public void execute(T c, Boolean value, Object data) { + c.setSortDisabled(!value); + + } + }; /* COMMANDS END */ @@ -168,9 +287,52 @@ public class Tables extends AbstractSelectTestCase createColumnReorderingAllowedCheckbox(CATEGORY_FEATURES); createColumnCollapsingAllowedCheckbox(CATEGORY_FEATURES); - createVisibleColumnsMultiToggle(CATEGORY_VISIBLE_COLUMNS); createContextMenuAction(CATEGORY_FEATURES); + createColumnHeaderMode(CATEGORY_FEATURES); + createAddGeneratedColumnAction(CATEGORY_FEATURES); + + createBooleanAction("Sort enabled", CATEGORY_FEATURES, true, + setSortEnabledCommand); + createColumnOptions(true); + } + + private void createAddGeneratedColumnAction(String categoryFeatures) { + String category = "Generated columns"; + createCategory(category, categoryFeatures); + createClickAction("Add Button", category, addGeneratedColumnCommand, + new GeneratedColumn(Button.class, null)); + createClickAction("Add 200px wide Button", category, + addGeneratedColumnCommand, new GeneratedColumn(Button.class, + "200px")); + createClickAction("Add 100% wide Button", category, + addGeneratedColumnCommand, new GeneratedColumn(Button.class, + "100%")); + createClickAction("Add Label", category, addGeneratedColumnCommand, + new GeneratedColumn(Label.class, null)); + createClickAction("Add 100px Label", category, + addGeneratedColumnCommand, new GeneratedColumn(Label.class, + "100px")); + createClickAction("Add 100% wide Label", category, + addGeneratedColumnCommand, new GeneratedColumn(Label.class, + "100%")); + + createClickAction("Remove generated columns", category, + removeGeneratedColumnsCommand, null); + } + + private void createColumnHeaderMode(String category) { + LinkedHashMap columnHeaderModeOptions = new LinkedHashMap(); + columnHeaderModeOptions.put("Hidden", Table.COLUMN_HEADER_MODE_HIDDEN); + columnHeaderModeOptions.put("Id", Table.COLUMN_HEADER_MODE_ID); + columnHeaderModeOptions.put("Explicit", + Table.COLUMN_HEADER_MODE_EXPLICIT); + columnHeaderModeOptions.put("Explicit defaults id", + Table.COLUMN_HEADER_MODE_EXPLICIT_DEFAULTS_ID); + + createSelectAction("Column header mode", category, + columnHeaderModeOptions, "Explicit defaults id", + columnHeaderModeCommand); } private void createValueSelection(String categorySelection) { @@ -234,14 +396,104 @@ public class Tables extends AbstractSelectTestCase }); } - private void createVisibleColumnsMultiToggle(String category) { - LinkedHashMap options = new LinkedHashMap(); + private void createColumnOptions(boolean init) { + if (!init && !hasCategory(CATEGORY_COLUMNS)) { + return; + } + + long start = System.currentTimeMillis(); + if (!init) { + removeCategory(CATEGORY_COLUMNS); + } + for (Object id : getComponent().getContainerPropertyIds()) { - options.put(id.toString(), id); + String name = id.toString(); + createCategory(name, CATEGORY_COLUMNS); + createColumnOption(name, id); + } + for (int i = 0; i < generatedColumnNextNr; i++) { + String id = generatedColumnId + i; + String name = id; + if (getTestComponents().get(0).getColumnGenerator(id) != null) { + createCategory(name, CATEGORY_COLUMNS); + createColumnOption(name, id); + } + } + + long end = System.currentTimeMillis(); + System.err.println("Create options took " + (end - start) + "ms"); + } + + private class Timer { + private long start, last; + + private Timer() { + start = System.currentTimeMillis(); + last = System.currentTimeMillis(); } - createMultiToggleAction("Visible columns", category, options, - visibleColumnCommand, true); + public void log(String msg) { + long now = System.currentTimeMillis(); + System.err.println("[This: " + (now - last) + "ms, total: " + + (now - start) + "ms]: " + msg); + last = now; + } + } + + private void createColumnOption(String category, Object propertyId) { + Timer t = new Timer(); + createBooleanAction("Visible", category, true, columnVisibleCommand, + propertyId); + t.log("Visible"); + createBooleanAction("Collapsed", category, false, columnCollapsed, + propertyId); + t.log("Collapsed"); + LinkedHashMap options = new LinkedHashMap(); + options.put("Left", Table.ALIGN_LEFT); + options.put("Center", Table.ALIGN_CENTER); + options.put("Right", Table.ALIGN_RIGHT); + + createSelectAction("Alignment", category, options, "Left", + columnAlignmentCommand, propertyId); + t.log("Alignment"); + LinkedHashMap widthOptions = new LinkedHashMap(); + widthOptions.put("- remove -", -1); + for (int i : new int[] { 0, 1, 10, 100, 200, 400 }) { + widthOptions.put(i + "px", i); + } + createSelectAction("Width", category, widthOptions, "- remove -", + columnWidthCommand, propertyId); + t.log("Width"); + + LinkedHashMap iconOptions = new LinkedHashMap(); + iconOptions.put("- none -", null); + iconOptions.put("ok 16x16", ICON_16_USER_PNG_CACHEABLE); + iconOptions.put("help 16x16", ICON_16_HELP_PNG_CACHEABLE); + iconOptions.put("folder 16x16", ICON_16_FOLDER_PNG_CACHEABLE); + iconOptions.put("attention 32x32", ICON_32_ATTENTION_PNG_CACHEABLE); + createSelectAction("Icon", category, iconOptions, "- none -", + columnIconCommand, propertyId); + + t.log("Icon"); + LinkedHashMap columnHeaderOptions = new LinkedHashMap(); + columnHeaderOptions.put("- none -", null); + columnHeaderOptions.put("A", "A"); + columnHeaderOptions.put("A nice column", "A nice column"); + + createSelectAction("Column header", category, columnHeaderOptions, + "- none -", columnHeaderCommand, propertyId); + t.log("Header"); + LinkedHashMap expandOptions = new LinkedHashMap(); + expandOptions.put("- remove -", -1f); + for (float i : new float[] { 0, 1, 2, 3, 4, 5 }) { + expandOptions.put(i + "", i); + } + createSelectAction("Expand ratio", category, expandOptions, + "- remove -", columnExpandRatioCommand, propertyId); + t.log("Expand"); + // Footer text (move) + // Header text (move) + } private void createRowHeaderModeSelect(String category) { @@ -318,20 +570,9 @@ public class Tables extends AbstractSelectTestCase } // TODO: - // Visible columns - // Column icons - // Column alignments - // Column width - // Column expand ratio - // Column collapse // setCurrentPageFirstItemIndex() - // setColumnHeaderMode(int) - // setRowHeaderMode(int) - // Generated column // Cell style generator // Editable - // Context menu - // Cache rate // CurrentPageFirstItemId @@ -433,4 +674,13 @@ public class Tables extends AbstractSelectTestCase + event.getButtonName()); } + @Override + protected void updateContainer() { + super.updateContainer(); + + // Recreate for the new properties + createColumnOptions(false); + + } + } -- 2.39.5