aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrik Lindström <patrik@vaadin.com>2014-07-16 02:57:20 +0300
committerVaadin Code Review <review@vaadin.com>2014-07-17 11:43:16 +0000
commit446c51e0f055aaf9d78020e9370e7d2dfbb451d1 (patch)
tree1e054fc41b2c182d717e9696c8c232beab1d05b9
parent59cdaeddf36f91b0e08464d7cd2beb3dd110445f (diff)
downloadvaadin-framework-446c51e0f055aaf9d78020e9370e7d2dfbb451d1.tar.gz
vaadin-framework-446c51e0f055aaf9d78020e9370e7d2dfbb451d1.zip
Add pure client-side test application for Grid (#13334)
Change-Id: I853a91c20e80361ef5daeb31024597200acad1d9
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicClientFeaturesTest.java69
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeaturesTest.java4
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridClientSelectionTest.java35
-rw-r--r--uitest/src/com/vaadin/tests/widgetset/TestingWidgetSet.gwt.xml2
-rw-r--r--uitest/src/com/vaadin/tests/widgetset/client/grid/GridBasicClientFeatures.java254
-rw-r--r--uitest/src/com/vaadin/tests/widgetset/client/grid/GridBasicClientFeaturesConnector.java36
-rw-r--r--uitest/src/com/vaadin/tests/widgetset/client/grid/PureGWTTestApplication.java308
-rw-r--r--uitest/src/com/vaadin/tests/widgetset/server/grid/GridBasicClientFeatures.java41
8 files changed, 747 insertions, 2 deletions
diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicClientFeaturesTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicClientFeaturesTest.java
new file mode 100644
index 0000000000..95b45b262e
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicClientFeaturesTest.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.components.grid.basicfeatures;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.interactions.Actions;
+
+import com.vaadin.testbench.TestBenchElement;
+import com.vaadin.tests.components.grid.GridElement;
+import com.vaadin.tests.widgetset.server.grid.GridBasicClientFeatures;
+
+/**
+ * Variant of GridBasicFeaturesTest to be used with GridBasicClientFeatures.
+ *
+ * @since
+ * @author Vaadin Ltd
+ */
+public abstract class GridBasicClientFeaturesTest extends GridBasicFeaturesTest {
+
+ @Override
+ protected Class<?> getUIClass() {
+ return GridBasicClientFeatures.class;
+ }
+
+ @Override
+ protected GridElement getGridElement() {
+ return ((TestBenchElement) findElement(By.className("v-grid")))
+ .wrap(GridElement.class);
+ }
+
+ @Override
+ protected void selectMenu(String menuCaption) {
+ WebElement menuElement = getMenuElement(menuCaption);
+ new Actions(getDriver()).moveToElement(menuElement).perform();
+ }
+
+ private WebElement getMenuElement(String menuCaption) {
+ return getDriver().findElement(
+ By.xpath("//td[text() = '" + menuCaption + "']"));
+ }
+
+ @Override
+ protected void selectMenuPath(String... menuCaptions) {
+ new Actions(getDriver()).moveToElement(getMenuElement(menuCaptions[0]))
+ .click().perform();
+ for (int i = 1; i < menuCaptions.length - 1; ++i) {
+ selectMenu(menuCaptions[i]);
+ }
+ new Actions(getDriver())
+ .moveToElement(
+ getMenuElement(menuCaptions[menuCaptions.length - 1]))
+ .click().perform();
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeaturesTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeaturesTest.java
index 3651a0c919..79501f50ac 100644
--- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeaturesTest.java
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeaturesTest.java
@@ -33,12 +33,12 @@ public abstract class GridBasicFeaturesTest extends MultiBrowserTest {
return GridBasicFeatures.class;
}
- private void selectSubMenu(String menuCaption) {
+ protected void selectSubMenu(String menuCaption) {
selectMenu(menuCaption);
new Actions(getDriver()).moveByOffset(100, 0).build().perform();
}
- private void selectMenu(String menuCaption) {
+ protected void selectMenu(String menuCaption) {
getDriver().findElement(
By.xpath("//span[text() = '" + menuCaption + "']")).click();
}
diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridClientSelectionTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridClientSelectionTest.java
new file mode 100644
index 0000000000..cb70c28b7d
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridClientSelectionTest.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.components.grid.basicfeatures;
+
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+public class GridClientSelectionTest extends GridBasicClientFeaturesTest {
+
+ @Test
+ public void testChangeSelectionMode() {
+ openTestURL();
+
+ selectMenuPath("Component", "State", "Selection mode", "none");
+ assertTrue("First column was selection column", getGridElement()
+ .getCell(0, 0).getText().equals("(0, 0)"));
+ selectMenuPath("Component", "State", "Selection mode", "multi");
+ assertTrue("First column was not selection column", getGridElement()
+ .getCell(0, 1).getText().equals("(0, 0)"));
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/widgetset/TestingWidgetSet.gwt.xml b/uitest/src/com/vaadin/tests/widgetset/TestingWidgetSet.gwt.xml
index fd52e5cd0e..ac93efd7d4 100644
--- a/uitest/src/com/vaadin/tests/widgetset/TestingWidgetSet.gwt.xml
+++ b/uitest/src/com/vaadin/tests/widgetset/TestingWidgetSet.gwt.xml
@@ -4,6 +4,8 @@
<!-- Inherit the DefaultWidgetSet -->
<inherits name="com.vaadin.DefaultWidgetSet" />
+ <inherits name="com.google.gwt.user.theme.standard.Standard" />
+
<replace-with class="com.vaadin.tests.widgetset.client.CustomUIConnector">
<when-type-is class="com.vaadin.client.ui.ui.UIConnector" />
</replace-with>
diff --git a/uitest/src/com/vaadin/tests/widgetset/client/grid/GridBasicClientFeatures.java b/uitest/src/com/vaadin/tests/widgetset/client/grid/GridBasicClientFeatures.java
new file mode 100644
index 0000000000..857ff14528
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/widgetset/client/grid/GridBasicClientFeatures.java
@@ -0,0 +1,254 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.widgetset.client.grid;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Random;
+
+import com.google.gwt.core.client.Scheduler.ScheduledCommand;
+import com.vaadin.client.ui.grid.FlyweightCell;
+import com.vaadin.client.ui.grid.Grid;
+import com.vaadin.client.ui.grid.Grid.SelectionMode;
+import com.vaadin.client.ui.grid.GridColumn;
+import com.vaadin.client.ui.grid.Renderer;
+import com.vaadin.client.ui.grid.datasources.ListDataSource;
+import com.vaadin.client.ui.grid.renderers.DateRenderer;
+import com.vaadin.client.ui.grid.renderers.HtmlRenderer;
+import com.vaadin.client.ui.grid.renderers.NumberRenderer;
+import com.vaadin.client.ui.grid.renderers.TextRenderer;
+import com.vaadin.tests.widgetset.client.grid.GridBasicClientFeatures.Data;
+
+/**
+ * Grid basic client features test application.
+ *
+ * @since
+ * @author Vaadin Ltd
+ */
+public class GridBasicClientFeatures extends
+ PureGWTTestApplication<Grid<List<Data>>> {
+
+ public static enum Renderers {
+ TEXT_RENDERER, HTML_RENDERER, NUMBER_RENDERER, DATE_RENDERER;
+ }
+
+ private static final int MANUALLY_FORMATTED_COLUMNS = 4;
+ public static final int COLUMNS = 11;
+ public static final int ROWS = 1000;
+
+ private final Grid<List<Data>> grid;
+ private final List<List<Data>> data;
+ private final ListDataSource<List<Data>> ds;
+
+ /**
+ * Our basic data object
+ */
+ public final static class Data {
+ Object value;
+ }
+
+ /**
+ * Convenience method for creating a list of Data objects to be used as a
+ * Row in the data source
+ *
+ * @param cols
+ * number of columns (items) to include in the row
+ * @return
+ */
+ private List<Data> createDataRow(int cols) {
+ List<Data> list = new ArrayList<Data>(cols);
+ for (int i = 0; i < cols; ++i) {
+ list.add(new Data());
+ }
+ data.add(list);
+ return list;
+ }
+
+ @SuppressWarnings("unchecked")
+ public GridBasicClientFeatures() {
+ super(new Grid<List<Data>>());
+
+ // Initialize data source
+ data = new ArrayList<List<Data>>();
+ {
+ Random rand = new Random();
+ rand.setSeed(13334);
+ long timestamp = 0;
+ for (int row = 0; row < ROWS; row++) {
+
+ List<Data> datarow = createDataRow(COLUMNS);
+ Data d;
+
+ int col = 0;
+ for (; col < COLUMNS - MANUALLY_FORMATTED_COLUMNS; ++col) {
+ d = datarow.get(col);
+ d.value = "(" + row + ", " + col + ")";
+ }
+
+ d = datarow.get(col++);
+ d.value = Integer.valueOf(row);
+
+ d = datarow.get(col++);
+ d.value = new Date(timestamp);
+ timestamp += 91250000; // a bit over a day, just to get
+ // variation
+
+ d = datarow.get(col++);
+ d.value = "<b>" + row + "</b>";
+
+ d = datarow.get(col++);
+ d.value = Integer.valueOf(rand.nextInt());
+ }
+ }
+
+ ds = new ListDataSource<List<Data>>(data);
+ grid = getTestedWidget();
+ grid.setDataSource(ds);
+ grid.setSelectionMode(SelectionMode.NONE);
+
+ // Create a bunch of grid columns
+
+ // Data source layout:
+ // text (String) * (COLUMNS - MANUALLY_FORMATTED_COLUMNS + 1) |
+ // rownumber (Integer) | some date (Date) | row number as HTML (String)
+ // | random value (Integer)
+
+ int col = 0;
+
+ // Text times COLUMNS - MANUALLY_FORMATTED_COLUMNS
+ for (col = 0; col < COLUMNS - MANUALLY_FORMATTED_COLUMNS; ++col) {
+
+ final int c = col;
+
+ grid.addColumn(new GridColumn<String, List<Data>>(
+ createRenderer(Renderers.TEXT_RENDERER)) {
+ @Override
+ public String getValue(List<Data> row) {
+ return (String) row.get(c).value;
+ }
+ });
+
+ }
+
+ // Integer row number
+ {
+ final int c = col++;
+ grid.addColumn(new GridColumn<Integer, List<Data>>(
+ createRenderer(Renderers.NUMBER_RENDERER)) {
+ @Override
+ public Integer getValue(List<Data> row) {
+ return (Integer) row.get(c).value;
+ }
+ });
+ }
+
+ // Some date
+ {
+ final int c = col++;
+ grid.addColumn(new GridColumn<Date, List<Data>>(
+ createRenderer(Renderers.DATE_RENDERER)) {
+ @Override
+ public Date getValue(List<Data> row) {
+ return (Date) row.get(c).value;
+ }
+ });
+ }
+
+ // Row number as a HTML string
+ {
+ final int c = col++;
+ grid.addColumn(new GridColumn<String, List<Data>>(
+ createRenderer(Renderers.HTML_RENDERER)) {
+ @Override
+ public String getValue(List<Data> row) {
+ return (String) row.get(c).value;
+ }
+ });
+ }
+
+ // Random integer value
+ {
+ final int c = col++;
+ grid.addColumn(new GridColumn<Integer, List<Data>>(
+ createRenderer(Renderers.NUMBER_RENDERER)) {
+ @Override
+ public Integer getValue(List<Data> row) {
+ return (Integer) row.get(c).value;
+ }
+ });
+ }
+
+ //
+ // Populate the menu
+ //
+
+ addMenuCommand("multi", new ScheduledCommand() {
+ @Override
+ public void execute() {
+ grid.setSelectionMode(SelectionMode.MULTI);
+ }
+ }, "Component", "State", "Selection mode");
+
+ addMenuCommand("single", new ScheduledCommand() {
+
+ @Override
+ public void execute() {
+ grid.setSelectionMode(SelectionMode.SINGLE);
+ }
+ }, "Component", "State", "Selection mode");
+
+ addMenuCommand("none", new ScheduledCommand() {
+
+ @Override
+ public void execute() {
+ grid.setSelectionMode(SelectionMode.NONE);
+ }
+ }, "Component", "State", "Selection mode");
+
+ grid.getElement().getStyle().setZIndex(0);
+ add(grid);
+ }
+
+ /**
+ * Creates a a renderer for a {@link Renderers}
+ */
+ @SuppressWarnings("rawtypes")
+ private final Renderer createRenderer(Renderers renderer) {
+ switch (renderer) {
+ case TEXT_RENDERER:
+ return new TextRenderer();
+
+ case HTML_RENDERER:
+ return new HtmlRenderer() {
+
+ @Override
+ public void render(FlyweightCell cell, String htmlString) {
+ super.render(cell, "<b>" + htmlString + "</b>");
+ }
+ };
+
+ case NUMBER_RENDERER:
+ return new NumberRenderer<Integer>();
+
+ case DATE_RENDERER:
+ return new DateRenderer();
+
+ default:
+ return new TextRenderer();
+ }
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/widgetset/client/grid/GridBasicClientFeaturesConnector.java b/uitest/src/com/vaadin/tests/widgetset/client/grid/GridBasicClientFeaturesConnector.java
new file mode 100644
index 0000000000..4b640e84e5
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/widgetset/client/grid/GridBasicClientFeaturesConnector.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.widgetset.client.grid;
+
+import com.vaadin.client.ui.AbstractComponentConnector;
+import com.vaadin.shared.ui.Connect;
+
+/**
+ * Connector for the GridClientBasicFeatures ApplicationWidget
+ *
+ * @since
+ * @author Vaadin Ltd
+ */
+@Connect(com.vaadin.tests.widgetset.server.grid.GridBasicClientFeatures.GridTestComponent.class)
+public class GridBasicClientFeaturesConnector extends
+ AbstractComponentConnector {
+
+ @Override
+ public GridBasicClientFeatures getWidget() {
+ return (GridBasicClientFeatures) super.getWidget();
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/widgetset/client/grid/PureGWTTestApplication.java b/uitest/src/com/vaadin/tests/widgetset/client/grid/PureGWTTestApplication.java
new file mode 100644
index 0000000000..e9c126f232
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/widgetset/client/grid/PureGWTTestApplication.java
@@ -0,0 +1,308 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.widgetset.client.grid;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.google.gwt.core.client.Scheduler.ScheduledCommand;
+import com.google.gwt.dom.client.Style.Unit;
+import com.google.gwt.user.client.Element;
+import com.google.gwt.user.client.ui.DockLayoutPanel;
+import com.google.gwt.user.client.ui.LayoutPanel;
+import com.google.gwt.user.client.ui.MenuBar;
+import com.google.gwt.user.client.ui.Panel;
+import com.vaadin.client.ui.SubPartAware;
+
+/**
+ * Pure GWT Test Application base for testing features of a single widget;
+ * provides a menu system and convenience method for adding items to it.
+ *
+ * @since
+ * @author Vaadin Ltd
+ */
+public abstract class PureGWTTestApplication<T> extends DockLayoutPanel
+ implements SubPartAware {
+
+ /**
+ * Class describing a menu item with an associated action
+ */
+ public static class Command {
+ private final String title;
+ private final ScheduledCommand command;
+
+ /**
+ * Creates a Command object, which is used as an action entry in the
+ * Menu
+ *
+ * @param t
+ * a title string
+ * @param cmd
+ * a scheduled command that is executed when this item is
+ * selected
+ */
+ public Command(String t, ScheduledCommand cmd) {
+ title = t;
+ command = cmd;
+ }
+
+ /**
+ * Returns the title of this command item
+ *
+ * @return a title string
+ */
+ public final String getTitle() {
+ return title;
+ }
+
+ /**
+ * Returns the actual scheduled command of this command item
+ *
+ * @return a scheduled command
+ */
+ public final ScheduledCommand getCommand() {
+ return command;
+ }
+ }
+
+ /**
+ * A menu object, providing a complete system for building a hierarchical
+ * menu bar system.
+ */
+ public static class Menu {
+
+ private final String title;
+ private final MenuBar menubar;
+ private final List<Menu> children;
+ private final List<Command> items;
+
+ /**
+ * Create base-level menu, without a title. This is the root menu bar,
+ * which can be attached to a client application window. All other Menus
+ * should be added as child menus to this Menu, in order to maintain a
+ * nice hierarchy.
+ */
+ private Menu() {
+ title = "";
+ menubar = new MenuBar();
+ children = new ArrayList<Menu>();
+ items = new ArrayList<Command>();
+ }
+
+ /**
+ * Create a sub-menu, with a title.
+ *
+ * @param title
+ */
+ public Menu(String title) {
+ this.title = title;
+ menubar = new MenuBar(true);
+ children = new ArrayList<Menu>();
+ items = new ArrayList<Command>();
+ }
+
+ /**
+ * Return the GWT {@link MenuBar} object that provides the widget for
+ * this Menu
+ *
+ * @return a menubar object
+ */
+ public MenuBar getMenuBar() {
+ return menubar;
+ }
+
+ /**
+ * Returns the title of this menu entry
+ *
+ * @return a title string
+ */
+ public String getTitle() {
+ return title;
+ }
+
+ /**
+ * Adds a child menu entry to this menu. The title for this entry is
+ * taken from the Menu object argument.
+ *
+ * @param m
+ * another Menu object
+ */
+ public void addChildMenu(Menu m) {
+ menubar.addItem(m.title, m.menubar);
+ children.add(m);
+ }
+
+ /**
+ * Tests for the existence of a child menu by title at this level of the
+ * menu hierarchy
+ *
+ * @param title
+ * a title string
+ * @return true, if this menu has a direct child menu with the specified
+ * title, otherwise false
+ */
+ public boolean hasChildMenu(String title) {
+ return getChildMenu(title) != null;
+ }
+
+ /**
+ * Gets a reference to a child menu with a certain title, that is a
+ * direct child of this menu level.
+ *
+ * @param title
+ * a title string
+ * @return a Menu object with the specified title string, or null, if
+ * this menu doesn't have a direct child with the specified
+ * title.
+ */
+ public Menu getChildMenu(String title) {
+ for (Menu m : children) {
+ if (m.title.equals(title)) {
+ return m;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Adds a command item to the menu. When the entry is clicked, the
+ * command is executed.
+ *
+ * @param cmd
+ * a command object.
+ */
+ public void addCommand(Command cmd) {
+ menubar.addItem(cmd.title, cmd.command);
+ items.add(cmd);
+ }
+
+ /**
+ * Tests for the existence of a {@link Command} that is the direct child
+ * of this level of menu.
+ *
+ * @param title
+ * the command's title
+ * @return true, if this menu level includes a command item with the
+ * specified title. Otherwise false.
+ */
+ public boolean hasCommand(String title) {
+ return getCommand(title) != null;
+ }
+
+ /**
+ * Gets a reference to a {@link Command} item that is the direct child
+ * of this level of menu.
+ *
+ * @param title
+ * the command's title
+ * @return a command, if found in this menu level, otherwise null.
+ */
+ public Command getCommand(String title) {
+ for (Command c : items) {
+ if (c.title.equals(title)) {
+ return c;
+ }
+ }
+ return null;
+ }
+ }
+
+ /**
+ * Base level menu object, provides visible menu bar
+ */
+ private final Menu menu;
+ private final T testedWidget;
+
+ /**
+ * This constructor creates the basic menu bar and adds it to the top of the
+ * parent {@link DockLayoutPanel}
+ */
+ protected PureGWTTestApplication(T widget) {
+ super(Unit.PX);
+ Panel menuPanel = new LayoutPanel();
+ menu = new Menu();
+ menuPanel.add(menu.getMenuBar());
+ addNorth(menuPanel, 25);
+ testedWidget = widget;
+ }
+
+ /**
+ * Connect an item to the menu structure
+ *
+ * @param cmd
+ * a scheduled command; see google's docs
+ * @param menupath
+ * path to the item
+ */
+ public void addMenuCommand(String title, ScheduledCommand cmd,
+ String... menupath) {
+ Menu m = createMenuPath(menupath);
+
+ m.addCommand(new Command(title, cmd));
+ }
+
+ /**
+ * Create a menu path, if one doesn't already exist, and return the last
+ * menu in the series.
+ *
+ * @param path
+ * a varargs list or array of strings describing a menu path,
+ * e.g. "File", "Recent", "User Files", which would result in the
+ * File menu having a submenu called "Recent" which would have a
+ * submenu called "User Files".
+ * @return the last Menu object specified by the path
+ */
+ private Menu createMenuPath(String... path) {
+ Menu m = menu;
+
+ for (String p : path) {
+ Menu sub = m.getChildMenu(p);
+
+ if (sub == null) {
+ sub = new Menu(p);
+ m.addChildMenu(sub);
+ }
+ m = sub;
+ }
+
+ return m;
+ }
+
+ @Override
+ public Element getSubPartElement(String subPart) {
+ if (testedWidget instanceof SubPartAware) {
+ return ((SubPartAware) testedWidget).getSubPartElement(subPart);
+ }
+ return null;
+ }
+
+ @Override
+ public String getSubPartName(Element subElement) {
+ if (testedWidget instanceof SubPartAware) {
+ return ((SubPartAware) testedWidget).getSubPartName(subElement);
+ }
+ return null;
+ }
+
+ /**
+ * Gets the tested widget.
+ *
+ * @return tested widget
+ */
+ public T getTestedWidget() {
+ return testedWidget;
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/widgetset/server/grid/GridBasicClientFeatures.java b/uitest/src/com/vaadin/tests/widgetset/server/grid/GridBasicClientFeatures.java
new file mode 100644
index 0000000000..fb217dc232
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/widgetset/server/grid/GridBasicClientFeatures.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.widgetset.server.grid;
+
+import com.vaadin.annotations.Widgetset;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.widgetset.TestingWidgetSet;
+import com.vaadin.ui.AbstractComponent;
+import com.vaadin.ui.UI;
+
+/**
+ * Initializer shell for GridClientBasicFeatures test application
+ *
+ * @since
+ * @author Vaadin Ltd
+ */
+@Widgetset(TestingWidgetSet.NAME)
+public class GridBasicClientFeatures extends UI {
+
+ public class GridTestComponent extends AbstractComponent {
+ }
+
+ @Override
+ protected void init(VaadinRequest request) {
+ setContent(new GridTestComponent());
+ }
+
+}