Search in sources :

Example 1 with ColumnSortInfo

use of org.gwtproject.user.cellview.client.ColumnSortList.ColumnSortInfo in project gwtproject by treblereel.

the class ColumnSortInfoTest method testEquals.

public void testEquals() {
    // Test equals.
    Column<String, String> column0 = new IdentityColumn<String>(new TextCell());
    ColumnSortInfo info0a = new ColumnSortInfo(column0, true);
    ColumnSortInfo info0b = new ColumnSortInfo(column0, true);
    assertTrue(info0a.equals(info0b));
    assertTrue(info0b.equals(info0a));
    assertEquals(info0a.hashCode(), info0b.hashCode());
    // Test null.
    assertFalse(info0a.equals(null));
    // Test different object.
    assertFalse(info0a.equals("not a ColumnSortInfo"));
    // Test different sort order.
    ColumnSortInfo info0desc = new ColumnSortInfo(column0, false);
    assertFalse(info0a.equals(info0desc));
    assertFalse(info0desc.equals(info0a));
    assertTrue(info0a.hashCode() != info0desc.hashCode());
    // Test different column.
    Column<String, String> column1 = new IdentityColumn<String>(new TextCell());
    ColumnSortInfo info1 = new ColumnSortInfo(column1, true);
    assertFalse(info0a.equals(info1));
    assertFalse(info1.equals(info0a));
    assertTrue(info0a.hashCode() != info1.hashCode());
}
Also used : ColumnSortInfo(org.gwtproject.user.cellview.client.ColumnSortList.ColumnSortInfo) TextCell(org.gwtproject.cell.client.TextCell)

Example 2 with ColumnSortInfo

use of org.gwtproject.user.cellview.client.ColumnSortList.ColumnSortInfo in project gwtproject by treblereel.

the class ColumnSortListTest method testEquals.

public void testEquals() {
    ColumnSortList list0 = new ColumnSortList();
    ColumnSortList list1 = new ColumnSortList();
    // Compare empty lists.
    assertTrue(list0.equals(list1));
    assertTrue(list1.equals(list0));
    assertEquals(list0.hashCode(), list1.hashCode());
    // Compare with one item.
    ColumnSortInfo info0 = createColumnSortInfo();
    list0.push(info0);
    list1.push(info0);
    assertTrue(list0.equals(list1));
    assertTrue(list1.equals(list0));
    assertEquals(list0.hashCode(), list1.hashCode());
    // Compare different sizes.
    ColumnSortInfo info1 = createColumnSortInfo();
    list0.push(info1);
    assertFalse(list0.equals(list1));
    assertFalse(list1.equals(list0));
    assertFalse(list0.hashCode() == list1.hashCode());
    // Make the lists equal again.
    list1.push(info1);
    // Compare with different items that equals each other.
    ColumnSortInfo info2a = createColumnSortInfo();
    ColumnSortInfo info2b = new ColumnSortInfo(info2a.getColumn(), info2a.isAscending());
    list0.push(info2a);
    list1.push(info2b);
    assertTrue(list0.equals(list1));
    assertTrue(list1.equals(list0));
    assertEquals(list0.hashCode(), list1.hashCode());
    // Compare same items, but out of order.
    list0.push(info0);
    assertFalse(list0.equals(list1));
    assertFalse(list1.equals(list0));
    assertFalse(list0.hashCode() == list1.hashCode());
    // Compare to null.
    assertFalse(list0.equals(null));
    assertFalse(list1.equals(null));
}
Also used : ColumnSortInfo(org.gwtproject.user.cellview.client.ColumnSortList.ColumnSortInfo)

Example 3 with ColumnSortInfo

use of org.gwtproject.user.cellview.client.ColumnSortList.ColumnSortInfo in project gwtproject by treblereel.

the class ColumnSortListTest method testPushColumn.

public void testPushColumn() {
    ColumnSortList list = new ColumnSortList();
    assertEquals(0, list.size());
    // Push an item.
    Column<String, String> col0 = new IdentityColumn<String>(new TextCell());
    ColumnSortInfo item0 = list.push(col0);
    assertEquals(1, list.size());
    assertEquals(item0, list.get(0));
    assertEquals(col0, list.get(0).getColumn());
    assertTrue(list.get(0).isAscending());
    // Push the same item. Should change sort order.
    ColumnSortInfo item0desc = list.push(col0);
    assertEquals(1, list.size());
    assertEquals(item0desc, list.get(0));
    assertEquals(col0, list.get(0).getColumn());
    assertFalse(list.get(0).isAscending());
    // Push a second item.
    Column<String, String> col1 = new IdentityColumn<String>(new TextCell());
    list.push(col1);
    assertEquals(2, list.size());
    assertEquals(col1, list.get(0).getColumn());
    assertTrue(list.get(0).isAscending());
    assertEquals(col0, list.get(1).getColumn());
    assertFalse(list.get(1).isAscending());
    // Push a third item.
    Column<String, String> col2 = new IdentityColumn<String>(new TextCell());
    list.push(col2);
    assertEquals(3, list.size());
    assertEquals(col2, list.get(0).getColumn());
    assertTrue(list.get(0).isAscending());
    assertEquals(col1, list.get(1).getColumn());
    assertTrue(list.get(1).isAscending());
    assertEquals(col0, list.get(2).getColumn());
    assertFalse(list.get(2).isAscending());
    // Push col0 again. Should move back to the front in ascending order.
    list.push(col0);
    assertEquals(3, list.size());
    assertEquals(col0, list.get(0).getColumn());
    assertTrue(list.get(0).isAscending());
    assertEquals(col2, list.get(1).getColumn());
    assertTrue(list.get(1).isAscending());
    assertEquals(col1, list.get(2).getColumn());
    assertTrue(list.get(2).isAscending());
}
Also used : ColumnSortInfo(org.gwtproject.user.cellview.client.ColumnSortList.ColumnSortInfo) TextCell(org.gwtproject.cell.client.TextCell)

Example 4 with ColumnSortInfo

use of org.gwtproject.user.cellview.client.ColumnSortList.ColumnSortInfo in project gwtproject by treblereel.

the class ColumnSortListTest method testRemove.

public void testRemove() {
    ColumnSortList list = new ColumnSortList();
    // Remove the only item.
    ColumnSortInfo info = createColumnSortInfo();
    list.push(info);
    assertEquals(1, list.size());
    assertTrue(list.remove(info));
    assertEquals(0, list.size());
    // Remove a middle item.
    ColumnSortInfo info0 = createColumnSortInfo();
    ColumnSortInfo info1 = createColumnSortInfo();
    ColumnSortInfo info2 = createColumnSortInfo();
    list.push(info0);
    list.push(info1);
    list.push(info2);
    assertEquals(3, list.size());
    assertTrue(list.remove(info1));
    assertEquals(2, list.size());
    assertEquals(info2, list.get(0));
    assertEquals(info0, list.get(1));
    // Remove an item that doesn't exist.
    assertFalse(list.remove(createColumnSortInfo()));
}
Also used : ColumnSortInfo(org.gwtproject.user.cellview.client.ColumnSortList.ColumnSortInfo)

Example 5 with ColumnSortInfo

use of org.gwtproject.user.cellview.client.ColumnSortList.ColumnSortInfo in project gwtproject by treblereel.

the class ColumnSortListTest method testPushColumnDescending.

/**
 * Test pushing a column with a default sort order of descending.
 */
public void testPushColumnDescending() {
    ColumnSortList list = new ColumnSortList();
    assertEquals(0, list.size());
    // Push a column.
    Column<String, String> col0 = new IdentityColumn<String>(new TextCell());
    col0.setDefaultSortAscending(false);
    ColumnSortInfo item0 = list.push(col0);
    assertEquals(1, list.size());
    assertEquals(item0, list.get(0));
    assertEquals(col0, list.get(0).getColumn());
    assertFalse(list.get(0).isAscending());
    // Push the same item. Should change sort order.
    ColumnSortInfo item0desc = list.push(col0);
    assertEquals(1, list.size());
    assertEquals(item0desc, list.get(0));
    assertEquals(col0, list.get(0).getColumn());
    assertTrue(list.get(0).isAscending());
}
Also used : ColumnSortInfo(org.gwtproject.user.cellview.client.ColumnSortList.ColumnSortInfo) TextCell(org.gwtproject.cell.client.TextCell)

Aggregations

ColumnSortInfo (org.gwtproject.user.cellview.client.ColumnSortList.ColumnSortInfo)10 TextCell (org.gwtproject.cell.client.TextCell)5