/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.exalttech.trex.ui;

import com.exalttech.trex.application.TrexApp;
import com.exalttech.trex.util.Util;
import java.io.File;
import java.util.concurrent.TimeoutException;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.input.KeyCode;
import javafx.scene.input.MouseButton;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;
import org.apache.commons.io.FileUtils;
import org.testfx.framework.junit.ApplicationTest;
import org.testng.Assert;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;

/**
 * Base class for automation UI test
 * @author Georgekh
 */
public class UIBaseTest extends UITestsServices {
    
    private static final String APP_DATA_PATH = File.separator + "TRex";
    @BeforeTest
    public void setUpClass() throws Exception {
        if (Util.isWindows()) {
            // remove appData folder
           File trexDirectory = new File(System.getenv("LOCALAPPDATA") + APP_DATA_PATH);
            if(trexDirectory.exists()){
                FileUtils.deleteQuietly(trexDirectory);
            }
            ApplicationTest.launch(TrexApp.class);
        }else{
            Assert.assertTrue(false, "Not windows OS");
        }
        
    }

    @Override
    public void start(Stage stage) throws Exception {
        TrexApp.setPrimaryStage(stage);
        AnchorPane page = (AnchorPane) FXMLLoader.load(getClass().getResource("/fxml/MainView.fxml"));
        Scene scene = new Scene(page);
        scene.getStylesheets().add(TrexApp.class.getResource("/styles/mainStyle.css").toExternalForm());
        stage.setScene(scene);
        stage.setTitle("TRex");
        stage.setResizable(true);
        stage.setMinWidth(1100);
        stage.setMinHeight(670);
        stage.show();
    }

    @AfterTest
    public void releaseAfterEachTest() throws TimeoutException {
        release(new KeyCode[]{});
        release(new MouseButton[]{});
    }
    
}

@@ -801,16 +801,19 @@
 UI test%0A
+ *%0A
  * @auth
@@ -878,20 +878,16 @@
 vices %7B%0A
-    
 %0A    pri
@@ -952,16 +952,17 @@
 %22TRex%22;%0A
+%0A
     @Bef
@@ -1021,44 +1021,9 @@
 n %7B%0A
-        if (Util.isWindows()) %7B%0A    
+%0A
     
@@ -1055,27 +1055,24 @@
 der%0A        
-  
- 
 File trexDir
@@ -1149,14 +1149,11 @@
     
-    
 if
+ 
 (tre
@@ -1172,16 +1172,17 @@
 xists())
+ 
 %7B%0A      
@@ -1183,28 +1183,24 @@
             
-  
-  
 FileUtils.de
@@ -1239,25 +1239,18 @@
     
-    %7D%0A   
+%7D%0A
         
  App
@@ -1245,17 +1245,16 @@
         
- 
 Applicat
@@ -1288,97 +1288,8 @@
 s);%0A
-        %7Delse%7B%0A            Assert.assertTrue(false, %22Not windows OS%22);%0A        %7D%0A        
 %0A   
@@ -1997,15 +1997,11 @@
 ;%0A    %7D%0A
-    
 %0A%7D%0A

Remove Restrictions