Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(refactor) API: Introduce FxSelector and FxSelectorContext. #165

Merged
merged 2 commits into from
Nov 30, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,11 @@
import org.loadui.testfx.robots.impl.BaseRobotImpl;
import org.loadui.testfx.service.finder.NodeFinder;
import org.loadui.testfx.service.finder.WindowFinder;
import org.loadui.testfx.service.finder.impl.NodeFinderImpl;
import org.loadui.testfx.service.finder.impl.WindowFinderImpl;
import org.loadui.testfx.service.support.CaptureSupport;
import org.loadui.testfx.service.support.WaitUntilSupport;

import static org.junit.Assume.assumeFalse;
import static org.testfx.api.FxSelector.selectorContext;

public abstract class GuiTest extends AppRobotTestBase implements StageSetupCallback {

Expand Down Expand Up @@ -159,8 +158,9 @@ public static File captureScreenshot() {
// PRIVATE STATIC FIELDS.
//---------------------------------------------------------------------------------------------

private static final WindowFinder windowFinder = new WindowFinderImpl();
private static final NodeFinder nodeFinder = new NodeFinderImpl(windowFinder);
private static final WindowFinder windowFinder = selectorContext().getWindowFinder();
private static final NodeFinder nodeFinder = selectorContext().getNodeFinder();

private static final WaitUntilSupport waitUntilSupport = new WaitUntilSupport();
private static final CaptureSupport captureSupport = new CaptureSupport(new BaseRobotImpl());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,44 +30,43 @@
import com.google.common.base.Predicate;
import org.hamcrest.Matcher;
import org.loadui.testfx.framework.robot.FxRobot;
import org.loadui.testfx.robots.BaseRobot;
import org.loadui.testfx.robots.ClickRobot;
import org.loadui.testfx.robots.DragRobot;
import org.loadui.testfx.robots.KeyboardRobot;
import org.loadui.testfx.robots.MouseRobot;
import org.loadui.testfx.robots.MoveRobot;
import org.loadui.testfx.robots.BaseRobot;
import org.loadui.testfx.robots.ScrollRobot;
import org.loadui.testfx.robots.SleepRobot;
import org.loadui.testfx.robots.TypeRobot;
import org.loadui.testfx.robots.WriteRobot;
import org.loadui.testfx.robots.impl.BaseRobotImpl;
import org.loadui.testfx.robots.impl.ClickRobotImpl;
import org.loadui.testfx.robots.impl.DragRobotImpl;
import org.loadui.testfx.robots.impl.KeyboardRobotImpl;
import org.loadui.testfx.robots.impl.MouseRobotImpl;
import org.loadui.testfx.robots.impl.MoveRobotImpl;
import org.loadui.testfx.robots.impl.BaseRobotImpl;
import org.loadui.testfx.robots.impl.ScrollRobotImpl;
import org.loadui.testfx.robots.impl.SleepRobotImpl;
import org.loadui.testfx.robots.impl.TypeRobotImpl;
import org.loadui.testfx.robots.impl.WriteRobotImpl;
import org.loadui.testfx.service.finder.NodeFinder;
import org.loadui.testfx.service.finder.WindowFinder;
import org.loadui.testfx.service.finder.impl.NodeFinderImpl;
import org.loadui.testfx.service.finder.impl.WindowFinderImpl;
import org.loadui.testfx.service.locator.BoundsLocator;
import org.loadui.testfx.service.locator.PointLocator;
import org.loadui.testfx.service.locator.impl.BoundsLocatorImpl;
import org.loadui.testfx.service.locator.impl.PointLocatorImpl;
import org.loadui.testfx.service.query.PointQuery;
import org.testfx.api.FxSelector;

public class FxRobotImpl implements FxRobot {

//---------------------------------------------------------------------------------------------
// PRIVATE FIELDS.
//---------------------------------------------------------------------------------------------

private final WindowFinder windowFinder = new WindowFinderImpl();
private final NodeFinder nodeFinder = new NodeFinderImpl(windowFinder);
private final WindowFinder windowFinder;
private final NodeFinder nodeFinder;

private Pos pointPosition = Pos.CENTER;
private final BoundsLocator boundsLocator;
Expand All @@ -90,6 +89,9 @@ public class FxRobotImpl implements FxRobot {
//---------------------------------------------------------------------------------------------

public FxRobotImpl() {
windowFinder = FxSelector.selectorContext().getWindowFinder();
nodeFinder = FxSelector.selectorContext().getNodeFinder();

boundsLocator = new BoundsLocatorImpl();
pointLocator = new PointLocatorImpl(boundsLocator);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ public interface WindowFinder {
public void target(int windowIndex);
public void target(String stageTitleRegex);
public void target(Scene scene);
//public void target(Node node);

public List<Window> listWindows();
public List<Window> listOrderedWindows();

public Window window(int windowIndex);
public Window window(String stageTitleRegex);
public Window window(Scene scene);
//public Window window(Node node);
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@
import javafx.application.Application;
import javafx.stage.Stage;

import com.google.common.annotations.Beta;
import org.loadui.testfx.framework.launch.StageFuture;
import org.loadui.testfx.framework.launch.ToolkitApplication;

import static java.lang.Long.parseLong;
import static java.lang.System.getProperty;

@Beta
public class FxLifecycleContext {

//---------------------------------------------------------------------------------------------
Expand All @@ -41,7 +43,7 @@ public class FxLifecycleContext {
private long setupTimeoutInMillis = parseLong(getProperty("testfx.setup.timeout", "30000"));

//---------------------------------------------------------------------------------------------
// METHODS.
// GETTER AND SETTER.
//---------------------------------------------------------------------------------------------

public Class<? extends Application> getApplicationClass() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright 2013-2014 SmartBear Software
*
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved by the European
* Commission - subsequent versions of the EUPL (the "Licence"); You may not use this work
* except in compliance with the Licence.
*
* You may obtain a copy of the Licence at:
* http://ec.europa.eu/idabc/eupl
*
* Unless required by applicable law or agreed to in writing, software distributed under the
* Licence is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the Licence for the specific language governing permissions
* and limitations under the Licence.
*/
package org.testfx.api;

import com.google.common.annotations.Beta;

@Beta
public class FxSelector {

//---------------------------------------------------------------------------------------------
// STATIC FIELDS.
//---------------------------------------------------------------------------------------------

private static final FxSelectorContext context = new FxSelectorContext();

//---------------------------------------------------------------------------------------------
// PRIVATE CONSTRUCTORS.
//---------------------------------------------------------------------------------------------

private FxSelector() {
throw new UnsupportedOperationException();
}

//---------------------------------------------------------------------------------------------
// STATIC METHODS.
//---------------------------------------------------------------------------------------------

public static FxSelectorContext selectorContext() {
return context;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright 2013-2014 SmartBear Software
*
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved by the European
* Commission - subsequent versions of the EUPL (the "Licence"); You may not use this work
* except in compliance with the Licence.
*
* You may obtain a copy of the Licence at:
* http://ec.europa.eu/idabc/eupl
*
* Unless required by applicable law or agreed to in writing, software distributed under the
* Licence is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the Licence for the specific language governing permissions
* and limitations under the Licence.
*/
package org.testfx.api;

import com.google.common.annotations.Beta;
import org.loadui.testfx.service.finder.NodeFinder;
import org.loadui.testfx.service.finder.WindowFinder;
import org.loadui.testfx.service.finder.impl.NodeFinderImpl;
import org.loadui.testfx.service.finder.impl.WindowFinderImpl;

@Beta
public class FxSelectorContext {

//---------------------------------------------------------------------------------------------
// PRIVATE FIELDS.
//---------------------------------------------------------------------------------------------

private WindowFinder windowFinder = new WindowFinderImpl();

private NodeFinder nodeFinder = new NodeFinderImpl(windowFinder);

//---------------------------------------------------------------------------------------------
// GETTER AND SETTER.
//---------------------------------------------------------------------------------------------

public WindowFinder getWindowFinder() {
return windowFinder;
}

public void setWindowFinder(WindowFinder windowFinder) {
this.windowFinder = windowFinder;
}

public NodeFinder getNodeFinder() {
return nodeFinder;
}

public void setNodeFinder(NodeFinder nodeFinder) {
this.nodeFinder = nodeFinder;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ protected Parent getRootNode() {
}

@Test
@Ignore
public void testScroll() {
String id1 = "#" + ID1;
String id2 = "#" + ID2;
Expand Down