Skip to content

Commit

Permalink
Merge pull request #153 from hastebrot/refactor-extract-toolkitapp
Browse files Browse the repository at this point in the history
refactor(Framework): Extract ToolkitApplication.
  • Loading branch information
hastebrot committed Oct 23, 2014
2 parents ddb8b5c + 9a64908 commit efa7499
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 28 deletions.
Expand Up @@ -22,7 +22,7 @@

import org.loadui.testfx.framework.app.AppSetup;
import org.loadui.testfx.framework.app.AppLauncher;
import org.loadui.testfx.utils.StageFuture;
import org.loadui.testfx.framework.launch.StageFuture;

/**
* Class that launches an application class and retrieves its primary stage.
Expand Down
Expand Up @@ -15,34 +15,11 @@
*/
package org.loadui.testfx.framework.app.impl;

import javafx.application.Application;
import javafx.stage.Stage;
import javafx.stage.StageStyle;

import org.loadui.testfx.framework.app.AppSetup;
import org.loadui.testfx.utils.StageFuture;
import org.loadui.testfx.framework.launch.ToolkitApplication;

public class ToolkitAppSetupFactory {

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

public static final StageFuture primaryStageFuture = StageFuture.create();

//---------------------------------------------------------------------------------------------
// STATIC CLASSES.
//---------------------------------------------------------------------------------------------

public static class ToolkitApplication extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
primaryStage.initStyle(StageStyle.UNDECORATED);
primaryStage.setTitle("DefaultApplication: primaryStage");
primaryStageFuture.set(primaryStage);
}
}

//---------------------------------------------------------------------------------------------
// STATIC METHODS.
//---------------------------------------------------------------------------------------------
Expand All @@ -51,7 +28,7 @@ public static AppSetup build() {
AppSetupImpl appSetup = new AppSetupImpl();
appSetup.setAppClass(ToolkitApplication.class);
appSetup.setAppLauncher(new ToolkitAppLauncher());
appSetup.setStageFuture(primaryStageFuture);
appSetup.setStageFuture(ToolkitApplication.primaryStageFuture);
return appSetup;
}

Expand Down
Expand Up @@ -13,9 +13,10 @@
* either express or implied. See the Licence for the specific language governing permissions
* and limitations under the Licence.
*/
package org.loadui.testfx.utils;
package org.loadui.testfx.framework.launch;

import javafx.stage.Stage;

import com.google.common.util.concurrent.AbstractFuture;

public class StageFuture extends AbstractFuture<Stage> {
Expand Down
@@ -0,0 +1,41 @@
/*
* 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.loadui.testfx.framework.launch;

import javafx.application.Application;
import javafx.stage.Stage;
import javafx.stage.StageStyle;

public class ToolkitApplication extends Application {

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

public static final StageFuture primaryStageFuture = StageFuture.create();

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

@Override
public void start(Stage primaryStage) throws Exception {
primaryStage.initStyle(StageStyle.UNDECORATED);
primaryStage.setTitle(getClass().getSimpleName());
primaryStageFuture.set(primaryStage);
}

}
Expand Up @@ -24,8 +24,8 @@
import org.junit.Before;
import org.junit.Test;
import org.loadui.testfx.framework.app.AppLauncher;
import org.loadui.testfx.framework.launch.StageFuture;
import org.loadui.testfx.utils.FXTestUtils;
import org.loadui.testfx.utils.StageFuture;

import org.hamcrest.Matchers;
import static org.hamcrest.MatcherAssert.assertThat;
Expand Down

0 comments on commit efa7499

Please sign in to comment.