You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LoadingIndicatorTest.java 3.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * Copyright 2000-2016 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.tests.components.grid.basicfeatures.server;
  17. import com.vaadin.tests.components.grid.LegacyGridElement;
  18. import org.junit.Assert;
  19. import org.junit.Test;
  20. import org.openqa.selenium.By;
  21. import org.openqa.selenium.WebDriver;
  22. import org.openqa.selenium.support.ui.ExpectedCondition;
  23. import org.openqa.selenium.support.ui.ExpectedConditions;
  24. import com.vaadin.testbench.elements.GridElement;
  25. import com.vaadin.tests.components.grid.basicfeatures.GridBasicFeaturesTest;
  26. public class LoadingIndicatorTest extends GridBasicFeaturesTest {
  27. @Test
  28. public void testLoadingIndicator() throws InterruptedException {
  29. setDebug(true);
  30. openTestURL();
  31. selectMenuPath("Component", "State", "Container delay", "2000");
  32. GridElement gridElement = $(LegacyGridElement.class).first();
  33. Assert.assertFalse(
  34. "Loading indicator should not be visible before disabling waitForVaadin",
  35. isLoadingIndicatorVisible());
  36. testBench().disableWaitForVaadin();
  37. // Scroll to a completely new location
  38. gridElement.getCell(200, 1);
  39. // Wait for loading indicator delay
  40. waitUntil(ExpectedConditions.visibilityOfElementLocated(
  41. By.className("v-loading-indicator")));
  42. waitUntilNot(ExpectedConditions.visibilityOfElementLocated(
  43. By.className("v-loading-indicator")));
  44. // Scroll so much that more data gets fetched, but not so much that
  45. // missing rows are shown
  46. gridElement.getCell(230, 1);
  47. // Wait for potentially triggered loading indicator to become visible
  48. Thread.sleep(500);
  49. Assert.assertFalse(
  50. "Loading indicator should not be visible when fetching rows that are not visible",
  51. isLoadingIndicatorVisible());
  52. // Finally verify that there was actually a request going on
  53. waitUntilLogContains("Requested items");
  54. }
  55. private void waitUntilLogContains(final String value) {
  56. waitUntil(new ExpectedCondition<Boolean>() {
  57. @Override
  58. public Boolean apply(WebDriver input) {
  59. return getLogRow(0).contains(value);
  60. }
  61. @Override
  62. public String toString() {
  63. // Timed out after 10 seconds waiting for ...
  64. return "first log row to contain '" + value + "' (was: '"
  65. + getLogRow(0) + "')";
  66. }
  67. });
  68. }
  69. }