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

test do not start through #20

Closed
tbee opened this issue Oct 18, 2013 · 4 comments
Closed

test do not start through #20

tbee opened this issue Oct 18, 2013 · 4 comments
Assignees

Comments

@tbee
Copy link

tbee commented Oct 18, 2013

I was able to build TestFX, include it in the JFXtras project and I've copied the essence of the example test over and created one of my own. The test starts but halts at the

stage = stageFuture.get( 25, TimeUnit.SECONDS );

line, where it will throw a TimeoutException

java.util.concurrent.TimeoutException: Timeout waiting for task.
at com.google.common.util.concurrent.AbstractFuture$Sync.get(AbstractFuture.java:269)
at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:96)
at jfxtras.labs.scene.control.test.ListSpinnerTest2.createWindow(ListSpinnerTest2.java:69)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

@tbee
Copy link
Author

tbee commented Oct 18, 2013

/**

  • ListSpinnerTest2.java
    *
  • Copyright (c) 2011-2013, JFXtras
  • All rights reserved.
  • Redistribution and use in source and binary forms, with or without
  • modification, are permitted provided that the following conditions are met:
  • \* Redistributions of source code must retain the above copyright
    
  •   notice, this list of conditions and the following disclaimer.
    
  • \* Redistributions in binary form must reproduce the above copyright
    
  •   notice, this list of conditions and the following disclaimer in the
    
  •   documentation and/or other materials provided with the distribution.
    
  • \* Neither the name of the <organization> nor the
    
  •   names of its contributors may be used to endorse or promote products
    
  •   derived from this software without specific prior written permission.
    
  • THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  • ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  • WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  • DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
  • DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  • (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  • LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  • ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  • (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  • SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    */

package jfxtras.labs.scene.control.test;

import java.util.concurrent.TimeUnit;

import org.jemmy.control.Wrap;
import org.jemmy.fx.ByStyleClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.loadui.testfx.FXScreenController;
import org.loadui.testfx.FXTestUtils;
import org.loadui.testfx.categories.TestFX;
import javafx.stage.Stage;
import jfxtras.labs.scene.control.ListSpinner;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Bounds;
import javafx.scene.Node;
import javafx.scene.SceneBuilder;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonBuilder;
import javafx.scene.control.TextField;
import javafx.scene.control.TextFieldBuilder;
import javafx.scene.input.KeyCode;
import javafx.scene.input.MouseButton;
import javafx.scene.layout.VBoxBuilder;
import javafx.stage.Stage;

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

@category( TestFX.class )
public class ListSpinnerTest2 {

@BeforeClass
public static void createWindow() throws Throwable
{
    FXTestUtils.launchApp( ListSpinnerTest1App.class );
    stage = stageFuture.get( 25, TimeUnit.SECONDS );
    FXTestUtils.bringToFront( stage );
}
private static final SettableFuture<Stage> stageFuture = SettableFuture.create();
private static final FXScreenController controller = new FXScreenController();
private static Stage stage;

@Before
public void setup() throws Exception
{
}

@Test
public void clickOnNextArrowShouldMoveToTheNextValue()
{
    ListSpinner<String> lSpinner = (ListSpinner<String>)stage.getScene().lookup( "#spinner" );
    System.out.println(lSpinner);
    Node lLeftArrow= (Node)stage.getScene().lookup( ".left-arrow");
    System.out.println(lLeftArrow);

    Bounds sceneBounds = lSpinner.localToScene( lSpinner.getBoundsInLocal() );

// controller.move( stage.getX() + stage.getScene().getX() + sceneBounds.getMinX() + 10, stage.getY() + stage.getScene().getY() + sceneBounds.getMinY() + 10 );
}
}

@ghost ghost assigned minisu Oct 19, 2013
@minisu
Copy link
Member

minisu commented Oct 20, 2013

Hi!

I've started looking at this, but I miss the file ListSpinnerTest1App.class in order to build your code.

@tbee
Copy link
Author

tbee commented Oct 20, 2013

JFXtras is open source, you can find the file here.
https://github.com/JFXtras/jfxtras-labs/tree/2.2/src/test/java/jfxtras/labs/scene/control/test

Also, the *Test1 is using the JemmyFX UI testing framework. But I'm not really happy with that.

Tom

@minisu
Copy link
Member

minisu commented Oct 21, 2013

This is how I would write a test for this class in TestFX:

ListSpinner<String> lSpinner = new ListSpinner<String>("a", "b", "c")
         .withEditable(true).withStringConverter(StringConverterFactory.forString())
         .withCyclic(true);

showNodeInStage( lSpinner );

click(".right-arrow");

assertNodeExists("b");

This compiles and runs fine in TestFX 2.7.4.

(If you still want to use the idiom launchApp idiom, you need to make ListSpinnerTest1App an inner class of the test and have its start method set stageFuture.)

@minisu minisu closed this as completed Oct 27, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants