]> source.dussan.org Git - vaadin-framework.git/commitdiff
Trigger ComplexRenderer.setContentVisible(false) initially #13334
authorJohn Ahlroos <john@vaadin.com>
Tue, 5 Aug 2014 10:58:00 +0000 (13:58 +0300)
committerTeemu Suo-Anttila <teemusa@vaadin.com>
Wed, 6 Aug 2014 09:32:51 +0000 (09:32 +0000)
Change-Id: Id2ebb2f7f6c0480ab6353df0ae87fea3b1153ea0

client/src/com/vaadin/client/ui/grid/Grid.java
uitest/src/com/vaadin/tests/components/grid/GridClientRenderers.java
uitest/src/com/vaadin/tests/widgetset/client/grid/GridClientColumnRendererConnector.java

index a32a31b0291b7ecb86432aed2b785722611f88bb..cff9f684541e98906bc39f278743991d574a5490 100644 (file)
@@ -1238,7 +1238,7 @@ public class Grid<T> extends Composite implements
                             Object value = column.getValue(rowData);
                             clxRenderer.render(cell, value);
 
-                        } else if (usedToHaveData) {
+                        } else {
                             // Prepare cell for no data
                             clxRenderer.setContentVisible(cell, false);
                         }
index d1aec66dbd6b8760ea970a7d87e07f7d103af969..fd3c8d5b2f5ffe5977b941c33a1a9ad4c2d30873 100644 (file)
@@ -17,6 +17,7 @@ package com.vaadin.tests.components.grid;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertTrue;
 
 import org.junit.Test;
@@ -80,7 +81,7 @@ public class GridClientRenderers extends MultiBrowserTest {
         $(NativeButtonElement.class).caption("Add").first().click();
 
         // Click the button in cell 1,1
-        TestBenchElement cell = getGrid().getCell(1, 1);
+        TestBenchElement cell = getGrid().getCell(1, 2);
         WebElement gwtButton = cell.findElement(By.tagName("button"));
         gwtButton.click();
 
@@ -102,7 +103,7 @@ public class GridClientRenderers extends MultiBrowserTest {
         $(NativeButtonElement.class).caption("DetachAttach").first().click();
 
         // Click the button in cell 1,1
-        TestBenchElement cell = getGrid().getCell(1, 1);
+        TestBenchElement cell = getGrid().getCell(1, 2);
         WebElement gwtButton = cell.findElement(By.tagName("button"));
         gwtButton.click();
 
@@ -159,17 +160,28 @@ public class GridClientRenderers extends MultiBrowserTest {
 
         openTestURL();
 
-        addColumn(Renderers.CPLX_RENDERER);
+        // Test initial renderering with contentVisible = False
+        TestBenchElement cell = getGrid().getCell(51, 1);
+        String backgroundColor = cell.getCssValue("backgroundColor");
+        assertEquals("Background color was not red.", colorRed, backgroundColor);
 
+        // data arrives...
         sleep((int) (latency * SLEEP_MULTIPLIER));
 
+        // Content becomes visible
+        cell = getGrid().getCell(51, 1);
+        backgroundColor = cell.getCssValue("backgroundColor");
+        assertNotEquals("Background color was red.", colorRed, backgroundColor);
+
+        // scroll down, new cells becomes contentVisible = False
         getGrid().scrollToRow(60);
+
         // Cell should be red (setContentVisible set cell red)
-        TestBenchElement cell = getGrid().getCell(51, 1);
-        String backgroundColor = cell.getCssValue("backgroundColor");
+        cell = getGrid().getCell(55, 1);
+        backgroundColor = cell.getCssValue("backgroundColor");
         assertEquals("Background color was not red.", colorRed, backgroundColor);
 
-        // Wait for data to arrive
+        // data arrives...
         sleep((int) (latency * SLEEP_MULTIPLIER));
 
         // Cell should no longer be red
index e685034c7bad45cb363be3ed984a539c2d296ac2..c0e57e97aa5a6223cb0b270ebbd5c7e241146919 100644 (file)
@@ -64,7 +64,7 @@ public class GridClientColumnRendererConnector extends
     private class DelayedDataSource implements DataSource<String> {
 
         private DataSource<String> ds;
-        private int firstRowIndex;
+        private int firstRowIndex = -1;
         private int numberOfRows;
         private DataChangeHandler dataChangeHandler;
         private int latency;
@@ -139,6 +139,11 @@ public class GridClientColumnRendererConnector extends
         grid.addColumn(c);
         grid.getHeader().getDefaultRow().getCell(0).setText("Column 1");
 
+        // Add another column with a custom complex renderer
+        c = createColumnWithRenderer(Renderers.CPLX_RENDERER);
+        grid.addColumn(c);
+        grid.getHeader().getDefaultRow().getCell(1).setText("Column 2");
+
         // Add method for testing sort event firing
         grid.addSortHandler(new SortEventHandler<String>() {
             @Override