]> source.dussan.org Git - vaadin-framework.git/blob
7913c948f79d1b329f5e2add9ee4c36d1b5a68df
[vaadin-framework.git] /
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.escalator;
17
18 import static org.junit.Assert.assertEquals;
19 import static org.junit.Assert.assertFalse;
20 import static org.junit.Assert.assertNull;
21
22 import java.io.IOException;
23
24 import org.junit.Before;
25 import org.junit.Test;
26
27 import com.vaadin.testbench.elements.NotificationElement;
28 import com.vaadin.tests.components.grid.basicfeatures.EscalatorBasicClientFeaturesTest;
29
30 public class EscalatorBasicsTest extends EscalatorBasicClientFeaturesTest {
31
32     @Before
33     public void setUp() {
34         setDebug(true);
35         openTestURL();
36     }
37
38     @Test
39     public void testDetachingAnEmptyEscalator() {
40         selectMenuPath(GENERAL, DETACH_ESCALATOR);
41         assertEscalatorIsRemovedCorrectly();
42     }
43
44     @Test
45     public void testDetachingASemiPopulatedEscalator() throws IOException {
46         selectMenuPath(COLUMNS_AND_ROWS, ADD_ONE_OF_EACH_ROW);
47         selectMenuPath(COLUMNS_AND_ROWS, COLUMNS, ADD_ONE_COLUMN_TO_BEGINNING);
48         selectMenuPath(GENERAL, DETACH_ESCALATOR);
49         assertEscalatorIsRemovedCorrectly();
50     }
51
52     @Test
53     public void testDetachingAPopulatedEscalator() {
54         selectMenuPath(GENERAL, POPULATE_COLUMN_ROW);
55         selectMenuPath(GENERAL, DETACH_ESCALATOR);
56         assertEscalatorIsRemovedCorrectly();
57     }
58
59     @Test
60     public void testDetachingAndReattachingAnEscalator() {
61         selectMenuPath(GENERAL, POPULATE_COLUMN_ROW);
62
63         scrollVerticallyTo(50);
64         scrollHorizontallyTo(50);
65
66         selectMenuPath(GENERAL, DETACH_ESCALATOR);
67         selectMenuPath(GENERAL, ATTACH_ESCALATOR);
68
69         assertEquals("Vertical scroll position", 50, getScrollTop());
70         assertEquals("Horizontal scroll position", 50, getScrollLeft());
71
72         assertEquals("First cell of first visible row", "Row 2: 0,2",
73                 getBodyCell(0, 0).getText());
74     }
75
76     private void assertEscalatorIsRemovedCorrectly() {
77         assertFalse($(NotificationElement.class).exists());
78         assertNull(getEscalator());
79     }
80 }