package com.vaadin.tests.components.grid.basics;

import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.Keys;
import org.openqa.selenium.remote.DesiredCapabilities;

import com.vaadin.testbench.parallel.Browser;

public class GridSortingTest extends GridBasicsTest {

    public static final Comparator<DataObject> BIG_RANDOM = Comparator
            .comparing(DataObject::getBigRandom);
    public static final Comparator<DataObject> SMALL_RANDOM = Comparator
            .comparing(DataObject::getSmallRandom);

    @Override
    public List<DesiredCapabilities> getBrowsersToTest() {
        // Should be browsersSupportingShiftClick but for whatever reason IE11
        // fails to shift click
        return Collections
                .singletonList(Browser.CHROME.getDesiredCapabilities());
    }

    @Test
    public void testSortBySingleColumnByUser() {
        getGridElement().getHeaderCell(0, 3).click();
        int i = 0;
        for (Integer rowNumber : getTestData().sorted(BIG_RANDOM)
                .map(DataObject::getRowNumber).limit(5)
                .collect(Collectors.toList())) {
            Assert.assertEquals(
                    "Grid was not sorted as expected, row number mismatch",
                    rowNumber.toString(),
                    getGridElement().getCell(i++, 0).getText());
        }
    }

    @Test
    public void testSortByMultipleColumnsByUser() {
        getGridElement().getHeaderCell(0, 4).click();
        getGridElement().getHeaderCell(0, 3).click(15, 15, Keys.SHIFT);

        int i = 0;
        for (Integer rowNumber : getTestData()
                .sorted(SMALL_RANDOM.thenComparing(BIG_RANDOM))
                .map(DataObject::getRowNumber).limit(5)
                .collect(Collectors.toList())) {
            Assert.assertEquals(
                    "Grid was not sorted as expected, row number mismatch",
                    rowNumber.toString(),
                    getGridElement().getCell(i++, 0).getText());
        }
    }
}

@@ -1032,33 +1032,33 @@
 etHeaderCell(0, 
-3
+6
 ).click();%0A     
@@ -1435,33 +1435,33 @@
 ().getCell(i++, 
-0
+3
 ).getText());%0A  
@@ -1583,9 +1583,9 @@
 (0, 
-4
+7
 ).cl
@@ -1633,17 +1633,17 @@
 Cell(0, 
-3
+6
 ).click(
@@ -2100,17 +2100,17 @@
 ll(i++, 
-0
+3
 ).getTex

Fix indices in GridSortingTest