From af19523dd55e1a81acabade6b8ade096ffa7d785 Mon Sep 17 00:00:00 2001 From: Automerge Date: Wed, 9 May 2012 09:07:00 +0000 Subject: [merge from 6.7] Test case for #8778 svn changeset:23696/svn branch:6.8 --- .../application/TerminalErrorNotification.html | 36 ++++++++++++++ .../application/TerminalErrorNotification.java | 57 ++++++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 tests/testbench/com/vaadin/tests/application/TerminalErrorNotification.html create mode 100644 tests/testbench/com/vaadin/tests/application/TerminalErrorNotification.java diff --git a/tests/testbench/com/vaadin/tests/application/TerminalErrorNotification.html b/tests/testbench/com/vaadin/tests/application/TerminalErrorNotification.html new file mode 100644 index 0000000000..f20967c8de --- /dev/null +++ b/tests/testbench/com/vaadin/tests/application/TerminalErrorNotification.html @@ -0,0 +1,36 @@ + + + + + + +TabSheetWithDisappearingContent + + + + + + + + + + + + + + + + + + + + + + + + + + +
TabSheetWithDisappearingContent
open/run/com.vaadin.tests.application.TerminalErrorNotification?restartApplication&debug
clickvaadin=runcomvaadintestsapplicationTerminalErrorNotification::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]
assertElementPresentvaadin=runcomvaadintestsapplicationTerminalErrorNotification::Root/VNotification[0]
assertTextvaadin=runcomvaadintestsapplicationTerminalErrorNotification::Root/VNotification[0]/HTML[0]/domChild[0]Got an exception: You asked for it
+ + diff --git a/tests/testbench/com/vaadin/tests/application/TerminalErrorNotification.java b/tests/testbench/com/vaadin/tests/application/TerminalErrorNotification.java new file mode 100644 index 0000000000..93e38bac5b --- /dev/null +++ b/tests/testbench/com/vaadin/tests/application/TerminalErrorNotification.java @@ -0,0 +1,57 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ +package com.vaadin.tests.application; + +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Window; +import com.vaadin.ui.Window.Notification; + +public class TerminalErrorNotification extends TestBase { + + @Override + protected void setup() { + Button button = new Button("Throw exception", + new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + throw new RuntimeException("You asked for it"); + } + }); + + addComponent(button); + } + + @Override + public void terminalError(com.vaadin.terminal.Terminal.ErrorEvent event) { + event.getThrowable().printStackTrace(); + + Window mainWindow = getMainWindow(); + if (mainWindow != null) { + Throwable throwable = event.getThrowable(); + + // Find the root cause + while (throwable.getCause() != null) { + throwable = throwable.getCause(); + } + + mainWindow.showNotification( + "Got an exception: " + throwable.getMessage(), + Notification.TYPE_ERROR_MESSAGE); + } else { + System.out.println("No main window found"); + } + } + + @Override + protected String getDescription() { + return "Showing a notification in the terminalError method should make the notification appear in the browser."; + } + + @Override + protected Integer getTicketNumber() { + return Integer.valueOf(8778); + } + +} -- cgit v1.2.3