public void testProcessScrolling() {
    ScrollableGridViewEvent event = new ScrollEvent(table, 20, 440);
    table.processScrolling(event);

    assertTrue(facesContext.getRenderResponse());
    assertEquals(440, table.getFirst());
  }
  public void testProcessSortingChange() {
    SortListener1 sortListener1 = new SortListener1();

    table.setSortListener(sortListener1);

    SortEvent sortEvent = new SortEvent(table, "0", 20, 30);

    table.processSortingChange(sortEvent);

    assertTrue(sortListener1.triggered);

    assertTrue(facesContext.getRenderResponse());

    assertEquals(30, table.getFirst());
  }
  public void setUp() throws Exception {
    // TODO Auto-generated method stub
    super.setUp();
    table =
        (UIScrollableDataTable) application.createComponent(UIScrollableDataTable.COMPONENT_TYPE);
    facesContext.getViewRoot().getChildren().add(table);
    table.setId("zzz");

    for (int i = 0; i < 10; i++) {
      UIComponent column = MockColumns.newColumn("zzz" + i);
      UIOutput output = new UIOutput();
      output.setId("h" + i);
      column.getFacets().put("header", output);
      table.getChildren().add(column);
    }
  }
  public void testBroadCast() {
    ScrollableGridViewEvent event = new ScrollEvent(table, 20, 30);
    event.setAttribute("attr", "value0");
    table.broadcast(event);
    assertEquals("value0", table.getAttributes().get("attr"));

    AjaxEvent ajaxEvent = new AjaxEvent(table);
    String id = AjaxRendererUtils.getAbsoluteId(table);
    table.broadcast(ajaxEvent);
    assertTrue(ajaxContext.getAjaxAreasToRender().contains(id));

    SortListener1 sortListener = new SortListener1();
    table.setSortListener(sortListener);
    table.broadcast(new SortEvent(table, "0", 20, 30));
    assertTrue(sortListener.triggered);
  }
 public void testFixedChildren() {
   Iterator iterator = table.fixedChildren();
   assertTrue(iterator.hasNext());
   int i = 0;
   while (iterator.hasNext()) {
     UIComponent kid = (UIComponent) iterator.next();
     assertEquals("h" + i, kid.getId());
     i++;
   }
 }
  public void testCreateDataModel() {

    ListDataModel l = new ListDataModel(Collections.singletonList("aaaa"));
    table.setValue(l);
    ExtendedDataModel model = table.createDataModel();

    assertTrue(model instanceof DataModelCache);

    assertEquals(1, model.getRowCount());
    // assertTrue(model instanceof ComponentSortableDataModel);

    // table.isCacheable()

    table.setValue(null);
    model = table.createDataModel();

    assertTrue(model instanceof ExtendedDataModel);

    assertEquals(0, model.getRowCount());
  }
  public void testSortListener() {
    table.setSortMode(UIScrollableDataTable.SORT_MULTI);
    assertSame(MultiColumnSortListener.INSTANCE, table.getSortListener());

    table.setSortMode(UIScrollableDataTable.SORT_SINGLE);
    assertSame(SingleColumnSortListener.INSTANCE, table.getSortListener());

    SortListener1 sortListener1 = new SortListener1();

    table.setSortListener(sortListener1);

    assertSame(sortListener1, table.getSortListener());
  }
 public void testGetResponseData() {
   List data = new ArrayList();
   table.setResponseData(data);
   assertSame(data, table.getResponseData());
 }