7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
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 package javafx.scene.control.test.pagination;
26
27 import com.sun.javafx.scene.control.skin.LabeledText;
28 import java.util.ArrayList;
29 import java.util.Arrays;
30 import java.util.Comparator;
31 import javafx.geometry.Orientation;
32 import javafx.scene.Node;
33 import javafx.scene.Scene;
34 import javafx.scene.control.Label;
35 import javafx.scene.control.Pagination;
36 import javafx.scene.control.ScrollBar;
37 import javafx.scene.control.TextArea;
38 import static javafx.scene.control.test.pagination.PaginationApp.*;
39 import javafx.scene.control.test.util.UtilTestFunctions;
40 import static javafx.scene.control.test.utils.ComponentsFactory.*;
41 import javafx.scene.control.test.utils.ptables.AbstractPropertyController.SettingType;
42 import javafx.scene.layout.StackPane;
43 import org.jemmy.Point;
44 import org.jemmy.action.GetAction;
45 import org.jemmy.control.Wrap;
46 import org.jemmy.env.Environment;
47 import org.jemmy.fx.ByID;
130 }
131
132 protected void setBulletStyleOfPageIndicators() {
133 clickButtonForTestPurpose(SET_BULLET_PAGE_INDICATOR_BUTTON_ID);
134 }
135
136 protected void setIndeterminatePageCount() {
137 clickButtonForTestPurpose(SET_PAGE_COUNT_TO_INDETERMINATE_BUTTON_ID);
138 }
139
140 protected void checkFormComponentButton() {
141 clickButtonByID(FORM_BUTTON_ID);
142 testedControl.waitState(new State<Integer>() {
143 public Integer reached() {
144 return Integer.parseInt(findTextField(FORM_CLICK_TEXT_FIELD_ID).getControl().getText());
145 }
146 }, 1);
147 }
148
149 protected void checkScrollingOfFormComponentScrollBar() {
150 Wrap<? extends ScrollBar> scrollBar = findScrollBar(testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, true);
151 scrollBar.mouse().turnWheel(-1);
152 testedControl.waitState(new State<Integer>() {
153 public Integer reached() {
154 return Integer.parseInt(findTextField(FORM_SCROLL_TEXT_FIELD_ID).getControl().getText());
155 }
156 }, 1);
157
158 AbstractScroll c = scrollBar.as(AbstractScroll.class);
159 c.allowError(0.01);
160 double meanValue = getScrollBarCenter(scrollBar);
161 c.caret().to(meanValue);
162 assertTrue(Math.abs(meanValue - getScrollBarValue(scrollBar)) <= 1);
163 }
164
165 protected double getScrollBarValue(final Wrap<? extends ScrollBar> scrollBar) {
166 return new GetAction<Double>() {
167 @Override
168 public void run(Object... os) throws Exception {
169 setResult(scrollBar.getControl().getValue());
170 }
256 setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefWidth, width);
257 setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefHeight, height);
258 }
259
260 /**
261 * 0 - begin, 1 - end.
262 *
263 * @param pos
264 */
265 protected void checkScrollBarPosition(final int pos) {
266 ScrollBar sb = getScrollbarWrap(true).getControl();
267 if (pos == 1) {
268 assertTrue(sb.getMax() == sb.getValue());
269 }
270 if (pos == 0) {
271 assertTrue(sb.getMin() == sb.getValue());
272 }
273 }
274
275 protected Wrap<? extends ScrollBar> getScrollbarWrap(boolean visible) {
276 return findScrollBar(testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, visible);
277 }
278
279 protected void checkNumberOfVisiblePageIndeces(int expectedIndeces) {
280 checkRightPageIndecesOrderAndContinuousOrder();
281 Wrap<? extends LabeledText>[] array = getSortedPageIndeces();
282 int len = array.length;
283 assertEquals(len, expectedIndeces, 0);
284 }
285
286 protected void checkRangeOfPageIndecesVisibility(int expectedStart, int expectedEnd) {
287 checkNumberOfVisiblePageIndeces(expectedEnd - expectedStart + 1);
288 Wrap<? extends LabeledText>[] array = getSortedPageIndeces();
289 int len = array.length;
290
291 assertEquals(Integer.parseInt(array[0].getControl().getText()), expectedStart, 0);
292 assertEquals(Integer.parseInt(array[len - 1].getControl().getText()), expectedEnd, 0);
293 }
294
295 protected void checkRightPageIndecesOrderAndContinuousOrder() {
296 testedControl.waitState(new State() {
|
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
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 package javafx.scene.control.test.pagination;
26
27 import com.sun.javafx.scene.control.LabeledText;
28 import java.util.ArrayList;
29 import java.util.Arrays;
30 import java.util.Comparator;
31 import javafx.geometry.Orientation;
32 import javafx.scene.Node;
33 import javafx.scene.Scene;
34 import javafx.scene.control.Label;
35 import javafx.scene.control.Pagination;
36 import javafx.scene.control.ScrollBar;
37 import javafx.scene.control.TextArea;
38 import static javafx.scene.control.test.pagination.PaginationApp.*;
39 import javafx.scene.control.test.util.UtilTestFunctions;
40 import static javafx.scene.control.test.utils.ComponentsFactory.*;
41 import javafx.scene.control.test.utils.ptables.AbstractPropertyController.SettingType;
42 import javafx.scene.layout.StackPane;
43 import org.jemmy.Point;
44 import org.jemmy.action.GetAction;
45 import org.jemmy.control.Wrap;
46 import org.jemmy.env.Environment;
47 import org.jemmy.fx.ByID;
130 }
131
132 protected void setBulletStyleOfPageIndicators() {
133 clickButtonForTestPurpose(SET_BULLET_PAGE_INDICATOR_BUTTON_ID);
134 }
135
136 protected void setIndeterminatePageCount() {
137 clickButtonForTestPurpose(SET_PAGE_COUNT_TO_INDETERMINATE_BUTTON_ID);
138 }
139
140 protected void checkFormComponentButton() {
141 clickButtonByID(FORM_BUTTON_ID);
142 testedControl.waitState(new State<Integer>() {
143 public Integer reached() {
144 return Integer.parseInt(findTextField(FORM_CLICK_TEXT_FIELD_ID).getControl().getText());
145 }
146 }, 1);
147 }
148
149 protected void checkScrollingOfFormComponentScrollBar() {
150 Wrap<? extends ScrollBar> scrollBar = findScrollBar((Parent<Node>)testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, true);
151 scrollBar.mouse().turnWheel(-1);
152 testedControl.waitState(new State<Integer>() {
153 public Integer reached() {
154 return Integer.parseInt(findTextField(FORM_SCROLL_TEXT_FIELD_ID).getControl().getText());
155 }
156 }, 1);
157
158 AbstractScroll c = scrollBar.as(AbstractScroll.class);
159 c.allowError(0.01);
160 double meanValue = getScrollBarCenter(scrollBar);
161 c.caret().to(meanValue);
162 assertTrue(Math.abs(meanValue - getScrollBarValue(scrollBar)) <= 1);
163 }
164
165 protected double getScrollBarValue(final Wrap<? extends ScrollBar> scrollBar) {
166 return new GetAction<Double>() {
167 @Override
168 public void run(Object... os) throws Exception {
169 setResult(scrollBar.getControl().getValue());
170 }
256 setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefWidth, width);
257 setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefHeight, height);
258 }
259
260 /**
261 * 0 - begin, 1 - end.
262 *
263 * @param pos
264 */
265 protected void checkScrollBarPosition(final int pos) {
266 ScrollBar sb = getScrollbarWrap(true).getControl();
267 if (pos == 1) {
268 assertTrue(sb.getMax() == sb.getValue());
269 }
270 if (pos == 0) {
271 assertTrue(sb.getMin() == sb.getValue());
272 }
273 }
274
275 protected Wrap<? extends ScrollBar> getScrollbarWrap(boolean visible) {
276 return findScrollBar((Parent<Node>)testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, visible);
277 }
278
279 protected void checkNumberOfVisiblePageIndeces(int expectedIndeces) {
280 checkRightPageIndecesOrderAndContinuousOrder();
281 Wrap<? extends LabeledText>[] array = getSortedPageIndeces();
282 int len = array.length;
283 assertEquals(len, expectedIndeces, 0);
284 }
285
286 protected void checkRangeOfPageIndecesVisibility(int expectedStart, int expectedEnd) {
287 checkNumberOfVisiblePageIndeces(expectedEnd - expectedStart + 1);
288 Wrap<? extends LabeledText>[] array = getSortedPageIndeces();
289 int len = array.length;
290
291 assertEquals(Integer.parseInt(array[0].getControl().getText()), expectedStart, 0);
292 assertEquals(Integer.parseInt(array[len - 1].getControl().getText()), expectedEnd, 0);
293 }
294
295 protected void checkRightPageIndecesOrderAndContinuousOrder() {
296 testedControl.waitState(new State() {
|