@@ -1,36 +0,0 @@ | |||
package com.vaadin.tests.components.grid; | |||
import org.junit.Assert; | |||
import org.junit.Test; | |||
import com.vaadin.testbench.elements.GridElement; | |||
import com.vaadin.testbench.elements.OptionGroupElement; | |||
import com.vaadin.tests.tb3.SingleBrowserTest; | |||
public class SortableHeaderStylesTest extends SingleBrowserTest { | |||
@Test | |||
public void testSortableHeaderStyles() { | |||
openTestURL(); | |||
Assert.assertFalse(hasSortableStyle(0)); | |||
for (int i = 1; i < 8; i++) { | |||
Assert.assertTrue(hasSortableStyle(i)); | |||
} | |||
OptionGroupElement sortableSelector = $(OptionGroupElement.class) | |||
.first(); | |||
// Toggle sortability | |||
sortableSelector.selectByText("lastName"); | |||
Assert.assertFalse(hasSortableStyle(3)); | |||
// Toggle back | |||
sortableSelector.selectByText("lastName"); | |||
Assert.assertTrue(hasSortableStyle(3)); | |||
} | |||
private boolean hasSortableStyle(int column) { | |||
return $(GridElement.class).first().getHeaderCell(0, column) | |||
.getAttribute("class").contains("sortable"); | |||
} | |||
} |
@@ -27,58 +27,6 @@ public class SplitPanelWithMinimumAndMaximumTest extends MultiBrowserTest { | |||
openTestURL(); | |||
} | |||
@Test | |||
public void testMoveHorizontalSplitsToLimits() { | |||
// Amount of pixels to move each splitter (to left) | |||
int[] movements = { -250, -350, -320, -100, -200, -100, -170, -400 }; | |||
// Expected final positions of splitters (at left limit) | |||
int[] finalPositions = { 60, 60, 100, 100, 478, 478, 550, 550 }; | |||
List<HorizontalSplitPanelElement> splits = $( | |||
HorizontalSplitPanelElement.class).all(); | |||
Actions actions = new Actions(driver); | |||
for (int i = 0; i < splits.size(); i++) { | |||
TestBenchElement splitter = splits.get(i).getSplitter(); | |||
actions.clickAndHold(splitter).moveByOffset(movements[i], 0) | |||
.release().perform(); | |||
double newX = parseHorizontalPosition(splitter, i < 4); | |||
int expectedX = finalPositions[i]; | |||
// Due to minor browser differences and sub-pixels we must allow 1px | |||
// of play between the expected and measured value | |||
assertTrue( | |||
"When moving left, the splitter at index " + i | |||
+ " was at position " + newX + " (expected " | |||
+ expectedX + ").", | |||
Math.abs(newX - expectedX) <= 1); | |||
} | |||
// Amount of pixels to move each splitter (to right) | |||
movements = new int[] { 450, 450, 480, 480, 450, 450, 480, 480 }; | |||
// Expected final positions of splitters (at right limit) | |||
finalPositions = new int[] { 478, 478, 550, 550, 60, 60, 100, 100 }; | |||
for (int i = 0; i < splits.size(); i++) { | |||
TestBenchElement splitter = splits.get(i).getSplitter(); | |||
actions.clickAndHold(splitter).moveByOffset(movements[i], 0) | |||
.release().perform(); | |||
double newX = parseHorizontalPosition(splitter, i < 4); | |||
int expectedX = finalPositions[i]; | |||
assertTrue( | |||
"When moving right, the splitter at index " + i | |||
+ " was at position " + newX + " (expected " | |||
+ expectedX + ").", | |||
Math.abs(newX - expectedX) <= 1); | |||
} | |||
} | |||
@Test | |||
public void testMoveVerticalSplitsToLimits() { | |||
$(TabSheetElement.class).first().openTab(1); |
@@ -1,90 +0,0 @@ | |||
package com.vaadin.tests.components.table; | |||
import static org.hamcrest.CoreMatchers.is; | |||
import static org.hamcrest.MatcherAssert.assertThat; | |||
import static org.hamcrest.Matchers.lessThan; | |||
import java.util.List; | |||
import org.junit.Test; | |||
import org.openqa.selenium.By; | |||
import org.openqa.selenium.WebElement; | |||
import org.openqa.selenium.interactions.Actions; | |||
import org.openqa.selenium.remote.DesiredCapabilities; | |||
import com.vaadin.tests.tb3.MultiBrowserTest; | |||
/** | |||
* Test for context menu position and size. | |||
* | |||
* @author Vaadin Ltd | |||
*/ | |||
public class ContextMenuSizeTest extends MultiBrowserTest { | |||
@Override | |||
public List<DesiredCapabilities> getBrowsersToTest() { | |||
return getBrowsersSupportingContextMenu(); | |||
} | |||
@Override | |||
public void setup() throws Exception { | |||
super.setup(); | |||
openTestURL(); | |||
} | |||
private void resizeViewPortHeightTo(int windowHeight) { | |||
// viewport width doesn't matter, let's use a magic number of 500. | |||
testBench().resizeViewPortTo(500, windowHeight); | |||
} | |||
private int getContextMenuY() { | |||
int y = openContextMenu().getLocation().getY(); | |||
closeContextMenu(); | |||
return y; | |||
} | |||
private int getContextMenuHeight() { | |||
int height = openContextMenu().getSize().getHeight(); | |||
closeContextMenu(); | |||
return height; | |||
} | |||
private WebElement openContextMenu() { | |||
Actions actions = new Actions(getDriver()); | |||
actions.contextClick(findElement(By.className("v-table-cell-wrapper"))); | |||
actions.perform(); | |||
return findElement(By.className("v-contextmenu")); | |||
} | |||
private void closeContextMenu() { | |||
findElement(By.className("v-app")).click(); | |||
} | |||
@Test | |||
public void contextMenuIsResizedToFitWindow() { | |||
int initialHeight = getContextMenuHeight(); | |||
resizeViewPortHeightTo(initialHeight - 10); | |||
assertThat(getContextMenuHeight(), lessThan(initialHeight)); | |||
resizeViewPortHeightTo(initialHeight + 100); | |||
assertThat(getContextMenuHeight(), is(initialHeight)); | |||
} | |||
@Test | |||
public void contextMenuPositionIsChangedAfterResize() { | |||
int height = getContextMenuHeight(); | |||
int y = getContextMenuY(); | |||
resizeViewPortHeightTo(y + height - 10); | |||
assertThat(getContextMenuY(), lessThan(y)); | |||
assertThat(getContextMenuHeight(), is(height)); | |||
} | |||
} |
@@ -1,36 +0,0 @@ | |||
package com.vaadin.tests.extensions; | |||
import org.junit.Test; | |||
import org.openqa.selenium.WebDriver; | |||
import org.openqa.selenium.support.ui.ExpectedCondition; | |||
import com.vaadin.testbench.By; | |||
import com.vaadin.testbench.elements.PanelElement; | |||
import com.vaadin.tests.tb3.MultiBrowserTest; | |||
public class ResponsiveLayoutUpdateTest extends MultiBrowserTest { | |||
@Test | |||
public void testWidthAndHeightRanges() throws Exception { | |||
openTestURL(); | |||
final PanelElement panelElement = $(PanelElement.class).first(); | |||
// I currently have no idea why PhantomJS wants a click here to work | |||
// properly | |||
panelElement.click(); | |||
waitForElementVisible(By.cssSelector(".layout-update")); | |||
compareScreen("large"); | |||
// Resize below 600px width breakpoint | |||
testBench().resizeViewPortTo(550, 768); | |||
waitUntil(new ExpectedCondition<Boolean>() { | |||
@Override | |||
public Boolean apply(WebDriver input) { | |||
return panelElement.getSize().getWidth() < 500; | |||
} | |||
}); | |||
compareScreen("small"); | |||
} | |||
} |
@@ -1,48 +0,0 @@ | |||
package com.vaadin.tests.extensions; | |||
import static org.junit.Assert.assertEquals; | |||
import org.junit.Before; | |||
import org.junit.Test; | |||
import org.openqa.selenium.support.ui.ExpectedConditions; | |||
import org.openqa.selenium.support.ui.WebDriverWait; | |||
import com.vaadin.testbench.By; | |||
import com.vaadin.testbench.elements.CssLayoutElement; | |||
import com.vaadin.tests.tb3.MultiBrowserTest; | |||
public class ResponsiveWidthAndHeightTest extends MultiBrowserTest { | |||
@Before | |||
public void setUp() throws Exception { | |||
// We need this in order to ensure that the initial width-range is | |||
// width: 600px- and height: 500px- | |||
testBench().resizeViewPortTo(1024, 768); | |||
} | |||
@Test | |||
public void testWidthAndHeightRanges() throws Exception { | |||
openTestURL(); | |||
// IE sometimes has trouble waiting long enough. | |||
new WebDriverWait(getDriver(), 30) | |||
.until(ExpectedConditions.presenceOfElementLocated( | |||
By.cssSelector(".v-csslayout-width-and-height"))); | |||
// Verify both width-range and height-range. | |||
assertEquals("600px-", | |||
$(CssLayoutElement.class).first().getAttribute("width-range")); | |||
assertEquals("500px-", | |||
$(CssLayoutElement.class).first().getAttribute("height-range")); | |||
// Resize | |||
testBench().resizeViewPortTo(550, 450); | |||
// Verify updated width-range and height-range. | |||
assertEquals("0-599px", | |||
$(CssLayoutElement.class).first().getAttribute("width-range")); | |||
assertEquals("0-499px", | |||
$(CssLayoutElement.class).first().getAttribute("height-range")); | |||
} | |||
} |
@@ -1,54 +0,0 @@ | |||
package com.vaadin.tests.extensions; | |||
import static org.junit.Assert.assertEquals; | |||
import java.util.List; | |||
import org.junit.Before; | |||
import org.junit.Test; | |||
import org.openqa.selenium.remote.DesiredCapabilities; | |||
import org.openqa.selenium.support.ui.ExpectedConditions; | |||
import org.openqa.selenium.support.ui.WebDriverWait; | |||
import com.vaadin.testbench.By; | |||
import com.vaadin.testbench.elements.ButtonElement; | |||
import com.vaadin.testbench.elements.CssLayoutElement; | |||
import com.vaadin.tests.tb3.MultiBrowserTest; | |||
public class SetThemeAndResponsiveLayoutTest extends MultiBrowserTest { | |||
@Before | |||
public void setUp() throws Exception { | |||
// We need this in order to ensure that the initial width-range is | |||
// width: 600px- and height: 500px- | |||
testBench().resizeViewPortTo(1024, 768); | |||
} | |||
@Test | |||
public void testWidthAndHeightRanges() throws Exception { | |||
openTestURL(); | |||
// IE sometimes has trouble waiting long enough. | |||
new WebDriverWait(getDriver(), 30) | |||
.until(ExpectedConditions.presenceOfElementLocated( | |||
By.cssSelector(".v-csslayout-width-and-height"))); | |||
// set the theme programmatically | |||
$(ButtonElement.class).caption("Set theme").first().click(); | |||
new WebDriverWait(getDriver(), 30).until(ExpectedConditions | |||
.presenceOfElementLocated(By.xpath("//div[@width-range]"))); | |||
// Verify both width-range and height-range. | |||
assertEquals("600px-", | |||
$(CssLayoutElement.class).first().getAttribute("width-range")); | |||
assertEquals("500px-", | |||
$(CssLayoutElement.class).first().getAttribute("height-range")); | |||
// Resize | |||
testBench().resizeViewPortTo(550, 450); | |||
// Verify updated width-range and height-range. | |||
assertEquals("0-599px", | |||
$(CssLayoutElement.class).first().getAttribute("width-range")); | |||
assertEquals("0-499px", | |||
$(CssLayoutElement.class).first().getAttribute("height-range")); | |||
} | |||
} |