2 * Copyright 2000-2016 Vaadin Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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
16 package com.vaadin.v7.tests.components.grid.basicfeatures.server;
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;
25 import com.vaadin.v7.testbench.customelements.GridElement;
26 import com.vaadin.v7.tests.components.grid.basicfeatures.GridBasicFeaturesTest;
28 public class LoadingIndicatorTest extends GridBasicFeaturesTest {
30 public void testLoadingIndicator() throws InterruptedException {
34 selectMenuPath("Component", "State", "Container delay", "2000");
36 GridElement gridElement = $(GridElement.class).first();
39 "Loading indicator should not be visible before disabling waitForVaadin",
40 isLoadingIndicatorVisible());
42 testBench().disableWaitForVaadin();
44 // Scroll to a completely new location
45 gridElement.getCell(200, 1);
47 // Wait for loading indicator delay
48 waitUntil(ExpectedConditions.visibilityOfElementLocated(
49 By.className("v-loading-indicator")));
51 waitUntilNot(ExpectedConditions.visibilityOfElementLocated(
52 By.className("v-loading-indicator")));
54 // Scroll so much that more data gets fetched, but not so much that
55 // missing rows are shown
56 gridElement.getCell(230, 1);
58 // Wait for potentially triggered loading indicator to become visible
62 "Loading indicator should not be visible when fetching rows that are not visible",
63 isLoadingIndicatorVisible());
65 // Finally verify that there was actually a request going on
66 waitUntilLogContains("Requested items");
69 private void waitUntilLogContains(final String value) {
70 waitUntil(new ExpectedCondition<Boolean>() {
72 public Boolean apply(WebDriver input) {
73 return getLogRow(0).contains(value);
77 public String toString() {
78 // Timed out after 10 seconds waiting for ...
79 return "first log row to contain '" + value + "' (was: '"
80 + getLogRow(0) + "')";