summaryrefslogtreecommitdiffstats
path: root/uitest/src
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2013-01-09 13:18:32 +0000
committerVaadin Code Review <review@vaadin.com>2013-01-09 13:18:32 +0000
commit9624d0a1540d790ea2889af9ba5f5a39ee2713d8 (patch)
tree15ac19ef7eb0bb6a9a527f636fe07b17cf3958fe /uitest/src
parent7daf3cbb584c78e27432164d8f5e9dd861f7a13c (diff)
parent447befae430975748f15b47aab99f58ce54854ad (diff)
downloadvaadin-framework-9624d0a1540d790ea2889af9ba5f5a39ee2713d8.tar.gz
vaadin-framework-9624d0a1540d790ea2889af9ba5f5a39ee2713d8.zip
Merge "Merge of (#10471) to Vaadin 7."
Diffstat (limited to 'uitest/src')
-rw-r--r--uitest/src/com/vaadin/tests/components/combobox/ComboBoxSQLContainerFilteredValueChange.html42
-rw-r--r--uitest/src/com/vaadin/tests/components/combobox/ComboBoxSQLContainerFilteredValueChange.java123
2 files changed, 165 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxSQLContainerFilteredValueChange.html b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxSQLContainerFilteredValueChange.html
new file mode 100644
index 0000000000..f3f44a5d90
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxSQLContainerFilteredValueChange.html
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="http://localhost:8888/" />
+<title>ComboBoxSQLContainerFilteredValueChange</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">ComboBoxSQLContainerFilteredValueChange</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.components.combobox.ComboBoxSQLContainerFilteredValueChange?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>enterCharacter</td>
+ <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxSQLContainerFilteredValueChange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VFilterSelect[0]#textbox</td>
+ <td>a</td>
+</tr>
+<tr>
+ <td>pressSpecialKey</td>
+ <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxSQLContainerFilteredValueChange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VFilterSelect[0]#textbox</td>
+ <td>down</td>
+</tr>
+<tr>
+ <td>pressSpecialKey</td>
+ <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxSQLContainerFilteredValueChange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VFilterSelect[0]#textbox</td>
+ <td>enter</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxSQLContainerFilteredValueChange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VLabel[0]</td>
+ <td>Selected: 1</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxSQLContainerFilteredValueChange.java b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxSQLContainerFilteredValueChange.java
new file mode 100644
index 0000000000..23a75ae56e
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxSQLContainerFilteredValueChange.java
@@ -0,0 +1,123 @@
+package com.vaadin.tests.components.combobox;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import com.vaadin.data.Property;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.util.sqlcontainer.SQLContainer;
+import com.vaadin.data.util.sqlcontainer.connection.JDBCConnectionPool;
+import com.vaadin.data.util.sqlcontainer.connection.SimpleJDBCConnectionPool;
+import com.vaadin.data.util.sqlcontainer.query.TableQuery;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.AbstractSelect.Filtering;
+import com.vaadin.ui.ComboBox;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.VerticalLayout;
+
+public class ComboBoxSQLContainerFilteredValueChange extends TestBase {
+
+ @Override
+ protected void setup() {
+ VerticalLayout layout = new VerticalLayout();
+ addComponent(layout);
+
+ final ComboBox myCombo = new ComboBox("MyCaption");
+ layout.addComponent(myCombo);
+
+ final Label selectedLabel = new Label("Selected: null");
+ layout.addComponent(selectedLabel);
+
+ try {
+ JDBCConnectionPool connectionPool = new SimpleJDBCConnectionPool(
+ "org.hsqldb.jdbc.JDBCDriver",
+ "jdbc:hsqldb:mem:sqlcontainer", "SA", "", 2, 20);
+
+ createTestTable(connectionPool);
+ insertTestData(connectionPool);
+
+ TableQuery q = new TableQuery("mytable", connectionPool);
+ q.setVersionColumn("version");
+ SQLContainer myContainer = new SQLContainer(q);
+
+ myCombo.setContainerDataSource(myContainer);
+
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+
+ myCombo.setItemCaptionPropertyId("MYFIELD");
+ myCombo.setFilteringMode(Filtering.FILTERINGMODE_CONTAINS);
+ myCombo.setImmediate(true);
+ myCombo.setWidth("100.0%");
+ myCombo.setHeight("-1px");
+ myCombo.addListener(new Property.ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ selectedLabel.setValue("Selected: "
+ + event.getProperty().getValue());
+ }
+ });
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Selecting the first filtered item should change the value of the label under the ComboBox to 'Selected: 1'.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 10471;
+ }
+
+ /**
+ * (Re)creates the test table
+ * @param connectionPool
+ */
+ private void createTestTable(JDBCConnectionPool connectionPool) {
+ Connection conn = null;
+ try {
+ conn = connectionPool.reserveConnection();
+ Statement statement = conn.createStatement();
+ try {
+ statement.executeUpdate("DROP TABLE mytable");
+ } catch (SQLException e) {
+ }
+ statement.execute("CREATE TABLE mytable "
+ + "(id INTEGER GENERATED BY DEFAULT AS IDENTITY, "
+ + "MYFIELD VARCHAR(45), " + "PRIMARY KEY(ID))");
+ statement.close();
+ conn.commit();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ } finally {
+ connectionPool.releaseConnection(conn);
+ }
+ }
+
+ /**
+ * Adds test data to the test table
+ * @param connectionPool
+ * @throws SQLException
+ */
+ private void insertTestData(JDBCConnectionPool connectionPool)
+ throws SQLException {
+ Connection conn = null;
+ try {
+ conn = connectionPool.reserveConnection();
+ Statement statement = conn.createStatement();
+
+ statement.executeUpdate("INSERT INTO mytable VALUES(1, 'A0')");
+ statement.executeUpdate("INSERT INTO mytable VALUES(2, 'A1')");
+ statement.executeUpdate("INSERT INTO mytable VALUES(3, 'B0')");
+ statement.executeUpdate("INSERT INTO mytable VALUES(4, 'B1')");
+
+ statement.close();
+ conn.commit();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ } finally {
+ connectionPool.releaseConnection(conn);
+ }
+ }
+} \ No newline at end of file