Sfoglia il codice sorgente

Test fixes (#12244)

tags/8.13.0.beta1
Anna Koskinen 3 anni fa
parent
commit
49ea04a13c
Nessun account collegato all'indirizzo email del committer

BIN
uitest/reference-screenshots/chrome/ResponsiveStylesTest-testValoMenuResponsiveHover_ANY_Chrome__collapsedMenu.png Vedi File


BIN
uitest/reference-screenshots/chrome/TableContextMenuAndIconsTest-tableContextMenuWithIcons_ANY_Chrome__contextmenu-empty-1.png Vedi File


+ 5
- 0
uitest/src/main/java/com/vaadin/v7/tests/components/grid/GridWithoutRenderer.java Vedi File

package com.vaadin.v7.tests.components.grid; package com.vaadin.v7.tests.components.grid;


import com.vaadin.server.UserError;
import com.vaadin.server.VaadinRequest; import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.tests.util.PersonContainer; import com.vaadin.tests.util.PersonContainer;
import com.vaadin.ui.Button;
import com.vaadin.v7.ui.Grid; import com.vaadin.v7.ui.Grid;


@SuppressWarnings("deprecation")
public class GridWithoutRenderer extends AbstractTestUI { public class GridWithoutRenderer extends AbstractTestUI {


@Override @Override
Grid grid = new Grid(); Grid grid = new Grid();
grid.setContainerDataSource(PersonContainer.createWithTestData()); grid.setContainerDataSource(PersonContainer.createWithTestData());
addComponent(grid); addComponent(grid);
addComponent(new Button("Add error",
e -> grid.setComponentError(new UserError("fail"))));


} }
} }

+ 20
- 11
uitest/src/test/java/com/vaadin/tests/components/combobox/ComboboxMenuBarAutoopenTest.java Vedi File

import com.vaadin.testbench.elements.ComboBoxElement; import com.vaadin.testbench.elements.ComboBoxElement;
import com.vaadin.testbench.elements.MenuBarElement; import com.vaadin.testbench.elements.MenuBarElement;
import com.vaadin.tests.tb3.MultiBrowserTest; import com.vaadin.tests.tb3.MultiBrowserTest;
import com.vaadin.ui.Notification.Type;


/** /**
* Test that checks whether Combobox popup is closed on click to autoopen * Test that checks whether Combobox popup is closed on click to autoopen


@Test @Test
public void closeComboboxPopupOnClickToMenuBar() { public void closeComboboxPopupOnClickToMenuBar() {
setDebug(true);
openTestURL(); openTestURL();


openPopup(); openPopup();
menuBar.click(); menuBar.click();
assertFalse("Combobox popup items are visible", assertFalse("Combobox popup items are visible",
isElementPresent(By.className("gwt-MenuItem"))); isElementPresent(By.className("gwt-MenuItem")));
}

@Test
public void closeComboboxPopupOnClickToMenuBarItem() {
openTestURL();


openPopup(); openPopup();
menuBar = selectMenuBar();


// hover over menubar to open
WebElement menuBarItem = findElement( WebElement menuBarItem = findElement(
By.className("v-menubar-menuitem-caption")); By.className("v-menubar-menuitem-caption"));
Actions actions = new Actions(getDriver());
actions.moveToElement(menuBarItem).build().perform();
menuBar.click();
moveToElement(menuBarItem);

// click submenu item
findElements(By.className("v-menubar-menuitem-caption")).get(1).click();
assertElementPresent(By.className(
"v-Notification-" + Type.HUMANIZED_MESSAGE.getStyle()));

assertFalse("Combobox popup items are visible", assertFalse("Combobox popup items are visible",
isElementPresent(By.className("gwt-MenuItem"))); isElementPresent(By.className("gwt-MenuItem")));
} }
ComboBoxElement combobox = $(ComboBoxElement.class).first(); ComboBoxElement combobox = $(ComboBoxElement.class).first();
combobox.openPopup(); combobox.openPopup();


Actions actions = new Actions(getDriver());
actions.moveToElement(
getDriver().findElement(By.className("gwt-MenuItem"))).build()
.perform();
moveToElement(findElement(By.className("gwt-MenuItem")));
} }


private MenuBarElement selectMenuBar() { private MenuBarElement selectMenuBar() {
MenuBarElement menuBar = $(MenuBarElement.class).first(); MenuBarElement menuBar = $(MenuBarElement.class).first();
menuBar.focus(); menuBar.focus();


Actions actions = new Actions(getDriver());
actions.moveToElement(menuBar).build().perform();
moveToElement(menuBar);


return menuBar; return menuBar;
} }


private void moveToElement(WebElement target) {
Actions actions = new Actions(driver);
actions.moveToElement(target).build().perform();
}
} }

+ 0
- 1
uitest/src/test/java/com/vaadin/tests/components/grid/GridDetailsUpdateItemsTest.java Vedi File

ButtonElement button = $(ButtonElement.class).first(); ButtonElement button = $(ButtonElement.class).first();


String details0 = grid.getDetails(0).getText(); String details0 = grid.getDetails(0).getText();
System.out.println("details: " + details0);


// change the contents // change the contents
button.click(); button.click();

+ 11
- 6
uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorMultiselectTest.java Vedi File

package com.vaadin.tests.components.grid; package com.vaadin.tests.components.grid;


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.util.List; import java.util.List;


import org.junit.Test; import org.junit.Test;
import com.vaadin.testbench.parallel.TestCategory; import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest; import com.vaadin.tests.tb3.MultiBrowserTest;


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

@TestCategory("grid") @TestCategory("grid")
public class GridEditorMultiselectTest extends MultiBrowserTest { public class GridEditorMultiselectTest extends MultiBrowserTest {


public void testSelectCheckboxesEnabledBackOnSave() { public void testSelectCheckboxesEnabledBackOnSave() {
openTestURL(); openTestURL();
GridElement grid = openEditor(); GridElement grid = openEditor();
grid.getEditor().save();
waitForElementPresent(By.className("v-grid-editor-save"));
sleep(100); // wait for repositioning
findElement(By.className("v-grid-editor-save")).click();
waitForElementNotPresent(By.className("v-grid-editor-cells")); waitForElementNotPresent(By.className("v-grid-editor-cells"));
assertCheckboxesEnabled(grid, true); assertCheckboxesEnabled(grid, true);
} }
public void testSelectCheckboxesEnabledBackOnCancel() { public void testSelectCheckboxesEnabledBackOnCancel() {
openTestURL(); openTestURL();
GridElement grid = openEditor(); GridElement grid = openEditor();
grid.getEditor().cancel();
sleep(100);
waitForElementPresent(By.className("v-grid-editor-cancel"));
sleep(100); // wait for repositioning
findElement(By.className("v-grid-editor-cancel")).click();
waitForElementNotPresent(By.className("v-grid-editor-cells"));
assertCheckboxesEnabled(grid, true); assertCheckboxesEnabled(grid, true);
} }


private GridElement openEditor() { private GridElement openEditor() {
GridElement grid = $(GridElement.class).first(); GridElement grid = $(GridElement.class).first();
grid.getRow(0).doubleClick(); grid.getRow(0).doubleClick();
waitForElementPresent(By.className("v-grid-editor-cells"));
assertTrue("Grid editor should be displayed.", assertTrue("Grid editor should be displayed.",
grid.getEditor().isDisplayed()); grid.getEditor().isDisplayed());
return grid; return grid;

+ 1
- 0
uitest/src/test/java/com/vaadin/tests/components/grid/GridResizeHiddenColumnTest.java Vedi File

// Click on "Last Name" menu item // Click on "Last Name" menu item
action.click(visibilityToggle).perform(); action.click(visibilityToggle).perform();
waitUntilLoadingIndicatorNotVisible(); waitUntilLoadingIndicatorNotVisible();
sleep(100); // wait for layouting


// Check if column "Last Name" is visible // Check if column "Last Name" is visible
headerCells = grid.getHeaderCells(0); headerCells = grid.getHeaderCells(0);

+ 15
- 0
uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/escalator/EscalatorSpacerTest.java Vedi File

assertFalse("No spacers should be shown at the start", assertFalse("No spacers should be shown at the start",
spacersAreFoundInDom()); spacersAreFoundInDom());
selectMenuPath(FEATURES, SPACERS, ROW_1, SET_100PX); selectMenuPath(FEATURES, SPACERS, ROW_1, SET_100PX);
waitForElementPresent(By.className("v-escalator-spacer"));
assertNotNull("Spacer should be shown after setting it", getSpacer(1)); assertNotNull("Spacer should be shown after setting it", getSpacer(1));
} }


@Test @Test
public void closeVisibleSpacer() { public void closeVisibleSpacer() {
selectMenuPath(FEATURES, SPACERS, ROW_1, SET_100PX); selectMenuPath(FEATURES, SPACERS, ROW_1, SET_100PX);
waitForElementPresent(By.className("v-escalator-spacer"));
assertNotNull("Unexpectedly missing spacer from row 1", getSpacer(1));
selectMenuPath(FEATURES, SPACERS, ROW_1, REMOVE); selectMenuPath(FEATURES, SPACERS, ROW_1, REMOVE);
assertNull("Spacer should not exist after removing it", getSpacer(1)); assertNull("Spacer should not exist after removing it", getSpacer(1));
} }
public void spacerPushesVisibleRowsDown() { public void spacerPushesVisibleRowsDown() {
double oldTop = getElementTop(getBodyRow(2)); double oldTop = getElementTop(getBodyRow(2));
selectMenuPath(FEATURES, SPACERS, ROW_1, SET_100PX); selectMenuPath(FEATURES, SPACERS, ROW_1, SET_100PX);
waitForElementPresent(By.className("v-escalator-spacer"));
double newTop = getElementTop(getBodyRow(2)); double newTop = getElementTop(getBodyRow(2));


assertGreater("Row below a spacer was not pushed down", newTop, oldTop); assertGreater("Row below a spacer was not pushed down", newTop, oldTop);
selectMenuPath(COLUMNS_AND_ROWS, BODY_ROWS, ADD_ONE_ROW_TO_BEGINNING); selectMenuPath(COLUMNS_AND_ROWS, BODY_ROWS, ADD_ONE_ROW_TO_BEGINNING);


selectMenuPath(FEATURES, SPACERS, ROW_1, SET_100PX); selectMenuPath(FEATURES, SPACERS, ROW_1, SET_100PX);
waitForElementPresent(By.className("v-escalator-spacer"));
double oldTop = getElementTop(getSpacer(1)); double oldTop = getElementTop(getSpacer(1));
selectMenuPath(COLUMNS_AND_ROWS, BODY_ROWS, ADD_ONE_ROW_TO_BEGINNING); selectMenuPath(COLUMNS_AND_ROWS, BODY_ROWS, ADD_ONE_ROW_TO_BEGINNING);
double newTop = getElementTop(getSpacer(2)); double newTop = getElementTop(getSpacer(2));
selectMenuPath(COLUMNS_AND_ROWS, BODY_ROWS, ADD_ONE_ROW_TO_BEGINNING); selectMenuPath(COLUMNS_AND_ROWS, BODY_ROWS, ADD_ONE_ROW_TO_BEGINNING);


selectMenuPath(FEATURES, SPACERS, ROW_1, SET_100PX); selectMenuPath(FEATURES, SPACERS, ROW_1, SET_100PX);
waitForElementPresent(By.className("v-escalator-spacer"));
double oldTop = getElementTop(getSpacer(1)); double oldTop = getElementTop(getSpacer(1));
selectMenuPath(COLUMNS_AND_ROWS, BODY_ROWS, ADD_ONE_ROW_TO_END); selectMenuPath(COLUMNS_AND_ROWS, BODY_ROWS, ADD_ONE_ROW_TO_END);
double newTop = getElementTop(getSpacer(1)); double newTop = getElementTop(getSpacer(1));
selectMenuPath(COLUMNS_AND_ROWS, BODY_ROWS, ADD_ONE_ROW_TO_BEGINNING); selectMenuPath(COLUMNS_AND_ROWS, BODY_ROWS, ADD_ONE_ROW_TO_BEGINNING);


selectMenuPath(FEATURES, SPACERS, ROW_1, SET_100PX); selectMenuPath(FEATURES, SPACERS, ROW_1, SET_100PX);
waitForElementPresent(By.className("v-escalator-spacer"));
double spacerTop = getElementTop(getSpacer(1)); double spacerTop = getElementTop(getSpacer(1));
selectMenuPath(COLUMNS_AND_ROWS, BODY_ROWS, ADD_ONE_ROW_TO_END); selectMenuPath(COLUMNS_AND_ROWS, BODY_ROWS, ADD_ONE_ROW_TO_END);
double rowTop = getElementTop(getBodyRow(2)); double rowTop = getElementTop(getBodyRow(2));
scrollVerticallyTo(999999); scrollVerticallyTo(999999);
long oldBottomScrollTop = getScrollTop(); long oldBottomScrollTop = getScrollTop();
selectMenuPath(FEATURES, SPACERS, ROW_99, SET_100PX); selectMenuPath(FEATURES, SPACERS, ROW_99, SET_100PX);
waitForElementPresent(By.className("v-escalator-spacer"));


assertEquals( assertEquals(
"Adding a spacer underneath the current viewport should " "Adding a spacer underneath the current viewport should "
@Test @Test
public void removingRowAboveSpacerMovesSpacerUp() { public void removingRowAboveSpacerMovesSpacerUp() {
selectMenuPath(FEATURES, SPACERS, ROW_1, SET_100PX); selectMenuPath(FEATURES, SPACERS, ROW_1, SET_100PX);
waitForElementPresent(By.className("v-escalator-spacer"));
WebElement spacer = getSpacer(1); WebElement spacer = getSpacer(1);
double originalElementTop = getElementTop(spacer); double originalElementTop = getElementTop(spacer);


public void spacersAreFixedInViewport_firstFreezeThenScroll() { public void spacersAreFixedInViewport_firstFreezeThenScroll() {
selectMenuPath(FEATURES, FROZEN_COLUMNS, FREEZE_1_COLUMN); selectMenuPath(FEATURES, FROZEN_COLUMNS, FREEZE_1_COLUMN);
selectMenuPath(FEATURES, SPACERS, ROW_1, SET_100PX); selectMenuPath(FEATURES, SPACERS, ROW_1, SET_100PX);
waitForElementPresent(By.className("v-escalator-spacer"));
assertEquals( assertEquals(
"Spacer's left position should've been 0 at the " + "beginning", "Spacer's left position should've been 0 at the " + "beginning",
0d, getElementLeft(getSpacer(1)), WidgetUtil.PIXEL_EPSILON); 0d, getElementLeft(getSpacer(1)), WidgetUtil.PIXEL_EPSILON);
int scrollTo = 10; int scrollTo = 10;
scrollHorizontallyTo(scrollTo); scrollHorizontallyTo(scrollTo);
selectMenuPath(FEATURES, SPACERS, ROW_1, SET_100PX); selectMenuPath(FEATURES, SPACERS, ROW_1, SET_100PX);
waitForElementPresent(By.className("v-escalator-spacer"));
assertEquals( assertEquals(
"Spacer's left position should've been " + scrollTo "Spacer's left position should've been " + scrollTo
+ " after scrolling " + scrollTo + "px", + " after scrolling " + scrollTo + "px",


selectMenuPath(FEATURES, SPACERS, FOCUSABLE_UPDATER); selectMenuPath(FEATURES, SPACERS, FOCUSABLE_UPDATER);
selectMenuPath(FEATURES, SPACERS, ROW_1, SET_100PX); selectMenuPath(FEATURES, SPACERS, ROW_1, SET_100PX);
waitForElementPresent(By.className("v-escalator-spacer"));


WebElement inputElement = getEscalator() WebElement inputElement = getEscalator()
.findElement(By.tagName("input")); .findElement(By.tagName("input"));
@Test @Test
public void spacersAreInsertedInCorrectDomPosition() { public void spacersAreInsertedInCorrectDomPosition() {
selectMenuPath(FEATURES, SPACERS, ROW_1, SET_100PX); selectMenuPath(FEATURES, SPACERS, ROW_1, SET_100PX);
waitForElementPresent(By.className("v-escalator-spacer"));


WebElement tbody = getEscalator().findElement(By.tagName("tbody")); WebElement tbody = getEscalator().findElement(By.tagName("tbody"));
WebElement spacer = getChild(tbody, 2); WebElement spacer = getChild(tbody, 2);
public void spacersAreInCorrectDomPositionAfterScroll() public void spacersAreInCorrectDomPositionAfterScroll()
throws InterruptedException { throws InterruptedException {
selectMenuPath(FEATURES, SPACERS, ROW_1, SET_100PX); selectMenuPath(FEATURES, SPACERS, ROW_1, SET_100PX);
waitForElementPresent(By.className("v-escalator-spacer"));


scrollVerticallyTo(40); // roughly two rows' worth scrollVerticallyTo(40); // roughly two rows' worth


public void spacerOpenedInViewGetsFocus() { public void spacerOpenedInViewGetsFocus() {
selectMenuPath(FEATURES, SPACERS, FOCUSABLE_UPDATER); selectMenuPath(FEATURES, SPACERS, FOCUSABLE_UPDATER);
selectMenuPath(FEATURES, SPACERS, ROW_1, SET_100PX); selectMenuPath(FEATURES, SPACERS, ROW_1, SET_100PX);
waitForElementPresent(By.className("v-escalator-spacer"));
tryToTabIntoFocusUpdaterElement(); tryToTabIntoFocusUpdaterElement();
WebElement focusedElement = getFocusedElement(); WebElement focusedElement = getFocusedElement();
assertEquals("input", focusedElement.getTagName()); assertEquals("input", focusedElement.getTagName());

+ 29
- 41
uitest/src/test/java/com/vaadin/tests/components/ui/TextAreaEventPropagationTest.java Vedi File

package com.vaadin.tests.components.ui; package com.vaadin.tests.components.ui;


import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;


import org.junit.Test; import org.junit.Test;
import org.openqa.selenium.Keys; import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.interactions.Actions;


import com.vaadin.testbench.elements.TextAreaElement; import com.vaadin.testbench.elements.TextAreaElement;
@Test @Test
public void textAreaEnterEventPropagation() throws InterruptedException { public void textAreaEnterEventPropagation() throws InterruptedException {
openTestURL(); openTestURL();
WebElement textArea = $(TextAreaElement.class).first();
TextAreaElement textArea = $(TextAreaElement.class).first();
Actions builder = new Actions(driver); Actions builder = new Actions(driver);
builder.click(textArea); builder.click(textArea);
builder.sendKeys(textArea, "first line asdf");
builder.sendKeys(textArea, "first line asdf", Keys.ENTER,
"second line jkl;");
builder.perform(); builder.perform();
waitUntilLoadingIndicatorNotVisible(); waitUntilLoadingIndicatorNotVisible();


builder.sendKeys(Keys.ENTER);
builder.perform();
waitUntilLoadingIndicatorNotVisible();

builder.sendKeys(textArea, "second line jkl;");
builder.perform();
waitUntilLoadingIndicatorNotVisible();

builder.perform();

String text = textArea.getValue();
assertEquals("Unexpected text area content,",
"first line asdf\nsecond line jkl;", text);
// Should not have triggered shortcut // Should not have triggered shortcut
assertEquals(" ", getLogRow(0)); assertEquals(" ", getLogRow(0));
} }
public void testTextAreaEscapeEventPropagation() public void testTextAreaEscapeEventPropagation()
throws InterruptedException { throws InterruptedException {
openTestURL(); openTestURL();
WebElement textArea = $(TextAreaElement.class).first();
TextAreaElement textArea = $(TextAreaElement.class).first();
Actions builder = new Actions(driver); Actions builder = new Actions(driver);
builder.click(textArea); builder.click(textArea);
builder.sendKeys(textArea, "first line asdf");
builder.perform();
waitUntilLoadingIndicatorNotVisible();

builder.sendKeys(Keys.ESCAPE);
builder.perform();
waitUntilLoadingIndicatorNotVisible();

builder.sendKeys(textArea, "second line jkl;");
builder.sendKeys(textArea, "first line asdf", Keys.ESCAPE,
"second line jkl;");
builder.perform(); builder.perform();
waitUntilLoadingIndicatorNotVisible(); waitUntilLoadingIndicatorNotVisible();


String text = textArea.getValue();
// sendKeys is erratic and can eat some letters after escape, so only
// test that beginning and end are present
assertTrue("Unexpected text area content: " + text,
text.startsWith("first line asdf"));
assertTrue("Unexpected text area content: " + text,
text.endsWith("nd line jkl;"));
assertFalse("Unexpected text area content: " + text,
text.contains("\n"));
assertEquals("1. Escape button pressed", getLogRow(0)); assertEquals("1. Escape button pressed", getLogRow(0));
} }


@Test @Test
public void testTextFieldEscapeEventPropagation() { public void testTextFieldEscapeEventPropagation() {
openTestURL(); openTestURL();
WebElement textField = $(TextFieldElement.class).first();
TextFieldElement textField = $(TextFieldElement.class).first();
Actions builder2 = new Actions(driver); Actions builder2 = new Actions(driver);
builder2.click(textField); builder2.click(textField);


builder2.sendKeys("third line");
builder2.perform();
waitUntilLoadingIndicatorNotVisible();

builder2.sendKeys(Keys.ENTER);
builder2.perform();
waitUntilLoadingIndicatorNotVisible();

builder2.sendKeys(Keys.ESCAPE);
builder2.sendKeys(textField, "third line", Keys.ESCAPE);
builder2.perform(); builder2.perform();
waitUntilLoadingIndicatorNotVisible(); waitUntilLoadingIndicatorNotVisible();


assertEquals("1. Enter button pressed", getLogRow(1));
assertEquals("2. Escape button pressed", getLogRow(0));
String text = textField.getValue();
assertEquals("Unexpected text field content,", "third line", text);
assertEquals("1. Escape button pressed", getLogRow(0));
} }


@Test @Test
public void testTextFieldEnterEventPropagation() { public void testTextFieldEnterEventPropagation() {
openTestURL(); openTestURL();
WebElement textField = $(TextFieldElement.class).first();
TextFieldElement textField = $(TextFieldElement.class).first();
Actions builder2 = new Actions(driver); Actions builder2 = new Actions(driver);
builder2.click(textField); builder2.click(textField);


builder2.sendKeys("third line");
builder2.perform();
waitUntilLoadingIndicatorNotVisible();

builder2.sendKeys(Keys.ENTER);
builder2.sendKeys(textField, "third line", Keys.ENTER);
builder2.perform(); builder2.perform();
waitUntilLoadingIndicatorNotVisible(); waitUntilLoadingIndicatorNotVisible();


String text = textField.getValue();
assertEquals("Unexpected text field content,", "third line", text);
assertEquals("1. Enter button pressed", getLogRow(0)); assertEquals("1. Enter button pressed", getLogRow(0));
} }
} }

+ 22
- 5
uitest/src/test/java/com/vaadin/tests/elements/menubar/MenuBarUITest.java Vedi File

package com.vaadin.tests.elements.menubar; package com.vaadin.tests.elements.menubar;


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import java.util.List; import java.util.List;


import org.junit.Before; import org.junit.Before;
import com.vaadin.testbench.elements.MenuBarElement; import com.vaadin.testbench.elements.MenuBarElement;
import com.vaadin.tests.tb3.MultiBrowserTest; import com.vaadin.tests.tb3.MultiBrowserTest;


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public class MenuBarUITest extends MultiBrowserTest { public class MenuBarUITest extends MultiBrowserTest {


@Override @Override
MenuBarElement menuBar = $(MenuBarElement.class).first(); MenuBarElement menuBar = $(MenuBarElement.class).first();


menuBar.clickItem("File"); menuBar.clickItem("File");
waitForElementPresent(By.className("v-menubar-popup"));
assertTrue(isItemVisible("Export..")); assertTrue(isItemVisible("Export.."));


menuBar.clickItem("Export.."); menuBar.clickItem("Export..");
sleep(100);
assertTrue(isItemVisible("As PDF...")); assertTrue(isItemVisible("As PDF..."));


menuBar.clickItem("File"); menuBar.clickItem("File");
sleep(100);
assertFalse(isItemVisible("Export..")); assertFalse(isItemVisible("Export.."));
} }


MenuBarElement menuBar = $(MenuBarElement.class).first(); MenuBarElement menuBar = $(MenuBarElement.class).first();


menuBar.clickItem("File"); menuBar.clickItem("File");
waitForElementPresent(By.className("v-menubar-popup"));
assertTrue(isItemVisible("Save As..")); assertTrue(isItemVisible("Save As.."));


menuBar.clickItem("Export.."); menuBar.clickItem("Export..");
sleep(100);
assertTrue(isItemVisible("As PDF...")); assertTrue(isItemVisible("As PDF..."));


// The Edit menu will be opened by moving the mouse over the item (done // The Edit menu will be opened by moving the mouse over the item (done
// by clickItem). The first click then actually closes the menu. // by clickItem). The first click then actually closes the menu.
menuBar.clickItem("Edit"); menuBar.clickItem("Edit");
sleep(100);
waitForElementNotPresent(By.className("v-menubar-popup"));
menuBar.clickItem("Edit"); menuBar.clickItem("Edit");
waitForElementPresent(By.className("v-menubar-popup"));
assertFalse(isItemVisible("Save As..")); assertFalse(isItemVisible("Save As.."));
assertTrue(isItemVisible("Paste")); assertTrue(isItemVisible("Paste"));


menuBar.clickItem("Edit"); menuBar.clickItem("Edit");
sleep(100);
assertFalse(isItemVisible("Save As..")); assertFalse(isItemVisible("Save As.."));
assertFalse(isItemVisible("Paste")); assertFalse(isItemVisible("Paste"));


menuBar.clickItem("Edit"); menuBar.clickItem("Edit");
sleep(100);
assertFalse(isItemVisible("Save As..")); assertFalse(isItemVisible("Save As.."));
assertTrue(isItemVisible("Paste")); assertTrue(isItemVisible("Paste"));


// Menu does not contain a submenu, no need to click twice. // Menu does not contain a submenu, no need to click twice.
menuBar.clickItem("Help"); menuBar.clickItem("Help");
sleep(100);
assertFalse(isItemVisible("Save As..")); assertFalse(isItemVisible("Save As.."));
assertFalse(isItemVisible("Paste")); assertFalse(isItemVisible("Paste"));


// No submenu is open, so click only once to open the File menu. // No submenu is open, so click only once to open the File menu.
menuBar.clickItem("File"); menuBar.clickItem("File");
sleep(100);
assertTrue(isItemVisible("Save As..")); assertTrue(isItemVisible("Save As.."));
} }


public void testMenuBarClickPath() { public void testMenuBarClickPath() {
MenuBarElement menuBar = $(MenuBarElement.class).first(); MenuBarElement menuBar = $(MenuBarElement.class).first();
menuBar.clickItem("File", "Export.."); menuBar.clickItem("File", "Export..");
waitForElementPresent(By.className("v-menubar-popup"));
assertTrue(isItemVisible("As Doc...")); assertTrue(isItemVisible("As Doc..."));
} }


MenuBarElement menuBar = $(MenuBarElement.class).get(2); MenuBarElement menuBar = $(MenuBarElement.class).get(2);


menuBar.clickItem("File"); menuBar.clickItem("File");
waitForElementPresent(By.className("v-menubar-popup"));
assertTrue(isItemVisible("Open2")); assertTrue(isItemVisible("Open2"));
// Close the menu item // Close the menu item
menuBar.clickItem("File"); menuBar.clickItem("File");
waitForElementNotPresent(By.className("v-menubar-popup"));


menuBar = $(MenuBarElement.class).get(1); menuBar = $(MenuBarElement.class).get(1);
menuBar.clickItem("Edit2"); menuBar.clickItem("Edit2");
waitForElementPresent(By.className("v-menubar-popup"));
assertTrue(isItemVisible("Cut")); assertTrue(isItemVisible("Cut"));
menuBar.clickItem("Edit2"); menuBar.clickItem("Edit2");
waitForElementNotPresent(By.className("v-menubar-popup"));


menuBar = $(MenuBarElement.class).first(); menuBar = $(MenuBarElement.class).first();
menuBar.clickItem("File"); menuBar.clickItem("File");
waitForElementPresent(By.className("v-menubar-popup"));
assertTrue(isItemVisible("Open")); assertTrue(isItemVisible("Open"));
} }


public void testMenuItemTooltips() { public void testMenuItemTooltips() {
MenuBarElement first = $(MenuBarElement.class).first(); MenuBarElement first = $(MenuBarElement.class).first();
first.clickItem("File"); first.clickItem("File");
waitForElementPresent(By.className("v-menubar-popup"));
assertTooltip("Open", "<b>Preformatted</b>\ndescription"); assertTooltip("Open", "<b>Preformatted</b>\ndescription");
assertTooltip("Save", "plain description, <b>HTML</b> is visible"); assertTooltip("Save", "plain description, <b>HTML</b> is visible");
assertTooltip("Exit", "HTML\ndescription"); assertTooltip("Exit", "HTML\ndescription");

+ 1
- 1
uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridClientRenderers.java Vedi File

return path; return path;
} }


@ServerClass("com.vaadin.tests.widgetset.server.grid.GridClientColumnRenderers.GridController")
@ServerClass("com.vaadin.tests.widgetset.server.v7.grid.GridClientColumnRenderers.GridController")
public static class MyClientGridElement extends GridElement { public static class MyClientGridElement extends GridElement {
} }



+ 11
- 4
uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridWithoutRendererTest.java Vedi File

package com.vaadin.v7.tests.components.grid; package com.vaadin.v7.tests.components.grid;


import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;


import java.util.List; import java.util.List;
import org.openqa.selenium.By; import org.openqa.selenium.By;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;


import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.parallel.TestCategory; import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.SingleBrowserTest; import com.vaadin.tests.tb3.SingleBrowserTest;


@Test @Test
public void ensureNoError() { public void ensureNoError() {
openTestURL(); openTestURL();
// WebElement errorIndicator = findElement(By
// .cssSelector("v-error-indicator"));
// System.out.println(errorIndicator);
waitForElementPresent(By.className("v-grid"));
List<WebElement> errorIndicator = findElements( List<WebElement> errorIndicator = findElements(
By.xpath("//span[@class='v-errorindicator']"));
By.className("v-errorindicator"));
assertTrue("There should not be an error indicator", assertTrue("There should not be an error indicator",
errorIndicator.isEmpty()); errorIndicator.isEmpty());

// add an error to ensure that the check is correct
$(ButtonElement.class).first().click();

errorIndicator = findElements(By.className("v-errorindicator"));
assertFalse("There should be an error indicator",
errorIndicator.isEmpty());
} }


} }

+ 15
- 3
uitest/src/test/java/com/vaadin/v7/tests/components/tree/TreeItemDoubleClickTest.java Vedi File

openTestURL(); openTestURL();
String caption = "Tree Item 2"; String caption = "Tree Item 2";
doubleClick(getTreeNodeByCaption(caption)); doubleClick(getTreeNodeByCaption(caption));
assertLogText("Double Click " + caption);
try {
assertLogText("Double Click " + caption);
} catch (AssertionError e) {
// double click is flaky, try again
doubleClick(getTreeNodeByCaption(caption));
assertLogText("Double Click " + caption);
}


changeImmediate(); changeImmediate();


caption = "Tree Item 3"; caption = "Tree Item 3";
doubleClick(getTreeNodeByCaption(caption)); doubleClick(getTreeNodeByCaption(caption));
assertLogText("Double Click " + caption);
try {
assertLogText("Double Click " + caption);
} catch (AssertionError e) {
// double click is flaky, try again
doubleClick(getTreeNodeByCaption(caption));
assertLogText("Double Click " + caption);
}
} }


private void changeImmediate() { private void changeImmediate() {


private void doubleClick(WebElement element) { private void doubleClick(WebElement element) {
new Actions(getDriver()).doubleClick(element).build().perform(); new Actions(getDriver()).doubleClick(element).build().perform();
sleep(100);
} }


private void assertLogText(String text) { private void assertLogText(String text) {

Loading…
Annulla
Salva