9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package javafx.scene.control.test.tableview; 27 28 import client.test.Smoke; 29 import com.sun.javafx.scene.control.skin.NestedTableColumnHeader; 30 import com.sun.javafx.scene.control.skin.TableColumnHeader; 31 import com.sun.javafx.scene.control.skin.TableHeaderRow; 32 import java.awt.Robot; 33 import java.awt.event.InputEvent; 34 import java.util.ArrayList; 35 import java.util.List; 36 import java.util.logging.Level; 37 import java.util.logging.Logger; 38 import static javafx.collections.FXCollections.*; 39 import javafx.collections.ObservableList; 40 import static javafx.commons.Consts.*; 41 import javafx.commons.Consts.CellEditorType; 42 import javafx.geometry.Orientation; 43 import javafx.scene.Group; 44 import javafx.scene.Node; 45 import javafx.scene.Scene; 46 import javafx.scene.control.Cell; 47 import javafx.scene.control.ChoiceBox; 48 import javafx.scene.control.ComboBox; 49 import javafx.scene.control.Control; 50 import javafx.scene.control.IndexedCell; 51 import javafx.scene.control.Label; 193 * preserved after sorting. 194 */ 195 public void tableViewNotScrollingOnSortTest() throws InterruptedException { 196 setSize(200, 200); 197 int count = 10; 198 for (int i = 0; i < count; i++) { 199 addColumn("items" + String.valueOf(i), i); 200 } 201 setNewDataSize(25); 202 switchToPropertiesTab("TreeTableView"); 203 setPropertyBySlider(SettingType.UNIDIRECTIONAL, Properties.prefWidth, 170); 204 setPropertyBySlider(SettingType.UNIDIRECTIONAL, Properties.prefHeight, 170); 205 206 for (int i = 0; i < count; i++) { 207 checkSortNotScrollingFor("items" + String.valueOf(i), i); 208 } 209 } 210 211 private void checkSortNotScrollingFor(String name, int index) { 212 scrollTo(index, 0); 213 final double initialScrollPos = getScrollBarValue(findScrollBar(testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, true)); 214 getTableColumnHeaderWrap(name).mouse().click(); 215 getTableColumnHeaderWrap(name).mouse().click(); 216 getTableColumnHeaderWrap(name).mouse().click(); 217 getTableColumnHeaderWrap(name).mouse().click(); 218 new Waiter(new Timeout("", 500)).ensureState(new State() { 219 public Object reached() { 220 if (Math.abs(initialScrollPos - getScrollBarValue(findScrollBar(testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, true))) < 0.001) { 221 return true; 222 } else { 223 return null; 224 } 225 } 226 }); 227 } 228 229 @Test(timeout = 300000) 230 /** 231 * This test applies new sortNode and checks, that it was applied. 232 */ 233 public void actualChangeSortNodeTest() throws InterruptedException { 234 setSize(200, 200); 235 String columnName = "column1"; 236 addColumn(columnName, 0, true); 237 setNewDataSize(10); 238 requestFocusOnControl(testedControl); 239 240 final Wrap<? extends TableColumnHeader> header = getTableColumnHeaderWrap(columnName); | 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package javafx.scene.control.test.tableview; 27 28 import client.test.Smoke; 29 import javafx.scene.control.skin.NestedTableColumnHeader; 30 import javafx.scene.control.skin.TableColumnHeader; 31 import javafx.scene.control.skin.TableHeaderRow; 32 import java.awt.Robot; 33 import java.awt.event.InputEvent; 34 import java.util.ArrayList; 35 import java.util.List; 36 import java.util.logging.Level; 37 import java.util.logging.Logger; 38 import static javafx.collections.FXCollections.*; 39 import javafx.collections.ObservableList; 40 import static javafx.commons.Consts.*; 41 import javafx.commons.Consts.CellEditorType; 42 import javafx.geometry.Orientation; 43 import javafx.scene.Group; 44 import javafx.scene.Node; 45 import javafx.scene.Scene; 46 import javafx.scene.control.Cell; 47 import javafx.scene.control.ChoiceBox; 48 import javafx.scene.control.ComboBox; 49 import javafx.scene.control.Control; 50 import javafx.scene.control.IndexedCell; 51 import javafx.scene.control.Label; 193 * preserved after sorting. 194 */ 195 public void tableViewNotScrollingOnSortTest() throws InterruptedException { 196 setSize(200, 200); 197 int count = 10; 198 for (int i = 0; i < count; i++) { 199 addColumn("items" + String.valueOf(i), i); 200 } 201 setNewDataSize(25); 202 switchToPropertiesTab("TreeTableView"); 203 setPropertyBySlider(SettingType.UNIDIRECTIONAL, Properties.prefWidth, 170); 204 setPropertyBySlider(SettingType.UNIDIRECTIONAL, Properties.prefHeight, 170); 205 206 for (int i = 0; i < count; i++) { 207 checkSortNotScrollingFor("items" + String.valueOf(i), i); 208 } 209 } 210 211 private void checkSortNotScrollingFor(String name, int index) { 212 scrollTo(index, 0); 213 final double initialScrollPos = getScrollBarValue(findScrollBar((Parent<Node>)testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, true)); 214 getTableColumnHeaderWrap(name).mouse().click(); 215 getTableColumnHeaderWrap(name).mouse().click(); 216 getTableColumnHeaderWrap(name).mouse().click(); 217 getTableColumnHeaderWrap(name).mouse().click(); 218 new Waiter(new Timeout("", 500)).ensureState(new State() { 219 public Object reached() { 220 if (Math.abs(initialScrollPos - getScrollBarValue(findScrollBar((Parent<Node>)testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, true))) < 0.001) { 221 return true; 222 } else { 223 return null; 224 } 225 } 226 }); 227 } 228 229 @Test(timeout = 300000) 230 /** 231 * This test applies new sortNode and checks, that it was applied. 232 */ 233 public void actualChangeSortNodeTest() throws InterruptedException { 234 setSize(200, 200); 235 String columnName = "column1"; 236 addColumn(columnName, 0, true); 237 setNewDataSize(10); 238 requestFocusOnControl(testedControl); 239 240 final Wrap<? extends TableColumnHeader> header = getTableColumnHeaderWrap(columnName); |