123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- /*
- * Copyright 2000-2016 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.grid;
-
- import java.util.List;
-
- import org.junit.Assert;
- import org.junit.Test;
- import org.openqa.selenium.By;
- import org.openqa.selenium.Dimension;
- import org.openqa.selenium.Point;
- import org.openqa.selenium.WebElement;
-
- import com.vaadin.testbench.elements.GridElement;
- import com.vaadin.tests.tb3.MultiBrowserTest;
-
- public class GridSidebarPositionTest extends MultiBrowserTest {
-
- @Test
- public void heightRestrictedToBrowserWindow() {
- openTestURL();
- GridElement gridWithVeryManyColumns = $(LegacyGridElement.class)
- .id(GridSidebarPosition.POPUP_WINDOW_HEIGHT);
- getSidebarOpenButton(gridWithVeryManyColumns).click();
- Dimension popupSize = getSidebarPopup().getSize();
- Dimension browserWindowSize = getDriver().manage().window().getSize();
-
- Assert.assertTrue(
- popupSize.getHeight() <= browserWindowSize.getHeight());
- }
-
- @Test
- public void popupNotBelowBrowserWindow() {
- openTestURL();
- GridElement gridAtBottom = $(LegacyGridElement.class)
- .id(GridSidebarPosition.POPUP_WINDOW_MOVED_UP);
- getSidebarOpenButton(gridAtBottom).click();
- WebElement sidebarPopup = getSidebarPopup();
- Dimension popupSize = sidebarPopup.getSize();
- Point popupLocation = sidebarPopup.getLocation();
- int popupBottom = popupLocation.getY() + popupSize.getHeight();
- Dimension browserWindowSize = getDriver().manage().window().getSize();
-
- Assert.assertTrue(popupBottom <= browserWindowSize.getHeight());
- }
-
- @Test
- public void popupAbove() {
- openTestURL();
- GridElement gridPopupAbove = $(LegacyGridElement.class)
- .id(GridSidebarPosition.POPUP_ABOVE);
- WebElement sidebarOpenButton = getSidebarOpenButton(gridPopupAbove);
- sidebarOpenButton.click();
- WebElement sidebarPopup = getSidebarPopup();
- Dimension popupSize = sidebarPopup.getSize();
- Point popupLocation = sidebarPopup.getLocation();
- int popupBottom = popupLocation.getY() + popupSize.getHeight();
- int sideBarButtonTop = sidebarOpenButton.getLocation().getY();
- Assert.assertTrue(popupBottom <= sideBarButtonTop);
- }
-
- protected WebElement getSidebarOpenButton(GridElement grid) {
- List<WebElement> elements = grid
- .findElements(By.className("v-grid-sidebar-button"));
- return elements.isEmpty() ? null : elements.get(0);
- }
-
- protected WebElement getSidebarPopup() {
- List<WebElement> elements = findElements(
- By.className("v-grid-sidebar-popup"));
- return elements.isEmpty() ? null : elements.get(0);
- }
-
- }
|