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

TableView: parentColumn width must be same as sum of its childrens' width

    XMLWordPrintable

Details

    Description

      Below are two test cases that I expect to pass:

      Resizing parent

      a) expected and actual: distribute the delta across children
      b) expected: resize itself to the new width - actual: parent width unchanged

          @Test
          public void testResizeParentColumn() {
              TableView table = new TableView();
              TableColumn first = new TableColumn("First Name");
              TableColumn last = new TableColumn("Last Name");
              TableColumn parent = new TableColumn("Parent");
              parent.getColumns().addAll(first, last);
              table.getColumns().addAll(parent);
              
              double initialWidth = 80;
              assertEquals(initialWidth, first.getWidth(), .1);
              assertEquals(initialWidth, last.getWidth(), .1);
              assertEquals(first.getWidth() + last.getWidth(), parent.getWidth(), .1);
              
              double delta = 100;
              assertTrue(table.resizeColumn(parent, delta));
              assertEquals(initialWidth + delta/2, first.getWidth(), .1);
              assertEquals("parent width must be same as sum of childrens width",
                      first.getWidth() + last.getWidth(), parent.getWidth(), .1);
          }
       
      Resizing child:

      a) expected and actual: resizes the child without touching siblings
      b) expected: resize parent to new combined width - actual: parent width unchanged
         
          @Test
          public void testResizeChildColumn() {
              TableView table = new TableView();
              TableColumn first = new TableColumn("First Name");
              TableColumn last = new TableColumn("Last Name");
              TableColumn parent = new TableColumn("Parent");
              parent.getColumns().addAll(first, last);
              table.getColumns().addAll(parent);
              
              double initialWidth = 80;
              assertEquals(initialWidth, first.getWidth(), .1);
              assertEquals(initialWidth, last.getWidth(), .1);
              assertEquals(first.getWidth() + last.getWidth(), parent.getWidth(), .1);
              
              double delta = 100;
              assertTrue(table.resizeColumn(first, delta));
              assertEquals(initialWidth + delta, first.getWidth(), .1);
              assertEquals(initialWidth, last.getWidth(), 0.1);
              assertEquals("parent width must be same as sum of childrens width",
                      first.getWidth() + last.getWidth(), parent.getWidth(), .1);
          }
          

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated: