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

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;

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() {
        return getBrowsersSupportingShiftClick();
    }

    @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());
        }
    }
}

@@ -39,24 +39,54 @@
 id.basics;%0A%0A
+import java.util.Collections;%0A
 import java.
@@ -102,16 +102,16 @@
 arator;%0A
-
 import j
@@ -299,16 +299,63 @@
 ities;%0A%0A
+import com.vaadin.testbench.parallel.Browser;%0A%0A
 public c
@@ -733,19 +733,22 @@
     
-return getB
+// Should be b
 rows
@@ -766,25 +766,183 @@
 ngShiftClick
-(
+ but for whatever reason IE11%0A        // fails to shift click%0A        return Collections%0A                .singletonList(Browser.CHROME.getDesiredCapabilities()
 );%0A    %7D%0A%0A  
@@ -1384,32 +1384,52 @@
 mber.toString(),
+%0A                   
  getGridElement(
@@ -2000,32 +2000,32 @@
 mber mismatch%22,%0A
-
                 
@@ -2049,16 +2049,36 @@
 tring(),
+%0A                   
  getGrid

Stop running test on IE11 which does not shift click when it should