From 38e73f28c8c1888349a6be0ca59cf6cbe4b1872e Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Fri, 16 Apr 2010 05:50:08 +0000 Subject: [PATCH] Test case for NativeSelect svn changeset:12580/svn branch:6.3 --- .../components/select/NativeSelects.html | 177 ++++++++++++++++++ .../components/select/NativeSelects.java | 153 +++++++++++++++ 2 files changed, 330 insertions(+) create mode 100644 tests/src/com/vaadin/tests/components/select/NativeSelects.html create mode 100644 tests/src/com/vaadin/tests/components/select/NativeSelects.java diff --git a/tests/src/com/vaadin/tests/components/select/NativeSelects.html b/tests/src/com/vaadin/tests/components/select/NativeSelects.html new file mode 100644 index 0000000000..caff14b5b4 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/select/NativeSelects.html @@ -0,0 +1,177 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
New Test
open/run/com.vaadin.tests.components.select.NativeSelects?restartApplication
waitForVaadin
selectvaadin=runcomvaadintestscomponentsselectNativeSelects::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VNativeSelect[0]/domChild[0]label=The second item
waitForVaadin
selectvaadin=runcomvaadintestscomponentsselectNativeSelects::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VNativeSelect[0]/domChild[0]label=an item 1
waitForVaadin
selectvaadin=runcomvaadintestscomponentsselectNativeSelects::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[7]/VNativeSelect[0]/domChild[0]label=The second item
waitForVaadin
selectvaadin=runcomvaadintestscomponentsselectNativeSelects::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[8]/VNativeSelect[0]/domChild[0]label=an item 1
waitForVaadin
screenCaptureenabled-readwrite-noerror
mouseClickvaadin=runcomvaadintestscomponentsselectNativeSelects::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VCheckBox[0]/domChild[0]7,6
waitForVaadin
screenCaptureenabled-readonly-noerror
mouseClickvaadin=runcomvaadintestscomponentsselectNativeSelects::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VCheckBox[0]/domChild[0]31,6
waitForVaadin
screenCaptureenabled-readonly-error
mouseClickvaadin=runcomvaadintestscomponentsselectNativeSelects::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VCheckBox[0]/domChild[0]3,9
waitForVaadin
screenCaptureenabled-readwrite-error
mouseClickvaadin=runcomvaadintestscomponentsselectNativeSelects::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[2]/VCheckBox[0]/domChild[0]32,6
waitForVaadin
screenCapturedisabled-readwrite-error
mouseClickvaadin=runcomvaadintestscomponentsselectNativeSelects::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VCheckBox[0]/domChild[0]47,6
waitForVaadin
screenCapturedisabled-readwrite-noerror
mouseClickvaadin=runcomvaadintestscomponentsselectNativeSelects::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VCheckBox[0]/domChild[0]31,11
waitForVaadin
screenCapturedisabled-readonly-noerror
mouseClickvaadin=runcomvaadintestscomponentsselectNativeSelects::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VCheckBox[0]/domChild[0]42,4
waitForVaadin
screenCapturedisabled-readonly-error
+ + diff --git a/tests/src/com/vaadin/tests/components/select/NativeSelects.java b/tests/src/com/vaadin/tests/components/select/NativeSelects.java new file mode 100644 index 0000000000..46b5267e28 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/select/NativeSelects.java @@ -0,0 +1,153 @@ +package com.vaadin.tests.components.select; + +import java.util.ArrayList; +import java.util.List; + +import com.vaadin.tests.components.ComponentTestCase; +import com.vaadin.ui.Button; +import com.vaadin.ui.CheckBox; +import com.vaadin.ui.Component; +import com.vaadin.ui.NativeSelect; +import com.vaadin.ui.Button.ClickEvent; + +public class NativeSelects extends ComponentTestCase { + + private static final Object CAPTION = "caption"; + NativeSelect label[] = new NativeSelect[20]; + + @Override + protected void setup() { + super.setup(); + + NativeSelect s; + + s = createNativeSelect(null); + s.setWidth(null); + addTestComponent(s); + + s = createNativeSelect("Undefined wide, empty select"); + s.setWidth(null); + addTestComponent(s); + + s = createNativeSelect("Undefined wide select with 5 items"); + s.setWidth(null); + addItem(s, "The first item"); + addItem(s, "The second item"); + addItem(s, "The third item"); + addItem(s, "The fourth item"); + addItem(s, "The fifth item"); + addTestComponent(s); + + s = createNativeSelect("Undefined wide select with 50 items"); + s.setWidth(null); + populate(s, 50); + addTestComponent(s); + + s = createNativeSelect(null); + s.setWidth("100px"); + addTestComponent(s); + + s = createNativeSelect("100px wide, empty select"); + s.setWidth("100px"); + addTestComponent(s); + + s = createNativeSelect("150px wide select with 5 items"); + s.setWidth("150px"); + addItem(s, "The first item"); + addItem(s, "The second item"); + addItem(s, "The third item"); + addItem(s, "The fourth item"); + addItem(s, "The fifth item"); + addTestComponent(s); + + s = createNativeSelect("200px wide select with 50 items"); + s.setWidth("200px"); + populate(s, 50); + addTestComponent(s); + + } + + private void populate(NativeSelect s, int nr) { + String text = " an item "; + + String caption = ""; + for (int i = 0; i < nr; i++) { + if (i % 2 == 0) { + caption += text; + } else { + caption += i; + } + + addItem(s, caption); + } + + } + + private void addItem(NativeSelect s, String string) { + Object id = s.addItem(); + s.getItem(id).getItemProperty(CAPTION).setValue(string); + + } + + private NativeSelect createNativeSelect(String caption) { + NativeSelect s = new NativeSelect(); + + s.addContainerProperty(CAPTION, String.class, ""); + s.setItemCaptionPropertyId(CAPTION); + s.setCaption(caption); + + return s; + } + + @Override + protected String getDescription() { + return "A generic test for Labels in different configurations"; + } + + @Override + protected List createActions() { + ArrayList actions = new ArrayList(); + + CheckBox errorIndicators = new CheckBox("Error indicators", + new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + Button b = event.getButton(); + boolean enabled = (Boolean) b.getValue(); + setErrorIndicators(enabled); + + } + }); + + CheckBox enabled = new CheckBox("Enabled", new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + Button b = event.getButton(); + boolean enabled = (Boolean) b.getValue(); + setEnabled(enabled); + } + }); + + CheckBox readonly = new CheckBox("Readonly", + new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + Button b = event.getButton(); + boolean enabled = (Boolean) b.getValue(); + setReadOnly(enabled); + } + }); + + errorIndicators.setValue(new Boolean(false)); + readonly.setValue(new Boolean(false)); + enabled.setValue(new Boolean(true)); + + errorIndicators.setImmediate(true); + readonly.setImmediate(true); + enabled.setImmediate(true); + + actions.add(errorIndicators); + actions.add(readonly); + actions.add(enabled); + + return actions; + } + +} -- 2.39.5