From 2d13fa3d299c4f59261ead2acd5be55cfd22a7f9 Mon Sep 17 00:00:00 2001 From: Manfred Karrer Date: Thu, 4 Sep 2014 12:58:34 +0200 Subject: [PATCH] Add seed words ui mock --- .../uimock/RegistrationViewUIMock.fxml | 34 +++++- .../uimock/SeedWordsControllerUIMock.java | 39 +++++++ .../uimock/SeedWordsUIMockRunner.java | 87 ++++++++++++++ .../settings/uimock/SeedWordsViewUIMock.fxml | 106 ++++++++++++++++++ .../uimock/SetPasswordControllerUIMock.java | 2 +- .../uimock/SetPasswordUIMockRunner.java | 4 +- .../uimock/SetPasswordViewUIMock.fxml | 4 +- 7 files changed, 269 insertions(+), 7 deletions(-) create mode 100644 src/test/java/io/bitsquare/gui/settings/uimock/SeedWordsControllerUIMock.java create mode 100644 src/test/java/io/bitsquare/gui/settings/uimock/SeedWordsUIMockRunner.java create mode 100644 src/test/java/io/bitsquare/gui/settings/uimock/SeedWordsViewUIMock.fxml rename src/test/java/io/bitsquare/gui/{registration => settings}/uimock/SetPasswordControllerUIMock.java (96%) rename src/test/java/io/bitsquare/gui/{registration => settings}/uimock/SetPasswordUIMockRunner.java (94%) rename src/test/java/io/bitsquare/gui/{registration => settings}/uimock/SetPasswordViewUIMock.fxml (97%) diff --git a/src/test/java/io/bitsquare/gui/registration/uimock/RegistrationViewUIMock.fxml b/src/test/java/io/bitsquare/gui/registration/uimock/RegistrationViewUIMock.fxml index 974ed015a8..5ee1499e67 100644 --- a/src/test/java/io/bitsquare/gui/registration/uimock/RegistrationViewUIMock.fxml +++ b/src/test/java/io/bitsquare/gui/registration/uimock/RegistrationViewUIMock.fxml @@ -33,6 +33,35 @@ + + + + + + + + + + + + + + + + + + + + + + +
- + + - +
diff --git a/src/test/java/io/bitsquare/gui/settings/uimock/SeedWordsControllerUIMock.java b/src/test/java/io/bitsquare/gui/settings/uimock/SeedWordsControllerUIMock.java new file mode 100644 index 0000000000..4a4fcf8f21 --- /dev/null +++ b/src/test/java/io/bitsquare/gui/settings/uimock/SeedWordsControllerUIMock.java @@ -0,0 +1,39 @@ +/* + * This file is part of Bitsquare. + * + * Bitsquare is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bitsquare is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bitsquare. If not, see . + */ + +package io.bitsquare.gui.settings.uimock; + +import java.net.URL; + +import java.util.ResourceBundle; + +import javafx.fxml.Initializable; + +public class SeedWordsControllerUIMock implements Initializable { + + + /////////////////////////////////////////////////////////////////////////////////////////// + // Lifecycle + /////////////////////////////////////////////////////////////////////////////////////////// + + @Override + public void initialize(URL url, ResourceBundle rb) { + } + + +} + diff --git a/src/test/java/io/bitsquare/gui/settings/uimock/SeedWordsUIMockRunner.java b/src/test/java/io/bitsquare/gui/settings/uimock/SeedWordsUIMockRunner.java new file mode 100644 index 0000000000..7043ee6a54 --- /dev/null +++ b/src/test/java/io/bitsquare/gui/settings/uimock/SeedWordsUIMockRunner.java @@ -0,0 +1,87 @@ +package io.bitsquare.gui.settings.uimock; + +import io.bitsquare.di.BitSquareModule; +import io.bitsquare.di.GuiceFXMLLoader; + +import com.google.inject.Guice; +import com.google.inject.Injector; + +import java.io.IOException; + +import java.net.MalformedURLException; +import java.net.URL; + +import javafx.application.Application; +import javafx.scene.*; +import javafx.scene.input.*; +import javafx.scene.layout.*; +import javafx.stage.Stage; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * For testing single isolated UI screens + */ +public class SeedWordsUIMockRunner extends Application { + private static final Logger log = LoggerFactory.getLogger(SeedWordsUIMockRunner.class); + private Scene scene; + private Parent view; + private Pane pane; + private boolean devTest = true; + + public static void main(String[] args) { + launch(args); + } + + @Override + public void start(Stage primaryStage) throws IOException { + Injector injector = Guice.createInjector(new BitSquareModule()); + GuiceFXMLLoader.setInjector(injector); + + pane = new StackPane(); + scene = new Scene(pane, 1000, 1200); + scene.getAccelerators().put(KeyCombination.valueOf("Shortcut+S"), this::loadMainWindow); + loadMainWindow(); + primaryStage.setScene(scene); + primaryStage.show(); + } + + public void loadMainWindow() { + log.debug("re load"); + pane.getChildren().removeAll(); + GuiceFXMLLoader loader = new GuiceFXMLLoader( + getUrl("/io/bitsquare/gui/settings/uimock/SeedWordsViewUIMock.fxml"), false); + + try { + view = loader.load(); + } catch (IOException e) { + e.printStackTrace(); + } + + pane.getChildren().setAll(view); + refreshStylesheets(); + } + + private void refreshStylesheets() { + scene.getStylesheets().clear(); + scene.getStylesheets().setAll(getUrl("/io/bitsquare/gui/bitsquare.css").toExternalForm()); + } + + private URL getUrl(String subPath) { + if (devTest) { + try { + // load from file system location to make a reload possible. makes dev process easier with hot reload + return new URL("file:///Users/mk/Documents/_intellij/bitsquare/src/test/java" + subPath); + } catch (MalformedURLException e) { + e.printStackTrace(); + return null; + } + } + else { + return getClass().getResource(subPath); + } + } + + +} diff --git a/src/test/java/io/bitsquare/gui/settings/uimock/SeedWordsViewUIMock.fxml b/src/test/java/io/bitsquare/gui/settings/uimock/SeedWordsViewUIMock.fxml new file mode 100644 index 0000000000..f04b09af28 --- /dev/null +++ b/src/test/java/io/bitsquare/gui/settings/uimock/SeedWordsViewUIMock.fxml @@ -0,0 +1,106 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/java/io/bitsquare/gui/registration/uimock/SetPasswordControllerUIMock.java b/src/test/java/io/bitsquare/gui/settings/uimock/SetPasswordControllerUIMock.java similarity index 96% rename from src/test/java/io/bitsquare/gui/registration/uimock/SetPasswordControllerUIMock.java rename to src/test/java/io/bitsquare/gui/settings/uimock/SetPasswordControllerUIMock.java index ce56f240a6..9b36bfddad 100644 --- a/src/test/java/io/bitsquare/gui/registration/uimock/SetPasswordControllerUIMock.java +++ b/src/test/java/io/bitsquare/gui/settings/uimock/SetPasswordControllerUIMock.java @@ -15,7 +15,7 @@ * along with Bitsquare. If not, see . */ -package io.bitsquare.gui.registration.uimock; +package io.bitsquare.gui.settings.uimock; import java.net.URL; diff --git a/src/test/java/io/bitsquare/gui/registration/uimock/SetPasswordUIMockRunner.java b/src/test/java/io/bitsquare/gui/settings/uimock/SetPasswordUIMockRunner.java similarity index 94% rename from src/test/java/io/bitsquare/gui/registration/uimock/SetPasswordUIMockRunner.java rename to src/test/java/io/bitsquare/gui/settings/uimock/SetPasswordUIMockRunner.java index 722c1b8ee0..f4030027e9 100644 --- a/src/test/java/io/bitsquare/gui/registration/uimock/SetPasswordUIMockRunner.java +++ b/src/test/java/io/bitsquare/gui/settings/uimock/SetPasswordUIMockRunner.java @@ -1,4 +1,4 @@ -package io.bitsquare.gui.registration.uimock; +package io.bitsquare.gui.settings.uimock; import io.bitsquare.di.BitSquareModule; import io.bitsquare.di.GuiceFXMLLoader; @@ -51,7 +51,7 @@ public class SetPasswordUIMockRunner extends Application { log.debug("re load"); pane.getChildren().removeAll(); GuiceFXMLLoader loader = new GuiceFXMLLoader( - getUrl("/io/bitsquare/gui/registration/uimock/SetPasswordViewUIMock.fxml"), false); + getUrl("/io/bitsquare/gui/settings/uimock/SetPasswordViewUIMock.fxml"), false); try { view = loader.load(); diff --git a/src/test/java/io/bitsquare/gui/registration/uimock/SetPasswordViewUIMock.fxml b/src/test/java/io/bitsquare/gui/settings/uimock/SetPasswordViewUIMock.fxml similarity index 97% rename from src/test/java/io/bitsquare/gui/registration/uimock/SetPasswordViewUIMock.fxml rename to src/test/java/io/bitsquare/gui/settings/uimock/SetPasswordViewUIMock.fxml index e7672cad07..ab6de1c5d4 100644 --- a/src/test/java/io/bitsquare/gui/registration/uimock/SetPasswordViewUIMock.fxml +++ b/src/test/java/io/bitsquare/gui/settings/uimock/SetPasswordViewUIMock.fxml @@ -24,9 +24,9 @@ + fx:controller="io.bitsquare.gui.settings.uimock.SetPasswordControllerUIMock"> - +