Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8221334

TableViewSkin: must initialize flow's cellCount in constructor

XMLWordPrintable

      at the end of initialization of all subclasses of VirtualContainerBase, the skin and its flow must be configured completely: in particular, the assertion below must be satisfied:

      assertEquals(control.getItems().size(), flow.getCellCount());

      TableViewSkin is the only one that fails this test (below are fixtures for all). Reason seems to be a missing updateItemCount in its constructor: comparing to the other, that method is called explicitly in ListViewSkin and implicitly for the tree/table/Skin in their setRoot(..).

          /**
           * bug in TableViewSkin: virtualFlow's cellCount not initialized.
           */
          @Test
          public void testTableSkinCellCountInitial() {
              TableView<Locale> control = new TableView<>(FXCollections.observableArrayList(Locale.getAvailableLocales()));
              control.setSkin(new TableViewSkin<>(control) {
                  {
                      assertEquals("flow's cellCount must be initialized", control.getItems().size(),
                              getVirtualFlow().getCellCount());
                  }
              });
          }
          
          @Test
          public void testTreeTableSkinCellCountInitial() {
              List<TreeItem<Locale>> treeItems = Arrays.stream(Locale.getAvailableLocales())
                      .map(TreeItem::new)
                      .collect(Collectors.toList());
              TreeItem<Locale> root = new TreeItem<>(new Locale("dummy"));
              root.setExpanded(true);
              root.getChildren().addAll(treeItems);
              TreeTableView<Locale> control = new TreeTableView<>(root);
              control.setSkin(new TreeTableViewSkin<>(control) {
                  {
                      assertEquals("flow's cellCount must be initialized", treeItems.size() + 1,
                              getVirtualFlow().getCellCount());
                  }
              });
          }
          
          @Test
          public void testTreeSkinCellCountInitial() {
              List<TreeItem<Locale>> treeItems = Arrays.stream(Locale.getAvailableLocales())
                      .map(TreeItem::new)
                      .collect(Collectors.toList());
              TreeItem<Locale> root = new TreeItem<>(new Locale("dummy"));
              root.setExpanded(true);
              root.getChildren().addAll(treeItems);
              TreeView<Locale> control = new TreeView<>(root);
              control.setSkin(new TreeViewSkin<>(control) {
                  {
                      assertEquals("flow's cellCount must be initialized", treeItems.size() +1,
                              getVirtualFlow().getCellCount());
                  }
              });
          }
          
          @Test
          public void testListSkinCellCountInitial() {
              ListView<Locale> control = new ListView<>(FXCollections.observableArrayList(Locale.getAvailableLocales()));
              control.setSkin(new ListViewSkin<>(control) {
                  {
                      assertEquals("flow's cellCount must be initialized", control.getItems().size(),
                              getVirtualFlow().getCellCount());
                  }
              });
          }
          

            fastegal Jeanette Winzenburg
            fastegal Jeanette Winzenburg
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: