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

FitleredList: incorrect initial state with batch and reject-all matcher

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P5 P5
    • 8
    • fx2.0
    • javafx
    • fx-beta-b36



          private static class Always implements Matcher<Integer> {
              
              @Override
              public boolean matches(Integer i) {
                  return true;
              }
          }
          
          private static class Never implements Matcher<Integer> {
              
              @Override
              public boolean matches(Integer i) {
                  return false;
              }
          }
          
          /**
           * Matcher rejecting all: strange behaviour in batch mode
           */
          @Test
          public void testFilteredKeepNoneBatch() {
              ObservableList<Integer> original = FXCollections.observableArrayList(
                      0, 1, 2, 3, 4 ,5, 6, 7, 8, 9
              );
              FilteredList list = new FilteredList(original, new Never(), FilterMode.BATCH);
              list.filter();
              assertEquals("must have null size, matcher rejects all " + list, 0, list.size());
          }

          /**
          * okay if set after some filtering has happened
          */
          @Test
          public void testFilteredBatchChangeMatcher() {
              ObservableList<Integer> original = FXCollections.observableArrayList(
                     0, 1, 2, 3, 4 ,5, 6, 7, 8, 9
              );
              FilteredList list = new FilteredList(original, new Always(), FilterMode.BATCH);
              list.filter();
              assertEquals(original.size(), list.size());
              list.setMatcher(new Never());
              list.filter();
              assertEquals(0, list.size());
              
          }

          /**
           * Filter okay in Live mode
           */
          @Test
          public void testFilteredKeepNoneLive() {
              ObservableList<Integer> original = FXCollections.observableArrayList(
                      0, 1, 2, 3, 4 ,5, 6, 7, 8, 9
              );
              FilteredList list = new FilteredList(original, new Never());
              assertEquals(0, list.size());
          }
          

            msladecek Martin Sládeček
            fastegal Jeanette Winzenburg
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: