971 // An "INFO: index exceeds maxCellCount" message should print out.
972 flow.setCreateCell(p -> new CellStub(flow) {
973 @Override
974 protected double computeMaxHeight(double width) { return 0; }
975 @Override
976 protected double computePrefHeight(double width) { return 0; }
977 @Override
978 protected double computeMinHeight(double width) { return 0; }
979
980 });
981 flow.setCellCount(10);
982 flow.setViewportLength(100);
983 flow.addLeadingCells(1, 0);
984 flow.sheetChildren.addListener((InvalidationListener) (o) -> {
985 int count = ((List) o).size();
986 assertTrue(Integer.toString(count), count <= 100);
987 });
988 flow.addTrailingCells(true);
989 }
990
991 }
992
993 class CellStub extends IndexedCell {
994 String s;
995 VirtualFlow flow;
996
997 public CellStub(VirtualFlow flow) { init(flow); }
998 public CellStub(VirtualFlow flow, String s) { init(flow); this.s = s; }
999
1000 private void init(VirtualFlow flow) {
1001 this.flow = flow;
1002 setSkin(new SkinStub<CellStub>(this));
1003 updateItem(this, false);
1004 }
1005
1006 @Override
1007 public void updateIndex(int i) {
1008 super.updateIndex(i);
1009
1010 s = "Item " + getIndex();
|
971 // An "INFO: index exceeds maxCellCount" message should print out.
972 flow.setCreateCell(p -> new CellStub(flow) {
973 @Override
974 protected double computeMaxHeight(double width) { return 0; }
975 @Override
976 protected double computePrefHeight(double width) { return 0; }
977 @Override
978 protected double computeMinHeight(double width) { return 0; }
979
980 });
981 flow.setCellCount(10);
982 flow.setViewportLength(100);
983 flow.addLeadingCells(1, 0);
984 flow.sheetChildren.addListener((InvalidationListener) (o) -> {
985 int count = ((List) o).size();
986 assertTrue(Integer.toString(count), count <= 100);
987 });
988 flow.addTrailingCells(true);
989 }
990
991 private int rt36556_instanceCount;
992 @Test
993 public void test_rt36556() {
994 rt36556_instanceCount = 0;
995 flow = new VirtualFlow();
996 flow.setVertical(true);
997 flow.setCreateCell(p -> {
998 rt36556_instanceCount++;
999 return new CellStub(flow);
1000 });
1001 flow.setCellCount(100);
1002 flow.resize(300, 300);
1003 pulse();
1004 final int cellCountAtStart = rt36556_instanceCount;
1005 flow.adjustPixels(10000);
1006 pulse();
1007 assertEquals(cellCountAtStart, rt36556_instanceCount);
1008 assertNull(flow.getVisibleCell(0));
1009 assertMinimalNumberOfCellsAreUsed(flow);
1010 }
1011
1012 @Test
1013 public void test_rt36556_scrollto() {
1014 rt36556_instanceCount = 0;
1015 flow = new VirtualFlow();
1016 flow.setVertical(true);
1017 flow.setCreateCell(p -> {
1018 rt36556_instanceCount++;
1019 return new CellStub(flow);
1020 });
1021 flow.setCellCount(100);
1022 flow.resize(300, 300);
1023 pulse();
1024 final int cellCountAtStart = rt36556_instanceCount;
1025 flow.scrollTo(80);
1026 pulse();
1027 assertEquals(cellCountAtStart, rt36556_instanceCount);
1028 assertNull(flow.getVisibleCell(0));
1029 assertMinimalNumberOfCellsAreUsed(flow);
1030 }
1031
1032 @Test
1033 public void test_RT39035() {
1034 flow.adjustPixels(250);
1035 pulse();
1036 flow.adjustPixels(500);
1037 pulse();
1038 assertTrue(flow.getPosition() < 1.0);
1039 assertMinimalNumberOfCellsAreUsed(flow);
1040 }
1041
1042 @Test
1043 public void test_RT37421() {
1044 flow.setPosition(0.98);
1045 pulse();
1046 flow.adjustPixels(100);
1047 pulse();
1048 assertEquals(1.0, flow.getPosition(), 0.0);
1049 assertMinimalNumberOfCellsAreUsed(flow);
1050 }
1051 }
1052
1053 class CellStub extends IndexedCell {
1054 String s;
1055 VirtualFlow flow;
1056
1057 public CellStub(VirtualFlow flow) { init(flow); }
1058 public CellStub(VirtualFlow flow, String s) { init(flow); this.s = s; }
1059
1060 private void init(VirtualFlow flow) {
1061 this.flow = flow;
1062 setSkin(new SkinStub<CellStub>(this));
1063 updateItem(this, false);
1064 }
1065
1066 @Override
1067 public void updateIndex(int i) {
1068 super.updateIndex(i);
1069
1070 s = "Item " + getIndex();
|