diff options
author | Johannes Dahlström <johannes.dahlstrom@vaadin.com> | 2011-12-30 12:51:56 +0000 |
---|---|---|
committer | Johannes Dahlström <johannes.dahlstrom@vaadin.com> | 2011-12-30 12:51:56 +0000 |
commit | dd786ffd3554828e91d4398bc9a3ce6e498f74b2 (patch) | |
tree | b95585606d711c925477cdaea23b4e31fcf68c97 /tests/testbench | |
parent | 02daee926e0bb40bcd8a321a2a27570da5c9c928 (diff) | |
download | vaadin-framework-dd786ffd3554828e91d4398bc9a3ce6e498f74b2.tar.gz vaadin-framework-dd786ffd3554828e91d4398bc9a3ce6e498f74b2.zip |
Merged changes from 6.7
svn changeset:22500/svn branch:6.8
Diffstat (limited to 'tests/testbench')
2 files changed, 135 insertions, 6 deletions
diff --git a/tests/testbench/com/vaadin/tests/components/textfield/TextChangeEventsWithNonImmediateValueChange.java b/tests/testbench/com/vaadin/tests/components/textfield/TextChangeEventsWithNonImmediateValueChange.java index a893739bff..df5b275a8e 100644 --- a/tests/testbench/com/vaadin/tests/components/textfield/TextChangeEventsWithNonImmediateValueChange.java +++ b/tests/testbench/com/vaadin/tests/components/textfield/TextChangeEventsWithNonImmediateValueChange.java @@ -19,10 +19,9 @@ public class TextChangeEventsWithNonImmediateValueChange extends TestBase { TextChangeListener inputEventListener = new TextChangeListener() { public void textChange(TextChangeEvent event) { - l.log("Text change event for " - + event.getComponent().getCaption() - + ", text content currently:'" + event.getText() - + "' Cursor at index:" + event.getCursorPosition()); + l.log("Text change event, text content currently:'" + + event.getText() + "' Cursor at index:" + + event.getCursorPosition()); } }; @@ -33,7 +32,7 @@ public class TextChangeEventsWithNonImmediateValueChange extends TestBase { tf.addListener(new ValueChangeListener() { public void valueChange(ValueChangeEvent event) { - l.log("Value change:" + event.getProperty().toString()); + l.log("Value change: '" + event.getProperty().toString() + "'"); } }); @@ -44,7 +43,8 @@ public class TextChangeEventsWithNonImmediateValueChange extends TestBase { @Override protected String getDescription() { - return "Type a, pause for a second, type ENTER, type a. Text field should not forget the last textchange event right after valuechange (enter)."; + return "Type a, pause for a second, type ENTER, type a. Text field should not forget the last textchange event right after valuechange (enter)." + + "<br />Then press backspace. The text field should send a text change event even though the text in the field is the same as the field's value"; } @Override diff --git a/tests/testbench/com/vaadin/tests/components/window/AttachShouldBeCalledForSubWindows.java b/tests/testbench/com/vaadin/tests/components/window/AttachShouldBeCalledForSubWindows.java new file mode 100644 index 0000000000..a6040c06d3 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/window/AttachShouldBeCalledForSubWindows.java @@ -0,0 +1,129 @@ +package com.vaadin.tests.components.window;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.terminal.gwt.server.HttpServletRequestListener;
+import com.vaadin.tests.components.AbstractTestCase;
+import com.vaadin.tests.util.Log;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Window;
+
+public class AttachShouldBeCalledForSubWindows extends AbstractTestCase
+ implements HttpServletRequestListener {
+ private static final long serialVersionUID = 1L;
+
+ private Log log = new Log(20);
+
+ boolean addSubWindowBeforeMainWindow = true;
+
+ @Override
+ public void init() {
+
+ Window mainWindow = new Window() {
+ @Override
+ public void attach() {
+ log(this);
+ super.attach();
+ }
+
+ @Override
+ public void addWindow(Window w) {
+ log.log("Adding sub window");
+ super.addWindow(w);
+ log.log("Sub window added");
+
+ }
+ };
+ mainWindow.setCaption("Main window");
+ mainWindow.addComponent(log);
+ mainWindow.getContent().setSizeFull();
+ Label label = new Label("This is the main app") {
+ @Override
+ public void attach() {
+ log(this);
+ super.attach();
+ }
+ };
+
+ mainWindow.addComponent(label);
+ Window loginWindow = createSubWindow();
+ if (addSubWindowBeforeMainWindow) {
+ mainWindow.addWindow(loginWindow);
+ }
+
+ log.log("Setting main window");
+ setMainWindow(mainWindow); // At this point
+ log.log("Main window set");
+
+ if (!addSubWindowBeforeMainWindow) {
+ mainWindow.addWindow(loginWindow);
+ }
+ }
+
+ private Window createSubWindow() {
+ Window w = new Window("Sub window") {
+ @Override
+ public void attach() {
+ log(this);
+ super.attach();
+ }
+ };
+ Button okButton = new Button("OK") {
+ @Override
+ public void attach() {
+ super.attach();
+ log(this);
+ }
+ };
+ okButton.addListener(new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ log.log("Button clicked");
+
+ }
+ });
+ okButton.setClickShortcut(KeyCode.ENTER);
+ w.addComponent(okButton);
+ w.center();
+ return w;
+ }
+
+ public void log(Component c) {
+ Class<?> cls = c.getClass();
+ if (cls.isAnonymousClass()) {
+ cls = cls.getSuperclass();
+ }
+ log.log(cls.getName() + " '" + c.getCaption()
+ + "' attached to application");
+ }
+
+ @Override
+ protected String getDescription() {
+ return "By default attaches a sub window with a button to the main window and then set the main window to the application. Use ?attachMainFirst to reverse the order. In both cases attach events should be sent for the components in the sub window";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 8170;
+ }
+
+ public void onRequestStart(HttpServletRequest request,
+ HttpServletResponse response) {
+ if (request.getParameter("attachMainFirst") != null) {
+ addSubWindowBeforeMainWindow = false;
+ }
+
+ }
+
+ public void onRequestEnd(HttpServletRequest request,
+ HttpServletResponse response) {
+ // TODO Auto-generated method stub
+
+ }
+}
|