From 6ab9e2d060d865f9ecd918209b0620a95a63f6a6 Mon Sep 17 00:00:00 2001 From: Jonatan Kronqvist Date: Tue, 3 Sep 2013 09:20:49 +0300 Subject: Allow different locator strategies #12485 Refactored the ComponentLocator class to allow for implementing different locator strategies. Change-Id: I93f3decbce4d4361cc605bcf0ce4379a187c482c --- .../componentlocator/TestDetachedNotPresent.html | 62 ++++++++++++++++++++++ .../componentlocator/TestDetachedNotPresent.html | 62 ---------------------- 2 files changed, 62 insertions(+), 62 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/componentlocator/TestDetachedNotPresent.html delete mode 100644 uitest/src/com/vaadin/tests/gwtadapter/componentlocator/TestDetachedNotPresent.html (limited to 'uitest/src') diff --git a/uitest/src/com/vaadin/tests/componentlocator/TestDetachedNotPresent.html b/uitest/src/com/vaadin/tests/componentlocator/TestDetachedNotPresent.html new file mode 100644 index 0000000000..24e5e992ca --- /dev/null +++ b/uitest/src/com/vaadin/tests/componentlocator/TestDetachedNotPresent.html @@ -0,0 +1,62 @@ + + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
New Test
open/run/com.vaadin.tests.components.table.Tables?restartApplication
mouseClickvaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item040,10
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item829,8
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[1]/VMenuBar[0]#item2103,3
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[2]/VMenuBar[0]#item134,6
contextmenuvaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]
assertElementPresentvaadin=runcomvaadintestscomponentstableTables::Root/VContextMenu[0]#option015,8
mouseClickvaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[2]/domChild[0]37,9
assertElementNotPresentvaadin=runcomvaadintestscomponentstableTables::Root/VContextMenu[0]#option015,8
+ + \ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/gwtadapter/componentlocator/TestDetachedNotPresent.html b/uitest/src/com/vaadin/tests/gwtadapter/componentlocator/TestDetachedNotPresent.html deleted file mode 100644 index 24e5e992ca..0000000000 --- a/uitest/src/com/vaadin/tests/gwtadapter/componentlocator/TestDetachedNotPresent.html +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - -New Test - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
New Test
open/run/com.vaadin.tests.components.table.Tables?restartApplication
mouseClickvaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item040,10
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item829,8
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[1]/VMenuBar[0]#item2103,3
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[2]/VMenuBar[0]#item134,6
contextmenuvaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]
assertElementPresentvaadin=runcomvaadintestscomponentstableTables::Root/VContextMenu[0]#option015,8
mouseClickvaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[2]/domChild[0]37,9
assertElementNotPresentvaadin=runcomvaadintestscomponentstableTables::Root/VContextMenu[0]#option015,8
- - \ No newline at end of file -- cgit v1.2.3 From a9f332fddb5ff70338527c1ddad3ca40dca70d6d Mon Sep 17 00:00:00 2001 From: Patrik Lindström Date: Mon, 23 Sep 2013 08:52:22 +0300 Subject: Add simple calculator test application (#12444) Change-Id: Ie2880c9321f46a004e53ca0fa08aa43f840e6a5d --- .../vaadin/tests/application/calculator/Calc.java | 190 +++++++++++++++++++++ 1 file changed, 190 insertions(+) create mode 100644 uitest/src/com/vaadin/tests/application/calculator/Calc.java (limited to 'uitest/src') diff --git a/uitest/src/com/vaadin/tests/application/calculator/Calc.java b/uitest/src/com/vaadin/tests/application/calculator/Calc.java new file mode 100644 index 0000000000..7d080adfa6 --- /dev/null +++ b/uitest/src/com/vaadin/tests/application/calculator/Calc.java @@ -0,0 +1,190 @@ +/* + * Copyright 2000-2013 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.application.calculator; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Alignment; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Button.ClickListener; +import com.vaadin.ui.GridLayout; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.TextArea; +import com.vaadin.ui.TextField; +import com.vaadin.ui.VerticalLayout; + +@SuppressWarnings("serial") +public class Calc extends AbstractTestUI { + + private class Log extends TextArea { + + public Log() { + super(); + setWidth("200px"); + } + + public void addRow(String row) { + setValue(getValue() + "\n" + row); + } + } + + // All variables are automatically stored in the session. + private Double current = 0.0; + private double stored = 0.0; + private char lastOperationRequested = 'C'; + private VerticalLayout topLayout = new VerticalLayout(); + + // User interface components + private final TextField display = new TextField("0.0"); + + private final Log log = new Log(); + + // Calculator "business logic" implemented here to keep the example + // minimal + private double calculate(char requestedOperation) { + if ('0' <= requestedOperation && requestedOperation <= '9') { + if (current == null) { + current = 0.0; + } + current = current * 10 + + Double.parseDouble("" + requestedOperation); + return current; + } + + if (current == null) { + current = stored; + } + switch (lastOperationRequested) { + case '+': + stored += current; + break; + case '-': + stored -= current; + break; + case '/': + stored /= current; + break; + case '*': + stored *= current; + break; + default: + stored = current; + break; + } + + switch (requestedOperation) { + case '+': + log.addRow(current + " +"); + break; + case '-': + log.addRow(current + " -"); + break; + case '/': + log.addRow(current + " /"); + break; + case '*': + log.addRow(current + " x"); + break; + case '=': + log.addRow(current + " ="); + log.addRow("------------"); + log.addRow("" + stored); + break; + } + + lastOperationRequested = requestedOperation; + current = null; + if (requestedOperation == 'C') { + log.addRow("0.0"); + stored = 0.0; + } + return stored; + } + + @Override + protected void setup(VaadinRequest request) { + setContent(topLayout); + + // Create the main layout for our application (4 columns, 5 rows) + final GridLayout layout = new GridLayout(4, 5); + + topLayout.setMargin(true); + topLayout.setSpacing(true); + Label title = new Label("Calculator"); + topLayout.addComponent(title); + topLayout.addComponent(log); + + HorizontalLayout horizontalLayout = new HorizontalLayout(); + horizontalLayout.setSpacing(true); + horizontalLayout.addComponent(layout); + horizontalLayout.addComponent(log); + topLayout.addComponent(horizontalLayout); + + // Create a result label that over all 4 columns in the first row + layout.addComponent(display, 0, 0, 3, 0); + layout.setComponentAlignment(display, Alignment.MIDDLE_RIGHT); + display.setSizeUndefined(); + display.setId("display"); + + // The operations for the calculator in the order they appear on the + // screen (left to right, top to bottom) + String[] operations = new String[] { "7", "8", "9", "/", "4", "5", "6", + "*", "1", "2", "3", "-", "0", "=", "C", "+" }; + + for (String caption : operations) { + + // Create a button and use this application for event handling + Button button = new Button(caption); + button.setHeight("30px"); + button.setWidth("40px"); + button.addClickListener(new ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + // Get the button that was clicked + Button button = event.getButton(); + + // Get the requested operation from the button caption + char requestedOperation = button.getCaption().charAt(0); + + // Calculate the new value + double newValue = calculate(requestedOperation); + + // Update the result label with the new value + display.setValue("" + newValue); + } + }); + button.setId("button_" + caption); + + // Add the button to our main layout + layout.addComponent(button); + } + + } + + @Override + protected String getTestDescription() { + return "Provide test application for generic testing purposes"; + } + + @Override + protected Integer getTicketNumber() { + return 12444; + } + +} -- cgit v1.2.3 From 90626d3583f04800c02e6c7856aac0921c6c2adb Mon Sep 17 00:00:00 2001 From: Patrik Lindström Date: Fri, 11 Oct 2013 14:19:52 +0300 Subject: Improve Calculator test application (#12744) Change-Id: Ib65ade5ecc589717e68e34b7469b5bae3c58786d --- .../vaadin/tests/application/calculator/Calc.java | 90 ++++++++++++++++++++-- 1 file changed, 84 insertions(+), 6 deletions(-) (limited to 'uitest/src') diff --git a/uitest/src/com/vaadin/tests/application/calculator/Calc.java b/uitest/src/com/vaadin/tests/application/calculator/Calc.java index 7d080adfa6..7911556f4e 100644 --- a/uitest/src/com/vaadin/tests/application/calculator/Calc.java +++ b/uitest/src/com/vaadin/tests/application/calculator/Calc.java @@ -25,23 +25,100 @@ import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.GridLayout; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; -import com.vaadin.ui.TextArea; +import com.vaadin.ui.Table; +import com.vaadin.ui.Table.ColumnHeaderMode; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; +import com.vaadin.ui.Window; @SuppressWarnings("serial") public class Calc extends AbstractTestUI { - private class Log extends TextArea { + private class Log extends VerticalLayout { + + private Table table; + private Button addCommentButton; + private int line = 0; public Log() { super(); + + table = new Table(); + table.setSizeFull(); + setWidth("200px"); + setHeight("100%"); + + table.setColumnHeaderMode(ColumnHeaderMode.HIDDEN); + table.addContainerProperty("Operation", String.class, ""); + + addComponent(table); + + addCommentButton = new Button("Add Comment"); + addCommentButton.setWidth("100%"); + + addCommentButton.addClickListener(new ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + + final Window w = new Window("Add comment"); + VerticalLayout vl = new VerticalLayout(); + vl.setMargin(true); + + final TextField tf = new TextField(); + tf.setSizeFull(); + vl.addComponent(tf); + + HorizontalLayout hl = new HorizontalLayout(); + + Button okButton = new Button("OK"); + okButton.setWidth("100%"); + okButton.addClickListener(new ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + addRow("[ " + tf.getValue() + " ]"); + tf.setValue(""); + w.close(); + removeWindow(w); + } + }); + + Button cancelButton = new Button("Cancel"); + cancelButton.setWidth("100%"); + cancelButton.addClickListener(new ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + tf.setValue(""); + w.close(); + removeWindow(w); + } + }); + + hl.addComponent(cancelButton); + hl.addComponent(okButton); + hl.setSpacing(true); + hl.setWidth("100%"); + + vl.addComponent(hl); + vl.setSpacing(true); + + w.setContent(vl); + addWindow(w); + } + }); + + addComponent(addCommentButton); + + setExpandRatio(table, 1); + setSpacing(true); } public void addRow(String row) { - setValue(getValue() + "\n" + row); + Integer id = ++line; + table.addItem(new Object[] { row }, id); + table.setCurrentPageFirstItemIndex(line + 1); } + } // All variables are automatically stored in the session. @@ -51,7 +128,7 @@ public class Calc extends AbstractTestUI { private VerticalLayout topLayout = new VerticalLayout(); // User interface components - private final TextField display = new TextField("0.0"); + private final TextField display = new TextField(); private final Log log = new Log(); @@ -137,10 +214,12 @@ public class Calc extends AbstractTestUI { topLayout.addComponent(horizontalLayout); // Create a result label that over all 4 columns in the first row + layout.setSpacing(true); layout.addComponent(display, 0, 0, 3, 0); layout.setComponentAlignment(display, Alignment.MIDDLE_RIGHT); - display.setSizeUndefined(); + display.setSizeFull(); display.setId("display"); + display.setValue("0.0"); // The operations for the calculator in the order they appear on the // screen (left to right, top to bottom) @@ -151,7 +230,6 @@ public class Calc extends AbstractTestUI { // Create a button and use this application for event handling Button button = new Button(caption); - button.setHeight("30px"); button.setWidth("40px"); button.addClickListener(new ClickListener() { @Override -- cgit v1.2.3