From 6f1f4ffd199d6df25d6334ee1d375054f9f64296 Mon Sep 17 00:00:00 2001 From: patrik Date: Mon, 22 Jun 2015 11:03:54 +0300 Subject: [PATCH] Port JavaScriptResizeListenerTest from TB2 to TB4 Change-Id: Ifb757eeea16da1f065fd533b63b6e536d9135d6f --- .../JavaScriptResizeListenerTest.java | 92 +++++++++++++++++++ .../JavaScriptResizeListener.html | 81 ---------------- 2 files changed, 92 insertions(+), 81 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/components/javascriptcomponent/JavaScriptResizeListenerTest.java delete mode 100644 uitest/tb2/com/vaadin/tests/components/javascriptcomponent/JavaScriptResizeListener.html diff --git a/uitest/src/com/vaadin/tests/components/javascriptcomponent/JavaScriptResizeListenerTest.java b/uitest/src/com/vaadin/tests/components/javascriptcomponent/JavaScriptResizeListenerTest.java new file mode 100644 index 0000000000..92ebc3a335 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/javascriptcomponent/JavaScriptResizeListenerTest.java @@ -0,0 +1,92 @@ +/* + * Copyright 2000-2014 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.components.javascriptcomponent; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +import com.vaadin.testbench.elements.AbstractJavaScriptComponentElement; +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.CheckBoxElement; +import com.vaadin.testbench.parallel.TestCategory; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * Re-implementation of Javascript Resize Listener TB2 Test in TB4. + */ +@TestCategory("javascript") +public class JavaScriptResizeListenerTest extends MultiBrowserTest { + + @Test + public void testResizeListener() throws InterruptedException { + openTestURL(); + + // Get handles to relevant elements in page + AbstractJavaScriptComponentElement jsComponent = $( + AbstractJavaScriptComponentElement.class).first(); + + ButtonElement sizeToggleButton = $(ButtonElement.class).first(); + + CheckBoxElement listenerToggleBox = $(CheckBoxElement.class).first(); + + // Make sure we're initialized correctly + assertEquals("Initial state", jsComponent.getText()); + + // Try to use the toggle button - nothing should happen + sizeToggleButton.click(); + Thread.sleep(1000); + assertEquals("Initial state", jsComponent.getText()); + + // Enable the JavaScript resize listener + listenerToggleBox.click(); + + // Vaadin doesn't do a server round-trip here, which means that + // waitForVaadin will fail to Do The Right Thing. Instead, we'll have to + // wait for a bit before resuming execution + Thread.sleep(2500); + + // The listener should change the text to reflect current component size + sizeToggleButton.click(); + Thread.sleep(1000); + assertEquals("Current size is 100 x 100", jsComponent.getText()); + + // Click button to change size + sizeToggleButton.click(); + Thread.sleep(1000); + assertEquals("Current size is 200 x 50", jsComponent.getText()); + + // Click it again to revert to previous state + sizeToggleButton.click(); + Thread.sleep(1000); + assertEquals("Current size is 100 x 100", jsComponent.getText()); + + // Disable the listener + listenerToggleBox.click(); + + // Again, we'll need to sleep for a bit due to waitForVaadin not doing + // the right thing + Thread.sleep(2500); + assertEquals("Listener disabled", jsComponent.getText()); + + // Check that nothing happens when clicking the button again + sizeToggleButton.click(); + Thread.sleep(1000); + assertEquals("Listener disabled", jsComponent.getText()); + + } + +} diff --git a/uitest/tb2/com/vaadin/tests/components/javascriptcomponent/JavaScriptResizeListener.html b/uitest/tb2/com/vaadin/tests/components/javascriptcomponent/JavaScriptResizeListener.html deleted file mode 100644 index 53af1d4ceb..0000000000 --- a/uitest/tb2/com/vaadin/tests/components/javascriptcomponent/JavaScriptResizeListener.html +++ /dev/null @@ -1,81 +0,0 @@ - - - - - - -New Test - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
New Test
open/run/com.vaadin.tests.components.javascriptcomponent.JavaScriptResizeListener?restartApplication&debug
assertTextvaadin=runcomvaadintestscomponentsjavascriptcomponentJavaScriptResizeListener::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VCssLayout[0]/JavaScriptWidget[0]Initial state
clickvaadin=runcomvaadintestscomponentsjavascriptcomponentJavaScriptResizeListener::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]
assertTextvaadin=runcomvaadintestscomponentsjavascriptcomponentJavaScriptResizeListener::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VCssLayout[0]/JavaScriptWidget[0]Initial state
mouseClickvaadin=runcomvaadintestscomponentsjavascriptcomponentJavaScriptResizeListener::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VCheckBox[0]/domChild[0]52,4
assertTextvaadin=runcomvaadintestscomponentsjavascriptcomponentJavaScriptResizeListener::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VCssLayout[0]/JavaScriptWidget[0]Current size is 200 x 50
clickvaadin=runcomvaadintestscomponentsjavascriptcomponentJavaScriptResizeListener::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VButton[0]/domChild[0]
assertTextvaadin=runcomvaadintestscomponentsjavascriptcomponentJavaScriptResizeListener::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VCssLayout[0]/JavaScriptWidget[0]Current size is 100 x 100
mouseClickvaadin=runcomvaadintestscomponentsjavascriptcomponentJavaScriptResizeListener::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VCheckBox[0]/domChild[0]69,2
assertTextvaadin=runcomvaadintestscomponentsjavascriptcomponentJavaScriptResizeListener::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VCssLayout[0]/JavaScriptWidget[0]Listener disabled
clickvaadin=runcomvaadintestscomponentsjavascriptcomponentJavaScriptResizeListener::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]
assertTextvaadin=runcomvaadintestscomponentsjavascriptcomponentJavaScriptResizeListener::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VCssLayout[0]/JavaScriptWidget[0]Listener disabled
- - -- 2.39.5