outline: 5px auto -webkit-focus-ring-color;
outline-offset: -4px;
}
+.v-ch & .#{$primaryStyleName}-focus {
+ /* remove safari focus outline offset for chrome (evaluates also as safari) */
+ outline-offset: 0;
+}
.#{$primaryStyleName}-button {
width: $select-button-width;
margin-right: $select-button-negative-width;
<categories.exclude>${categories.exclude}</categories.exclude>
<browserstack.identifier>${browserstack.identifier}</browserstack.identifier>
</systemPropertyVariables>
- <includes>
- <include>**/AllTB3Tests.java</include>
- </includes>
</configuration>
<executions>
<execution>
+ <id>no-components</id>
+ <configuration>
+ <includes>
+ <include>**/LimitedTB3TestsNonComponent.java</include>
+ </includes>
+ </configuration>
+ <goals>
+ <goal>integration-test</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>components-no-grid</id>
+ <configuration>
+ <includes>
+ <include>**/LimitedTB3TestsComponentsNoGrid.java</include>
+ </includes>
+ </configuration>
+ <goals>
+ <goal>integration-test</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>grid-only</id>
+ <configuration>
+ <includes>
+ <include>**/LimitedTB3TestsComponentsGridOnly.java</include>
+ </includes>
+ </configuration>
<goals>
<goal>integration-test</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>verify</id>
+ <configuration>
+ <includes>
+ <include>**/LimitedTB3TestsNonComponent.java</include>
+ <include>**/LimitedTB3TestsComponentsNoGrid.java</include>
+ <include>**/LimitedTB3TestsComponentsGridOnly.java</include>
+ </includes>
+ </configuration>
+ <goals>
<goal>verify</goal>
</goals>
</execution>
import com.vaadin.tests.components.AbstractReindeerTestUI;
import com.vaadin.tests.widgetset.TestingWidgetSet;
import com.vaadin.tests.widgetset.server.LayoutDuringStateUpdateComponent;
+import com.vaadin.ui.Button;
@Widgetset(TestingWidgetSet.NAME)
public class LayoutDuringStateUpdate extends AbstractReindeerTestUI {
@Override
protected void setup(VaadinRequest request) {
- addComponent(new LayoutDuringStateUpdateComponent());
+ // delay adding of the component to ensure unrelated layouting calls
+ // don't interfere with the test
+ addComponent(new Button("Add component",
+ e -> addComponent(new LayoutDuringStateUpdateComponent())));
}
-
}
public class LayoutDuringStateUpdateConnector extends AbstractComponentConnector
implements PostLayoutListener {
private int layoutCount = 0;
+ private String changeLog = "";
@Override
protected void init() {
try {
getLayoutManager().layoutNow();
+
+ // these should never be reached
+ if (changeLog.isEmpty()) {
+ changeLog += " properties: ";
+ }
+ for (String property : stateChangeEvent.getChangedProperties()) {
+ changeLog += property + ", ";
+ }
} catch (AssertionError e) {
// Ignore
}
}
private void updateLabelText() {
- getWidget().setText("Layout phase count: " + layoutCount);
+ getWidget().setText("Layout phase count: " + layoutCount + changeLog);
+ changeLog = "";
}
@Override
import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.Alert;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebDriverException;
+import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
+import org.openqa.selenium.support.ui.ExpectedCondition;
import com.vaadin.testbench.elements.MenuBarElement;
import com.vaadin.testbench.parallel.Browser;
@Test
public void testTriggerExtension() {
openTestURL();
- MenuBarElement first = $(MenuBarElement.class).first();
- first.clickItem("TestExtension", "RunMe");
+ MenuBarElement menu = $(MenuBarElement.class).first();
+ clickItem(menu, "TestExtension", "RunMe");
checkAndCloseAlert();
- first.clickItem("TestExtension", "AddTrigger");
- first.clickItem("TestExtension", "RunMe");
+ clickItem(menu, "TestExtension", "AddTrigger");
+ clickItem(menu, "TestExtension", "RunMe");
checkAndCloseAlert();
checkAndCloseAlert();
sleep(500);
- first.clickItem("TestExtension", "RemoveTrigger");
- first.clickItem("TestExtension", "RunMe");
+ clickItem(menu, "TestExtension", "RemoveTrigger");
+ clickItem(menu, "TestExtension", "RunMe");
checkAndCloseAlert();
}
+ private void clickItem(MenuBarElement menu, String... captions) {
+ // click each given menu item in turn
+ for (String caption : captions) {
+ // wait for the menu item to become available
+ waitUntil(new ExpectedCondition<Boolean>() {
+ @Override
+ public Boolean apply(WebDriver arg0) {
+ List<WebElement> captionElements = findElements(
+ By.className("v-menubar-menuitem-caption"));
+ for (WebElement captionElement : captionElements) {
+ try {
+ if (captionElement.getText().equals(caption)) {
+ return true;
+ }
+ } catch (WebDriverException e) {
+ // stale, detached element is not visible
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ // Expected condition failed: waiting for ...
+ return caption + " to be available";
+ }
+ });
+ // menu item was found, click it
+ menu.clickItem(caption);
+ }
+ }
+
private void checkAndCloseAlert() {
Alert alert = getDriver().switchTo().alert();
Assert.assertEquals("Trigger", alert.getText());
package com.vaadin.tests.components.datefield;
+import static org.junit.Assert.assertEquals;
+
import org.junit.Test;
import org.openqa.selenium.By;
import com.vaadin.testbench.elements.TextFieldElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
-import static org.junit.Assert.assertEquals;
-
public class DateFieldFocusTest extends MultiBrowserTest {
@Test
// open DateField popup
dateField.findElement(By.className("v-datefield-button")).click();
- sleep(100);
+ waitUntilLoadingIndicatorNotVisible();
// close DateField popup
dateField.findElement(By.className("v-datefield-button")).click();
- sleep(100);
+ waitUntilLoadingIndicatorNotVisible();
assertEquals("1. focused", getLogRow(0));
textField.focus();
package com.vaadin.tests.components.datefield;
-import com.vaadin.tests.tb3.MultiBrowserTest;
+import static org.junit.Assert.assertNotEquals;
+
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement;
-import static org.junit.Assert.assertNotEquals;
+import com.vaadin.tests.tb3.MultiBrowserTest;
public class DateFieldNavigationKeyBoardTest extends MultiBrowserTest {
@Test
// Opening pop-up
findElement(By.className("v-datefield-button")).click();
waitForElementVisible(By.className("v-datefield-calendarpanel"));
+ waitForElementPresent(
+ By.className("v-datefield-calendarpanel-day-focused"));
// Focused element in the calendarPanel
WebElement focused = findElement(
By.className("v-datefield-calendarpanel-day-focused"));
openTestURL();
openEditor(10);
+ waitUntilLoadingIndicatorNotVisible();
waitForElementPresent(By.className("v-grid-editor"));
compareScreen("noscroll");
scrollGridHorizontallyTo(100);
- sleep(500);
+ waitUntilLoadingIndicatorNotVisible();
compareScreen("scrolled");
}
@Test
public void resizeWindow() {
openTestURL();
+ waitUntilLoadingIndicatorNotVisible();
+
GridElement grid = $(GridElement.class).first();
int col1WidthBefore = grid.getCell(0, 0).getSize().getWidth();
$(ButtonElement.class).caption("resize").first().click();
package com.vaadin.tests.components.grid;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import java.util.List;
import org.junit.Before;
import com.vaadin.testbench.parallel.BrowserUtil;
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 GridResizeHiddenColumnTest extends MultiBrowserTest {
@Before
sidebarPopup.findElements(By.className("gwt-MenuItem")));
// Click on "Last Name" menu item
action.click(visibilityToggle).perform();
+ waitUntilLoadingIndicatorNotVisible();
// Check if column "Last Name" is visible
headerCells = grid.getHeaderCells(0);
for (GridCellElement e : headerCells) {
widthSum += e.getSize().getWidth();
}
- sleep(100);
assertEquals("'Last Name' column should take up the remaining space",
grid.getHeader().getSize().getWidth(), widthSum, 1d);
}
getXOffset(headerCell, size.getWidth() + posX),
getYOffset(headerCell, size.getHeight() / 2))
.clickAndHold().moveByOffset(offset, 0).release().perform();
+ waitUntilLoadingIndicatorNotVisible();
}
}
selectMenuPath(GENERAL, POPULATE_COLUMN_ROW);
scrollVerticallyTo(99999);
+ waitUntilLoadingIndicatorNotVisible();
+
assertTrue("Escalator is not scrolled to bottom.",
isElementPresent(By.xpath("//td[text() = 'Row 99: 0,99']")));
selectMenuPath(COLUMNS_AND_ROWS, BODY_ROWS, REMOVE_ALL_INSERT_SCROLL);
scrollVerticallyTo(99999);
+ waitUntilLoadingIndicatorNotVisible();
+
assertTrue("Escalator is not scrolled to bottom.",
isElementPresent(By.xpath("//td[text() = 'Row 29: 0,129']")));
}
}
failed = true;
exceptions.append(i + ": " + e.getMessage());
+ if (e.getCause() != null && e.getCause().getMessage() != null
+ && !e.getCause().getMessage().trim().isEmpty()) {
+ exceptions.append(" - " + e.getCause().getMessage());
+ }
} catch (AssertionError e) {
if (failed) {
exceptions.append(" --- ");
}
failed = true;
exceptions.append(i + ": " + e.getMessage());
+ if (e.getCause() != null && e.getCause().getMessage() != null
+ && !e.getCause().getMessage().trim().isEmpty()) {
+ exceptions.append(" - " + e.getCause().getMessage());
+ }
} catch (AssertionError e) {
if (failed) {
exceptions.append(" --- ");
private void testResize(int start)
throws IOException, InterruptedException {
testBench().resizeViewPortTo(start, 600);
+ waitUntilLoadingIndicatorNotVisible();
int iterations = 0;
while (scrollRight() && iterations < 50) {
+ waitUntilLoadingIndicatorNotVisible();
++iterations;
}
// assertNoExtraRoom(start);
testBench().resizeViewPortTo(start + 150, 600);
+ waitUntilLoadingIndicatorNotVisible();
assertNoExtraRoom(start + 150);
}
Actions builder = new Actions(driver);
builder.click(textArea);
builder.sendKeys(textArea, "first line asdf");
+ builder.perform();
+ waitUntilLoadingIndicatorNotVisible();
+
builder.sendKeys(Keys.ENTER);
+ builder.perform();
+ waitUntilLoadingIndicatorNotVisible();
+
builder.sendKeys(textArea, "second line jkl;");
+ builder.perform();
+ waitUntilLoadingIndicatorNotVisible();
+
builder.perform();
// Should not have triggered shortcut
Actions builder = new Actions(driver);
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.perform();
+ waitUntilLoadingIndicatorNotVisible();
assertEquals("1. Escape button pressed", getLogRow(0));
}
builder2.click(textField);
builder2.sendKeys("third line");
- sleep(100);
+ builder2.perform();
+ waitUntilLoadingIndicatorNotVisible();
+
builder2.sendKeys(Keys.ENTER);
- sleep(100);
+ builder2.perform();
+ waitUntilLoadingIndicatorNotVisible();
+
builder2.sendKeys(Keys.ESCAPE);
builder2.perform();
+ waitUntilLoadingIndicatorNotVisible();
assertEquals("1. Enter button pressed", getLogRow(1));
assertEquals("2. Escape button pressed", getLogRow(0));
builder2.click(textField);
builder2.sendKeys("third line");
- builder2.sendKeys(Keys.ENTER);
+ builder2.perform();
+ waitUntilLoadingIndicatorNotVisible();
+ builder2.sendKeys(Keys.ENTER);
builder2.perform();
+ waitUntilLoadingIndicatorNotVisible();
assertEquals("1. Enter button pressed", getLogRow(0));
}
package com.vaadin.tests.components.window;
+import static org.junit.Assert.assertTrue;
+
import java.io.IOException;
import org.junit.Test;
import com.vaadin.testbench.elements.WindowElement;
import com.vaadin.tests.tb3.SingleBrowserTest;
-import static org.junit.Assert.assertTrue;
-
public class WindowHeaderButtonKeyboardActionsTest extends SingleBrowserTest {
private static final String HEADER_CLASS = "v-window-header";
// click button with mouse and wait
closeButton.click();
- sleep(200);
-
- assertTrue("Window is not closed when focused element is clicked",
- findElements(By.className("v-window")).size() == 0);
+ waitForElementNotPresent(By.className("v-window"));
}
// Tests for maximize-restore button
package com.vaadin.tests.components.window;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import org.junit.Test;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import com.vaadin.testbench.elements.TwinColSelectElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
public class WindowTwinColSelectTest extends MultiBrowserTest {
@Test
public void testBothVisibleInitially() {
openTestURL();
+ waitUntilLoadingIndicatorNotVisible();
TwinColSelectElement twinColSelect = $(TwinColSelectElement.class)
.first();
WebElement optionsElement = twinColSelect.getOptionsElement();
@Test
public void testResizingWindowReflowsLayout() throws Exception {
openTestURL();
+ waitUntilLoadingIndicatorNotVisible();
assertEquals("401px-600px",
$(".v-csslayout-grid.first").getAttribute("width-range"));
$(".v-csslayout-grid.second").getAttribute("width-range"));
testBench().resizeViewPortTo(1224, 768);
+ waitUntilLoadingIndicatorNotVisible();
assertEquals("601-800",
$(".v-csslayout-grid.first").getAttribute("width-range"));
$(".v-csslayout-grid.second").getAttribute("width-range"));
testBench().resizeViewPortTo(674, 768);
+ waitUntilLoadingIndicatorNotVisible();
assertEquals("201px-400px",
$(".v-csslayout-grid.first").getAttribute("width-range"));
@Test
public void checkScreenshot() throws IOException {
openTestURL();
+ waitUntilLoadingIndicatorNotVisible();
compareScreen("allVaadinIcons");
}
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
+import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.tests.tb3.SingleBrowserTest;
public class LayoutDuringStateUpdateTest extends SingleBrowserTest {
@Test
public void layoutDuringStateUpdate() {
openTestURL();
+ waitUntilLoadingIndicatorNotVisible();
- WebElement label = findElement(By.className("gwt-Label"));
+ // add the custom component
+ $(ButtonElement.class).first().click();
+ waitUntilLoadingIndicatorNotVisible();
+ // ensure the layouting failed to be triggered during the state update
+ WebElement label = findElement(By.className("gwt-Label"));
assertEquals("Layout phase count: 1", label.getText());
}
@Test
public void testNoLayout() {
openTestURL();
- assertCounts(1, 0);
+ // In some situations initial layouting is done in batches. That is OK,
+ // the point of this test is to ensure each subsequent action only
+ // causes expected amount of layouting rounds.
+ int offset = getCount("layoutCount") - 1;
+
+ assertCounts(1 + offset, 0);
$(CheckBoxElement.class).caption("UI polling enabled").first()
.findElement(By.tagName("input")).click();
// Toggling check box requires layout
- assertCounts(2, 0);
+ assertCounts(2 + offset, 0);
try {
Thread.sleep(2000);
e.printStackTrace();
}
// Count should not change even with polling enabled
- assertCounts(2, 0);
+ assertCounts(2 + offset, 0);
// Disable polling
$(CheckBoxElement.class).caption("UI polling enabled").first()
.findElement(By.tagName("input")).click();
// Toggling checkbox layotus again
- assertCounts(3, 0);
+ assertCounts(3 + offset, 0);
$(ButtonElement.class).caption("Change regular state").first().click();
// Updating normal state layouts
- assertCounts(4, 0);
+ assertCounts(4 + offset, 0);
$(ButtonElement.class).caption("Change @NoLayout state").first();
// Updating @NoLayout state does not layout
- assertCounts(4, 0);
+ assertCounts(4 + offset, 0);
$(ButtonElement.class).caption("Do regular RPC").first().click();
// Doing normal RPC layouts
- assertCounts(5, 0);
+ assertCounts(5 + offset, 0);
$(ButtonElement.class).caption("Do @NoLayout RPC").first().click();
// Doing @NoLayout RPC does not layout, but updates the RPC count
- assertCounts(5, 1);
+ assertCounts(5 + offset, 1);
$(ButtonElement.class).caption("Update LegacyComponent").first()
.click();
// Painting LegacyComponent layouts
- assertCounts(6, 1);
+ assertCounts(6 + offset, 1);
}
private void assertCounts(int layoutCount, int rpcCount) {
int h = SCREENSHOT_HEIGHT;
try {
- if (BrowserUtil.isChrome(getDesiredCapabilities())) {
- // Chrome 85 keeps failing in this task...
- sleep(200);
- }
testBench().resizeViewPortTo(w, h);
} catch (UnsupportedOperationException e) {
// Opera does not support this...
--- /dev/null
+package com.vaadin.tests.tb3;
+
+import java.io.IOException;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.model.InitializationError;
+
+import com.vaadin.tests.tb3.LimitedTB3TestsComponentsGridOnly.LimitedTB3TestsComponentsGridOnlySuite;
+
+/**
+ * Test consisting of all TB3 tests within package
+ * com.vaadin.tests.components.grid (classes extending AbstractTB3Test).
+ *
+ * @author Vaadin Ltd
+ */
+@RunWith(LimitedTB3TestsComponentsGridOnlySuite.class)
+public class LimitedTB3TestsComponentsGridOnly {
+
+ public static class LimitedTB3TestsComponentsGridOnlySuite
+ extends TB3TestSuite {
+
+ public LimitedTB3TestsComponentsGridOnlySuite(Class<?> klass)
+ throws InitializationError, IOException {
+ super(klass, AbstractTB3Test.class,
+ "com.vaadin.tests.components.grid", new String[] {});
+ }
+
+ }
+
+}
--- /dev/null
+package com.vaadin.tests.tb3;
+
+import java.io.IOException;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.model.InitializationError;
+
+import com.vaadin.tests.tb3.LimitedTB3TestsComponentsNoGrid.LimitedTB3TestsComponentsNoGridSuite;
+
+/**
+ * Test consisting of all TB3 tests within package com.vaadin.tests.components
+ * except those within package com.vaadin.tests.components.grid (classes
+ * extending AbstractTB3Test).
+ *
+ * @author Vaadin Ltd
+ */
+@RunWith(LimitedTB3TestsComponentsNoGridSuite.class)
+public class LimitedTB3TestsComponentsNoGrid {
+
+ public static class LimitedTB3TestsComponentsNoGridSuite
+ extends TB3TestSuite {
+
+ public LimitedTB3TestsComponentsNoGridSuite(Class<?> klass)
+ throws InitializationError, IOException {
+ super(klass, AbstractTB3Test.class, "com.vaadin.tests.components",
+ new String[] { "com.vaadin.tests.components.grid" });
+ }
+
+ }
+
+}
--- /dev/null
+package com.vaadin.tests.tb3;
+
+import java.io.IOException;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.model.InitializationError;
+
+import com.vaadin.tests.tb3.LimitedTB3TestsNonComponent.LimitedTB3TestsNonComponentSuite;
+
+/**
+ * Test consisting of all TB3 tests except integration tests and component tests
+ * (classes extending AbstractTB3Test, excludes packages
+ * com.vaadin.test.integration and com.vaadin.tests.components).
+ *
+ * @author Vaadin Ltd
+ */
+@RunWith(LimitedTB3TestsNonComponentSuite.class)
+public class LimitedTB3TestsNonComponent {
+
+ public static class LimitedTB3TestsNonComponentSuite extends TB3TestSuite {
+
+ public LimitedTB3TestsNonComponentSuite(Class<?> klass)
+ throws InitializationError, IOException {
+ super(klass, AbstractTB3Test.class, "com.vaadin.tests",
+ new String[] { "com.vaadin.tests.integration",
+ "com.vaadin.tests.components" });
+ }
+
+ }
+
+}
WebElement wideMenu = menus.get(WIDE_ELEMENT_INDEX);
int wideWidth = wideMenu.getSize().width;
assertThat(wideWidth, equalTo(WIDE_WIDTH));
- sleep(200);
+ sleep(300);
compareScreen("defaultMenuWidths");
}