From 1525f13fea9150d2ac97f405f6536fd137d7da75 Mon Sep 17 00:00:00 2001 From: Craig Tadlock Date: Tue, 19 May 2020 14:59:26 -0700 Subject: [PATCH] Move all existing code into tornadofx-core; change version to 2.1 https://github.com/edvin/tornadofx2/issues/3 --- pom.xml | 398 +-- src/main/java/module-info.java | 28 - .../kotlin/tornadofx/testapps/AccelTest.kt | 24 - .../tornadofx/testapps/AnimationHelperTest.kt | 46 - .../tornadofx/testapps/AsyncProgressApp.kt | 61 - .../tornadofx/testapps/AwaitUntilTest.kt | 42 - .../tornadofx/testapps/BorderPaneTest.kt | 18 - .../tornadofx/testapps/BrokenLineTest.kt | 62 - .../tornadofx/testapps/BuilderWindowTest.kt | 63 - .../kotlin/tornadofx/testapps/ChartTestApp.kt | 33 - .../kotlin/tornadofx/testapps/ComboBoxTest.kt | 196 -- .../kotlin/tornadofx/testapps/CommandTest.kt | 102 - .../kotlin/tornadofx/testapps/DataGridTest.kt | 91 - .../kotlin/tornadofx/testapps/DrawerTest.kt | 122 - .../kotlin/tornadofx/testapps/EventBusTest.kt | 80 - .../tornadofx/testapps/ExpandableTableTest.kt | 70 - .../testapps/ExternalStylesheetTest.kt | 16 - .../kotlin/tornadofx/testapps/FormTest.kt | 30 - .../kotlin/tornadofx/testapps/GotoViewApp.kt | 52 - .../kotlin/tornadofx/testapps/ImportStyles.kt | 45 - .../tornadofx/testapps/InternalWindowTest.kt | 40 - .../tornadofx/testapps/KeyboardTestView.kt | 93 - .../kotlin/tornadofx/testapps/ListMenuTest.kt | 73 - .../testapps/MultipleLifecycleAsyncApp.kt | 20 - .../tornadofx/testapps/NestedTableColumns.kt | 23 - .../tornadofx/testapps/NewViewTransition.kt | 243 -- .../tornadofx/testapps/PaddingPropertyTest.kt | 16 - .../tornadofx/testapps/PaintBackgroundTest.kt | 14 - .../kotlin/tornadofx/testapps/ParamTest.kt | 34 - .../tornadofx/testapps/PojoTableColumns.kt | 23 - .../testapps/PojoTreeTableColumns.kt | 42 - .../tornadofx/testapps/ReloadStylesInModal.kt | 36 - .../kotlin/tornadofx/testapps/RemoveTest.kt | 32 - .../tornadofx/testapps/ShortLongPressTest.kt | 31 - .../tornadofx/testapps/SlideshowTest.kt | 34 - .../tornadofx/testapps/SqueezeBoxTest.kt | 55 - .../tornadofx/testapps/StylesheetErrorTest.kt | 25 - .../tornadofx/testapps/SwitchViewApp.kt | 46 - .../kotlin/tornadofx/testapps/TabPaneTest.kt | 42 - .../testapps/TableViewCellCacheTest.kt | 26 - .../tornadofx/testapps/TableViewDNDTest.kt | 74 - .../tornadofx/testapps/TableViewDirtyTest.kt | 106 - .../testapps/TableViewSelectionTest.kt | 76 - .../testapps/TableViewSortFilterTest.kt | 49 - .../tornadofx/testapps/TaskStatusTest.kt | 56 - .../kotlin/tornadofx/testapps/TodoTestApp.kt | 83 - .../tornadofx/testapps/ToggleButtonTestApp.kt | 24 - .../tornadofx/testapps/TransitionsTest.kt | 49 - .../tornadofx/testapps/ViewDockingApp.kt | 79 - .../tornadofx/testapps/WizardTestApp.kt | 109 - src/test/kotlin/tornadofx/tests/AsyncTest.kt | 101 - .../kotlin/tornadofx/tests/BindingTest.kt | 90 - .../kotlin/tornadofx/tests/BuildersTest.kt | 33 - .../tornadofx/tests/ChildInterceptorTest.kt | 82 - .../kotlin/tornadofx/tests/ClipboardTest.kt | 43 - .../kotlin/tornadofx/tests/CollectionsTest.kt | 172 - .../kotlin/tornadofx/tests/ComponentTest.kt | 68 - .../kotlin/tornadofx/tests/ControlsTest.kt | 112 - src/test/kotlin/tornadofx/tests/Customer.kt | 46 - .../kotlin/tornadofx/tests/EventBusTest.kt | 58 - src/test/kotlin/tornadofx/tests/FXMLTest.kt | 85 - src/test/kotlin/tornadofx/tests/FormTest.kt | 21 - .../tests/InternalWindowClosingTest.kt | 43 - .../kotlin/tornadofx/tests/JavaPerson.java | 102 - src/test/kotlin/tornadofx/tests/JsonTest.kt | 140 - .../kotlin/tornadofx/tests/LayoutsTest.kt | 227 -- src/test/kotlin/tornadofx/tests/ListTest.kt | 32 - .../tests/ListViewFragmentTestView.kt | 46 - .../tests/MultipleLifecycleAsyncAppTest.kt | 56 - src/test/kotlin/tornadofx/tests/NodeTest.kt | 49 - src/test/kotlin/tornadofx/tests/Person.kt | 40 - src/test/kotlin/tornadofx/tests/PersonPoko.kt | 6 - .../kotlin/tornadofx/tests/PreferencesTest.kt | 29 - .../kotlin/tornadofx/tests/PropertiesTest.kt | 2935 ----------------- .../kotlin/tornadofx/tests/RestClientTest.kt | 98 - src/test/kotlin/tornadofx/tests/ScopeTest.kt | 84 - .../tornadofx/tests/SimpleListViewTest.kt | 15 - .../tornadofx/tests/StylesheetErrorTest.kt | 45 - .../kotlin/tornadofx/tests/StylesheetTest.kt | 639 ---- .../kotlin/tornadofx/tests/TableViewTest.kt | 49 - .../kotlin/tornadofx/tests/ValidationTest.kt | 44 - .../kotlin/tornadofx/tests/VectorMathTest.kt | 234 -- .../tornadofx/tests/ViewDockingTests.kt | 149 - .../kotlin/tornadofx/tests/ViewModelTest.kt | 246 -- .../services/tornadofx.ChildInterceptor | 2 - src/test/resources/teststyles.css | 5 - .../tornadofx/tests/ComposedForm.fxml | 25 - .../tornadofx/tests/ComposedFormList.fxml | 11 - .../tornadofx/tests/ComposedFormSearch.fxml | 15 - .../resources/tornadofx/tests/FXMLTest.fxml | 7 - .../resources/tornadofx/tests/SimpleForm.fxml | 50 - .../tornadofx/tests/TornadoKeyboard.json | 344 -- src/test/resources/tornadofx/tests/person.png | Bin 952 -> 0 bytes tornadofx-core/pom.xml | 17 + .../tablerow/DirtyDecoratingTableRowSkin.java | 5 +- .../skin/tablerow/ExpandableTableRowSkin.java | 2 +- .../sun/net/www/protocol/css/Handler.kt | 2 +- .../src/main/kotlin}/tornadofx/Animation.kt | 0 .../src/main/kotlin}/tornadofx/App.kt | 0 .../src/main/kotlin}/tornadofx/Async.kt | 0 .../tornadofx/AutoCompleteComboBoxSkin.kt | 0 .../src/main/kotlin}/tornadofx/Binding.kt | 0 .../src/main/kotlin}/tornadofx/CSS.kt | 0 .../src/main/kotlin}/tornadofx/Charts.kt | 0 .../kotlin}/tornadofx/ChildInterceptor.kt | 0 .../src/main/kotlin}/tornadofx/Collections.kt | 0 .../src/main/kotlin}/tornadofx/Commands.kt | 0 .../src/main/kotlin}/tornadofx/Component.kt | 0 .../src/main/kotlin}/tornadofx/Controls.kt | 0 .../src/main/kotlin}/tornadofx/DataGrid.kt | 0 .../src/main/kotlin}/tornadofx/Decoration.kt | 0 .../src/main/kotlin}/tornadofx/Dialogs.kt | 0 .../src/main/kotlin}/tornadofx/Drawer.kt | 0 .../main/kotlin}/tornadofx/ErrorHandler.kt | 0 .../src/main/kotlin}/tornadofx/EventBus.kt | 0 .../src/main/kotlin}/tornadofx/EventLog.kt | 0 .../src/main/kotlin}/tornadofx/FX.kt | 0 .../src/main/kotlin}/tornadofx/Forms.kt | 0 .../main/kotlin}/tornadofx/InternalWindow.kt | 0 .../main/kotlin}/tornadofx/ItemControls.kt | 0 .../src/main/kotlin}/tornadofx/Json.kt | 0 .../src/main/kotlin}/tornadofx/Keyboard.kt | 0 .../main/kotlin}/tornadofx/LayoutDebugger.kt | 0 .../src/main/kotlin}/tornadofx/Layouts.kt | 0 .../src/main/kotlin}/tornadofx/Lib.kt | 0 .../src/main/kotlin}/tornadofx/ListMenu.kt | 0 .../src/main/kotlin}/tornadofx/ListView.kt | 0 .../src/main/kotlin}/tornadofx/Menu.kt | 53 +- .../src/main/kotlin}/tornadofx/Messages.kt | 0 .../src/main/kotlin}/tornadofx/Nodes.kt | 0 .../src/main/kotlin}/tornadofx/Properties.kt | 0 .../kotlin}/tornadofx/ReflectionUtils.java | 0 .../src/main/kotlin}/tornadofx/Rest.kt | 0 .../src/main/kotlin}/tornadofx/Shapes.kt | 0 .../kotlin}/tornadofx/ShutdownExecutor.kt | 0 .../src/main/kotlin}/tornadofx/Slideshow.kt | 0 .../src/main/kotlin}/tornadofx/SmartResize.kt | 0 .../src/main/kotlin}/tornadofx/SqueezeBox.kt | 0 .../src/main/kotlin}/tornadofx/StackPane.kt | 0 .../src/main/kotlin}/tornadofx/TabPane.kt | 0 .../src/main/kotlin}/tornadofx/TableView.kt | 0 .../src/main/kotlin}/tornadofx/TreeView.kt | 0 .../src/main/kotlin}/tornadofx/Validation.kt | 0 .../src/main/kotlin}/tornadofx/VectorMath.kt | 0 .../src/main/kotlin}/tornadofx/ViewModel.kt | 0 .../kotlin}/tornadofx/ViewModelFacades.kt | 0 .../src/main/kotlin}/tornadofx/Wizard.kt | 0 .../src/main/kotlin}/tornadofx/Workspace.kt | 0 .../tornadofx/adapters/TornadoFXColumns.kt | 0 .../adapters/TornadoFXResizeFeatures.kt | 0 .../tornadofx/adapters/TornadoFXTables.kt | 0 .../tornadofx/osgi/ApplicationProvider.kt | 0 .../osgi/ChildInterceptorProvider.kt | 0 .../kotlin}/tornadofx/osgi/OSGIConsole.kt | 0 .../tornadofx/osgi/StylesheetProvider.kt | 0 .../kotlin}/tornadofx/osgi/ViewProvider.kt | 0 .../kotlin}/tornadofx/osgi/impl/Activator.kt | 0 .../osgi/impl/ApplicationListener.kt | 0 .../osgi/impl/CSSURLStreamHandlerService.kt | 0 .../osgi/impl/InterceptorListener.kt | 0 .../tornadofx/osgi/impl/OSGISupport.kt | 0 .../tornadofx/osgi/impl/StylesheetListener.kt | 0 .../tornadofx/osgi/impl/ViewListener.kt | 0 .../main/resources/tornadofx/datagrid.css | 0 .../src}/main/resources/tornadofx/form.css | 0 .../tornadofx/i18n/ViewModel.properties | 0 .../tornadofx/i18n/ViewModel_de_DE.properties | 0 .../tornadofx/i18n/ViewModel_es.properties | 0 .../tornadofx/i18n/ViewModel_nb_NO.properties | 0 .../tornadofx/i18n/ViewModel_nl_NL.properties | 0 .../tornadofx/i18n/ViewModel_ru_RU.properties | 0 .../tornadofx/i18n/Wizard.properties | 0 .../tornadofx/i18n/Wizard_de_DE.properties | 0 .../tornadofx/i18n/Wizard_es.properties | 0 .../tornadofx/i18n/Wizard_nb_NO.properties | 0 .../tornadofx/i18n/Wizard_nl_NL.properties | 0 .../tornadofx/i18n/Wizard_ru_RU.properties | 0 .../main/resources/tornadofx/listmenu.css | 0 .../main/resources/tornadofx/maskpane.css | 0 .../resources/tornadofx/rowexpanderpane.css | 0 .../main/resources/tornadofx/workspace.css | 0 tornadofx-http/pom.xml | 17 + tornadofx-json/pom.xml | 17 + 183 files changed, 251 insertions(+), 9772 deletions(-) delete mode 100644 src/main/java/module-info.java delete mode 100644 src/test/kotlin/tornadofx/testapps/AccelTest.kt delete mode 100644 src/test/kotlin/tornadofx/testapps/AnimationHelperTest.kt delete mode 100644 src/test/kotlin/tornadofx/testapps/AsyncProgressApp.kt delete mode 100644 src/test/kotlin/tornadofx/testapps/AwaitUntilTest.kt delete mode 100644 src/test/kotlin/tornadofx/testapps/BorderPaneTest.kt delete mode 100644 src/test/kotlin/tornadofx/testapps/BrokenLineTest.kt delete mode 100644 src/test/kotlin/tornadofx/testapps/BuilderWindowTest.kt delete mode 100644 src/test/kotlin/tornadofx/testapps/ChartTestApp.kt delete mode 100644 src/test/kotlin/tornadofx/testapps/ComboBoxTest.kt delete mode 100644 src/test/kotlin/tornadofx/testapps/CommandTest.kt delete mode 100644 src/test/kotlin/tornadofx/testapps/DataGridTest.kt delete mode 100644 src/test/kotlin/tornadofx/testapps/DrawerTest.kt delete mode 100644 src/test/kotlin/tornadofx/testapps/EventBusTest.kt delete mode 100644 src/test/kotlin/tornadofx/testapps/ExpandableTableTest.kt delete mode 100644 src/test/kotlin/tornadofx/testapps/ExternalStylesheetTest.kt delete mode 100644 src/test/kotlin/tornadofx/testapps/FormTest.kt delete mode 100644 src/test/kotlin/tornadofx/testapps/GotoViewApp.kt delete mode 100644 src/test/kotlin/tornadofx/testapps/ImportStyles.kt delete mode 100644 src/test/kotlin/tornadofx/testapps/InternalWindowTest.kt delete mode 100644 src/test/kotlin/tornadofx/testapps/KeyboardTestView.kt delete mode 100644 src/test/kotlin/tornadofx/testapps/ListMenuTest.kt delete mode 100644 src/test/kotlin/tornadofx/testapps/MultipleLifecycleAsyncApp.kt delete mode 100644 src/test/kotlin/tornadofx/testapps/NestedTableColumns.kt delete mode 100644 src/test/kotlin/tornadofx/testapps/NewViewTransition.kt delete mode 100644 src/test/kotlin/tornadofx/testapps/PaddingPropertyTest.kt delete mode 100644 src/test/kotlin/tornadofx/testapps/PaintBackgroundTest.kt delete mode 100644 src/test/kotlin/tornadofx/testapps/ParamTest.kt delete mode 100644 src/test/kotlin/tornadofx/testapps/PojoTableColumns.kt delete mode 100644 src/test/kotlin/tornadofx/testapps/PojoTreeTableColumns.kt delete mode 100644 src/test/kotlin/tornadofx/testapps/ReloadStylesInModal.kt delete mode 100644 src/test/kotlin/tornadofx/testapps/RemoveTest.kt delete mode 100644 src/test/kotlin/tornadofx/testapps/ShortLongPressTest.kt delete mode 100644 src/test/kotlin/tornadofx/testapps/SlideshowTest.kt delete mode 100644 src/test/kotlin/tornadofx/testapps/SqueezeBoxTest.kt delete mode 100644 src/test/kotlin/tornadofx/testapps/StylesheetErrorTest.kt delete mode 100644 src/test/kotlin/tornadofx/testapps/SwitchViewApp.kt delete mode 100644 src/test/kotlin/tornadofx/testapps/TabPaneTest.kt delete mode 100644 src/test/kotlin/tornadofx/testapps/TableViewCellCacheTest.kt delete mode 100644 src/test/kotlin/tornadofx/testapps/TableViewDNDTest.kt delete mode 100644 src/test/kotlin/tornadofx/testapps/TableViewDirtyTest.kt delete mode 100644 src/test/kotlin/tornadofx/testapps/TableViewSelectionTest.kt delete mode 100644 src/test/kotlin/tornadofx/testapps/TableViewSortFilterTest.kt delete mode 100644 src/test/kotlin/tornadofx/testapps/TaskStatusTest.kt delete mode 100644 src/test/kotlin/tornadofx/testapps/TodoTestApp.kt delete mode 100644 src/test/kotlin/tornadofx/testapps/ToggleButtonTestApp.kt delete mode 100644 src/test/kotlin/tornadofx/testapps/TransitionsTest.kt delete mode 100644 src/test/kotlin/tornadofx/testapps/ViewDockingApp.kt delete mode 100644 src/test/kotlin/tornadofx/testapps/WizardTestApp.kt delete mode 100644 src/test/kotlin/tornadofx/tests/AsyncTest.kt delete mode 100644 src/test/kotlin/tornadofx/tests/BindingTest.kt delete mode 100644 src/test/kotlin/tornadofx/tests/BuildersTest.kt delete mode 100644 src/test/kotlin/tornadofx/tests/ChildInterceptorTest.kt delete mode 100644 src/test/kotlin/tornadofx/tests/ClipboardTest.kt delete mode 100644 src/test/kotlin/tornadofx/tests/CollectionsTest.kt delete mode 100644 src/test/kotlin/tornadofx/tests/ComponentTest.kt delete mode 100644 src/test/kotlin/tornadofx/tests/ControlsTest.kt delete mode 100644 src/test/kotlin/tornadofx/tests/Customer.kt delete mode 100644 src/test/kotlin/tornadofx/tests/EventBusTest.kt delete mode 100644 src/test/kotlin/tornadofx/tests/FXMLTest.kt delete mode 100644 src/test/kotlin/tornadofx/tests/FormTest.kt delete mode 100644 src/test/kotlin/tornadofx/tests/InternalWindowClosingTest.kt delete mode 100644 src/test/kotlin/tornadofx/tests/JavaPerson.java delete mode 100644 src/test/kotlin/tornadofx/tests/JsonTest.kt delete mode 100644 src/test/kotlin/tornadofx/tests/LayoutsTest.kt delete mode 100644 src/test/kotlin/tornadofx/tests/ListTest.kt delete mode 100644 src/test/kotlin/tornadofx/tests/ListViewFragmentTestView.kt delete mode 100644 src/test/kotlin/tornadofx/tests/MultipleLifecycleAsyncAppTest.kt delete mode 100644 src/test/kotlin/tornadofx/tests/NodeTest.kt delete mode 100644 src/test/kotlin/tornadofx/tests/Person.kt delete mode 100644 src/test/kotlin/tornadofx/tests/PersonPoko.kt delete mode 100644 src/test/kotlin/tornadofx/tests/PreferencesTest.kt delete mode 100644 src/test/kotlin/tornadofx/tests/PropertiesTest.kt delete mode 100644 src/test/kotlin/tornadofx/tests/RestClientTest.kt delete mode 100644 src/test/kotlin/tornadofx/tests/ScopeTest.kt delete mode 100644 src/test/kotlin/tornadofx/tests/SimpleListViewTest.kt delete mode 100644 src/test/kotlin/tornadofx/tests/StylesheetErrorTest.kt delete mode 100644 src/test/kotlin/tornadofx/tests/StylesheetTest.kt delete mode 100644 src/test/kotlin/tornadofx/tests/TableViewTest.kt delete mode 100644 src/test/kotlin/tornadofx/tests/ValidationTest.kt delete mode 100644 src/test/kotlin/tornadofx/tests/VectorMathTest.kt delete mode 100644 src/test/kotlin/tornadofx/tests/ViewDockingTests.kt delete mode 100644 src/test/kotlin/tornadofx/tests/ViewModelTest.kt delete mode 100644 src/test/resources/META-INF/services/tornadofx.ChildInterceptor delete mode 100644 src/test/resources/teststyles.css delete mode 100644 src/test/resources/tornadofx/tests/ComposedForm.fxml delete mode 100644 src/test/resources/tornadofx/tests/ComposedFormList.fxml delete mode 100644 src/test/resources/tornadofx/tests/ComposedFormSearch.fxml delete mode 100644 src/test/resources/tornadofx/tests/FXMLTest.fxml delete mode 100644 src/test/resources/tornadofx/tests/SimpleForm.fxml delete mode 100644 src/test/resources/tornadofx/tests/TornadoKeyboard.json delete mode 100644 src/test/resources/tornadofx/tests/person.png create mode 100644 tornadofx-core/pom.xml rename {src => tornadofx-core/src}/main/java/tornadofx/skin/tablerow/DirtyDecoratingTableRowSkin.java (97%) rename {src => tornadofx-core/src}/main/java/tornadofx/skin/tablerow/ExpandableTableRowSkin.java (97%) rename {src/main/java => tornadofx-core/src/main/kotlin}/sun/net/www/protocol/css/Handler.kt (99%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/Animation.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/App.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/Async.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/AutoCompleteComboBoxSkin.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/Binding.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/CSS.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/Charts.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/ChildInterceptor.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/Collections.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/Commands.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/Component.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/Controls.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/DataGrid.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/Decoration.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/Dialogs.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/Drawer.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/ErrorHandler.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/EventBus.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/EventLog.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/FX.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/Forms.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/InternalWindow.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/ItemControls.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/Json.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/Keyboard.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/LayoutDebugger.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/Layouts.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/Lib.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/ListMenu.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/ListView.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/Menu.kt (79%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/Messages.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/Nodes.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/Properties.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/ReflectionUtils.java (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/Rest.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/Shapes.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/ShutdownExecutor.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/Slideshow.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/SmartResize.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/SqueezeBox.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/StackPane.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/TabPane.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/TableView.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/TreeView.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/Validation.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/VectorMath.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/ViewModel.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/ViewModelFacades.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/Wizard.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/Workspace.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/adapters/TornadoFXColumns.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/adapters/TornadoFXResizeFeatures.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/adapters/TornadoFXTables.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/osgi/ApplicationProvider.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/osgi/ChildInterceptorProvider.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/osgi/OSGIConsole.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/osgi/StylesheetProvider.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/osgi/ViewProvider.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/osgi/impl/Activator.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/osgi/impl/ApplicationListener.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/osgi/impl/CSSURLStreamHandlerService.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/osgi/impl/InterceptorListener.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/osgi/impl/OSGISupport.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/osgi/impl/StylesheetListener.kt (100%) rename {src/main/java => tornadofx-core/src/main/kotlin}/tornadofx/osgi/impl/ViewListener.kt (100%) rename {src => tornadofx-core/src}/main/resources/tornadofx/datagrid.css (100%) rename {src => tornadofx-core/src}/main/resources/tornadofx/form.css (100%) rename {src => tornadofx-core/src}/main/resources/tornadofx/i18n/ViewModel.properties (100%) rename {src => tornadofx-core/src}/main/resources/tornadofx/i18n/ViewModel_de_DE.properties (100%) rename {src => tornadofx-core/src}/main/resources/tornadofx/i18n/ViewModel_es.properties (100%) rename {src => tornadofx-core/src}/main/resources/tornadofx/i18n/ViewModel_nb_NO.properties (100%) rename {src => tornadofx-core/src}/main/resources/tornadofx/i18n/ViewModel_nl_NL.properties (100%) rename {src => tornadofx-core/src}/main/resources/tornadofx/i18n/ViewModel_ru_RU.properties (100%) rename {src => tornadofx-core/src}/main/resources/tornadofx/i18n/Wizard.properties (100%) rename {src => tornadofx-core/src}/main/resources/tornadofx/i18n/Wizard_de_DE.properties (100%) rename {src => tornadofx-core/src}/main/resources/tornadofx/i18n/Wizard_es.properties (100%) rename {src => tornadofx-core/src}/main/resources/tornadofx/i18n/Wizard_nb_NO.properties (100%) rename {src => tornadofx-core/src}/main/resources/tornadofx/i18n/Wizard_nl_NL.properties (100%) rename {src => tornadofx-core/src}/main/resources/tornadofx/i18n/Wizard_ru_RU.properties (100%) rename {src => tornadofx-core/src}/main/resources/tornadofx/listmenu.css (100%) rename {src => tornadofx-core/src}/main/resources/tornadofx/maskpane.css (100%) rename {src => tornadofx-core/src}/main/resources/tornadofx/rowexpanderpane.css (100%) rename {src => tornadofx-core/src}/main/resources/tornadofx/workspace.css (100%) create mode 100644 tornadofx-http/pom.xml create mode 100644 tornadofx-json/pom.xml diff --git a/pom.xml b/pom.xml index bf5bbf3..d2d1563 100644 --- a/pom.xml +++ b/pom.xml @@ -1,32 +1,60 @@ - + + 4.0.0 no.tornado - tornadofx2 - 2.0.0-SNAPSHOT - jar - TornadoFX2 + tornadofx + 2.1.0-SNAPSHOT + pom + + tornadofx JavaFX Framework for Kotlin https://github.com/edvin/tornadofx2 + + tornadofx-core + tornadofx-json + tornadofx-http + + + + + UTF-8 + + + 3.8.0 + 11 + 11 + 3.0.1 + + + 1.3.72 + official + + + 4.12 + + + 13 + + + 1.1.2 + + + 4.5.3 + + + 6.0.1 + + + 3.0.2 + + + 1.4 + + - - org.glassfish - javax.json - ${org.glassfish.javax.json.version} - - - org.apache.httpcomponents - httpclient - ${org.apache.httpcomponents.httpclient.version} - provided - - - org.apache.felix - org.apache.felix.framework - ${org.apache.felix.framework.version} - provided - + org.jetbrains.kotlin kotlin-stdlib-jdk8 @@ -37,41 +65,16 @@ kotlin-reflect ${kotlin.version} - - de.jensd - fontawesomefx-fontawesome - ${de.jensd.fontawesomefx.version} - + + junit junit ${junit.version} test - - org.jetbrains.kotlin - kotlin-test-junit - ${kotlin.version} - test - - - org.testfx - testfx-core - ${org.testfx.testfx-core.version} - test - - - org.testfx - testfx-junit - ${org.testfx.testfx-junit.version} - test - - - org.hamcrest - hamcrest-library - 1.3 - test - + + org.openjfx javafx-controls @@ -84,100 +87,67 @@ org.openjfx - javafx-web + javafx-media ${javafx.version} org.openjfx - javafx-media + javafx-swing ${javafx.version} org.openjfx - javafx-swing + javafx-web ${javafx.version} - - - - sonatype-nexus - Nexus Release Repository - https://oss.sonatype.org/service/local/staging/deploy/maven2/ - - - sonatype-nexus - https://oss.sonatype.org/content/repositories/snapshots - - + + + org.glassfish + javax.json + ${org.glassfish.javax.json.version} + - - SYSE - https://www.syse.no/ - + + + org.apache.httpcomponents + httpclient + ${org.apache.httpcomponents.httpclient.version} + provided + - - - The Apache License, Version 2.0 - https://www.apache.org/licenses/LICENSE-2.0.txt - - + + + org.apache.felix + org.apache.felix.framework + ${org.apache.felix.framework.version} + provided + - - - Edvin Syse - es@syse.no - SYSE AS - https://www.syse.no - - - Thomas Nield - thomasnield@live.com - Southwest Airlines - https://www.southwest.com/ - - - Matthew Turnblom - uberawesomeemailaddressofdoom@gmail.com - Xactware - https://www.xactware.com/ - - - Craig Tadlock - craig.tadlock@gototags.com - GoToTags - https://gototags.com/ - - + + + org.jetbrains.kotlin + kotlin-test-junit + ${kotlin.version} + test + - - scm:git:git@github.com:edvin/tornadofx2.git - scm:git:git@github.com:edvin/tornadofx2.git - git@github.com:edvin/tornadofx2.git - + - - ${project.basedir}/src/test/kotlin - - - - - org.apache.maven.plugins - maven-release-plugin - ${maven.release.version} - - forked-path - false - -Psonatype-oss-release - - - - + + + jcenter + JCenter + https://jcenter.bintray.com/ + + + + - kotlin-maven-plugin org.jetbrains.kotlin + kotlin-maven-plugin ${kotlin.version} 1.8 @@ -185,19 +155,34 @@ compile - process-sources + compile compile + + + ${project.basedir}/src/main/kotlin + ${project.basedir}/src/main/java + + test-compile + test-compile test-compile + + + ${project.basedir}/src/test/kotlin + ${project.basedir}/src/test/java + + + + maven-compiler-plugin ${maven.compiler.version} @@ -207,73 +192,38 @@ 11 UTF-8 - - - org.jetbrains.dokka - dokka-maven-plugin - ${dokka.version} + - pre-site - - javadocJar - + default-compile + none + + + + default-testCompile + none - - - false - true - 8 - - JVM - - true - true - - - - org.apache.maven.plugins - maven-source-plugin - ${maven.source.version} - + java-compile compile - - aggregate - jar - + compile + + + java-test-compile + test-compile + testCompile + + + org.apache.maven.plugins maven-jar-plugin ${maven.jar.version} - - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - - - - - org.apache.felix - maven-bundle-plugin - ${maven.bundle.version} - - - bundle-manifest - process-classes - - manifest - - - - - - tornadofx.osgi.impl.Activator - no.tornado.tornadofx - - + + org.apache.maven.plugins maven-gpg-plugin @@ -288,56 +238,48 @@ - - org.apache.maven.plugins - maven-surefire-plugin - ${maven.surefire.version} - - - --add-exports javafx.graphics/com.sun.javafx.application=ALL-UNNAMED - --add-exports tornadofx/tornadofx.tests=kotlin.reflect - --add-opens tornadofx/tornadofx.tests=javafx.base - --add-reads tornadofx=jdk.httpserver - - - + - - - - jcenter - JCenter - https://jcenter.bintray.com/ - - - - 13 - 1.3.61 - 0.10.0 + + + The Apache License, Version 2.0 + https://www.apache.org/licenses/LICENSE-2.0.txt + + - 1.1.2 - 4.5.3 - 6.0.1 - 4.12 - 4.0.15-alpha - 4.0.15-alpha - 4.7.0-9.1.2 + + + Edvin Syse + es@syse.no + SYSE AS + https://www.syse.no + + + Craig Tadlock + craig.tadlock@gototags.com + GoToTags + https://gototags.com + + - 2.1 - 3.8.0 - 3.0.1 - 3.0.2 - 3.5.1 - 1.4 - 3.0.0-M3 + + scm:git:git@github.com:edvin/tornadofx2.git + scm:git:git@github.com:edvin/tornadofx2.git + git@github.com:edvin/tornadofx2.git + - UTF-8 - 11 - 11 - - \ No newline at end of file + + + sonatype-nexus + Nexus Release Repository + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + + + sonatype-nexus + https://oss.sonatype.org/content/repositories/snapshots + + + + diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java deleted file mode 100644 index ef03604..0000000 --- a/src/main/java/module-info.java +++ /dev/null @@ -1,28 +0,0 @@ -import tornadofx.ChildInterceptor; -import tornadofx.Stylesheet; - -module tornadofx { - requires transitive javafx.controls; - requires javafx.fxml; - requires javafx.swing; - requires javafx.web; - requires javafx.media; - - requires kotlin.stdlib; - requires kotlin.reflect; - - requires static httpcore; - requires static httpclient; - requires static org.apache.felix.framework; - - requires transitive java.json; - requires transitive java.prefs; - requires transitive java.logging; - - opens tornadofx to javafx.fxml; - - exports tornadofx; - - uses ChildInterceptor; - uses Stylesheet; -} \ No newline at end of file diff --git a/src/test/kotlin/tornadofx/testapps/AccelTest.kt b/src/test/kotlin/tornadofx/testapps/AccelTest.kt deleted file mode 100644 index b281ac4..0000000 --- a/src/test/kotlin/tornadofx/testapps/AccelTest.kt +++ /dev/null @@ -1,24 +0,0 @@ -package tornadofx.testapps - -import javafx.scene.control.Alert -import javafx.scene.input.KeyCode -import javafx.scene.input.KeyCodeCombination -import javafx.scene.input.KeyCombination -import tornadofx.* - -class AccelTestApp : App(AccelTest::class) - -class AccelTest : View() { - override val root = stackpane { - add() - } -} - -class AccelView : View() { - override val root = button("Click me") { - shortcut(KeyCodeCombination(KeyCode.A, KeyCombination.SHORTCUT_ANY, KeyCombination.SHIFT_ANY)) - action { - alert(Alert.AlertType.INFORMATION, "Fire!", "You clicked.") - } - } -} \ No newline at end of file diff --git a/src/test/kotlin/tornadofx/testapps/AnimationHelperTest.kt b/src/test/kotlin/tornadofx/testapps/AnimationHelperTest.kt deleted file mode 100644 index 15b9532..0000000 --- a/src/test/kotlin/tornadofx/testapps/AnimationHelperTest.kt +++ /dev/null @@ -1,46 +0,0 @@ -package tornadofx.testapps - -import javafx.animation.Animation -import javafx.animation.Interpolator -import javafx.scene.paint.Color -import tornadofx.* - -class ShapeTransitionTest : App(Main::class) { - class Main : View("Shape Transition Test") { - var switch = true - val nextFill get() = if (switch) c(1.0, 0.0, 0.0) else c(0.0, 0.0, 1.0) - val nextStroke get() = if (switch) c(0.0, 0.0, 1.0) else c(1.0, 0.0, 0.0) - override val root = stackpane { - background = Color.BLACK.asBackground() - val round = circle(radius = 100.0) { - fill = nextFill - stroke = nextStroke - switch = !switch - strokeWidth = 20.0 - } - val orbit = circle(0.0, 0.0, 10.0) { - animateFill(0.33.seconds, Color.ORANGE, Color.YELLOW) { - isAutoReverse = true - cycleCount = Animation.INDEFINITE - } - }.follow(3.seconds, round, Interpolator.LINEAR) { cycleCount = Animation.INDEFINITE } - button("Click Me") { - action { - isDisable = true - val startFill = round.fill as? Color ?: Color.BLACK - val endFill = nextFill - val startStroke = round.stroke as? Color ?: Color.BLACK - val endStroke = nextStroke - switch = !switch - listOf( - pause(0.75.seconds, play = false) { setOnFinished { orbit.rate = -orbit.rate } }, - listOf( - round.animateFill(0.25.seconds, startFill, endFill, play = false), - round.animateStroke(0.25.seconds, startStroke, endStroke, play = false) - ).playParallel(false) - ).playSequential { setOnFinished { isDisable = false } } - } - } - } - } -} diff --git a/src/test/kotlin/tornadofx/testapps/AsyncProgressApp.kt b/src/test/kotlin/tornadofx/testapps/AsyncProgressApp.kt deleted file mode 100644 index 1e03b61..0000000 --- a/src/test/kotlin/tornadofx/testapps/AsyncProgressApp.kt +++ /dev/null @@ -1,61 +0,0 @@ -package tornadofx.testapps - -import javafx.scene.paint.Color -import javafx.scene.text.FontWeight -import tornadofx.* - -class AsyncProgressApp : App(AsyncProgressView::class) - -class AsyncProgressView : View("Async Progress") { - override val root = borderpane { - setPrefSize(400.0, 300.0) - - center { - button("Start") { - action { - runAsync { - updateTitle("Doing some work") - for (i in 1..10) { - updateMessage("Working $i...") - if (i == 5) - updateTitle("Dome something else") - Thread.sleep(200) - updateProgress(i.toLong(), 10) - } - } - } - } - } - bottom { - add() - } - } -} - -class ProgressView : View() { - val status: TaskStatus by inject() - - override val root = vbox(4) { - visibleWhen { status.running } - style { borderColor += box(Color.LIGHTGREY, Color.TRANSPARENT, Color.TRANSPARENT, Color.TRANSPARENT) } - label(status.title).style { fontWeight = FontWeight.BOLD } - hbox(4) { - label(status.message) - progressbar(status.progress) - visibleWhen { status.running } - } - } -} - -class AsyncProgressButtonView : View() { - override val root = stackpane { - setPrefSize(400.0, 400.0) - button("Click me") { - action { - runAsyncWithProgress { - Thread.sleep(2000) - } - } - } - } -} \ No newline at end of file diff --git a/src/test/kotlin/tornadofx/testapps/AwaitUntilTest.kt b/src/test/kotlin/tornadofx/testapps/AwaitUntilTest.kt deleted file mode 100644 index 27739ef..0000000 --- a/src/test/kotlin/tornadofx/testapps/AwaitUntilTest.kt +++ /dev/null @@ -1,42 +0,0 @@ -package tornadofx.testapps - -import javafx.beans.property.SimpleBooleanProperty -import javafx.beans.property.SimpleObjectProperty -import javafx.beans.property.SimpleStringProperty -import javafx.util.converter.IntegerStringConverter -import tornadofx.* -import java.time.LocalDateTime - -class AwaitUntilTest : View("Await Until Test") { - val number = SimpleObjectProperty() - val flag = SimpleBooleanProperty(false) - val output = SimpleStringProperty("") - - override val root = borderpane { - top { - toolbar { - label("Number:") - textfield(number, IntegerStringConverter()) - button("Wait until 42").action { - number.awaitUntil { it == 42 } - output.value += "Number is now 42\n" - } - button("Wait until true").action { - runLater(2.seconds) { - flag.set(true) - } - flag.awaitUntil() - output.value += "Flag is true\n" - } - button("Look alive").action { - output.value += "Alive at ${LocalDateTime.now()}\n" - } - } - } - center { - textarea(output) - } - } -} - -class AwaitUntilApp : App(AwaitUntilTest::class) diff --git a/src/test/kotlin/tornadofx/testapps/BorderPaneTest.kt b/src/test/kotlin/tornadofx/testapps/BorderPaneTest.kt deleted file mode 100644 index 22fbd7e..0000000 --- a/src/test/kotlin/tornadofx/testapps/BorderPaneTest.kt +++ /dev/null @@ -1,18 +0,0 @@ -package tornadofx.testapps - -import tornadofx.* - -class BorderPaneTestApp : App(BorderPaneTest::class) - -class BorderPaneTest : View("Border Pane Builder Test") { - override val root = borderpane { - // Direct access - top = label("Top") - // Builder target - center { - hbox { - label("Center") - } - } - } -} \ No newline at end of file diff --git a/src/test/kotlin/tornadofx/testapps/BrokenLineTest.kt b/src/test/kotlin/tornadofx/testapps/BrokenLineTest.kt deleted file mode 100644 index 47ac62e..0000000 --- a/src/test/kotlin/tornadofx/testapps/BrokenLineTest.kt +++ /dev/null @@ -1,62 +0,0 @@ -package tornadofx.testapps - -import javafx.scene.layout.BorderStrokeStyle -import javafx.scene.shape.StrokeLineCap -import javafx.scene.shape.StrokeLineJoin -import javafx.scene.shape.StrokeType -import tornadofx.* - -class BrokenLineApp : App(BrokenLineView::class, BrokenStyles::class) -class BrokenLineView : View("Broken Line Test") { - override val root = stackpane { - line { - addClass(BrokenStyles.blue) - endXProperty().bind(this@stackpane.widthProperty()) - endYProperty().bind(this@stackpane.heightProperty()) - } - line { - addClass(BrokenStyles.blue) - endXProperty().bind(this@stackpane.widthProperty()) - startYProperty().bind(this@stackpane.heightProperty()) - } - label("This is a label with a border").addClass(BrokenStyles.red) - } -} - -class BrokenStyles : Stylesheet() { - companion object { - val red by cssclass() - val blue by cssclass() - } - - init { - root { - padding = box(25.px) - backgroundColor += c("white") - } - red { - val radius = box(50.px) - backgroundColor += c("white", 0.9) - backgroundRadius += radius - borderColor += box(c("red")) - borderWidth += box(5.px) - borderRadius += radius - borderStyle += BorderStrokeStyle( - StrokeType.CENTERED, - StrokeLineJoin.MITER, - StrokeLineCap.SQUARE, - 10.0, - 0.0, - listOf(5.0, 15.0, 0.0, 15.0) - ) - padding = box(50.px) - } - blue { - stroke = c("dodgerblue") - strokeWidth = 5.px - strokeType = StrokeType.CENTERED - strokeLineCap = StrokeLineCap.SQUARE - strokeDashArray = listOf(25.px, 15.px, 0.px, 15.px) - } - } -} \ No newline at end of file diff --git a/src/test/kotlin/tornadofx/testapps/BuilderWindowTest.kt b/src/test/kotlin/tornadofx/testapps/BuilderWindowTest.kt deleted file mode 100644 index 28ced08..0000000 --- a/src/test/kotlin/tornadofx/testapps/BuilderWindowTest.kt +++ /dev/null @@ -1,63 +0,0 @@ -package tornadofx.testapps - -import javafx.application.Platform -import javafx.scene.paint.Color -import javafx.scene.text.FontWeight -import javafx.stage.StageStyle.DECORATED -import javafx.stage.StageStyle.UNDECORATED -import tornadofx.* - -class BuilderWindowTestApp : App(DangerButtonView::class) - -class DangerButtonView : View("Do not click the button!") { - override val root = stackpane { - setPrefSize(400.0, 150.0) - hbox { - button("Don't click me") { - style { - fontSize = 20.px - fontWeight = FontWeight.BOLD - textFill = Color.RED - } - action { - builderWindow("What do you want?", stageStyle = UNDECORATED, owner = primaryStage) { - vbox(10) { - style { - padding = box(20.px) - borderColor += box(Color.ORANGE) - borderWidth += box(2.px) - } - - label("So, you clicked it anyway.. What do you want?") { - style { - fontWeight = FontWeight.BOLD - } - } - - hbox(10) { - button("Tell them you clicked").action { - this@DangerButtonView.title = "It's not dangerous to click the button :)" - close() - } - button("Close app").action { - Platform.exit() - } - button("Cancel").action { - close() - } - } - } - } - } - } - button("the same in internalWindow").action { - openInternalBuilderWindow("Internal window", modal = true, overlayPaint = Color.DARKRED) { - vbox(20) { - label("opened in an internalwindow") - button("close").action { close() } - } - } - } - } - } -} \ No newline at end of file diff --git a/src/test/kotlin/tornadofx/testapps/ChartTestApp.kt b/src/test/kotlin/tornadofx/testapps/ChartTestApp.kt deleted file mode 100644 index 602d21d..0000000 --- a/src/test/kotlin/tornadofx/testapps/ChartTestApp.kt +++ /dev/null @@ -1,33 +0,0 @@ -package tornadofx.testapps - -import javafx.scene.chart.CategoryAxis -import javafx.scene.chart.NumberAxis -import javafx.scene.paint.Color -import tornadofx.* - -class BarChartTestApp : App(BarChartTest::class, BarChartStyles::class) - -class BarChartTest : View() { - override val root = barchart("Stock Monitoring, 2010", CategoryAxis(), NumberAxis()) { - series("Portfolio 1") { - data("Jan", 23) - data("Feb", 14) - data("Mar", 15) - } - series("Portfolio 2") { - data("Jan", 11) - data("Feb", 19) - data("Mar", 27) - } - } -} - -class BarChartStyles : Stylesheet() { - val chartBar by cssclass() - - init { - defaultColor0 and chartBar { - barFill = Color.VIOLET - } - } -} \ No newline at end of file diff --git a/src/test/kotlin/tornadofx/testapps/ComboBoxTest.kt b/src/test/kotlin/tornadofx/testapps/ComboBoxTest.kt deleted file mode 100644 index e0c1ee5..0000000 --- a/src/test/kotlin/tornadofx/testapps/ComboBoxTest.kt +++ /dev/null @@ -1,196 +0,0 @@ -package tornadofx.testapps - -import javafx.beans.property.SimpleObjectProperty -import javafx.beans.property.SimpleStringProperty -import javafx.util.StringConverter -import tornadofx.* -import java.util.* - -class ComboBoxTestApp : App(ComboboxTest::class) - -class ComboboxTest : View("Combobox test") { - val items = listOf("Item 1", "Item 2", "Item 3") - val selectedItem = SimpleStringProperty(items.first()) - - override val root = stackpane { - setPrefSize(400.0, 400.0) - combobox(selectedItem, items) { - cellFormat { - text = it - } - } - } -} - -class AutoCompleteComboBoxExtensionTestApp : App(AutoCompleteComboBoxExtensionTest::class) - -class AutoCompleteComboBoxExtensionTest : View("AutoComplete comboBox extension test") { - val itemsGlobalObject = Locale.getISOCountries().map { Locale("", it) } - val itemsGlobal = itemsGlobalObject.mapEach { displayCountry } - val selectedItem = SimpleStringProperty(itemsGlobal.first()) - val selectedItem2 = SimpleStringProperty(itemsGlobal.first()) - val selectedItem3 = SimpleStringProperty(itemsGlobal.first()) - val selectedItemObject = SimpleObjectProperty(itemsGlobalObject.first()) - val selectedItemObject2 = SimpleObjectProperty(itemsGlobalObject.first()) - val selectedItemObject3 = SimpleObjectProperty(itemsGlobalObject.first()) - - val selectedItemE = SimpleStringProperty(itemsGlobal.first()) - val selectedItem2E = SimpleStringProperty(itemsGlobal.first()) - val selectedItemObjectE = SimpleObjectProperty(itemsGlobalObject.first()) - val selectedItemObject2E = SimpleObjectProperty(itemsGlobalObject.first()) - val selectedItemObject3E = SimpleObjectProperty(itemsGlobalObject.first()) - - override val root = form { - setPrefSize(400.0, 400.0) - fieldset { - field("Default") { - combobox(selectedItem, itemsGlobal) { - makeAutocompletable() - } - textfield(selectedItem) - useMaxSize = true - } - /** - * Example using automatic popup width - */ - field("With automatic popup width") { - combobox(selectedItem2, itemsGlobal) { - makeAutocompletable(automaticPopupWidth = true) - } - textfield(selectedItem2) - useMaxSize = true - } - /** - * Example using custom filter using startswith instead of contains - */ - field("With custom Filter") { - combobox(selectedItem3, itemsGlobal) { - makeAutocompletable { - itemsGlobal.filter { current -> converter.toString(current).startsWith(it, true) } - } - } - textfield(selectedItem3) - useMaxSize = true - } - /** - * Example using converter - */ - field("Default with custom converter") { - combobox(selectedItemObject, itemsGlobalObject) { - converter = LocaleStringConverter() - makeAutocompletable() - } - label(selectedItemObject) - useMaxSize = true - } - /** - * Example using converter and custom filter - */ - field("With custom converter and filter") { - combobox(selectedItemObject2, itemsGlobalObject) { - converter = LocaleStringConverter() - makeAutocompletable { - itemsGlobalObject.asObservable().filtered { current -> current.displayCountry.contains(it, true) || current.isO3Country.contains(it, true) || current.country.contains(it, true) } - } - } - label(selectedItemObject2) - useMaxSize = true - } - /** - * Example using custom cell factory - */ - field("With custom cell factory") { - combobox(selectedItemObject3, itemsGlobalObject) { - converter = LocaleStringConverter() - cellFormat { - text = "Locale: " + converter.toString(it) - } - makeAutocompletable { - itemsGlobalObject.asObservable().filtered { current -> current.displayCountry.contains(it, true) || current.isO3Country.contains(it, true) || current.country.contains(it, true) } - } - } - label(selectedItemObject3) - } - field("Editable Default") { - combobox(selectedItemE, itemsGlobal) { - val tmpValue = value - isEditable = true - value = tmpValue - makeAutocompletable() - } - textfield(selectedItemE) - } - /** - * Example using custom filter using startswith instead of contains - */ - field("Editable With custom Filter") { - combobox(selectedItem2E, itemsGlobal) { - val tmpValue = value - isEditable = true - value = tmpValue - makeAutocompletable { - itemsGlobal.filter { current -> converter.toString(current).startsWith(it, true) } - } - } - textfield(selectedItem2E) - } - /** - * Example using converter - */ - field("Editable Default with custom converter") { - combobox(selectedItemObjectE, itemsGlobalObject) { - val tmpValue = value - isEditable = true - value = tmpValue - converter = LocaleStringConverter() - makeAutocompletable() - } - label(selectedItemObjectE) - } - /** - * Example using converter and custom filter - */ - field("Editable With custom converter and filter") { - combobox(selectedItemObject2E, itemsGlobalObject) { - val tmpValue = value - isEditable = true - value = tmpValue - converter = LocaleStringConverter() - makeAutocompletable { - itemsGlobalObject.asObservable().filtered { current -> current.displayCountry.contains(it, true) || current.isO3Country.contains(it, true) || current.country.contains(it, true) } - } - } - label(selectedItemObject2E) - } - /** - * Example using custom cell factory - */ - field("Editable With custom cell factory") { - combobox(selectedItemObject3E, itemsGlobalObject) { - val tmpValue = value - isEditable = true - value = tmpValue - converter = LocaleStringConverter() - cellFormat { - text = "Locale: " + converter.toString(it) - } - makeAutocompletable { - itemsGlobalObject.asObservable().filtered { current -> current.displayCountry.contains(it, true) || current.isO3Country.contains(it, true) || current.country.contains(it, true) } - } - } - label(selectedItemObject3E) - } - } - } -} - -class LocaleStringConverter : StringConverter() { - val mapLocale = mutableMapOf() - override fun fromString(string: String?): Locale? = string?.let { mapLocale[it] } - - override fun toString(locale: Locale?): String? { - val output = locale?.displayCountry + ", " + locale?.isO3Country - if (locale != null && !mapLocale.containsKey(output)) mapLocale[output] = locale - return output - } -} diff --git a/src/test/kotlin/tornadofx/testapps/CommandTest.kt b/src/test/kotlin/tornadofx/testapps/CommandTest.kt deleted file mode 100644 index 74e49b1..0000000 --- a/src/test/kotlin/tornadofx/testapps/CommandTest.kt +++ /dev/null @@ -1,102 +0,0 @@ -package tornadofx.testapps - -import javafx.beans.property.SimpleDoubleProperty -import javafx.beans.property.SimpleIntegerProperty -import javafx.beans.property.SimpleStringProperty -import javafx.geometry.Pos -import javafx.scene.control.Alert -import javafx.scene.control.Alert.AlertType.INFORMATION -import tornadofx.* - -class CommandTestApp : App(CommandTest::class) - -class CommandTest : View("Command test") { - val ctrl: CommandController by inject() - val nameProperty = SimpleStringProperty() - val numberProperty = SimpleDoubleProperty() - - override val root = borderpane { - top { - menubar { - menu("Talk") { - item("Say hello").command = ctrl.helloCommand - customitem { - vbox { - text("I'm custom!") - } - action { - println("Custom item clicked!") - } - } - } - } - } - center { - vbox(20) { - minWidth = 600.0 - paddingAll = 50 - - hbox(10) { - alignment = Pos.CENTER - label("Name:") - textfield(nameProperty) - - button("Say hello") { - command = ctrl.helloCommand with nameProperty - } - - button("Call action off of UI thread").action { - runAsync { - ctrl.helloCommand.execute("Some Name") - } - } - } - hbox(10) { - alignment = Pos.CENTER - label("Enter number:") - textfield(numberProperty) - hyperlink("Calculate square root") { - command = ctrl.squareRootCommand with numberProperty - } - label("Square root:") - label(ctrl.squareRootResult) - } - vbox(10) { - alignment = Pos.CENTER - button("Download file") { - command = ctrl.downloadCommand - } - progressbar(ctrl.downloadProgress) { - visibleWhen { progressProperty().greaterThan(0) } - } - } - } - } - } -} - -class CommandController : Controller() { - val helloCommand = command(this::hello, ui = true, nullable = true) - val squareRootCommand = command(this::squareRoot) - val downloadCommand = command(this::download, async = true) - - val squareRootResult = SimpleIntegerProperty() - val downloadProgress = SimpleDoubleProperty() - - private fun hello(name: String?) { - Alert(INFORMATION, "Hello, ${name ?: "there"}").showAndWait() - } - - private fun squareRoot(value: Double) { - squareRootResult.value = Math.sqrt(value).toInt() - } - - private fun download() { - for (i in 1..100) { - downloadProgress.value = i / 100.0 - Thread.sleep(50) - } - Thread.sleep(1000) - downloadProgress.value = 0.0 - } -} diff --git a/src/test/kotlin/tornadofx/testapps/DataGridTest.kt b/src/test/kotlin/tornadofx/testapps/DataGridTest.kt deleted file mode 100644 index 6cd45a1..0000000 --- a/src/test/kotlin/tornadofx/testapps/DataGridTest.kt +++ /dev/null @@ -1,91 +0,0 @@ -package tornadofx.testapps - -import javafx.collections.FXCollections -import javafx.scene.Parent -import javafx.scene.control.SelectionMode -import tornadofx.* -import tornadofx.testapps.DataGridTestApp.Companion.images - -class DataGridTestApp : App(DataGridTest::class, DataGridStyles::class) { - companion object { - val images = mapOf( - "kittens" to listOf( - "http://i.imgur.com/DuFZ6PQb.jpg", - "http://i.imgur.com/o2QoeNnb.jpg", - "http://i.imgur.com/P8wpBvub.jpg", - "http://i.imgur.com/a2NDDglb.jpg", - "http://i.imgur.com/79C37Scb.jpg", - "http://i.imgur.com/N0fPCU2b.jpg", - "http://i.imgur.com/qRfWC9wb.jpg", - "http://i.imgur.com/i3crLYcb.jpg"), - - "puppies" to listOf( - "http://i.imgur.com/37hCL2Pb.jpg", - "http://i.imgur.com/v9vBE67b.jpg", - "http://i.imgur.com/koQoEExb.jpg", - "http://i.imgur.com/qRfWC9wb.jpg", - "http://i.imgur.com/ftDV8oJb.jpg") - - ) - } -} - -class DataGridTest : View("DataGrid") { - var datagrid: DataGrid by singleAssign() - val list = FXCollections.observableArrayList() - var paginator = DataGridPaginator(list, itemsPerPage = 5) - - override val root = borderpane { - left { - vbox { - combobox(values = images.keys.toList()) { - promptText = "Select images" - valueProperty().onChange { - list.setAll(images[it]) - } - shortcut("k") { value = "kittens" } - shortcut("p") { value = "puppies" } - } - button("Add").action { - list.add("http://i.imgur.com/bvqTBT0b.jpg") - } - } - } - center { - datagrid = datagrid(paginator.items) { - setPrefSize(550.0, 550.0) - - selectionModel.selectionMode = SelectionMode.SINGLE - cellWidth = 164.0 - cellHeight = 164.0 - - cellCache { - imageview(it, true) - } - - onUserSelect(1) { - println("Selected $it") - } - } - } - bottom { - vbox { - add(paginator) - hbox { - label(stringBinding(datagrid.selectionModel.selectedItems) { joinToString(", ") }) - button("Remove from index 2").action { - if (list.size > 2) list.removeAt(2) - } - } - } - } - } -} - -class DataGridStyles : Stylesheet() { - init { - datagridCell and selected { - opacity = 0.7 - } - } -} \ No newline at end of file diff --git a/src/test/kotlin/tornadofx/testapps/DrawerTest.kt b/src/test/kotlin/tornadofx/testapps/DrawerTest.kt deleted file mode 100644 index edcbb8d..0000000 --- a/src/test/kotlin/tornadofx/testapps/DrawerTest.kt +++ /dev/null @@ -1,122 +0,0 @@ -package tornadofx.testapps - -import javafx.beans.property.SimpleStringProperty -import javafx.scene.paint.Color -import tornadofx.* - -class DrawerTestApp : App(DrawerWorkspace::class) { - override fun onBeforeShow(view: UIComponent) { - workspace.root.setPrefSize(600.0, 400.0) - workspace.dock() - } -} - -class JustAView : View("Just A View") { - override val root = vbox { - label("I'm just a view - I do nothing") - button("Load another View").action { - workspace.dock() - } - } -} - -class AnotherView : View("Another") { - override val root = stackpane { - label(title) - } -} - -class YetAnotherView : View("Yet Another") { - override val root = stackpane { - label(title) - } -} - -class TestDrawerContributor : View("Test View with dynamic drawer item") { - override val root = stackpane { - vbox { - label("I add something to the drawer when I'm docked") - button("Load another View").action { - workspace.dock() - } - button("Load yet another View").action { - workspace.dock() - } - } - } - - override fun onDock() { - workspace.leftDrawer.item("Temp Drawer") { - stackpane { - label("I'm only guest starring!") - } - } - } -} - -class DrawerWorkspace : Workspace("Drawer Workspace", Workspace.NavigationMode.Stack) { - init { - menubar { - menu("Options") { - checkmenuitem("Toggle Navigation Mode").action { - navigationMode = if (navigationMode == NavigationMode.Stack) NavigationMode.Tabs else NavigationMode.Stack - } - } - } - with(bottomDrawer) { - item("Console") { - style { - backgroundColor += Color.BLACK - } - label("""Connected to the target VM, address: '127.0.0.1:64653', transport: 'socket' -Disconnected from the target VM, address: '127.0.0.1:64653', transport: 'socket' - -Process finished with exit code 0 -""") { - style { - backgroundColor += Color.BLACK - textFill = Color.LIGHTGREY - fontFamily = "Consolas" - } - } - } - - item("Events") { - - } - } - with(leftDrawer) { - item() - item("Form item") { - form { - fieldset("Customer Details") { - field("Name") { textfield() } - field("Password") { textfield() } - } - } - } - item("SqueezeBox Item", showHeader = false) { - squeezebox(multiselect = false, fillHeight = true) { - fold("Customer Editor") { - form { - fieldset("Customer Details") { - field("Name") { textfield() } - field("Password") { textfield() } - } - } - } - fold("Some other editor") { - stackpane { - label("Nothing here") - } - } - fold("A Table") { - tableview(observableListOf("One", "Two", "Three")) { - column("Value") { SimpleStringProperty(it.value) } - } - } - } - } - } - } -} \ No newline at end of file diff --git a/src/test/kotlin/tornadofx/testapps/EventBusTest.kt b/src/test/kotlin/tornadofx/testapps/EventBusTest.kt deleted file mode 100644 index 9f961a1..0000000 --- a/src/test/kotlin/tornadofx/testapps/EventBusTest.kt +++ /dev/null @@ -1,80 +0,0 @@ -package tornadofx.testapps - -import javafx.beans.property.SimpleObjectProperty -import javafx.beans.property.SimpleStringProperty -import tornadofx.* -import tornadofx.EventBus.RunOn.BackgroundThread -import java.time.LocalDateTime -import kotlin.concurrent.timer - -class EventBusTestApp : App(EventBusTestView::class) { - init { - find() - } -} - -class MyDataEvent(val data: List) : FXEvent() -object GiveMeData : FXEvent(BackgroundThread) - -data class MyEvent(val text: String) : FXEvent() - -class EventBusTestView : View("Data Event Table") { - val labelText = SimpleStringProperty("") - val regProperty = SimpleObjectProperty() - var reg by regProperty - - - override val root = borderpane { - top { - hbox(10) { - button("Load data").action { - fire(GiveMeData) - } - button("Subscribe label") { - setOnAction { - reg = subscribe { - labelText.value = it.text - } - } - enableWhen { regProperty.isNull } - } - button("Unsubscribe label") { - setOnAction { - reg!!.unsubscribe() - reg = null - } - enableWhen { regProperty.isNotNull } - } - } - } - center { - tableview { - column("Value", String::class) { - value { it.value } - } - subscribe { - items.setAll(it.data) - selectionModel.select(0) - requestFocus() - } - } - } - bottom { - label(labelText) - } - } - - init { - timer(daemon = true, period = 1000) { - fire(MyEvent(LocalDateTime.now().toString())) - } - } -} - -class MyController : Controller() { - init { - subscribe { - fire(MyDataEvent(listOf("Simulate", "Data", "Loaded", "From", "The", "Database"))) - } - } -} \ No newline at end of file diff --git a/src/test/kotlin/tornadofx/testapps/ExpandableTableTest.kt b/src/test/kotlin/tornadofx/testapps/ExpandableTableTest.kt deleted file mode 100644 index 17ce4ba..0000000 --- a/src/test/kotlin/tornadofx/testapps/ExpandableTableTest.kt +++ /dev/null @@ -1,70 +0,0 @@ -package tornadofx.testapps - -import javafx.collections.ObservableList -import javafx.scene.layout.Background.EMPTY -import tornadofx.* -import java.time.LocalDate -import kotlin.random.Random - -class ExpandableTableTest : View("Smart Resize Demo") { - class Room(val id: Int, val number: String, val type: String, val bed: String, val occupancy: ObservableList) - class Occupancy(val id: Int, val date: LocalDate, val customer: Int) - - val rooms = observableListOf( - Room(1, "104", "Bedroom", "Queen", makeOccupancy(5)), - Room(2, "105", "Bedroom", "King", makeOccupancy(5)), - Room(3, "106", "Bedroom", "King", makeOccupancy(5)), - Room(4, "107", "Suite", "Queen", makeOccupancy(5)), - Room(4, "108", "Bedroom", "King", makeOccupancy(5)), - Room(4, "109", "Conference Room", "Queen", makeOccupancy(5)), - Room(4, "110", "Bedroom", "Queen", makeOccupancy(5)), - Room(4, "111", "Playroom", "King", makeOccupancy(5)), - Room(4, "112", "Bedroom", "Queen", makeOccupancy(5)) - ) - - override val root = tableview(rooms) { - prefWidth = 600.0 - - readonlyColumn("#", Room::id).contentWidth(10.0, true, true) - readonlyColumn("Number", Room::number).weightedWidth(1.0) - readonlyColumn("Bed", Room::bed).apply { - weightedWidth(2.0) - cellFormat { - graphic = cache { - textfield(itemProperty()) { - isEditable = false - paddingAll = 0 - background = EMPTY - } - } - } - } - readonlyColumn("Type", Room::type).weightedWidth(2.0) - - smartResize() - - rowExpander { - tableview(it.occupancy) { - readonlyColumn("Occupancy", Occupancy::id) - readonlyColumn("Date", Occupancy::date) - readonlyColumn("Customer", Occupancy::customer) - prefHeight = 100.0 - } - } - } - - init { - runAsync { - Thread.sleep(5000) - } ui { - root.items.add(Room(4, "113", "Suite", "King size long description", makeOccupancy(5))) - SmartResize.POLICY.requestResize(root) - } - } - -} - - -private fun makeOccupancy(count: Int) = (0..count).map { - ExpandableTableTest.Occupancy(Random.nextInt(100), LocalDate.now().minusDays(it.toLong()), Random.nextInt(100000)) -}.asObservable() diff --git a/src/test/kotlin/tornadofx/testapps/ExternalStylesheetTest.kt b/src/test/kotlin/tornadofx/testapps/ExternalStylesheetTest.kt deleted file mode 100644 index 521d2e7..0000000 --- a/src/test/kotlin/tornadofx/testapps/ExternalStylesheetTest.kt +++ /dev/null @@ -1,16 +0,0 @@ -package tornadofx.testapps - -import javafx.scene.text.FontWeight -import javafx.stage.Stage -import tornadofx.* - -class ExternalStylesheetTestApp : App(ExternalStylesheetTestView::class) { - override fun start(stage: Stage) { - importStylesheet("https://raw.githubusercontent.com/edvin/tornadofx/master/src/test/resources/teststyles.css") - super.start(stage) - } -} - -class ExternalStylesheetTestView: View("External Stylesheet") { - override val root = label(title).addClass("testclass") -} \ No newline at end of file diff --git a/src/test/kotlin/tornadofx/testapps/FormTest.kt b/src/test/kotlin/tornadofx/testapps/FormTest.kt deleted file mode 100644 index b0e9f77..0000000 --- a/src/test/kotlin/tornadofx/testapps/FormTest.kt +++ /dev/null @@ -1,30 +0,0 @@ -package tornadofx.testapps - -import javafx.geometry.Orientation -import tornadofx.* - -class FormApp : App(FormView::class) - -class FormView : View("My Form") { - override val root = form { - fieldset(title) { - field("Name") { - textfield() - } - field("Date Of _Birth") { - textfield { - mnemonicTarget() - } - } - field("Height") { - textfield() - } - field("Weight") { - textfield() - } - buttonbar { - button("Save") - } - } - } -} \ No newline at end of file diff --git a/src/test/kotlin/tornadofx/testapps/GotoViewApp.kt b/src/test/kotlin/tornadofx/testapps/GotoViewApp.kt deleted file mode 100644 index 9b00107..0000000 --- a/src/test/kotlin/tornadofx/testapps/GotoViewApp.kt +++ /dev/null @@ -1,52 +0,0 @@ -package tornadofx.testapps - -import tornadofx.* - -class SwitchViewApp : App(ContainerView::class) - -class ContainerView : View("ContainerView") { - val subView1: SubView1 by inject() - val subView2: SubView2 by inject() - - override val root = borderpane { - top { - hbox(10) { - button("Switch view").action { - if (center.lookup("#view1") != null) - subView1.replaceWith(subView2, ViewTransition.Slide(0.2.seconds)) - else - subView2.replaceWith(subView1, ViewTransition.Slide(0.2.seconds, ViewTransition.Direction.RIGHT)) - } - button("Fire event").action { fire(MySwitchViewEvent) } - } - } - center { - add(subView1) - } - } -} - -class SubView1 : View("SubView1") { - override val root = hbox { - id = "view1" - label("I'm subview 1") - } - init { - subscribe { - println("SubView1 received event") - } - } -} - -class SubView2 : View("SubView2") { - override val root = hbox { - label("I'm subview 2") - } - init { - subscribe { - println("SubView2 received event") - } - } -} - -object MySwitchViewEvent : FXEvent() \ No newline at end of file diff --git a/src/test/kotlin/tornadofx/testapps/ImportStyles.kt b/src/test/kotlin/tornadofx/testapps/ImportStyles.kt deleted file mode 100644 index 5594e38..0000000 --- a/src/test/kotlin/tornadofx/testapps/ImportStyles.kt +++ /dev/null @@ -1,45 +0,0 @@ -package tornadofx.testapps - -import javafx.scene.paint.Color -import javafx.scene.text.FontWeight -import tornadofx.* - -/** - * @author I58695 (2016-08-18) - */ -class ImportStyles : App(MainView::class, Styles::class) { - init { - dumpStylesheets() - } - - class MainView : View() { - override val root = vbox { - addClass(box) - label("Test").addClass(test) - } - } - - companion object { - val box by cssclass() - val test by cssclass() - } - - class Styles : Stylesheet(ParentStyles::class) { - init { - test { - fontSize = 36.px - fontWeight = FontWeight.BOLD - textFill = Color.WHITE - } - } - } - - class ParentStyles : Stylesheet() { - init { - box { - backgroundColor += Color.GRAY - padding = box(10.px, 100.px) - } - } - } -} diff --git a/src/test/kotlin/tornadofx/testapps/InternalWindowTest.kt b/src/test/kotlin/tornadofx/testapps/InternalWindowTest.kt deleted file mode 100644 index cb14d38..0000000 --- a/src/test/kotlin/tornadofx/testapps/InternalWindowTest.kt +++ /dev/null @@ -1,40 +0,0 @@ -package tornadofx.testapps - -import tornadofx.* - -class InternalWindowTestApp : App(InternalWindowTest::class) - -class InternalWindowTest : View("Internal Window") { - override val root = stackpane { - setPrefSize(600.0, 400.0) - button("Open editor").action { - openInternalWindow(modal = false, icon = FX.icon) - } - - } -} - -class Editor : View("Editor") { - override val root = form { - prefWidth = 300.0 - - fieldset("Editor") { - field("First field") { - textfield() - } - field("Second field") { - textfield() - } - button("Save") { - shortcut("Alt+S") - action { - save() - } - } - } - } - - private fun save() { - close() - } -} \ No newline at end of file diff --git a/src/test/kotlin/tornadofx/testapps/KeyboardTestView.kt b/src/test/kotlin/tornadofx/testapps/KeyboardTestView.kt deleted file mode 100644 index ee3c492..0000000 --- a/src/test/kotlin/tornadofx/testapps/KeyboardTestView.kt +++ /dev/null @@ -1,93 +0,0 @@ -package tornadofx.testapps - -import tornadofx.* - -class KeyboardTestApp : App(KeyboardTestView::class) - -class KeyboardTestView : View("TornadoFX Keyboard Layout") { - override val root = vbox(30) { - paddingAll = 40 - // Loaded with JSON - keyboard { - load(resources.json("/tornadofx/tests/TornadoKeyboard.json")) - println(toKeyboardLayoutEditorFormat()) - } - // Generated with builders - keyboard { - row { - key("", width = 1.25) - key("") - key("") - key("") - key("") - key("") - key("Del", height = 2) - key("") - key("") - key("") - key("") - key("") - key("") - key("") - } - row { - key("", width = 1.25) - key("") - key("Ctrl+W") - key("Esc") - key("") - key("") - spacer() - key("") - key("PgUp") - key("▲") - key("PgDn") - key("") - key("") - key("") - } - row { - key("", width = 1.25) - key("") - key("") - key("") - key("") - key("") - key("", height = 2) - key("Home") - key("◀") - key("▼") - key("▶") - key("Ins") - key("Del") - key("") - } - row { - key("", width = 1.25) - key("Ctrl+Z") - key("Ctrl+X") - key("Ctrl+C") - key("Ctrl+V") - key("") - spacer() - key("End") - key("") - key("") - key("") - key("") - key("", width = 2) - } - row { - key("", width = 1.25) - key("", width = 1.25) - key("", width = 1.25) - key("FN (Pressed)", width = 2.75) - key("", width = 2.75) - key("", width = 1.25) - key("", width = 1.25) - key("", width = 1.25) - key("", width = 1.25) - } - } - } -} \ No newline at end of file diff --git a/src/test/kotlin/tornadofx/testapps/ListMenuTest.kt b/src/test/kotlin/tornadofx/testapps/ListMenuTest.kt deleted file mode 100644 index 0d953f7..0000000 --- a/src/test/kotlin/tornadofx/testapps/ListMenuTest.kt +++ /dev/null @@ -1,73 +0,0 @@ -import de.jensd.fx.glyphs.fontawesome.FontAwesomeIcon -import de.jensd.fx.glyphs.fontawesome.FontAwesomeIcon.* -import de.jensd.fx.glyphs.fontawesome.FontAwesomeIconView -import javafx.geometry.Orientation -import javafx.geometry.Pos -import javafx.geometry.Side -import javafx.scene.paint.Color -import tornadofx.* - -class ListMenuTestApp : App(ListMenuTest::class) - -class ListMenuTest : View("ListMenu Test") { - val listmenu = listmenu(theme = "blue") { - addMenuItems() - activeItem = items.first() - maxHeight = Double.MAX_VALUE - } - - override val root = borderpane { - setPrefSize(650.0, 500.0) - top { - vbox(10) { - label(title).style { fontSize = 3.em } - hbox(10) { - alignment = Pos.CENTER - label("Orientation") - combobox(listmenu.orientationProperty, Orientation.values().toList()) - label("Icon Position") - combobox(listmenu.iconPositionProperty, values = Side.values().toList()) - label("Theme") - combobox(listmenu.themeProperty, values = listOf("none", "blue")) - checkbox("Icons Only") { - selectedProperty().onChange { - with(listmenu) { - items.clear() - if (it) { - iconOnlyMenuItems() - } else { - addMenuItems() - } - } - } - } - } - label(stringBinding(listmenu.activeItemProperty) { "Currently selected: ${value?.text}" }) { - style { textFill = Color.RED } - } - style { - alignment = Pos.CENTER - } - } - } - center = listmenu - style { - backgroundColor += Color.WHITE - } - paddingAll = 20 - } - - private fun ListMenu.iconOnlyMenuItems() { - item(graphic = icon(USER)) - item(graphic = icon(SUITCASE)) - item(graphic = icon(COG)) - } - - private fun ListMenu.addMenuItems() { - item("Contacts", icon(USER)) - item("Projects", icon(SUITCASE)) - item("Settings", icon(COG)) - } - - private fun icon(icon: FontAwesomeIcon) = FontAwesomeIconView(icon).apply { glyphSize = 20 } -} \ No newline at end of file diff --git a/src/test/kotlin/tornadofx/testapps/MultipleLifecycleAsyncApp.kt b/src/test/kotlin/tornadofx/testapps/MultipleLifecycleAsyncApp.kt deleted file mode 100644 index e107cec..0000000 --- a/src/test/kotlin/tornadofx/testapps/MultipleLifecycleAsyncApp.kt +++ /dev/null @@ -1,20 +0,0 @@ -package tornadofx.testapps - -import javafx.beans.property.SimpleIntegerProperty -import tornadofx.* - -class MultipleLifecycleAsyncView : View("Multiple Lifecycle Async") { - val counterProperty = SimpleIntegerProperty() - var counter by counterProperty - override val root = pane { - button("Increment on background thread and main thread") { - action { - runAsync { - counter++ - } success { - counter++ - } - } - } - } -} \ No newline at end of file diff --git a/src/test/kotlin/tornadofx/testapps/NestedTableColumns.kt b/src/test/kotlin/tornadofx/testapps/NestedTableColumns.kt deleted file mode 100644 index 9f34cc0..0000000 --- a/src/test/kotlin/tornadofx/testapps/NestedTableColumns.kt +++ /dev/null @@ -1,23 +0,0 @@ -package tornadofx.testapps - -import javafx.collections.FXCollections -import tornadofx.* - -class NestedTableColumnsApp : App(NestedTableColumns::class) - -class NestedTableColumns : View("Nested Table Columns") { - data class Person(val name: String, val primaryEmail: String, val secondaryEmail: String) - - val people = FXCollections.observableArrayList( - Person("John Doe", "john@doe.com", "john.doe@gmail.com"), - Person("Jane Doe", "jane@doe.com", "jane.doe@gmail.com") - ) - - override val root = tableview(people) { - readonlyColumn("Name", Person::name) - nestedColumn("Email addresses") { - readonlyColumn("Primary Email", Person::primaryEmail) - readonlyColumn("Secondary Email", Person::secondaryEmail) - } - } -} \ No newline at end of file diff --git a/src/test/kotlin/tornadofx/testapps/NewViewTransition.kt b/src/test/kotlin/tornadofx/testapps/NewViewTransition.kt deleted file mode 100644 index c399331..0000000 --- a/src/test/kotlin/tornadofx/testapps/NewViewTransition.kt +++ /dev/null @@ -1,243 +0,0 @@ -package tornadofx.testapps - -import javafx.animation.Animation -import javafx.animation.Interpolator -import javafx.beans.property.SimpleStringProperty -import javafx.geometry.Pos -import javafx.scene.Node -import javafx.scene.layout.StackPane -import javafx.scene.paint.* -import javafx.scene.text.FontWeight -import javafx.util.Duration -import tornadofx.* - -/** - * Run the demo as the root of the scene - */ -class NewViewTransitionRoot : App(NewViewTransitionMain::class, NewViewTransitionStyles::class) - -/** - * Run the demo in a VBox - * - * Notice the z-ordering is based on the index withing the VBox - */ -class NewViewTransitionVBox : App(VBoxRootView::class, NewViewTransitionStyles::class) { - class VBoxRootView : View("Switching Sub Views In VBox") { - override val root = vbox { - label("Top").addClass(NewViewTransitionStyles.darkLabel) - add() - label("Bottom").addClass(NewViewTransitionStyles.lightLabel) - } - } -} - -/** - * Run the demo in a BorderPane - * - * Notice the z-ordering is based on when the node was added to the scene graph - */ -class NewViewTransitionBorderPane : App(BorderPaneRootView::class, NewViewTransitionStyles::class) { - class BorderPaneRootView : View("Switching Sub Views In BorderPane") { - override val root = borderpane { - top = label("Top") { addClass(NewViewTransitionStyles.darkLabel) } - right = label("Right") { addClass(NewViewTransitionStyles.greenLabel) } - bottom = label("Bottom") { addClass(NewViewTransitionStyles.lightLabel) } - left = label("Left") { addClass(NewViewTransitionStyles.greenLabel) } - center() - } - } -} - -abstract class NewViewTransitionSwapView(name: String, cssClass: CssRule) : View("Switching Views On Scene Root") { - val controller: NewViewTransitionController by inject() - val nextTransition = SimpleStringProperty(controller.firstTransition) - val nameLabel = label(name) - val surpriseLabel = label("Surprise!") - - override val root = stackpane { - vbox { - addClass(NewViewTransitionStyles.box, cssClass) - this += nameLabel - button { - textProperty().bind(nextTransition) - action { swap() } - } - } - } - - init { - val surprise = ViewTransition.Flip(.1.seconds, true) - nameLabel.setOnMouseClicked { nameLabel.replaceWith(surpriseLabel, surprise) } - surpriseLabel.setOnMouseClicked { surpriseLabel.replaceWith(nameLabel, surprise) } - } - - abstract fun swap() -} - -class NewViewTransitionMain : NewViewTransitionSwapView("Main", NewViewTransitionStyles.red) { - val alt: NewViewTransitionAlternate by inject() - override fun swap() { - controller.swap(this, alt) - } -} - -class NewViewTransitionAlternate : NewViewTransitionSwapView("Alternate", NewViewTransitionStyles.blue) { - val main: NewViewTransitionMain by inject() - override fun swap() { - controller.swap(this, main) - } -} - -class NewViewTransitionController : Controller() { - private val time = .25.seconds - private val doubleTime = time.multiply(2.0) - private val fades = listOf( - "Black" to Color.BLACK, - "White" to Color.WHITE, - "Orange" to Color.ORANGE, - "Fade" to LinearGradient(0.0, 0.0, 0.0, 1.0, true, CycleMethod.NO_CYCLE, Stop(0.0, Color.BLACK), Stop(1.0, Color.WHITE)), - "Crazy" to RadialGradient(0.0, 0.0, 150.0, 100.0, 75.0, false, CycleMethod.REPEAT, - Stop(0.0, NewViewTransitionStyles.nukeRed), Stop(0.33, NewViewTransitionStyles.nukeRed), - Stop(0.33, NewViewTransitionStyles.nukeGreen), Stop(0.66, NewViewTransitionStyles.nukeGreen), - Stop(0.66, NewViewTransitionStyles.nukeBlue), Stop(1.0, NewViewTransitionStyles.nukeBlue) - ) - ) - - private inline infix fun String.eachWay(constructor: (ViewTransition.Direction) -> ViewTransition): Array> { - return ViewTransition.Direction.values().map { "$this $it" to constructor(it) }.toTypedArray() - } - - private val transitions = listOf( - "None" to null, - "Fade" to ViewTransition.Fade(time), - *fades.map { "${it.first} Fade" to ViewTransition.FadeThrough(doubleTime, it.second) }.toTypedArray(), - *"Slide" eachWay { ViewTransition.Slide(time, it) }, - *"Cover" eachWay { ViewTransition.Cover(time, it) }, - *"Reveal" eachWay { ViewTransition.Reveal(time, it) }, - *"Metro" eachWay { ViewTransition.Metro(time, it) }, - *"Swap" eachWay { ViewTransition.Swap(doubleTime, it) }, - *"Wipe" eachWay { ViewTransition.Wipe(time, it) }, - *"Custom" eachWay { CustomViewTransition(doubleTime, it) }, - "Flip Horizontal" to ViewTransition.Flip(time, false), - "Flip Vertical" to ViewTransition.Flip(time, true), - "Explode" to ViewTransition.Explode(time), - "Implode" to ViewTransition.Implode(time), - "NewsFlash" to ViewTransition.NewsFlash(doubleTime, 2.0), - "Dissolve" to ViewTransition.Dissolve(doubleTime) - ) - val firstTransition = transitions[0].first - private var currentTransition = 0 - fun swap(current: NewViewTransitionSwapView, replacement: NewViewTransitionSwapView) { - val t = transitions[currentTransition].second - currentTransition = (currentTransition + 1) % transitions.size - replacement.nextTransition.value = transitions[currentTransition].first - current.replaceWith(replacement, t) - } -} - -class NewViewTransitionStyles : Stylesheet() { - companion object { - val box by cssclass() - val red by cssclass() - val blue by cssclass() - val bg by cssproperty("-fx-background-color") - val nuke by cssproperty() - val darkLabel by cssclass() - val lightLabel by cssclass() - val greenLabel by cssclass() - - val nukeRed = c(0.75, 0.5, 0.5) - val nukeGreen = c(0.5, 0.75, 0.5) - val nukeBlue = c(0.5, 0.5, 0.75) - - val boxMix = mixin { - bg force nuke - button { - bg force raw("derive(${nuke.name}, -10%)") - and(hover) { - bg force raw("derive(${nuke.name}, -15%)") - } - } - } - - val labelMix = mixin { - maxWidth = infinity - maxHeight = infinity - alignment = Pos.BASELINE_CENTER - padding = box(12.px) - fontSize = 24.px - } - } - - init { - box { - prefWidth = 400.px - prefHeight = 300.px - spacing = 12.px - alignment = Pos.CENTER - s(label, button) { - textFill = Color.WHITE - fontSize = 36.px - fontWeight = FontWeight.BOLD - alignment = Pos.BASELINE_CENTER - } - and(red) { - nuke.value = nukeRed - +boxMix - } - and(blue) { - nuke.value = nukeBlue - +boxMix - } - } - darkLabel { - +labelMix - backgroundColor += Color.BLACK - textFill = Color.WHITE - } - lightLabel { - +labelMix - backgroundColor += Color.WHITE - textFill = Color.BLACK - } - greenLabel { - +labelMix - backgroundColor += nukeGreen - textFill = Color.WHITE - } - } -} - -class CustomViewTransition(val duration: Duration, val direction: Direction = ViewTransition.Direction.LEFT) : ViewTransition.ReversibleViewTransition() { - val halfSpeed = duration.divide(2.0)!! - val scale = when (direction) { - Direction.UP, Direction.DOWN -> point(1, 0) - Direction.LEFT, Direction.RIGHT -> point(0, 1) - } - - override fun create(current: Node, replacement: Node, stack: StackPane): Animation { - val bounds = current.boundsInLocal - val destination = when (direction) { - Direction.UP -> point(0, -bounds.height / 2) - Direction.RIGHT -> point(bounds.width / 2, 0) - Direction.DOWN -> point(0, bounds.height / 2) - Direction.LEFT -> point(-bounds.width / 2, 0) - } - return replacement.transform( - halfSpeed, destination.multiply(-1.0), 0.0, scale, 1.0, - easing = Interpolator.LINEAR, reversed = true, play = false - ) and current.transform( - halfSpeed, destination, 0.0, scale, 1.0, - easing = Interpolator.LINEAR, play = false - ) - } - - override fun reversed() = CustomViewTransition(duration, direction.reversed()) - - override fun onComplete(removed: Node, replacement: Node) { - removed.translateX = 0.0 - removed.translateY = 0.0 - removed.scaleX = 1.0 - removed.scaleY = 1.0 - } -} diff --git a/src/test/kotlin/tornadofx/testapps/PaddingPropertyTest.kt b/src/test/kotlin/tornadofx/testapps/PaddingPropertyTest.kt deleted file mode 100644 index 52a3d77..0000000 --- a/src/test/kotlin/tornadofx/testapps/PaddingPropertyTest.kt +++ /dev/null @@ -1,16 +0,0 @@ -package tornadofx.testapps - -import javafx.scene.paint.Color -import tornadofx.* - -class PaddingPropertyTestApp : App(PaddingPropertyTest::class) - -class PaddingPropertyTest : View("Slide Padding") { - override val root = vbox { - setPrefSize(400.0, 150.0) - style { backgroundColor += Color.CADETBLUE } - slider(0.0, 100.0, 20.0) { - this@vbox.paddingAllProperty.bind(valueProperty()) - } - } -} \ No newline at end of file diff --git a/src/test/kotlin/tornadofx/testapps/PaintBackgroundTest.kt b/src/test/kotlin/tornadofx/testapps/PaintBackgroundTest.kt deleted file mode 100644 index 2775aa3..0000000 --- a/src/test/kotlin/tornadofx/testapps/PaintBackgroundTest.kt +++ /dev/null @@ -1,14 +0,0 @@ -package tornadofx.testapps - -import javafx.scene.paint.Color -import tornadofx.* - -class PaintBackgroundTestApp : App(PaintBackgroundTest::class) - -class PaintBackgroundTest : View() { - override val root = hbox { - label("Hello Background Color") { - background = Color.LIGHTBLUE.asBackground() - } - } -} \ No newline at end of file diff --git a/src/test/kotlin/tornadofx/testapps/ParamTest.kt b/src/test/kotlin/tornadofx/testapps/ParamTest.kt deleted file mode 100644 index 5261f77..0000000 --- a/src/test/kotlin/tornadofx/testapps/ParamTest.kt +++ /dev/null @@ -1,34 +0,0 @@ -package tornadofx.testapps - -import tornadofx.* -import java.time.LocalDateTime - -class ParamTestApp : App(ParamCallerView::class) - -class ParamCallerView : View() { - override val root = vbox { - button("Open modal with paramMap"){ - action { - find(mapOf("name" to "Param ${LocalDateTime.now()}")).openModal() - } - } - button("Open modal with paramVararg"){ - action { - find("name" to "Param ${LocalDateTime.now()}").openModal() - } - } - } -} - -class ParamReceiverView : View() { - val name: String by param() - - override val root = vbox() - - override fun onDock() { - with(root) { - label(name) - } - currentStage?.sizeToScene() - } -} \ No newline at end of file diff --git a/src/test/kotlin/tornadofx/testapps/PojoTableColumns.kt b/src/test/kotlin/tornadofx/testapps/PojoTableColumns.kt deleted file mode 100644 index 13073ba..0000000 --- a/src/test/kotlin/tornadofx/testapps/PojoTableColumns.kt +++ /dev/null @@ -1,23 +0,0 @@ -package tornadofx.testapps - -import javafx.collections.FXCollections -import tornadofx.* -import tornadofx.tests.JavaPerson - -class PojoTableColumnsApp : App(PojoTableColumns::class) - -class PojoTableColumns : View("Pojo Table Columns") { - val people = FXCollections.observableArrayList( - JavaPerson().apply { name = "John Doe"; primaryEmail = "john@doe.com"; secondaryEmail = "john.doe@gmail.com"}, - JavaPerson().apply { name = "Jane Doe"; primaryEmail = "jane@doe.com"; secondaryEmail = "jane.doe@gmail.com"} - ) - - override val root = tableview(people) { - column("Name", JavaPerson::getName ) - nestedColumn("Email addresses") { - column("Primary Email", JavaPerson::getPrimaryEmail ) - column("Secondary Email", JavaPerson::getSecondaryEmail ) - } - resizeColumnsToFitContent() - } -} \ No newline at end of file diff --git a/src/test/kotlin/tornadofx/testapps/PojoTreeTableColumns.kt b/src/test/kotlin/tornadofx/testapps/PojoTreeTableColumns.kt deleted file mode 100644 index 8f78084..0000000 --- a/src/test/kotlin/tornadofx/testapps/PojoTreeTableColumns.kt +++ /dev/null @@ -1,42 +0,0 @@ -package tornadofx.testapps - -import javafx.scene.control.TreeItem -import tornadofx.* -import tornadofx.tests.JavaPerson - -class PojoTreeTableColumnsApp : App(PojoTreeTableColumns::class) - -class PojoTreeTableColumns : View("Pojo Tree Table Columns") { - - val people = observableListOf( - JavaPerson("Mary Hanes", "IT Administration", "mary.hanes@contoso.com", "mary2.hanes@contoso.com", listOf( - JavaPerson("Jacob Mays", "IT Help Desk", "jacob.mays@contoso.com", "jacob2.mays@contoso.com"), - JavaPerson("John Ramsy", "IT Help Desk", "john.ramsy@contoso.com", "john2.ramsy@contoso.com"))), - JavaPerson("Erin James", "Human Resources", "erin.james@contoso.com", "erin2.james@contoso.com", listOf( - JavaPerson("Erlick Foyes", "Customer Service", "erlick.foyes@contoso.com", "erlick2.foyes@contoso.com"), - JavaPerson("Steve Folley", "Customer Service", "steve.folley@contoso.com", "erlick2.foyes@contoso.com"), - JavaPerson("Larry Cable", "Customer Service", "larry.cable@contoso.com", "larry2.cable@contoso.com"))) - ) - - // Create the root item that holds all top level employees - val rootItem = TreeItem(JavaPerson().apply { name = "Employees by Manager"; employees = people }) - - override val root = treetableview(rootItem) { - prefWidth = 800.0 - - column("Name", "name").contentWidth(50) // non type safe - column("Department", JavaPerson::getDepartment).remainingWidth() - nestedColumn("Email addresses") { - column("Primary Email", JavaPerson::getPrimaryEmail) - column("Secondary Email", JavaPerson::getSecondaryEmail) - } - - // Always return employees under the current person - populate { it.value.employees } - - // Expand the two first levels - root.isExpanded = true - root.children.withEach { isExpanded = true } - smartResize() - } -} \ No newline at end of file diff --git a/src/test/kotlin/tornadofx/testapps/ReloadStylesInModal.kt b/src/test/kotlin/tornadofx/testapps/ReloadStylesInModal.kt deleted file mode 100644 index 347ba3a..0000000 --- a/src/test/kotlin/tornadofx/testapps/ReloadStylesInModal.kt +++ /dev/null @@ -1,36 +0,0 @@ -package tornadofx.testapps - -import tornadofx.* - -class ReloadStylesInModal : App(MainView::class, Styles::class) { - class MainView : View() { - override val root = hbox { - button("Open").action { - find().openModal() - } - } - } - - class MyModal : Fragment() { - override val root = vbox { - label("My label") - button("Close").action { - close() - } - } - } - - class Styles : Stylesheet(Base::class) - - class Base : Stylesheet() { - init { - button { - fontSize = 30.px - } - label { - fontSize = 30.px - } - } - } -} - diff --git a/src/test/kotlin/tornadofx/testapps/RemoveTest.kt b/src/test/kotlin/tornadofx/testapps/RemoveTest.kt deleted file mode 100644 index 5a402fc..0000000 --- a/src/test/kotlin/tornadofx/testapps/RemoveTest.kt +++ /dev/null @@ -1,32 +0,0 @@ -package tornadofx.testapps - -import javafx.beans.property.SimpleBooleanProperty -import javafx.scene.paint.Color -import javafx.scene.text.FontWeight -import tornadofx.* - -class RemoveTestApp : App(RemoveTest::class) - -class RemoveTest : View("Remove Test") { - val remove = SimpleBooleanProperty(false) - - override val root = vbox { - setPrefSize(400.0, 200.0) - form { - label("I'm above the removable element (which might be removed of course)") - label("Remove me!") { - removeWhen { remove } - style { - fontWeight = FontWeight.BOLD - textFill = Color.RED - } - } - label("I'm below the removable element (which might be removed of course)") - fieldset { - field("Remove") { - combobox(remove, values = listOf(true, false)) - } - } - } - } -} \ No newline at end of file diff --git a/src/test/kotlin/tornadofx/testapps/ShortLongPressTest.kt b/src/test/kotlin/tornadofx/testapps/ShortLongPressTest.kt deleted file mode 100644 index e637974..0000000 --- a/src/test/kotlin/tornadofx/testapps/ShortLongPressTest.kt +++ /dev/null @@ -1,31 +0,0 @@ -package tornadofx.testapps - -import javafx.collections.FXCollections -import tornadofx.* -import java.time.LocalDateTime - -class ShortLongPressTestApp : App(ShortLongPressTest::class) - -class ShortLongPressTest : View("Short or long press") { - val actuations = FXCollections.observableArrayList() - - override val root = borderpane { - top { - stackpane { - paddingAll = 20 - button("Short or longpress me") { - longpress { actuations.add("Long at ${LocalDateTime.now()}") } - shortpress { actuations.add("Short at ${LocalDateTime.now()}") } - } - } - } - center { - listview(actuations) - } - bottom { - label("Hold for 700ms to actuate long action, or less to actuate short action") { - paddingAll = 20 - } - } - } -} diff --git a/src/test/kotlin/tornadofx/testapps/SlideshowTest.kt b/src/test/kotlin/tornadofx/testapps/SlideshowTest.kt deleted file mode 100644 index cf3baa4..0000000 --- a/src/test/kotlin/tornadofx/testapps/SlideshowTest.kt +++ /dev/null @@ -1,34 +0,0 @@ -package tornadofx.testapps - -import tornadofx.* - -class SlideshowTestApp : App(SlideshowTest::class, NewViewTransitionStyles::class) - -class SlideshowTest : View("Slideshow") { - override val root = slideshow { - slide() - slide(ViewTransition.Fade(0.3.seconds)) - slide() - } -} - -class Slide1 : View("Slide 1") { - override val root = stackpane { - label(titleProperty) - addClass(NewViewTransitionStyles.box, NewViewTransitionStyles.blue) - } -} - -class Slide2 : View("Slide 2") { - override val root = stackpane { - label(titleProperty) - addClass(NewViewTransitionStyles.box, NewViewTransitionStyles.red) - } -} - -class Slide3 : View("Slide 3") { - override val root = stackpane { - label(titleProperty) - addClass(NewViewTransitionStyles.box, NewViewTransitionStyles.blue) - } -} diff --git a/src/test/kotlin/tornadofx/testapps/SqueezeBoxTest.kt b/src/test/kotlin/tornadofx/testapps/SqueezeBoxTest.kt deleted file mode 100644 index c9e7c93..0000000 --- a/src/test/kotlin/tornadofx/testapps/SqueezeBoxTest.kt +++ /dev/null @@ -1,55 +0,0 @@ -package tornadofx.testapps - -import javafx.geometry.Pos -import javafx.scene.input.KeyCombination -import tornadofx.* - -class SqueezeBoxTestApp : App(SqueezeBoxTestView::class) - -object AddFoldEvent : FXEvent() - -class SqueezeBoxTestView : View("SqueezeBox Multiple Open Folds") { - override val root = vbox(5.0) { - setPrefSize(300.0, 600.0) - - button("Add node") { - action { - fire(AddFoldEvent) - } - shortcut(KeyCombination.valueOf("Ctrl+A")) - } - - scrollpane(fitToWidth = true) { - squeezebox { - fold("Pane 1", expanded = true, closeable = true) { - stackpane { - vbox { - alignment = Pos.CENTER - label("I'm inside 1") - label("Me too!") - } - } - } - fold("Pane 2", expanded = true, closeable = true) { - label("I'm inside 2") - } - fold("Pane 3", closeable = true) { - label("I'm inside 3") - } - fold("Pane 4", expanded = true, closeable = true) { - label("I'm inside 4") - } - fold("Pane 5", closeable = true) { - label("I'm inside 5") - } - subscribe { - fold("Another fold by subscription", closeable = true) { - stackpane { - label("Yo!") - } - } - } - } - } - } -} \ No newline at end of file diff --git a/src/test/kotlin/tornadofx/testapps/StylesheetErrorTest.kt b/src/test/kotlin/tornadofx/testapps/StylesheetErrorTest.kt deleted file mode 100644 index 1939abd..0000000 --- a/src/test/kotlin/tornadofx/testapps/StylesheetErrorTest.kt +++ /dev/null @@ -1,25 +0,0 @@ -package tornadofx.testapps - -import tornadofx.App -import tornadofx.Stylesheet -import tornadofx.View -import tornadofx.addClass -import tornadofx.button -import tornadofx.stackpane - -class StylesheetErrorTest : App(StylesheetErrorView::class, Styles::class) - -class StylesheetErrorView : View() { - override val root = stackpane { - button("Click here").addClass("my-button") - } -} - -class Styles : Stylesheet() { - init { - text { - // cannot refer to unset property - stroke = baseColor - } - } -} diff --git a/src/test/kotlin/tornadofx/testapps/SwitchViewApp.kt b/src/test/kotlin/tornadofx/testapps/SwitchViewApp.kt deleted file mode 100644 index 72dd9b4..0000000 --- a/src/test/kotlin/tornadofx/testapps/SwitchViewApp.kt +++ /dev/null @@ -1,46 +0,0 @@ -package tornadofx.testapps - -import javafx.scene.control.Alert.AlertType.ERROR -import tornadofx.* - -class GotoViewApp : App(GotoContainerView::class) - -class GotoContainerView : View("ContainerView") { - val gotoSubView1: GotoSubView1 by inject() - val gotoSubView2: GotoSubView2 by inject() - - override val root = borderpane { - top { - button("Goto view").action { - if (center.lookup("#view1") != null) - gotoSubView1.goto(gotoSubView2) - else - gotoSubView2.goto(gotoSubView1) - } - } - center { - add(gotoSubView1) - } - } -} - -class GotoSubView1 : View("GotoSubView2") { - override val root = hbox { - id = "view1" - label("I'm subview 1") - } - - override fun onGoto(source: UIComponent) { - when (source) { - is GotoSubView2 -> if (source.isDocked) source.replaceWith(this) else openModal() - is GotoSubView1 -> source.replaceWith(this) - else -> alert(ERROR, "I refuse!", "Not going to happen") - } - } -} - -class GotoSubView2 : View("GotoSubView2") { - override val root = hbox { - label("I'm subview 2") - } -} diff --git a/src/test/kotlin/tornadofx/testapps/TabPaneTest.kt b/src/test/kotlin/tornadofx/testapps/TabPaneTest.kt deleted file mode 100644 index 64534ad..0000000 --- a/src/test/kotlin/tornadofx/testapps/TabPaneTest.kt +++ /dev/null @@ -1,42 +0,0 @@ -package tornadofx.testapps - -import javafx.beans.property.SimpleBooleanProperty -import tornadofx.* - -class TabPaneTestApp : App(TabPaneTest::class) - -class TabPaneTest : View("TabPane Test") { - override val root = tabpane { - tab() - tab() - // This is not the typical use case for using index, but instead when tab is added programmatically, - // ex.: duplicate the current tab - tab(1, "Tab Three", TabThree().root) - // Here we verify that the original implementation works correctly, i.e. adds the tab to the end of the list - tab("Tab Four", TabFour().root) - } -} - -/** - * Check that the tab title updates when the input changes. - * The Tab should not be closeable as it binds to the closeable property. - */ -class TabOne : View("Tab One") { - override val root = textfield(titleProperty) - override val closeable = SimpleBooleanProperty(false) -} - -class TabTwo : View("Tab Two") { - override val root = textfield(titleProperty) - override val closeable = SimpleBooleanProperty(false) -} - -class TabThree : View("Tab Three") { - override val root = textfield(titleProperty) - override val closeable = SimpleBooleanProperty(false) -} - -class TabFour : View("Tab Four") { - override val root = textfield(titleProperty) - override val closeable = SimpleBooleanProperty(false) -} diff --git a/src/test/kotlin/tornadofx/testapps/TableViewCellCacheTest.kt b/src/test/kotlin/tornadofx/testapps/TableViewCellCacheTest.kt deleted file mode 100644 index 0dd34a7..0000000 --- a/src/test/kotlin/tornadofx/testapps/TableViewCellCacheTest.kt +++ /dev/null @@ -1,26 +0,0 @@ -package tornadofx.testapps - -import tornadofx.* - -class TableViewCellCacheTestApp : App(TableViewCellCacheTest::class) - -class TableViewCellCacheTest : View("TableView CellCache Test") { - val kittens = DataGridTestApp.images["kittens"] as List - - override val root = tableview(kittens.asObservable()) { - prefWidth = 300.0 - - column("Filename", String::class) { - value { it.value.substringAfterLast("/") } - } - column("Image", String::class) { - value { it.value } - cellCache { imageview(it, true) } - cellFormat { - prefHeight = 160.0 - prefWidth = 160.0 - } - } - } -} - diff --git a/src/test/kotlin/tornadofx/testapps/TableViewDNDTest.kt b/src/test/kotlin/tornadofx/testapps/TableViewDNDTest.kt deleted file mode 100644 index 668c2b7..0000000 --- a/src/test/kotlin/tornadofx/testapps/TableViewDNDTest.kt +++ /dev/null @@ -1,74 +0,0 @@ -package tornadofx.testapps - -import javafx.scene.control.TableRow -import javafx.scene.input.ClipboardContent -import javafx.scene.input.TransferMode -import javafx.scene.paint.Color -import javafx.scene.text.FontWeight -import tornadofx.* -import tornadofx.tests.Person -import tornadofx.tests.PersonRef - -class DNDReorderTableViewApp : App(DNDReorderTableView::class) - -class DNDReorderTableView : View() { - val people = observableListOf(Person("Bob", 42), Person("Jane", 24), Person("John", 31)) - - override val root = tableview(people) { - column("Name", Person::nameProperty) - column("Age", Person::ageProperty) - - setOnDragDetected { event -> - val person = if (!selectionModel.isEmpty) selectedItem else null - if (person != null) { - val dragboard = startDragAndDrop(TransferMode.MOVE) - dragboard.setContent(ClipboardContent().apply { put(Person.DATA_FORMAT, PersonRef(person.id)) }) - } - event.consume() - } - - // Handle DND per row - setRowFactory { - object : TableRow() { - init { - setOnDragOver { - if (it.dragboard.hasContent(Person.DATA_FORMAT)) { - it.acceptTransferModes(TransferMode.MOVE) - it.consume() - } - } - setOnDragEntered { - if (it.dragboard.hasContent(Person.DATA_FORMAT)) { - val ref = it.dragboard.getContent(Person.DATA_FORMAT) as PersonRef - style { - if (ref.id != item.id) { - fontWeight = FontWeight.BOLD - } else { - textFill = Color.RED - } - } - it.consume() - } - } - setOnDragExited { - style = null - it.consume() - } - setOnDragDropped { - if (it.dragboard.hasContent(Person.DATA_FORMAT)) { - val draggedRef = it.dragboard.getContent(Person.DATA_FORMAT) as PersonRef - val droppedPerson = item - val targetIndex = items.indexOf(droppedPerson) - val sourcePerson = items.find { it.id == draggedRef.id } - items.move(sourcePerson, targetIndex) - it.isDropCompleted = true - } else { - it.isDropCompleted = false - } - it.consume() - } - } - } - } - } -} \ No newline at end of file diff --git a/src/test/kotlin/tornadofx/testapps/TableViewDirtyTest.kt b/src/test/kotlin/tornadofx/testapps/TableViewDirtyTest.kt deleted file mode 100644 index 5dc27bb..0000000 --- a/src/test/kotlin/tornadofx/testapps/TableViewDirtyTest.kt +++ /dev/null @@ -1,106 +0,0 @@ -package tornadofx.testapps - -import javafx.beans.property.SimpleObjectProperty -import javafx.beans.property.SimpleStringProperty -import javafx.collections.FXCollections -import javafx.scene.control.SelectionMode -import javafx.scene.control.TableView -import javafx.scene.control.TableView.CONSTRAINED_RESIZE_POLICY -import javafx.scene.text.FontWeight -import tornadofx.* -import java.util.* - -class TableViewDirtyTestApp : WorkspaceApp(TableViewDirtyTest::class) - -class TableViewDirtyTest : View("Dirty Tables") { - val customers = FXCollections.observableArrayList(Customer("Thomas", "Nield"), Customer("Matthew", "Turnblom"), Customer("Edvin", "Syse")) - var table: TableView by singleAssign() - - override val root = borderpane { - center { - tableview(customers) { - table = this - prefHeight = 200.0 - - column("First Name", Customer::firstNameProperty) { - makeEditable() - cellDecorator { - style { - fontWeight = FontWeight.BOLD - } - } - } - column("Last Name", Customer::lastNameProperty).makeEditable() - enableCellEditing() - regainFocusAfterEdit() - enableDirtyTracking() - selectOnDrag() - contextmenu { - item(stringBinding(selectionModel.selectedCells) { "Rollback ${selectedColumn?.text}" }) { - disableWhen { editModel.selectedItemDirty.not() } - action { editModel.rollback(selectedItem, selectedColumn) } - } - item(stringBinding(selectionModel.selectedCells) { "Commit ${selectedColumn?.text}" }) { - disableWhen { editModel.selectedItemDirty.not() } - action { editModel.commit(selectedItem, selectedColumn) } - } - } - selectionModel.selectionMode = SelectionMode.MULTIPLE - columnResizePolicy = CONSTRAINED_RESIZE_POLICY - } - } - bottom { - hbox(10) { - paddingAll = 4 - button("Commit row") { - disableWhen { table.editModel.selectedItemDirty.not() } - action { table.editModel.commitSelected() } - } - button("Rollback row") { - disableWhen { table.editModel.selectedItemDirty.not() } - action { table.editModel.rollbackSelected() } - } - } - } - } - - override fun onSave() { - table.editModel.commit() - } - - override fun onRefresh() { - table.editModel.rollback() - } - - init { - icon = FX.icon - } - - class Customer(firstName: String, lastName: String) { - val idProperty = SimpleObjectProperty(UUID.randomUUID()) - var id by idProperty - - val firstNameProperty = SimpleStringProperty(firstName) - var firstName by firstNameProperty - - val lastNameProperty = SimpleStringProperty(lastName) - val lastName by lastNameProperty - - override fun toString() = "$firstName $lastName" - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other?.javaClass != javaClass) return false - - other as Customer - - if (id != other.id) return false - - return true - } - - override fun hashCode(): Int { - return id.hashCode() - } - } -} diff --git a/src/test/kotlin/tornadofx/testapps/TableViewSelectionTest.kt b/src/test/kotlin/tornadofx/testapps/TableViewSelectionTest.kt deleted file mode 100644 index 4889366..0000000 --- a/src/test/kotlin/tornadofx/testapps/TableViewSelectionTest.kt +++ /dev/null @@ -1,76 +0,0 @@ -package tornadofx.testapps - -import javafx.scene.control.TabPane -import javafx.scene.control.TreeItem -import tornadofx.* -import tornadofx.tests.JavaPerson - -class TableViewSelectionTestApp : App(TableViewSelectionTest::class) - -class TableViewSelectionTest : View("Table Selection Test") { - val people = observableListOf( - JavaPerson("Mary Hanes", "IT Administration", "mary.hanes@contoso.com", "mary2.hanes@contoso.com"), - JavaPerson("Erin James", "Human Resources", "erin.james@contoso.com", "erin2.james@contoso.com") - ) - - override val root = tabpane { - prefWidth = 800.0 - tabClosingPolicy = TabPane.TabClosingPolicy.UNAVAILABLE - - tab("Table") { - tableview(people) { - column("Name", JavaPerson::getName).contentWidth(50.0) - column("Department", JavaPerson::getDepartment).remainingWidth() - nestedColumn("Email addresses") { - column("Primary Email", JavaPerson::getPrimaryEmail) - column("Secondary Email", JavaPerson::getSecondaryEmail) - } - - selectionModel.isCellSelectionEnabled = true - smartResize() - - contextmenu { - item("Print selected").action { println(selectedValue.toString()) } - item("Print selected position").action { println("(${selectedCell!!.column}, ${selectedCell!!.row})") } - item("Print selected column").action { println(selectedColumn!!.text) } - separator() - item("Print employee's name").action { println(selectedItem!!.name) } - item("Print employee's department").action { println(selectedItem!!.department) } - item("Print employee's primary email").action { println(selectedItem!!.primaryEmail) } - item("Print employee's secondary email").action { println(selectedItem!!.secondaryEmail) } - } - } - } - - tab("Tree Table") { - val rootItem = TreeItem(JavaPerson().apply { name = "Employees"; employees = people }) - - treetableview(rootItem) { - column("Name", JavaPerson::getName).contentWidth(50.0) - column("Department", JavaPerson::getDepartment).remainingWidth() - nestedColumn("Email addresses") { - column("Primary Email", JavaPerson::getPrimaryEmail) - column("Secondary Email", JavaPerson::getSecondaryEmail) - } - - populate { it.value.employees } - - selectionModel.isCellSelectionEnabled = true - root.isExpanded = true - root.children.withEach { isExpanded = true } - smartResize() - - contextmenu { - item("Print selected").action { println(selectedValue.toString()) } - item("Print selected position").action { println("(${selectedCell!!.column}, ${selectedCell!!.row})") } - item("Print selected column").action { println(selectedColumn!!.text) } - separator() - item("Print employee's name").action { println(selectedItem!!.name) } - item("Print employee's department").action { println(selectedItem!!.department) } - item("Print employee's primary email").action { println(selectedItem!!.primaryEmail) } - item("Print employee's secondary email").action { println(selectedItem!!.secondaryEmail) } - } - } - } - } -} \ No newline at end of file diff --git a/src/test/kotlin/tornadofx/testapps/TableViewSortFilterTest.kt b/src/test/kotlin/tornadofx/testapps/TableViewSortFilterTest.kt deleted file mode 100644 index e2388d9..0000000 --- a/src/test/kotlin/tornadofx/testapps/TableViewSortFilterTest.kt +++ /dev/null @@ -1,49 +0,0 @@ -package tornadofx.testapps - -import tornadofx.* -import java.time.LocalDate - - -class TableViewSortFilterTestApp : App(TableViewSortFilterTest::class) - -class TableViewSortFilterTest : View("Table Sort and Filter") { - data class Person(val id: Int, var name: String, var birthday: LocalDate) { - val age: Int - get() = birthday.until(LocalDate.now()).years - } - - private val persons = listOf( - Person(1, "Samantha Stuart", LocalDate.of(1981, 12, 4)), - Person(2, "Tom Marks", LocalDate.of(2001, 1, 23)), - Person(3, "Stuart Gills", LocalDate.of(1989, 5, 23)), - Person(3, "Nicole Williams", LocalDate.of(1998, 8, 11)) - ) - - val data = SortedFilteredList() - - override val root = vbox { - textfield { - data.filterWhen(textProperty(), { query, item -> item.name.contains(query, true) }) - } - - tableview(data) { - readonlyColumn("ID", Person::id) - column("Name", Person::name) - nestedColumn("DOB") { - readonlyColumn("Birthday", Person::birthday) - readonlyColumn("Age", Person::age).contentWidth() - } - smartResize() - } - - hbox(5) { - label("Filter count:") - label(data.sizeProperty.stringBinding { "$it records matching filter"}) - } - } - - init { - // Simulate data access - data.asyncItems { persons } - } -} diff --git a/src/test/kotlin/tornadofx/testapps/TaskStatusTest.kt b/src/test/kotlin/tornadofx/testapps/TaskStatusTest.kt deleted file mode 100644 index 5cc70f9..0000000 --- a/src/test/kotlin/tornadofx/testapps/TaskStatusTest.kt +++ /dev/null @@ -1,56 +0,0 @@ -package tornadofx.testapps - -import javafx.beans.property.SimpleStringProperty -import tornadofx.* - -class TaskStatusTest : View("Task Status Test") { - val status = TaskStatus() - val output = SimpleStringProperty("") - - override val root = borderpane { - top { - toolbar { - button("Run Async").action { - output.value += "\n" - runAsync(status) { - Thread.sleep(1000) - "hello" - } ui { - output.value += "$it\n" - } - } - button("Run Await").action { - output.value += "\n" - runAsync(status) { - Thread.sleep(1000) - "hello 2" - } ui { - output.value += "$it\n" - } - status.completed.awaitUntil() - output.value += "Await exited\n" - } - enableWhen { status.running.not() } - } - } - center { - textarea(output) - } - bottom { - label("Running...") { - visibleWhen { status.running } - } - } - } - - override fun onDock() { - status.completed.onChange { - output.value += "completed $it\n" - } - status.running.onChange { - output.value += "running $it\n" - } - } -} - -class TaskStatusApp : App(TaskStatusTest::class) diff --git a/src/test/kotlin/tornadofx/testapps/TodoTestApp.kt b/src/test/kotlin/tornadofx/testapps/TodoTestApp.kt deleted file mode 100644 index ba3529a..0000000 --- a/src/test/kotlin/tornadofx/testapps/TodoTestApp.kt +++ /dev/null @@ -1,83 +0,0 @@ -package tornadofx.testapps - -import javafx.beans.property.SimpleBooleanProperty -import javafx.beans.property.SimpleObjectProperty -import javafx.beans.property.SimpleStringProperty -import javafx.collections.FXCollections -import javafx.geometry.Pos -import javafx.scene.control.CheckBox -import javafx.scene.control.RadioButton -import javafx.scene.control.TableColumn -import javafx.scene.control.ToggleGroup -import tornadofx.* - -class TodoItem(text: String? = null, completed: Boolean = true) { - val textProperty = SimpleStringProperty(text) - var text by textProperty - - val completedProperty = SimpleBooleanProperty(completed) - var completed by completedProperty - - override fun toString() = "[${if (completed) "X" else " "}] $text" -} - -enum class TodoFilter { All, Completed, Active } - -class TodoList : View("Todo List") { - val todos = SortedFilteredList(FXCollections.observableArrayList(TodoItem("Item 1"), TodoItem("Item 2"), TodoItem("Item 3", false), TodoItem("Item 4"), TodoItem("Item 5"))) - val todoFilter = SimpleObjectProperty(TodoFilter.All) - - override val root = borderpane { - center { - tableview(todos) { - setPrefSize(300.0, 200.0) - column("Completed", TodoItem::completedProperty) { - sortType = TableColumn.SortType.DESCENDING - sortOrder.add(this) - cellFormat { - graphic = cache { - alignment = Pos.CENTER - checkbox { - selectedProperty().bindBidirectional(itemProperty()) - - action { - tableView.edit(index, tableColumn) - commitEdit(!isSelected) - sort() - } - } - } - } - } - column("Text", TodoItem::textProperty).makeEditable() - - } - } - bottom { - hbox { - togglegroup { - TodoFilter.values().forEach { - radiobutton(value = it) - } - bind(todoFilter) - } - } - todoFilter.onChange { - todos.refilter() - } - } - } - - init { - todos.predicate = { - when (todoFilter.value) { - TodoFilter.All -> true - TodoFilter.Completed -> it.completed - TodoFilter.Active -> !it.completed - } - } - } -} - -class TodoTestApp : WorkspaceApp(TodoList::class) - diff --git a/src/test/kotlin/tornadofx/testapps/ToggleButtonTestApp.kt b/src/test/kotlin/tornadofx/testapps/ToggleButtonTestApp.kt deleted file mode 100644 index b5930b1..0000000 --- a/src/test/kotlin/tornadofx/testapps/ToggleButtonTestApp.kt +++ /dev/null @@ -1,24 +0,0 @@ -package tornadofx.testapps - -import javafx.beans.property.SimpleStringProperty -import javafx.geometry.Insets -import tornadofx.* - -/** - * Test case for #785 - * - * Functions to bind both String and ObservableValue - * - * @author carl - */ - -class ToggleButtonTestView : View("Toggle Button Test") { - override val root = vbox { - togglebutton("String") - togglebutton(SimpleStringProperty("Observable")) - padding = Insets(10.0) - spacing = 4.0 - } -} - -class ToggleButtonTestApp : App(ToggleButtonTestView::class) diff --git a/src/test/kotlin/tornadofx/testapps/TransitionsTest.kt b/src/test/kotlin/tornadofx/testapps/TransitionsTest.kt deleted file mode 100644 index 19c2a38..0000000 --- a/src/test/kotlin/tornadofx/testapps/TransitionsTest.kt +++ /dev/null @@ -1,49 +0,0 @@ -package tornadofx.testapps - -import javafx.animation.Interpolator -import javafx.scene.paint.Color -import javafx.scene.shape.Rectangle -import tornadofx.* - -class TransitionsTestApp : App(TransitionsTestView::class) - -class TransitionsTestView : View() { - val r1 = Rectangle(20.0, 20.0, Color.RED) - val r2 = Rectangle(20.0, 20.0, Color.YELLOW) - val r3 = Rectangle(20.0, 20.0, Color.GREEN) - val r4 = Rectangle(20.0, 20.0, Color.BLUE) - - override val root = vbox { - button("Animate").action { - sequentialTransition { - timeline { - keyframe(0.5.seconds) { - keyvalue(r1.translateXProperty(), 50.0, interpolator = Interpolator.EASE_BOTH) - } - } - timeline { - keyframe(0.5.seconds) { - keyvalue(r2.translateXProperty(), 100.0, interpolator = Interpolator.EASE_BOTH) - } - } - timeline { - keyframe(0.5.seconds) { - keyvalue(r3.translateXProperty(), 150.0, interpolator = Interpolator.EASE_BOTH) - } - } - timeline { - keyframe(0.5.seconds) { - keyvalue(r4.translateXProperty(), 200.0, interpolator = Interpolator.EASE_BOTH) - } - } - } - } - pane { - add(r1) - add(r2) - add(r3) - add(r4) - } - } -} - diff --git a/src/test/kotlin/tornadofx/testapps/ViewDockingApp.kt b/src/test/kotlin/tornadofx/testapps/ViewDockingApp.kt deleted file mode 100644 index 6cd1afc..0000000 --- a/src/test/kotlin/tornadofx/testapps/ViewDockingApp.kt +++ /dev/null @@ -1,79 +0,0 @@ -package tornadofx.testapps - -import javafx.beans.property.SimpleIntegerProperty -import javafx.scene.Scene -import javafx.stage.Stage -import tornadofx.* -import java.util.concurrent.atomic.AtomicInteger - -class ViewDockingApp : App(PrimaryDockingView::class) - -open class PrimaryDockingView : View() { - - companion object { - val instanceCounter = AtomicInteger() - } - val instanceId = instanceCounter.getAndIncrement() - val dockCounterProperty = SimpleIntegerProperty() - var dockCounter by dockCounterProperty - val undockCounterProperty = SimpleIntegerProperty() - var undockCounter by undockCounterProperty - - init { - println("$tag.init()") - } - - open val tag: String - get() = "PrimaryDockingView" - - override val root = vbox { - form { - fieldset { - field("Instance ID") { - label(instanceId.toString()) - } - field("Dock Counter") { - label(dockCounterProperty) { - style { - fontSize = 48.pt - } - } - } - field("Undock Counter") { - label(undockCounterProperty) { - style { - fontSize = 48.pt - } - } - } - } - } - } - - override fun onDock() { - super.onDock() - dockCounter++ - println("$tag.dockCounter: $dockCounter") - } - - override fun onUndock() { - super.onUndock() - undockCounter++ - println("$tag.undockCounter: $undockCounter") - } -} - -class SecondaryDockingView : PrimaryDockingView() { - - override val tag: String - get() = "SecondaryDockingView" -} - -class NoPrimaryViewDockingApp : App() { - - override fun start(stage: Stage) { - super.start(stage) - stage.scene = Scene(find().root) - stage.show() - } -} \ No newline at end of file diff --git a/src/test/kotlin/tornadofx/testapps/WizardTestApp.kt b/src/test/kotlin/tornadofx/testapps/WizardTestApp.kt deleted file mode 100644 index d6ce34d..0000000 --- a/src/test/kotlin/tornadofx/testapps/WizardTestApp.kt +++ /dev/null @@ -1,109 +0,0 @@ -package tornadofx.testapps - -import javafx.collections.FXCollections -import javafx.geometry.Pos -import javafx.scene.control.Button -import javafx.scene.control.ButtonBar -import javafx.scene.input.KeyCode -import javafx.scene.input.KeyEvent -import tornadofx.* -import tornadofx.tests.Customer -import tornadofx.tests.CustomerModel - -class WizardTestApp : WorkspaceApp(WizardCustomerList::class) - -class CustomerWizard : Wizard("Create customer", "Provide customer information") { - val customer: CustomerModel by inject() - - override val canGoNext = currentPageComplete - override val canFinish = allPagesComplete - - init { - add() - add() - customer.item = Customer() - graphic = resources.imageview("/tornadofx/tests/person.png") - showSteps = true - stepLinksCommits = true - showHeader = true - numberedSteps = true - showStepsHeader = false - enableStepLinks = true - enterProgresses = true - } - - override fun onCancel() { - confirm("Confirm cancel", "Do you really want to loose your progress?") { - cancel() - } - } -} - -class WizardStep1 : View("Customer Data") { - val customer: CustomerModel by inject() - val wizard: CustomerWizard by inject() - - override val complete = customer.valid(customer.name) - - override val root = form { - fieldset(title) { - field("Type") { - combobox(customer.type, Customer.Type.values().toList()) - } - field("Name") { - textfield(customer.name) { - required() - // Make sure we get focus instead of the type combo - whenDocked { requestFocus() } - } - } - hbox { - alignment = Pos.BASELINE_RIGHT - hyperlink("Skip") { - action { - wizard.currentPage = wizard.pages.last() - } - } - } - } - } -} - -class WizardStep2 : View("Address") { - val customer: CustomerModel by inject() - override val complete = customer.valid(customer.zip, customer.city) - - override val root = form { - fieldset(title) { - field("Zip/City") { - textfield(customer.zip) { - prefColumnCount = 5 - required() - } - textarea(customer.city) { - required() - } - } - } - } -} - -class WizardCustomerList : View() { - val customers = FXCollections.observableArrayList() - - override val root = tableview(customers) { - column("Name", Customer::nameProperty) - columnResizePolicy = SmartResize.POLICY - } - - override fun onDock() { - with(workspace) { - button("_Add").action { - find { - onComplete { customers.add(customer.item) } - openModal() - } - } - } - } -} \ No newline at end of file diff --git a/src/test/kotlin/tornadofx/tests/AsyncTest.kt b/src/test/kotlin/tornadofx/tests/AsyncTest.kt deleted file mode 100644 index e1d4514..0000000 --- a/src/test/kotlin/tornadofx/tests/AsyncTest.kt +++ /dev/null @@ -1,101 +0,0 @@ -package tornadofx.tests - -import javafx.scene.control.Button -import javafx.scene.layout.BorderPane -import javafx.scene.layout.Pane -import javafx.scene.layout.StackPane -import javafx.stage.Stage -import org.junit.Assert -import org.junit.Test -import org.testfx.api.FxToolkit -import tornadofx.* -import java.util.concurrent.CountDownLatch -import kotlin.test.assertEquals -import kotlin.test.assertFalse -import kotlin.test.assertNotEquals -import kotlin.test.assertTrue - -class AsyncTest { - val primaryStage: Stage = FxToolkit.registerPrimaryStage() - - @Test - fun runAsyncWithOverlay() { - //Initially container has embedded node - val container = BorderPane() - val node = Pane() - val mask = Pane() - - container.center = node - assertEquals(container.center, node) - - //This latch will be used to control asynchronously executed task, it's a part of the test - val latch = Latch() - assertTrue(latch.locked) - - //This is a standard CountDownLatch and will be used to synchronize test thread with application thread - val appThreadLatch = CountDownLatch(1) - - //ui is needed here because only after task is executed we can check if overlay is removed propertly - //and it can only be used from within a UIComponent, so we need a temporary object - val component = object : Controller() { - fun run() = node.runAsyncWithOverlay(latch, null, mask) ui { appThreadLatch.countDown() } - } - component.run() - - //Until latch is released, a node is replaced with StackPane containing both the original component and the mask - assertNotEquals(node, container.center) - assertTrue(container.center is StackPane) - assertTrue((container.center as StackPane).children.containsAll(setOf(node, mask))) - - //The working thread (test thread in this case) proceeds, which should result in removing overlay - latch.release() - assertFalse(latch.locked) - - //Waiting until we have confirmed post-task ui execution - appThreadLatch.await() - - //At this point overlay should be removed and node should be again in its original place - assertEquals(node, container.center) - } - - @Test - fun latch() { - //Latch set for 5 concurrent tasks - val count = 5 - val latch = Latch(count) - val button = Button() - - assertFalse(button.disabledProperty().value) - - //Button should stay disabled until all tasks are over - button.disableWhen(latch.lockedProperty()) - - (1..count).forEach { - assertTrue(button.disabledProperty().value) - assertTrue(latch.locked) - assertTrue(latch.lockedProperty().value) - latch.countDown() - //Latch count should decrease after each iteration - Assert.assertEquals(count, (it + latch.count).toInt()) - } - - assertFalse(button.disabledProperty().value) - assertFalse(latch.locked) - - //Should have no effect anyway - latch.release() - assertFalse(button.disabledProperty().value) - assertFalse(latch.locked) - } - - @Test - fun runAsync() { - tornadofx.runAsync(daemon = true) { - assertTrue { Thread.currentThread().isDaemon } - } - tornadofx.runAsync { - assertFalse { Thread.currentThread().isDaemon } - } - } - -} \ No newline at end of file diff --git a/src/test/kotlin/tornadofx/tests/BindingTest.kt b/src/test/kotlin/tornadofx/tests/BindingTest.kt deleted file mode 100644 index 3312099..0000000 --- a/src/test/kotlin/tornadofx/tests/BindingTest.kt +++ /dev/null @@ -1,90 +0,0 @@ -package tornadofx.tests - -import javafx.beans.binding.BooleanExpression -import javafx.beans.property.SimpleBooleanProperty -import javafx.beans.property.SimpleDoubleProperty -import javafx.collections.FXCollections -import javafx.scene.control.Label -import javafx.stage.Stage -import org.junit.Assert -import org.junit.Test -import org.testfx.api.FxToolkit -import tornadofx.* -import java.text.DecimalFormat -import java.text.DecimalFormatSymbols -import java.util.* - -class BindingTest { - val primaryStage: Stage = FxToolkit.registerPrimaryStage() - - @Test - fun testBindingFormat() { - val property = SimpleDoubleProperty(Math.PI) - - val label = Label() - label.bind(property, format = DecimalFormat("#0.0", DecimalFormatSymbols.getInstance(Locale.ENGLISH))) - - Assert.assertEquals("3.1", label.text) - } - - @Test - fun observableListBinding() { - val elements = FXCollections.observableArrayList("Hello", "World") - val binding = stringBinding(elements, elements) { this.joinToString(" ")} - val uielement = Label().apply { bind(binding) } - Assert.assertEquals("Hello World", uielement.text) - elements.setAll("Hello", "Changed") - Assert.assertEquals("Hello Changed", uielement.text) - } - - @Test - fun observableMapBinding() { - val map = FXCollections.observableHashMap() - val list = observableListOf() - map["0123456"] = 3 - list.bind(map){k,v-> k[v]} - Assert.assertEquals(list, listOf('3')) - map["0123456"] = 4 - Assert.assertEquals(list, listOf('4')) - map["abcdefg"] = 3 - Assert.assertTrue( - "expected ['d', '4'] got ${list.joinToString() }}", - list.containsAll(listOf('d', '4')) && list.size == 2 - ) - } - - @Test - fun nestedBinding() { - val father = Person("Mr Father", 50) - val stepFather = Person("Mr Step Father", 40) - val child = Person("Firstborn Child", 18) - child.parent = father - - val fatherName = child.parentProperty().select(Person::nameProperty) - Assert.assertEquals("Mr Father", fatherName.value) - fatherName.value = "Mister Father" - Assert.assertEquals("Mister Father", father.name) - child.parent = stepFather - Assert.assertEquals("Mr Step Father", fatherName.value) - } - - @Test - fun booleanBinding() { - val mylist = FXCollections.observableArrayList() - val complete = booleanBinding(mylist) { isNotEmpty() } - Assert.assertFalse(complete.value) - mylist.add("One") - Assert.assertTrue(complete.value) - } - - @Test - fun booleanListBinding() { - val mylist = FXCollections.observableArrayList() - val complete = booleanListBinding(mylist) { this } - Assert.assertFalse(complete.value) - mylist.add(SimpleBooleanProperty(true)) - Assert.assertTrue(complete.value) - mylist.add(SimpleBooleanProperty(false)) - Assert.assertFalse(complete.value) - } -} \ No newline at end of file diff --git a/src/test/kotlin/tornadofx/tests/BuildersTest.kt b/src/test/kotlin/tornadofx/tests/BuildersTest.kt deleted file mode 100644 index b351c54..0000000 --- a/src/test/kotlin/tornadofx/tests/BuildersTest.kt +++ /dev/null @@ -1,33 +0,0 @@ -package tornadofx.tests - -import javafx.scene.layout.StackPane -import javafx.scene.text.Text -import javafx.stage.Stage -import org.hamcrest.Matchers -import org.junit.Before -import org.junit.Test -import org.testfx.api.FxAssert.verifyThat -import org.testfx.api.FxToolkit -import org.testfx.matcher.control.TextMatchers -import tornadofx.* - -class BuildersTest { - val primaryStage: Stage = FxToolkit.registerPrimaryStage() - - lateinit var pane: StackPane - - @Before - fun setup() { - pane = StackPane() - } - - @Test - fun text_builder() { - // expect: - verifyThat(pane.text(), Matchers.instanceOf(Text::class.java)) - verifyThat(pane.text(), TextMatchers.hasText("")) - verifyThat(pane.text("foo"), TextMatchers.hasText("foo")) - verifyThat(pane.text() { text = "bar" }, TextMatchers.hasText("bar")) - } - -} diff --git a/src/test/kotlin/tornadofx/tests/ChildInterceptorTest.kt b/src/test/kotlin/tornadofx/tests/ChildInterceptorTest.kt deleted file mode 100644 index 06217c0..0000000 --- a/src/test/kotlin/tornadofx/tests/ChildInterceptorTest.kt +++ /dev/null @@ -1,82 +0,0 @@ -package tornadofx.tests - -import javafx.event.EventTarget -import javafx.scene.Node -import javafx.scene.layout.Pane -import javafx.stage.Stage -import org.junit.AfterClass -import org.junit.BeforeClass -import org.junit.Ignore -import org.junit.Test -import org.testfx.api.FxToolkit -import tornadofx.* -import kotlin.test.assertEquals - -abstract class BaseInterceptor : ChildInterceptor { - var intercepted: Boolean = false -} - -class DummyPane : Pane() - -fun EventTarget.dummyPane(op: DummyPane.() -> Unit = {}) = DummyPane().attachTo(this, op) - -class FirstInterceptor : BaseInterceptor() { - override fun invoke(parent: EventTarget, node: Node, index: Int?): Boolean = when (parent) { - is DummyPane -> { - intercepted = true - true - } - else -> false - } -} - -class SecondInterceptor : BaseInterceptor() { - override fun invoke(parent: EventTarget, node: Node, index: Int?): Boolean = when (parent) { - is DummyPane -> { - intercepted = true - true - } - else -> false - } -} - -class MyTestView : View("TestView") { - override val root = dummyPane { - button {} - } -} - -class ChildInterceptorTest { - - companion object { - val app = App(MyTestView::class) - - @JvmStatic - @BeforeClass - fun before() { - val primaryStage: Stage = FxToolkit.registerPrimaryStage() - FX.registerApplication(FxToolkit.setupApplication { - app - }, primaryStage) - } - - @JvmStatic - @AfterClass - fun after() { - FxToolkit.cleanupApplication(app) - } - } - - @Ignore // TODO: Verify behavior change w.r.t. JDK 8 version. - @Test - fun interceptorsLoaded() { - assertEquals(FX.childInterceptors.size, 2) - } - - - @Ignore // TODO: Verify behavior change w.r.t. JDK 8 version. - @Test - fun onlyOneInterceptorShouldWork() { - assertEquals(1, FX.childInterceptors.map { it as BaseInterceptor }.filter { it.intercepted }.size) - } -} diff --git a/src/test/kotlin/tornadofx/tests/ClipboardTest.kt b/src/test/kotlin/tornadofx/tests/ClipboardTest.kt deleted file mode 100644 index 492cc86..0000000 --- a/src/test/kotlin/tornadofx/tests/ClipboardTest.kt +++ /dev/null @@ -1,43 +0,0 @@ -package tornadofx.tests - -import javafx.scene.input.DataFormat -import javafx.stage.Stage -import org.junit.Assert -import org.junit.Test -import org.testfx.api.FxToolkit -import tornadofx.Controller -import tornadofx.FX -import tornadofx.putString -import tornadofx.setContent - -class ClipboardTest { - - val primaryStage: Stage = FxToolkit.registerPrimaryStage() - - val CustomDataFormat = DataFormat("myFormat") - - @Test - fun testClipboard() { - val string1 = "TornadoFX Clipboard Test" - val string2 = "TornadoFX Clipboard Test 2" - - FX.runAndWait { - object : Controller() { - init { - clipboard.setContent { - putString(string1) - put(CustomDataFormat, 42) - } - - Assert.assertEquals(string1, clipboard.string) - Assert.assertEquals(42, clipboard.getContent(CustomDataFormat)) - - clipboard.putString(string2) - Assert.assertEquals(string2, clipboard.string) - Assert.assertNull(clipboard.getContent(CustomDataFormat)) - } - } - } - - } -} diff --git a/src/test/kotlin/tornadofx/tests/CollectionsTest.kt b/src/test/kotlin/tornadofx/tests/CollectionsTest.kt deleted file mode 100644 index a8d013f..0000000 --- a/src/test/kotlin/tornadofx/tests/CollectionsTest.kt +++ /dev/null @@ -1,172 +0,0 @@ -package tornadofx.tests - -import org.junit.Test -import tornadofx.* -import kotlin.test.assertEquals -import kotlin.test.assertFalse -import kotlin.test.assertTrue - -class CollectionsTest { - - @Test - fun testMoveWithValidIndex() { - val list = mutableListOf(1, 2, 3, 4) - - list.move(2, 3) - - assertEquals(mutableListOf(1, 3, 4, 2), list) - } - - @Test - fun testMoveWithInvalidIndex() { - val list = mutableListOf(1, 2, 3, 4) - - try { - list.move(2, 102) - } catch (e: Exception) { - assert(e is IllegalStateException) - } - } - - @Test - fun testMoveWithInvalidItem() { - val list = mutableListOf(1, 2, 3, 4) - - list.move(10, 1) - - assertEquals(mutableListOf(1, 2, 3, 4), list) - } - - @Test - fun testMoveAtForward() { - val list = mutableListOf(1, 2, 3, 4) - val newIndex = 2 - - list.moveAt(0, newIndex) - - assertEquals(1, list[newIndex]) - } - - @Test - fun testMoveAtBackward() { - val list = mutableListOf(1, 2, 3, 4) - val newIndex = 0 - - list.moveAt(2, newIndex) - - assertEquals(3, list[newIndex]) - } - - @Test - fun testMoveAtWithInvalidNewIndex() { - val list = mutableListOf(1, 2, 3, 4) - val newIndex = 10 - - try { - list.moveAt(2, newIndex) - } catch (e: Exception) { - assert(e is IllegalStateException) - } - } - - - @Test - fun testMoveAllValidIndex() { - val list = mutableListOf(1, 2, 3, 4, 5) - - list.moveAll(2, { it < 3 }) - - assertEquals(mutableListOf(3, 4, 1, 2, 5), list) - } - - @Test - fun testMoveAllInvalidIndex() { - val list = mutableListOf(1, 2, 3, 4, 5) - - try { - list.moveAll(101, { it < 3 }) - } catch (e: Exception) { - assert(e is IllegalStateException) - } - } - - @Test - fun testMoveUpAtValidIndex() { - val list = mutableListOf(0, 1, 2, 3, 4) - - list.moveUpAt(2) - - assertEquals(listOf(0, 2, 1, 3, 4), list) - } - - @Test - fun testMoveUpAtInvalidIndex() { - val list = mutableListOf(0, 1, 2, 3, 4) - - try { - list.moveUpAt(10) - } catch (e: Exception) { - assert(e is IllegalStateException) - } - } - - @Test - fun testMoveDownAtValidIndex() { - val list = mutableListOf(0, 1, 2, 3, 4) - - list.moveDownAt(2) - - assertEquals(listOf(0, 1, 3, 2, 4), list) - } - - @Test - fun testMoveDownAtInvalidIndex() { - val list = mutableListOf(0, 1, 2, 3, 4) - - try { - list.moveDownAt(10) - } catch (e: Exception) { - assert(e is IllegalStateException) - } - } - - @Test - fun testMoveUpWithValidItem() { - val list = mutableListOf(0, 1, 2, 3, 4) - - val result = list.moveUp(2) - - assertTrue(result) - assertEquals(listOf(0, 2, 1, 3, 4), list) - } - - @Test - fun testMoveUpWithInvalidItem() { - val list = mutableListOf(0, 1, 2, 3, 4) - - val result = list.moveUp(10) - - assertFalse(result) - assertEquals(listOf(0, 1, 2, 3, 4), list) - } - - @Test - fun testMoveDownWithValidItem() { - val list = mutableListOf(0, 1, 2, 3, 4) - - val result = list.moveDown(2) - - assertTrue(result) - assertEquals(listOf(0, 1, 3, 2, 4), list) - } - - @Test - fun testMoveDownWithInvalidItem() { - val list = mutableListOf(0, 1, 2, 3, 4) - - val result = list.moveDown(10) - - assertFalse(result) - assertEquals(listOf(0, 1, 2, 3, 4), list) - } -} \ No newline at end of file diff --git a/src/test/kotlin/tornadofx/tests/ComponentTest.kt b/src/test/kotlin/tornadofx/tests/ComponentTest.kt deleted file mode 100644 index 99cb609..0000000 --- a/src/test/kotlin/tornadofx/tests/ComponentTest.kt +++ /dev/null @@ -1,68 +0,0 @@ -package tornadofx.tests - -import javafx.stage.Stage -import org.junit.Test -import org.testfx.api.FxToolkit -import tornadofx.Fragment -import tornadofx.singleAssign -import tornadofx.vbox -//import tornadofx.* -import kotlin.test.assertFalse -import kotlin.test.assertNull -import kotlin.test.assertTrue -import kotlin.test.fail - -class ComponentTest { - - val primaryStage: Stage = FxToolkit.registerPrimaryStage() - - @Test - fun testParam2() { - - val mainFragment = MainFragment() - - try { - mainFragment.subFragmentNoParam.booleanParam - fail("IllegalStateException should have been thrown") - } catch (e: IllegalStateException) { - // param not set - } - - assertTrue(mainFragment.subFragmentNoParam.booleanParamWithDefault, - "parameter value should match default value") - - assertFalse(mainFragment.subFragmentWithParam.booleanParam, - "parameter value should match parameter passed in") - - assertNull(mainFragment.subFragmentWithParam.nullableBooleanParam, - "nullable parameter value should match parameter passed in") - } - - class MainFragment : Fragment() { - - var subFragmentNoParam: SubFragment by singleAssign() - - var subFragmentWithParam: SubFragment by singleAssign() - - override val root = vbox { - add { - subFragmentNoParam = this - } - add( - SubFragment::booleanParam to false, - SubFragment::nullableBooleanParam to null - ){ - subFragmentWithParam = this - } - } - - } - - class SubFragment : Fragment() { - val booleanParam: Boolean by param() - val booleanParamWithDefault: Boolean by param(defaultValue = true) - val nullableBooleanParam: Boolean? by param() - override val root = vbox() - } - -} \ No newline at end of file diff --git a/src/test/kotlin/tornadofx/tests/ControlsTest.kt b/src/test/kotlin/tornadofx/tests/ControlsTest.kt deleted file mode 100644 index ccff450..0000000 --- a/src/test/kotlin/tornadofx/tests/ControlsTest.kt +++ /dev/null @@ -1,112 +0,0 @@ -package tornadofx.tests - -import javafx.beans.property.SimpleDoubleProperty -import javafx.beans.property.SimpleIntegerProperty -import javafx.beans.property.SimpleStringProperty -import javafx.embed.swing.JFXPanel -import javafx.scene.layout.VBox -import javafx.util.StringConverter -import javafx.util.converter.NumberStringConverter -import org.junit.Assert -import org.junit.Before -import org.junit.Test -import org.testfx.api.FxToolkit -import tornadofx.* -import java.text.NumberFormat -import java.util.* - -/** - * @author carl - */ - -class TestView : View() { - override val root = VBox() -} - -class ControlsTest { - - @Before - fun setupFX() { - FxToolkit.registerPrimaryStage() - } - - @Test - fun testTextfield() { - - JFXPanel() - - val view = TestView() - - view.textfield(SimpleStringProperty("carl")) - - view.textfield(SimpleIntegerProperty(101), NumberStringConverter()) - - view.textfield() { - bind(SimpleIntegerProperty(102)) - } - - view.textfield(SimpleIntegerProperty(103)) // w. fix 184 - - view.textfield(SimpleDoubleProperty(100.131)) // also fixed 184 - } - - @Test - fun testImageview() { - - val view = TestView() - val property = SimpleStringProperty(null) - val imageView = view.imageview(property) - - Assert.assertNull(imageView.image) - - property.value = "/tornadofx/tests/person.png" - - Assert.assertNotNull(imageView.image) - } - - @Test - fun testLabelWithStringObservable() { - - val view = TestView() - val property = SimpleStringProperty("Daan") - val label = view.label(property) - val labelWithConverter = view.label(property, converter = object : StringConverter() { - override fun toString(string: String?) = string?.toUpperCase() ?: "" - override fun fromString(string: String?) = throw NotImplementedError() - }) - - Assert.assertEquals("Daan", label.text) - Assert.assertEquals("DAAN", labelWithConverter.text) - } - - @Test - fun testLabelWithIntegerObservable() { - - val view = TestView() - val property = SimpleIntegerProperty(12718) - val label = view.label(property) - val labelWithConverter = view.label(property, converter = NumberStringConverter(Locale.US)) - - Assert.assertEquals("12718", label.text) - Assert.assertEquals(NumberFormat.getNumberInstance(Locale.US).format(12718), labelWithConverter.text) - } - - @Test - fun testSliderRange() { - val view = TestView() - val slider = view.slider(24..42) - Assert.assertEquals(24.0, slider.min, 10e-5) - Assert.assertEquals(42.0, slider.max, 10e-5) - } - - @Test - fun testSplitMenuButton() { - val view = TestView() - val button = view.splitmenubutton("Text") { - item("Item Name") - } - - Assert.assertEquals(button.text, "Text") - Assert.assertEquals(button.items.first().text, "Item Name") - } -} diff --git a/src/test/kotlin/tornadofx/tests/Customer.kt b/src/test/kotlin/tornadofx/tests/Customer.kt deleted file mode 100644 index e0ad21d..0000000 --- a/src/test/kotlin/tornadofx/tests/Customer.kt +++ /dev/null @@ -1,46 +0,0 @@ -package tornadofx.tests - -import javafx.beans.property.SimpleObjectProperty -import javafx.beans.property.SimpleStringProperty -import tornadofx.* -import javax.json.JsonObject - -class Customer : JsonModel { - enum class Type { Private, Company } - - val nameProperty = SimpleStringProperty() - var name by nameProperty - - val zipProperty = SimpleStringProperty() - var zip by zipProperty - - val cityProperty = SimpleStringProperty() - var city by cityProperty - - val typeProperty = SimpleObjectProperty(Type.Private) - var type by typeProperty - - override fun toString(): String { - return "Customer(name=$name, zip=$zip, city=$city)" - } - - override fun updateModel(json: JsonObject) { - with(json) { - name = string("name") - } - } - - override fun toJSON(json: JsonBuilder) { - with(json) { - add("name", name) - } - } - -} - -class CustomerModel : ItemViewModel() { - val name = bind(Customer::nameProperty, autocommit = true) - val zip = bind(Customer::zipProperty, autocommit = true) - val city = bind(Customer::cityProperty, autocommit = true) - val type = bind(Customer::typeProperty, autocommit = true) -} diff --git a/src/test/kotlin/tornadofx/tests/EventBusTest.kt b/src/test/kotlin/tornadofx/tests/EventBusTest.kt deleted file mode 100644 index c3a1660..0000000 --- a/src/test/kotlin/tornadofx/tests/EventBusTest.kt +++ /dev/null @@ -1,58 +0,0 @@ -package tornadofx.tests - -import javafx.application.Platform -import javafx.stage.Stage -import org.junit.Test -import org.testfx.api.FxToolkit -import tornadofx.* -import java.util.concurrent.atomic.AtomicBoolean -import java.util.concurrent.atomic.AtomicInteger -import kotlin.test.assertTrue - -class EventBusTest { - val primaryStage: Stage = FxToolkit.registerPrimaryStage() - private val success = AtomicBoolean(true) - private val latch = Latch() - - init { - FxToolkit.setupFixture { - Thread.setDefaultUncaughtExceptionHandler { _, t -> - t.printStackTrace() - success.set(false) - latch.countDown() - } - } - } - - val iterations: Int = 100 - val count = AtomicInteger(0) - val view = object : View() { - - init { - for (i in 1..iterations) { - subscribe(times = i) { - callOnUndock() - print(" ${count.getAndIncrement()} ") - callOnDock() - } - } - } - - override val root = vbox {} - } - - @Test - fun testUnsubscribe() { - Platform.runLater { - view.callOnDock() - repeat(iterations / 2) { - view.fire(FXEvent()) - view.fire(FXEvent(EventBus.RunOn.BackgroundThread)) - } - latch.countDown() - } - latch.await() - assertTrue(success.get()) - } -} - diff --git a/src/test/kotlin/tornadofx/tests/FXMLTest.kt b/src/test/kotlin/tornadofx/tests/FXMLTest.kt deleted file mode 100644 index 08befbb..0000000 --- a/src/test/kotlin/tornadofx/tests/FXMLTest.kt +++ /dev/null @@ -1,85 +0,0 @@ -package tornadofx.tests - -import javafx.scene.Parent -import javafx.scene.control.Label -import javafx.scene.control.ListView -import javafx.scene.control.TextField -import javafx.scene.layout.Pane -import javafx.scene.layout.VBox -import javafx.stage.Stage -import org.junit.Assert -import org.junit.Test -import org.testfx.api.FxToolkit -import tornadofx.* - -class FXMLTest { - val primaryStage: Stage = FxToolkit.registerPrimaryStage() - - @Test(expected = IllegalArgumentException::class) - fun wrongFXId() { - object : Fragment() { - override val root: VBox by fxml("/tornadofx/tests/FXMLTest.fxml") - val myLabelx : Label by fxid() - - init { - myLabelx.text = "Expect log warning and RuntimeException" - } - } - } - - @Test(expected = ClassCastException::class) - fun wrongFXType() { - object : Fragment() { - override val root: VBox by fxml("/tornadofx/tests/FXMLTest.fxml") - val myLabel : TextField by fxid() - - init { - myLabel.text = "Expect ClassCastException" - } - } - } - - @Test - fun simpleFormFXML() { - val simpleForm = find() - Assert.assertNotNull(simpleForm.tfField1) - Assert.assertNotNull(simpleForm.tfField2) - Assert.assertNotNull(simpleForm.tfField3) - } - - @Test - fun composedFormFXML() { - - val composedForm = find() - - Assert.assertNotNull(composedForm.searchPane) - Assert.assertNotNull(composedForm.listPane) - - // searchPane > HBox > tfSearch - Assert.assertTrue( - (composedForm.searchPane.children[0] as Parent).childrenUnmodifiable[1] is TextField ) - - // listPane > AnchorPane > lvItems - Assert.assertEquals(ListView::class.java, - (composedForm.listPane.children[0] as Parent).childrenUnmodifiable[0].javaClass) - - } - -} - -class SimpleForm : View() { - override val root: VBox by fxml("/tornadofx/tests/SimpleForm.fxml") - val tfField1 : TextField by fxid() - val tfField2 : TextField by fxid() - val tfField3 : TextField by fxid() - fun ok() {} - fun cancel() {} -} - -class ComposedForm : View() { - override val root : VBox by fxml("/tornadofx/tests/ComposedForm.fxml") - val searchPane : Pane by fxid() - val listPane : Pane by fxid() - fun ok() {} - fun cancel() {} -} diff --git a/src/test/kotlin/tornadofx/tests/FormTest.kt b/src/test/kotlin/tornadofx/tests/FormTest.kt deleted file mode 100644 index b688cce..0000000 --- a/src/test/kotlin/tornadofx/tests/FormTest.kt +++ /dev/null @@ -1,21 +0,0 @@ -package tornadofx.tests - -import javafx.stage.Stage -import org.junit.Test -import org.testfx.api.FxToolkit -import tornadofx.* -import kotlin.test.assertEquals -import kotlin.test.assertTrue - -class FormTest { - val primaryStage: Stage = FxToolkit.registerPrimaryStage() - - @Test fun formLegendVisible() { - val form = Form().apply { - fieldset("Hello world") - } - val fieldset = form.select
(Stylesheet.fieldset) - assertEquals("Hello world", fieldset.text) - assertTrue(fieldset.isVisible, "Fieldset should be visible") - } -} \ No newline at end of file diff --git a/src/test/kotlin/tornadofx/tests/InternalWindowClosingTest.kt b/src/test/kotlin/tornadofx/tests/InternalWindowClosingTest.kt deleted file mode 100644 index cb6b06b..0000000 --- a/src/test/kotlin/tornadofx/tests/InternalWindowClosingTest.kt +++ /dev/null @@ -1,43 +0,0 @@ -package tornadofx.tests - -import javafx.scene.Scene -import javafx.scene.layout.Pane -import javafx.stage.Stage -import org.junit.Ignore -import org.junit.Test -import org.testfx.api.FxToolkit -import tornadofx.* -import kotlin.test.assertFalse -import kotlin.test.assertNotNull -import kotlin.test.assertNull - -/** - * Tests if it's possible to open an [InternalWindow] instance and then close it using [UIComponent.close] - */ -class InternalWindowClosingTest { - val primaryStage: Stage = FxToolkit.registerPrimaryStage() - - @Ignore // TODO: Fails in JDK 10 - @Test - fun testClosing() { - val owner = Pane() - - val view = object : View() { - override val root = pane() - fun executeClose() { close() } - } - - FxToolkit.setupFixture { - primaryStage.scene = Scene(owner) - primaryStage.show() - val iw = InternalWindow(null, true, true, true) - iw.open(view, owner) - assertNotNull(iw.scene) - // Why do we assume that the view should be docked because we open an internal window inside it? -// assertTrue(view.isDocked) - view.executeClose() - assertNull(iw.scene) - assertFalse(view.isDocked) - } - } -} \ No newline at end of file diff --git a/src/test/kotlin/tornadofx/tests/JavaPerson.java b/src/test/kotlin/tornadofx/tests/JavaPerson.java deleted file mode 100644 index 8e96276..0000000 --- a/src/test/kotlin/tornadofx/tests/JavaPerson.java +++ /dev/null @@ -1,102 +0,0 @@ -package tornadofx.tests; - -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; -import java.util.ArrayList; -import java.util.List; - -public class JavaPerson { - - private PropertyChangeSupport pcs; - private Integer id; - private String name; - private String department; - private String primaryEmail; - private String secondaryEmail; - private List employees = new ArrayList<>(); - - public JavaPerson(){ - pcs = new PropertyChangeSupport(this); - } - - public JavaPerson( String name, String department, String primaryEmail, String secondaryEmail ){ - this( name, department, primaryEmail, secondaryEmail, null ); - } - - public JavaPerson( String name, String department, String primaryEmail, String secondaryEmail, List employees ){ - this.name = name; - this.department = department; - this.primaryEmail = primaryEmail; - this.secondaryEmail = secondaryEmail; - this.employees = employees; - } - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - Integer oldValue = this.id; - this.id = id; - pcs.firePropertyChange("id",oldValue,id); - } - - public String getName() { - return name; - } - - public void setName(String name) { - String oldValue = this.name; - this.name = name; - pcs.firePropertyChange("name",oldValue,name); - } - - public String getDepartment() { - return department; - } - - public void setDepartment(String department) { - this.department = department; - } - - public String getPrimaryEmail() { - return primaryEmail; - } - - public void setPrimaryEmail(String primaryEmail) { - this.primaryEmail = primaryEmail; - } - - public String getSecondaryEmail() { - return secondaryEmail; - } - - public void setSecondaryEmail(String secondaryEmail) { - this.secondaryEmail = secondaryEmail; - } - - public List getEmployees() { - return employees; - } - - public void setEmployees(List employees) { - this.employees = employees; - } - - public String toString() { - return "JavaPerson{" + - "id=" + id + - ", name='" + name + '\'' + - '}'; - } - - public void addPropertyChangeListener(PropertyChangeListener listener) { - this.pcs.addPropertyChangeListener(listener); - } - - public void removePropertyChangeListener(PropertyChangeListener listener) { - this.pcs.removePropertyChangeListener(listener); - } - - -} diff --git a/src/test/kotlin/tornadofx/tests/JsonTest.kt b/src/test/kotlin/tornadofx/tests/JsonTest.kt deleted file mode 100644 index 491a280..0000000 --- a/src/test/kotlin/tornadofx/tests/JsonTest.kt +++ /dev/null @@ -1,140 +0,0 @@ -package tornadofx.tests - -import javafx.beans.property.SimpleStringProperty -import org.junit.Assert -import org.junit.Test -import tornadofx.* -import java.time.LocalDate - -class JsonTest { - - class AutoPerson : JsonModelAuto { - val firstNameProperty = SimpleStringProperty() - var firstName by firstNameProperty - - var lastName by property() - fun lastNameProperty() = getProperty(AutoPerson::lastName) - - var dob by property() - fun dobProperty() = getProperty(AutoPerson::dob) - - var type: Int? = null - var global = false - } - - class AutoPerson2 ( - firstName: String? = null, - lastName: String? = null, - dob: LocalDate? = null, - type: Int? = null, - global: Boolean? = null - ): JsonModelAuto { - - var firstName by property(firstName) - fun firstNameProperty() = getProperty(AutoPerson2::firstName) - - var lastName by property(lastName) - fun lastNameProperty() = getProperty(AutoPerson2::lastName) - - var dob by property(dob) - fun dobProperty() = getProperty(AutoPerson2::dob) - - var type by property(type) - fun typeProperty() = getProperty(AutoPerson2::type) - - var global by property(global) - fun globalProperty() = getProperty(AutoPerson2::global) - } - - - @Test - fun automodel() { - val p = AutoPerson().apply { - firstName = "John" - lastName = "Doe" - dob = LocalDate.of(1970, 6, 12) - type = 42 - global = true - } - val json = """{"dob":"1970-06-12","firstName":"John","global":true,"lastName":"Doe","type":42}""" - Assert.assertEquals(json, p.toJSON().toString()) - val l = loadJsonModel(json) - Assert.assertEquals("John", l.firstName) - Assert.assertEquals("Doe", l.lastName) - Assert.assertEquals(LocalDate.of(1970, 6, 12), l.dob) - Assert.assertEquals(42, l.type) - Assert.assertEquals(true, l.global) - Assert.assertEquals(json, l.toJSON().toString()) - } - - @Test - fun automodelRoundTrip() { - val writtenP = AutoPerson().apply { - firstName = "John" - lastName = "Doe" - dob = LocalDate.of(1970, 6, 12) - type = 42 - global = true - } - val j = writtenP.toJSON().toString() - val readP = loadJsonModel(j) - val rewrittenJ = readP.toJSON().toString() - - Assert.assertEquals("John", readP.firstName) - Assert.assertEquals("Doe", readP.lastName) - Assert.assertEquals(LocalDate.of(1970, 6, 12), readP.dob) - Assert.assertEquals(42, readP.type) - Assert.assertEquals(true, readP.global) - Assert.assertEquals(j, rewrittenJ) - - } - - @Test - fun automodel2() { - val p = AutoPerson2().apply { - firstName = "John" - lastName = "Doe" - dob = LocalDate.of(1970, 6, 12) - type = 42 - global = true - } - val json = """{"dob":"1970-06-12","firstName":"John","global":true,"lastName":"Doe","type":42}""" - Assert.assertEquals(json, p.toJSON().toString()) - val l = loadJsonModel(json) - Assert.assertEquals("John", l.firstName) - Assert.assertEquals("Doe", l.lastName) - Assert.assertEquals(LocalDate.of(1970, 6, 12), l.dob) - Assert.assertEquals(42, l.type) - Assert.assertEquals(true, l.global) - Assert.assertEquals(json, l.toJSON().toString()) - } - - @Test - fun automodelRoundTrip2() { - val writtenP = AutoPerson2().apply { - firstName = "John" - lastName = "Doe" - dob = LocalDate.of(1970, 6, 12) - type = 42 - global = true - } - val j = writtenP.toJSON().toString() - val readP = loadJsonModel(j) - val rewrittenJ = readP.toJSON().toString() - - Assert.assertEquals("John", readP.firstName) - Assert.assertEquals("Doe", readP.lastName) - Assert.assertEquals(LocalDate.of(1970, 6, 12), readP.dob) - Assert.assertEquals(42, readP.type) - Assert.assertEquals(true, readP.global) - Assert.assertEquals(j, rewrittenJ) - - } - - @Test - fun firstAvailable() { - val json = loadJsonObject("""{"dob":"1970-06-12","firstName":"John","global":true,"lastName":"Doe","type":42}""") - val dob = json.date("date_of_birth", "dob") - Assert.assertEquals(LocalDate.of(1970, 6, 12),dob) - } -} diff --git a/src/test/kotlin/tornadofx/tests/LayoutsTest.kt b/src/test/kotlin/tornadofx/tests/LayoutsTest.kt deleted file mode 100644 index e5b5425..0000000 --- a/src/test/kotlin/tornadofx/tests/LayoutsTest.kt +++ /dev/null @@ -1,227 +0,0 @@ -package tornadofx.tests - -import javafx.scene.Node -import javafx.scene.Scene -import javafx.scene.control.Label -import javafx.scene.control.ScrollPane -import javafx.scene.layout.GridPane -import javafx.scene.layout.Pane -import javafx.scene.layout.VBox -import javafx.scene.text.Text -import javafx.stage.Stage -import org.junit.Test -import org.testfx.api.FxToolkit -import tornadofx.* -import kotlin.test.assertEquals -import kotlin.test.assertFalse -import kotlin.test.assertNull - -/** - * - * @author Anindya Chatterjee - */ -class RegionTest { - val GridPaneRowIdKey = "TornadoFX.GridPaneRowId" - val primaryStage: Stage = FxToolkit.registerPrimaryStage() - - lateinit var vbox: VBox - - @Test - fun testFitToParentSize() { - FxToolkit.setupFixture { - val root = Pane().apply { - vbox { - this@RegionTest.vbox = this - fitToParentSize() - } - setPrefSize(400.0, 160.0) - } - primaryStage.scene = Scene(root) - primaryStage.show() - - assertEquals(root.width, vbox.width) - assertEquals(root.height, vbox.height) - } - } - - @Test - fun testFitToSize() { - FxToolkit.setupFixture { - val root = ScrollPane().apply { - content = vbox { - this@RegionTest.vbox = this - } - setPrefSize(400.0, 160.0) - } - - vbox.fitToSize(root) - primaryStage.scene = Scene(root) - primaryStage.show() - - assertEquals(root.width, vbox.width) - assertEquals(root.height, vbox.height) - } - } - - @Test - fun testEmptyGridPane() { - FxToolkit.setupFixture { - val root = GridPane().apply { - } - - assertFalse(root.properties.containsKey(GridPaneRowIdKey)) - assertEquals(root.children, observableListOf()) - } - } - - @Test - fun testGridPaneAddRows() { - lateinit var label: Label - lateinit var text1: Text - lateinit var text2: Text - lateinit var text3: Text - lateinit var vbox: VBox - FxToolkit.setupFixture { - val root = GridPane().apply { - row { - label = label() - } - row { - text1 = text() - text2 = text() - text3 = text() - } - row { - vbox = vbox() - } - - } - - assertEquals(root.properties[GridPaneRowIdKey], 2) - assertEquals(GridPane.getRowIndex(label), 0) - assertEquals(GridPane.getColumnIndex(label), 0) - assertEquals(GridPane.getRowIndex(text1), 1) - assertEquals(GridPane.getColumnIndex(text1), 0) - assertEquals(GridPane.getRowIndex(text2), 1) - assertEquals(GridPane.getColumnIndex(text2), 1) - assertEquals(GridPane.getRowIndex(text3), 1) - assertEquals(GridPane.getColumnIndex(text3), 2) - assertEquals(GridPane.getRowIndex(vbox), 2) - assertEquals(GridPane.getColumnIndex(vbox), 0) - assertEquals(root.children, observableListOf(label, text1, text2, text3, vbox)) - } - } - - @Test - fun testGridPaneRemoveNoRow() { - val label = Label() - FxToolkit.setupFixture { - val root = GridPane().apply { - } - - root.removeRow(label) - - assertFalse(root.properties.containsKey(GridPaneRowIdKey)) - assertEquals(root.children, observableListOf()) - } - } - - @Test - fun testGridPaneRemoveSingleRow() { - lateinit var label: Label - FxToolkit.setupFixture { - val root = GridPane().apply { - row { - label = label() - } - } - - root.removeRow(label) - - assertFalse(root.properties.containsKey(GridPaneRowIdKey)) - assertNull(GridPane.getRowIndex(label)) - assertNull(GridPane.getColumnIndex(label)) - assertEquals(root.children, observableListOf()) - } - } - - @Test - fun testGridPaneRemoveMiddleRow() { - lateinit var label: Label - lateinit var text1: Text - lateinit var text2: Text - lateinit var text3: Text - lateinit var vbox: VBox - FxToolkit.setupFixture { - val root = GridPane().apply { - row { - label = label() - } - row { - text1 = text() - text2 = text() - text3 = text() - } - row { - vbox = vbox() - } - - } - - root.removeRow(text1) - - assertEquals(root.properties[GridPaneRowIdKey], 1) - assertEquals(GridPane.getRowIndex(label), 0) - assertEquals(GridPane.getColumnIndex(label), 0) - assertNull(GridPane.getRowIndex(text1)) - assertNull(GridPane.getColumnIndex(text1)) - assertNull(GridPane.getRowIndex(text2)) - assertNull(GridPane.getColumnIndex(text2)) - assertNull(GridPane.getRowIndex(text3)) - assertNull(GridPane.getColumnIndex(text3)) - assertEquals(GridPane.getRowIndex(vbox), 1) - assertEquals(GridPane.getColumnIndex(vbox), 0) - assertEquals(root.children, observableListOf(label, vbox)) - } - } - - @Test - fun testGridPaneRemoveAllRows() { - lateinit var label: Label - lateinit var text1: Text - lateinit var text2: Text - lateinit var text3: Text - lateinit var vbox: VBox - FxToolkit.setupFixture { - val root = GridPane().apply { - row { - label = label() - } - row { - text1 = text() - text2 = text() - text3 = text() - } - row { - vbox = vbox() - } - - } - - root.removeAllRows() - - assertFalse(root.properties.containsKey(GridPaneRowIdKey)) - assertNull(GridPane.getRowIndex(label)) - assertNull(GridPane.getColumnIndex(label)) - assertNull(GridPane.getRowIndex(text1)) - assertNull(GridPane.getColumnIndex(text1)) - assertNull(GridPane.getRowIndex(text2)) - assertNull(GridPane.getColumnIndex(text2)) - assertNull(GridPane.getRowIndex(text3)) - assertNull(GridPane.getColumnIndex(text3)) - assertNull(GridPane.getRowIndex(vbox)) - assertNull(GridPane.getColumnIndex(vbox)) - assertEquals(root.children, observableListOf()) - } - } -} \ No newline at end of file diff --git a/src/test/kotlin/tornadofx/tests/ListTest.kt b/src/test/kotlin/tornadofx/tests/ListTest.kt deleted file mode 100644 index d93cf59..0000000 --- a/src/test/kotlin/tornadofx/tests/ListTest.kt +++ /dev/null @@ -1,32 +0,0 @@ -package tornadofx.tests - -import javafx.beans.property.SimpleBooleanProperty -import javafx.beans.property.SimpleIntegerProperty -import javafx.beans.property.SimpleStringProperty -import javafx.collections.FXCollections -import org.junit.Assert -import org.junit.Test -import tornadofx.* - -class ListTest { - class Person(name: String, age: Int, checked: Boolean = true) { - val name = SimpleStringProperty(name) - val age = SimpleIntegerProperty(age) - val checked = SimpleBooleanProperty(checked) - override fun toString() = name.value - } - - val persons = FXCollections.observableArrayList( - Person("Samantha Stuart", 34, true), - Person("Tom Marks", 42, false), - Person("Stuart Gills", 17), - Person("Nicole Williams", 27)) - - @Test - fun filterTest() { - val data = SortedFilteredList(persons) - data.predicate = { it.name.get().contains("Stu") } - Assert.assertEquals(2, data.size) - } - -} \ No newline at end of file diff --git a/src/test/kotlin/tornadofx/tests/ListViewFragmentTestView.kt b/src/test/kotlin/tornadofx/tests/ListViewFragmentTestView.kt deleted file mode 100644 index c439859..0000000 --- a/src/test/kotlin/tornadofx/tests/ListViewFragmentTestView.kt +++ /dev/null @@ -1,46 +0,0 @@ -package tornadofx.tests - -import javafx.beans.property.SimpleStringProperty -import javafx.geometry.Pos -import javafx.scene.text.FontWeight -import tornadofx.* - -class ListViewTestApp : App(ListViewFragmentTestView::class) - -class ListViewItem(value: String) { - val valueProperty = SimpleStringProperty(value) -} - -class MyItemViewModel : ItemViewModel() { - val value = bind { item?.valueProperty } -} - -class PersonListFragment : ListCellFragment() { - val person = PersonModel().bindTo(this) - - override val root = form { - fieldset { - field("Name") { - label(person.name) - } - field("Age") { - label(person.age) - } - label(stringBinding(person.age) { "$value years old" }) { - alignment = Pos.CENTER_RIGHT - style { - fontSize = 22.px - fontWeight = FontWeight.BOLD - } - } - } - } -} - -class ListViewFragmentTestView : View("ListCellFragment Test") { - val items = observableListOf(Person("John", 42), Person("Jane", 24), Person("Tommy", 11)) - - override val root = listview(items) { - cellFragment(PersonListFragment::class) - } -} \ No newline at end of file diff --git a/src/test/kotlin/tornadofx/tests/MultipleLifecycleAsyncAppTest.kt b/src/test/kotlin/tornadofx/tests/MultipleLifecycleAsyncAppTest.kt deleted file mode 100644 index 24f89dc..0000000 --- a/src/test/kotlin/tornadofx/tests/MultipleLifecycleAsyncAppTest.kt +++ /dev/null @@ -1,56 +0,0 @@ -package tornadofx.tests - -import org.junit.After -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith -import org.junit.runners.Parameterized -import org.testfx.api.FxRobot -import org.testfx.api.FxToolkit -import tornadofx.* -import tornadofx.testapps.MultipleLifecycleAsyncView -import java.util.concurrent.CountDownLatch -import kotlin.test.assertEquals - -//@RunWith(Parameterized::class) -class MultipleLifecycleAsyncAppTest(val round: Int) { -// -// companion object { -// @JvmStatic -// @Parameterized.Parameters -// fun data(): Collection> { -// return listOf(arrayOf(1), arrayOf(2)) -// } -// } -// -// lateinit var robot: FxRobot -// lateinit var app: App -// -// @Before -// fun before() { -// FxToolkit.registerPrimaryStage() -// app = App(MultipleLifecycleAsyncView::class) -// FxToolkit.setupApplication { app } -// robot = FxRobot() -// -// println("round: $round") -// } -// -// @After -// fun after() { -// FxToolkit.cleanupStages() -// FxToolkit.cleanupApplication(app) -// } -// -// @Test(timeout = 20000) -// fun itShouldSurviveRunAsyncMultipleTimes() { -// val latch = CountDownLatch(2) -// val view: MultipleLifecycleAsyncView = find() -// view.counterProperty.onChange { latch.countDown() } -// -// robot.clickOn(".button") -// -// latch.await() -// assertEquals(2, view.counter) -// } -} \ No newline at end of file diff --git a/src/test/kotlin/tornadofx/tests/NodeTest.kt b/src/test/kotlin/tornadofx/tests/NodeTest.kt deleted file mode 100644 index 3c61cf5..0000000 --- a/src/test/kotlin/tornadofx/tests/NodeTest.kt +++ /dev/null @@ -1,49 +0,0 @@ -package tornadofx.tests - -import javafx.scene.control.Label -import javafx.scene.control.TableColumn -import javafx.scene.layout.HBox -import javafx.scene.layout.StackPane -import javafx.stage.Stage -import org.junit.Before -import org.junit.Test -import org.testfx.api.FxToolkit -import tornadofx.* -import kotlin.test.assertEquals -import kotlin.test.assertTrue - -class NodeTest { - val primaryStage: Stage = FxToolkit.registerPrimaryStage() - - lateinit var pane: StackPane - - @Before - fun setup() { - pane = StackPane() - } - - @Test - fun make_editable_boolean_column() { - val column = TableColumn() - column.makeEditable() - assertTrue(column.cellFactory != null) - } - - @Test - fun findComponents() { - val view1 = find() - val view2 = find() - val view3 = find() - - view1 += view2 - view1 += view3 - - assertEquals(view2, view1.lookup()) - assertEquals(view3, view1.lookup()) - assertEquals(2, view1.findAll().size) - } - - class View1 : View() { override val root = HBox(Label("View 1")) } - class View2 : View() { override val root = HBox(Label("View 2")) } - class View3 : View() { override val root = HBox(Label("View 3")) } -} \ No newline at end of file diff --git a/src/test/kotlin/tornadofx/tests/Person.kt b/src/test/kotlin/tornadofx/tests/Person.kt deleted file mode 100644 index e33b32b..0000000 --- a/src/test/kotlin/tornadofx/tests/Person.kt +++ /dev/null @@ -1,40 +0,0 @@ -package tornadofx.tests - -import javafx.collections.FXCollections -import javafx.scene.input.DataFormat -import tornadofx.* -import java.io.Serializable -import java.util.* - -class PersonRef(val id: UUID) : Serializable - -class Person(name: String, age: Int) { - constructor() : this("", 18) - - val id = UUID.randomUUID() - - var name: String by property(name) - fun nameProperty() = getProperty(Person::name) - - var phone: String by property() - fun phoneProperty() = getProperty(Person::phone) - - var email: String by property() - fun emailProperty() = getProperty(Person::email) - - var age by property(age) - fun ageProperty() = getProperty(Person::age) - - var parent by property() - fun parentProperty() = getProperty(Person::parent) - - val children = FXCollections.observableArrayList() - - override fun toString() = name - - class PersonDataFormat : DataFormat("tornadofx.Person") - - companion object { - val DATA_FORMAT = PersonDataFormat() - } -} \ No newline at end of file diff --git a/src/test/kotlin/tornadofx/tests/PersonPoko.kt b/src/test/kotlin/tornadofx/tests/PersonPoko.kt deleted file mode 100644 index 318fc3f..0000000 --- a/src/test/kotlin/tornadofx/tests/PersonPoko.kt +++ /dev/null @@ -1,6 +0,0 @@ -package tornadofx.tests - -data class PersonPoko(var name: String, var phone: String?, var email: String?, var age: Int, var parent: PersonPoko?) { - constructor(name: String, age: Int) : this(name, null, null, age, null) - constructor() : this("", 18) -} diff --git a/src/test/kotlin/tornadofx/tests/PreferencesTest.kt b/src/test/kotlin/tornadofx/tests/PreferencesTest.kt deleted file mode 100644 index 5cf2461..0000000 --- a/src/test/kotlin/tornadofx/tests/PreferencesTest.kt +++ /dev/null @@ -1,29 +0,0 @@ -package tornadofx.tests - -import org.junit.Assert -import org.junit.Test -import tornadofx.Controller - -class PreferencesTest { - - @Test - fun testPreferences() { - object : Controller() { - init { - preferences("test app") { - putBoolean("boolean key", true) - put("string", "value") - } - - var bool: Boolean = false - var str: String = "" - preferences("test app") { - bool = getBoolean("boolean key", false) - str = get("string", "") - } - Assert.assertEquals(true, bool) - Assert.assertEquals("value", str) - } - } - } -} diff --git a/src/test/kotlin/tornadofx/tests/PropertiesTest.kt b/src/test/kotlin/tornadofx/tests/PropertiesTest.kt deleted file mode 100644 index 22e8cc8..0000000 --- a/src/test/kotlin/tornadofx/tests/PropertiesTest.kt +++ /dev/null @@ -1,2935 +0,0 @@ -package tornadofx.tests - -import javafx.beans.binding.DoubleBinding -import javafx.beans.binding.FloatBinding -import javafx.beans.binding.IntegerBinding -import javafx.beans.binding.LongBinding -import javafx.beans.property.* -import javafx.collections.FXCollections -import org.junit.Assert -import org.junit.Assert.assertTrue -import org.junit.Test -import tornadofx.* -import kotlin.test.assertEquals - -class PropertiesTest { - @Test - fun primitiveOnChange() { - val d = SimpleDoubleProperty() - // Ensure getting the value does not throw an NPE - d.onChange { assert((it + 7) is Double) } - - d.value = 100.0 - d.value = Double.POSITIVE_INFINITY - d.value = Double.NaN - d.value = null - } - - @Test - fun property_delegation() { - // given: - val fixture = object { - val nameProperty = SimpleStringProperty("Alice") - var name by nameProperty - - val ageProperty = SimpleDoubleProperty(1.0) - var age by ageProperty - - val dirtyProperty = SimpleBooleanProperty(false) - var dirty by dirtyProperty - } - // expect: - assertEquals("Alice", fixture.name) - assertEquals("Alice", fixture.nameProperty.value) - - assertEquals(1.0, fixture.age) - assertEquals(1.0, fixture.ageProperty.value) - - assertEquals(false, fixture.dirty) - assertEquals(false, fixture.dirtyProperty.value) - - // when: - fixture.name = "Bob" - fixture.age = 100.0 - fixture.dirty = true - - // expect: - assertEquals("Bob", fixture.name) - assertEquals("Bob", fixture.nameProperty.value) - - assertEquals(100.0, fixture.age) - assertEquals(100.0, fixture.ageProperty.value) - - assertEquals(true, fixture.dirty) - assertEquals(true, fixture.dirtyProperty.value) - } - - @Test - fun property_get_should_read_value() { - // given: - val fixture = object { - val string by property() - val integer: Int? by property() - val stringDefault by property("foo") - val integerDefault by property(42) - } - - // expect: - assertEquals(null, fixture.string) - assertEquals(null, fixture.integer) - assertEquals("foo", fixture.stringDefault) - assertEquals(42, fixture.integerDefault) - } - - @Test - fun property_set_should_write_value() { - // given: - val fixture = object { - var string by property() - var integer: Int? by property() - var stringDefault by property("foo") - var integerDefault by property(42) - } - - // when: - fixture.string = "foo" - fixture.integer = 42 - - // then: - assertEquals("foo", fixture.string) - assertEquals("foo", fixture.stringDefault) - assertEquals(42, fixture.integer) - assertEquals(42, fixture.integerDefault) - } - - class TestClass { - var myProperty: String by singleAssign() - } - - @Test - fun failNoAssignment() { - val instance = TestClass() - var failed = false - - try { - instance.myProperty - } catch (e: Exception) { - failed = true - } - assertTrue(failed) - } - - @Test - fun succeedAssignment() { - val instance = TestClass() - instance.myProperty = "foo" - instance.myProperty - } - - @Test - fun failDoubleAssignment() { - - val instance = TestClass() - var failed = false - instance.myProperty = "foo" - - try { - instance.myProperty = "bar" - } catch (e: Exception) { - failed = true - } - assertTrue(failed) - } - - @Test - fun pojoWritableObservable() { - val person = JavaPerson() - person.id = 1 - person.name = "John" - - val idObservable = person.observable(JavaPerson::getId, JavaPerson::setId) - val nameObservable = person.observable("name") - - idObservable.value = 44 - nameObservable.value = "Doe" - - Assert.assertEquals(44, person.id) - Assert.assertEquals("Doe", person.name) - - person.id = 5 - Assert.assertEquals(5, idObservable.value) - } - - @Test - fun pojoWritableObservableGetterOnly() { - val person = JavaPerson() - person.id = 1 - person.name = "John" - - val idObservable = person.observable(JavaPerson::getId) - val nameObservable = person.observable("name") - val idBinding = idObservable.integerBinding { idObservable.value } - - idObservable.value = 44 - nameObservable.value = "Doe" - Assert.assertEquals(44, idBinding.value) - Assert.assertEquals(44, person.id) - Assert.assertEquals("Doe", person.name) - - person.id = 5 - // property change events on the pojo are propogated - Assert.assertEquals(5, idBinding.value) - Assert.assertEquals(5, idObservable.value) - } - - @Test fun property_on_change() { - var called = false - val property = SimpleStringProperty("Hello World") - property.onChange { called = true } - property.value = "Changed" - assertTrue(called) - } - - @Test fun assign_if_null() { - val has = SimpleObjectProperty("Hello") - has.assignIfNull { "World" } - assertEquals(has.value, "Hello") - val hasNot = SimpleObjectProperty() - hasNot.assignIfNull { "World" } - assertEquals(hasNot.value, "World") - } - - @Test fun testDoubleToProperty() { - val property = 5.0.toProperty() - Assert.assertTrue(property is DoubleProperty) - Assert.assertEquals(5.0, property.get(), .001) - } - - @Test fun testFloatToProperty() { - val property = 5.0f.toProperty() - Assert.assertTrue(property is FloatProperty) - Assert.assertEquals(5.0f, property.get(), .001f) - } - - @Test fun testLongToProperty() { - val property = 5L.toProperty() - Assert.assertTrue(property is LongProperty) - Assert.assertEquals(5, property.get()) - } - - @Test fun testIntToProperty() { - val property = 5.toProperty() - Assert.assertTrue(property is IntegerProperty) - Assert.assertEquals(5, property.get()) - } - - @Test fun testBooleanToProperty() { - val property = true.toProperty() - Assert.assertTrue(property is BooleanProperty) - Assert.assertTrue(property.get()) - } - - @Test fun testStringToProperty() { - val property = "Hello World!".toProperty() - Assert.assertTrue(property is StringProperty) - Assert.assertEquals("Hello World!", property.get()) - } - - @Test fun testDoubleExpressionPlusNumber() { - val property = 0.0.toProperty() - - val binding = property + 5 - Assert.assertEquals(5.0, binding.get(), .001) - - property.value -= 5f - Assert.assertEquals(0.0, binding.get(), .001) - } - - @Test fun testDoubleExpressionPlusNumberProperty() { - val property1 = 0.0.toProperty() - val property2 = 5.toProperty() - - val binding = property1 + property2 - Assert.assertEquals(5.0, binding.get(), .001) - - property1.value -= 10 - Assert.assertEquals(-5.0, binding.get(), .001) - - property2.value = 0 - Assert.assertEquals(-10.0, binding.get(), .001) - } - - @Test fun testDoublePropertyPlusAssignNumber() { - val property = 0.0.toProperty() - property += 5 - - Assert.assertEquals(5.0, property.get(), .001) - } - - @Test fun testDoublePropertyPlusAssignNumberProperty() { - val property1 = 0.0.toProperty() - val property2 = 5.toProperty() - - property1 += property2 - Assert.assertEquals(5.0, property1.get(), .001) - } - - @Test fun testDoubleExpressionMinusNumber() { - val property = 0.0.toProperty() - - val binding = property - 5 - Assert.assertEquals(-5.0, binding.get(), .001) - - property.value -= 5f - Assert.assertEquals(-10.0, binding.get(), .001) - } - - @Test fun testDoubleExpressionMinusNumberProperty() { - val property1 = 0.0.toProperty() - val property2 = 5.toProperty() - - val binding = property1 - property2 - Assert.assertEquals(-5.0, binding.get(), .001) - - property1.value -= 10 - Assert.assertEquals(-15.0, binding.get(), .001) - - property2.value = 0 - Assert.assertEquals(-10.0, binding.get(), .001) - } - - @Test fun testDoublePropertyMinusAssignNumber() { - val property = 0.0.toProperty() - property -= 5 - - Assert.assertEquals(-5.0, property.get(), .001) - } - - @Test fun testDoublePropertyMinusAssignNumberProperty() { - val property1 = 0.0.toProperty() - val property2 = 5.toProperty() - - property1 -= property2 - Assert.assertEquals(-5.0, property1.get(), .001) - } - - @Test fun testDoublePropertyUnaryMinus() { - val property = 1.0.toProperty() - - val binding = -property - Assert.assertEquals(-1.0, binding.get(), .001) - - property += 1 - Assert.assertEquals(-2.0, binding.get(), .001) - } - - @Test fun testDoubleExpressionTimesNumber() { - val property = 2.0.toProperty() - - val binding = property * 5 - Assert.assertEquals(10.0, binding.get(), .001) - - property.value = 5.0 - Assert.assertEquals(25.0, binding.get(), .001) - } - - @Test fun testDoubleExpressionTimesNumberProperty() { - val property1 = 2.0.toProperty() - val property2 = 5.toProperty() - - val binding = property1 * property2 - Assert.assertEquals(10.0, binding.get(), .001) - - property1.value = 5.0 - Assert.assertEquals(25.0, binding.get(), .001) - - property2.value = 0 - Assert.assertEquals(0.0, binding.get(), .001) - } - - @Test fun testDoublePropertyTimesAssignNumber() { - val property = 1.0.toProperty() - property *= 5 - - Assert.assertEquals(5.0, property.get(), .001) - } - - @Test fun testDoublePropertyTimesAssignNumberProperty() { - val property1 = 1.0.toProperty() - val property2 = 5.toProperty() - - property1 *= property2 - Assert.assertEquals(5.0, property1.get(), .001) - } - - @Test fun testDoubleExpressionDivNumber() { - val property = 5.0.toProperty() - - val binding = property / 5 - Assert.assertEquals(1.0, binding.get(), .001) - - property.value = 10.0 - Assert.assertEquals(2.0, binding.get(), .001) - } - - @Test fun testDoubleExpressionDivNumberProperty() { - val property1 = 5.0.toProperty() - val property2 = 5.toProperty() - - val binding = property1 / property2 - Assert.assertEquals(1.0, binding.get(), .001) - - property1.value = 10.0 - Assert.assertEquals(2.0, binding.get(), .001) - - property2.value = 20 - Assert.assertEquals(0.5, binding.get(), .001) - } - - @Test fun testDoublePropertyDivAssignNumber() { - val property = 5.0.toProperty() - property /= 5 - - Assert.assertEquals(1.0, property.get(), .001) - } - - @Test fun testDoublePropertyDivAssignNumberProperty() { - val property1 = 5.0.toProperty() - val property2 = 5.toProperty() - - property1 /= property2 - Assert.assertEquals(1.0, property1.get(), .001) - } - - @Test fun testDoubleExpressionRemNumber() { - val property = 6.0.toProperty() - - val binding = property % 5 - Assert.assertEquals(1.0, binding.get(), .001) - - property.value = 12.0 - Assert.assertEquals(2.0, binding.get(), .001) - } - - @Test fun testDoubleExpressionRemNumberProperty() { - val property1 = 6.0.toProperty() - val property2 = 5.toProperty() - - val binding = property1 % property2 - Assert.assertEquals(1.0, binding.get(), .001) - - property1.value = 12.0 - Assert.assertEquals(2.0, binding.get(), .001) - - property2.value = 11 - Assert.assertEquals(1.0, binding.get(), .001) - } - - @Test fun testDoublePropertyRemAssignNumber() { - val property = 6.0.toProperty() - property %= 5 - - Assert.assertEquals(1.0, property.get(), .001) - } - - @Test fun testDoublePropertyRemAssignNumberProperty() { - val property1 = 6.0.toProperty() - val property2 = 5.toProperty() - - property1 %= property2 - Assert.assertEquals(1.0, property1.get(), .001) - } - - @Test fun testDoublePropertyCompareToNumber() { - val property = 5.0.toProperty() - - Assert.assertTrue(property > 4) - Assert.assertTrue(property >= 5) - Assert.assertTrue(property >= 4) - Assert.assertTrue(property <= 5) - Assert.assertTrue(property <= 5) - Assert.assertTrue(property <= 6) - Assert.assertTrue(property < 6) - - Assert.assertFalse(property > 6) - Assert.assertFalse(property >= 6) - Assert.assertFalse(property <= 4) - Assert.assertFalse(property < 4) - } - - @Test fun testDoublePropertyCompareToNumberProperty() { - val property = 5.0.toProperty() - - - Assert.assertTrue(property > 4.toProperty()) - Assert.assertTrue(property >= 5.toProperty()) - Assert.assertTrue(property >= 4.toProperty()) - Assert.assertTrue(property <= 5.toProperty()) - Assert.assertTrue(property <= 5.toProperty()) - Assert.assertTrue(property <= 6.toProperty()) - Assert.assertTrue(property < 6.toProperty()) - - Assert.assertFalse(property > 6.toProperty()) - Assert.assertFalse(property >= 6.toProperty()) - Assert.assertFalse(property <= 4.toProperty()) - Assert.assertFalse(property < 4.toProperty()) - } - - @Test fun testFloatExpressionPlusNumber() { - val property = 0.0f.toProperty() - - val binding = property + 5 - Assert.assertTrue(binding is FloatBinding) - Assert.assertEquals(5.0f, binding.get(), .001f) - - property.value -= 5f - Assert.assertEquals(0.0f, binding.get(), .001f) - } - - @Test fun testFloatExpressionPlusDouble() { - val property = 0.0f.toProperty() - - val binding = property + 5.0 - Assert.assertTrue(binding is DoubleBinding) - Assert.assertEquals(5.0, binding.get(), .001) - - property.value -= 5f - Assert.assertEquals(0.0, binding.get(), .001) - } - - @Test fun testFloatExpressionPlusNumberProperty() { - val property1 = 0.0f.toProperty() - val property2 = 5.toProperty() - - val binding = property1 + property2 - Assert.assertTrue(binding is FloatBinding) - Assert.assertEquals(5.0f, binding.get(), .001f) - - property1.value -= 10f - Assert.assertEquals(-5.0f, binding.get(), .001f) - - property2.value = 0 - Assert.assertEquals(-10.0f, binding.get(), .001f) - } - - @Test fun testFloatExpressionPlusDoubleProperty() { - val property1 = 0.0f.toProperty() - val property2 = 5.0.toProperty() - - val binding = property1 + property2 - Assert.assertTrue(binding is DoubleBinding) - Assert.assertEquals(5.0, binding.get(), .001) - - property1.value -= 10f - Assert.assertEquals(-5.0, binding.get(), .001) - - property2.value = 0.0 - Assert.assertEquals(-10.0, binding.get(), .001) - } - - @Test fun testFloatPropertyPlusAssignNumber() { - val property = 0.0f.toProperty() - property += 5 - - Assert.assertEquals(5.0f, property.get(), .001f) - } - - @Test fun testFloatPropertyPlusAssignNumberProperty() { - val property1 = 0.0f.toProperty() - val property2 = 5.toProperty() - - property1 += property2 - Assert.assertEquals(5.0f, property1.get(), .001f) - } - - @Test fun testFloatExpressionMinusNumber() { - val property = 0.0f.toProperty() - - val binding = property - 5 - Assert.assertTrue(binding is FloatBinding) - Assert.assertEquals(-5.0f, binding.get(), .001f) - - property.value -= 5f - Assert.assertEquals(-10.0f, binding.get(), .001f) - } - - @Test fun testFloatExpressionMinusDouble() { - val property = 0.0f.toProperty() - - val binding = property - 5.0 - Assert.assertTrue(binding is DoubleBinding) - Assert.assertEquals(-5.0, binding.get(), .001) - - property.value -= 5f - Assert.assertEquals(-10.0, binding.get(), .001) - } - - @Test fun testFloatExpressionMinusNumberProperty() { - val property1 = 0.0f.toProperty() - val property2 = 5.toProperty() - - val binding = property1 - property2 - Assert.assertTrue(binding is FloatBinding) - Assert.assertEquals(-5.0f, binding.get(), .001f) - - property1.value -= 10f - Assert.assertEquals(-15.0f, binding.get(), .001f) - - property2.value = 0 - Assert.assertEquals(-10.0f, binding.get(), .001f) - } - - @Test fun testFloatExpressionMinusDoubleProperty() { - val property1 = 0.0f.toProperty() - val property2 = 5.0.toProperty() - - val binding = property1 - property2 - Assert.assertTrue(binding is DoubleBinding) - Assert.assertEquals(-5.0, binding.get(), .001) - - property1.value -= 10f - Assert.assertEquals(-15.0, binding.get(), .001) - - property2.value = 0.0 - Assert.assertEquals(-10.0, binding.get(), .001) - } - - @Test fun testFloatPropertyMinusAssignNumber() { - val property = 0.0f.toProperty() - property -= 5 - - Assert.assertEquals(-5.0f, property.get(), .001f) - } - - @Test fun testFloatPropertyMinusAssignNumberProperty() { - val property1 = 0.0f.toProperty() - val property2 = 5.toProperty() - - property1 -= property2 - Assert.assertEquals(-5.0f, property1.get(), .001f) - } - - @Test fun testFloatPropertyUnaryMinus() { - val property = 1.0f.toProperty() - - val binding = -property - Assert.assertEquals(-1.0f, binding.get(), .001f) - - property += 1 - Assert.assertEquals(-2.0f, binding.get(), .001f) - } - - @Test fun testFloatExpressionTimesNumber() { - val property = 2.0f.toProperty() - - val binding = property * 5 - Assert.assertTrue(binding is FloatBinding) - Assert.assertEquals(10.0f, binding.get(), .001f) - - property.value = 5f - Assert.assertEquals(25.0f, binding.get(), .001f) - } - - @Test fun testFloatExpressionTimesDouble() { - val property = 2.0f.toProperty() - - val binding = property * 5.0 - Assert.assertTrue(binding is DoubleBinding) - Assert.assertEquals(10.0, binding.get(), .001) - - property.value = 5f - Assert.assertEquals(25.0, binding.get(), .001) - } - - @Test fun testFloatExpressionTimesNumberProperty() { - val property1 = 2.0f.toProperty() - val property2 = 5.toProperty() - - val binding = property1 * property2 - Assert.assertTrue(binding is FloatBinding) - Assert.assertEquals(10.0f, binding.get(), .001f) - - property1.value = 10f - Assert.assertEquals(50.0f, binding.get(), .001f) - - property2.value = 0 - Assert.assertEquals(0.0f, binding.get(), .001f) - } - - @Test fun testFloatExpressionTimesDoubleProperty() { - val property1 = 2.0f.toProperty() - val property2 = 5.0.toProperty() - - val binding = property1 * property2 - Assert.assertTrue(binding is DoubleBinding) - Assert.assertEquals(10.0, binding.get(), .001) - - property1.value = 10f - Assert.assertEquals(50.0, binding.get(), .001) - - property2.value = 0.0 - Assert.assertEquals(0.0, binding.get(), .001) - } - - @Test fun testFloatPropertyTimesAssignNumber() { - val property = 1.0f.toProperty() - property *= 5 - - Assert.assertEquals(5.0f, property.get(), .001f) - } - - @Test fun testFloatPropertyTimesAssignNumberProperty() { - val property1 = 1.0f.toProperty() - val property2 = 5.toProperty() - - property1 *= property2 - Assert.assertEquals(5.0f, property1.get(), .001f) - } - - @Test fun testFloatExpressionDivNumber() { - val property = 5.0f.toProperty() - - val binding = property / 5 - Assert.assertTrue(binding is FloatBinding) - Assert.assertEquals(1.0f, binding.get(), .001f) - - property.value = 10f - Assert.assertEquals(2.0f, binding.get(), .001f) - } - - @Test fun testFloatExpressionDivDouble() { - val property = 5.0f.toProperty() - - val binding = property / 5.0 - Assert.assertTrue(binding is DoubleBinding) - Assert.assertEquals(1.0, binding.get(), .001) - - property.value = 10f - Assert.assertEquals(2.0, binding.get(), .001) - } - - @Test fun testFloatExpressionDivNumberProperty() { - val property1 = 5.0f.toProperty() - val property2 = 5.toProperty() - - val binding = property1 / property2 - Assert.assertTrue(binding is FloatBinding) - Assert.assertEquals(1.0f, binding.get(), .001f) - - property1.value = 10f - Assert.assertEquals(2.0f, binding.get(), .001f) - - property2.value = 20 - Assert.assertEquals(0.5f, binding.get(), .001f) - } - - @Test fun testFloatExpressionDivDoubleProperty() { - val property1 = 5.0f.toProperty() - val property2 = 5.0.toProperty() - - val binding = property1 / property2 - Assert.assertTrue(binding is DoubleBinding) - Assert.assertEquals(1.0, binding.get(), .001) - - property1.value = 10f - Assert.assertEquals(2.0, binding.get(), .001) - - property2.value = 20.0 - Assert.assertEquals(0.5, binding.get(), .001) - } - - @Test fun testFloatPropertyDivAssignNumber() { - val property = 5.0f.toProperty() - property /= 5 - - Assert.assertEquals(1.0f, property.get(), .001f) - } - - @Test fun testFloatPropertyDivAssignNumberProperty() { - val property1 = 5.0f.toProperty() - val property2 = 5.toProperty() - - property1 /= property2 - Assert.assertEquals(1.0f, property1.get(), .001f) - } - - @Test fun testFloatExpressionRemNumber() { - val property = 6.0f.toProperty() - - val binding = property % 5 - Assert.assertTrue(binding is FloatBinding) - Assert.assertEquals(1.0f, binding.get(), .001f) - - property.value = 12.0f - Assert.assertEquals(2.0f, binding.get(), .001f) - } - - @Test fun testFloatExpressionRemDouble() { - val property = 6.0f.toProperty() - - val binding = property % 5.0 - Assert.assertTrue(binding is DoubleBinding) - Assert.assertEquals(1.0, binding.get(), .001) - - property.value = 12.0f - Assert.assertEquals(2.0, binding.get(), .001) - } - - @Test fun testFloatExpressionRemNumberProperty() { - val property1 = 6.0f.toProperty() - val property2 = 5.toProperty() - - val binding = property1 % property2 - Assert.assertTrue(binding is FloatBinding) - Assert.assertEquals(1.0f, binding.get(), .001f) - - property1.value = 12f - Assert.assertEquals(2.0f, binding.get(), .001f) - - property2.value = 11 - Assert.assertEquals(1.0f, binding.get(), .001f) - } - - @Test fun testFloatExpressionRemDoubleProperty() { - val property1 = 6.0f.toProperty() - val property2 = 5.0.toProperty() - - val binding = property1 % property2 - Assert.assertTrue(binding is DoubleBinding) - Assert.assertEquals(1.0, binding.get(), .001) - - property1.value = 12f - Assert.assertEquals(2.0, binding.get(), .001) - - property2.value = 11.0 - Assert.assertEquals(1.0, binding.get(), .001) - } - - @Test fun testFloatPropertyRemAssignNumber() { - val property = 6.0f.toProperty() - property %= 5 - - Assert.assertEquals(1.0f, property.get(), .001f) - } - - @Test fun testFloatPropertyRemAssignNumberProperty() { - val property1 = 6.0f.toProperty() - val property2 = 5.toProperty() - - property1 %= property2 - Assert.assertEquals(1.0f, property1.get(), .001f) - } - - @Test fun testFloatPropertyCompareToNumber() { - val property = 5.0f.toProperty() - - Assert.assertTrue(property > 4) - Assert.assertTrue(property >= 5) - Assert.assertTrue(property >= 4) - Assert.assertTrue(property <= 5) - Assert.assertTrue(property <= 5) - Assert.assertTrue(property <= 6) - Assert.assertTrue(property < 6) - - Assert.assertFalse(property > 6) - Assert.assertFalse(property >= 6) - Assert.assertFalse(property <= 4) - Assert.assertFalse(property < 4) - } - - @Test fun testFloatPropertyCompareToNumberProperty() { - val property = 5.0f.toProperty() - - - Assert.assertTrue(property > 4.toProperty()) - Assert.assertTrue(property >= 5.toProperty()) - Assert.assertTrue(property >= 4.toProperty()) - Assert.assertTrue(property <= 5.toProperty()) - Assert.assertTrue(property <= 5.toProperty()) - Assert.assertTrue(property <= 6.toProperty()) - Assert.assertTrue(property < 6.toProperty()) - - Assert.assertFalse(property > 6.toProperty()) - Assert.assertFalse(property >= 6.toProperty()) - Assert.assertFalse(property <= 4.toProperty()) - Assert.assertFalse(property < 4.toProperty()) - } - - @Test fun testIntegerExpressionPlusInt() { - val property = 0.toProperty() - - val binding = property + 5 - Assert.assertTrue(binding is IntegerBinding) - Assert.assertEquals(5, binding.get()) - - property.value -= 5 - Assert.assertEquals(0, binding.get()) - } - - @Test fun testIntegerExpressionPlusLong() { - val property = 0.toProperty() - - val binding = property + 5L - Assert.assertTrue(binding is LongBinding) - Assert.assertEquals(5L, binding.get()) - - property.value -= 5 - Assert.assertEquals(0, binding.get()) - } - - @Test fun testIntegerExpressionPlusFloat() { - val property = 0.toProperty() - - val binding = property + 5f - Assert.assertTrue(binding is FloatBinding) - Assert.assertEquals(5f, binding.get(), .001f) - - property.value -= 5 - Assert.assertEquals(0f, binding.get(), .001f) - } - - @Test fun testIntegerExpressionPlusDouble() { - val property = 0.toProperty() - - val binding = property + 5.0 - Assert.assertTrue(binding is DoubleBinding) - Assert.assertEquals(5.0, binding.get(), .001) - - property.value -= 5 - Assert.assertEquals(0.0, binding.get(), .001) - } - - @Test fun testIntegerExpressionPlusIntegerProperty() { - val property1 = 0.toProperty() - val property2 = 5.toProperty() - - val binding = property1 + property2 - Assert.assertTrue(binding is IntegerBinding) - Assert.assertEquals(5, binding.get()) - - property1.value -= 10 - Assert.assertEquals(-5, binding.get()) - - property2.value = 0 - Assert.assertEquals(-10, binding.get()) - } - - @Test fun testIntegerExpressionPlusLongProperty() { - val property1 = 0.toProperty() - val property2 = 5L.toProperty() - - val binding = property1 + property2 - Assert.assertTrue(binding is LongBinding) - Assert.assertEquals(5L, binding.get()) - - property1.value -= 10 - Assert.assertEquals(-5L, binding.get()) - - property2.value = 0L - Assert.assertEquals(-10L, binding.get()) - } - - @Test fun testIntegerExpressionPlusFloatProperty() { - val property1 = 0.toProperty() - val property2 = 5f.toProperty() - - val binding = property1 + property2 - Assert.assertTrue(binding is FloatBinding) - Assert.assertEquals(5f, binding.get(), .001f) - - property1.value -= 10 - Assert.assertEquals(-5f, binding.get(), .001f) - - property2.value = 0f - Assert.assertEquals(-10f, binding.get(), .001f) - } - - @Test fun testIntegerExpressionPlusDoubleProperty() { - val property1 = 0.toProperty() - val property2 = 5.0.toProperty() - - val binding = property1 + property2 - Assert.assertTrue(binding is DoubleBinding) - Assert.assertEquals(5.0, binding.get(), .001) - - property1.value -= 10 - Assert.assertEquals(-5.0, binding.get(), .001) - - property2.value = 0.0 - Assert.assertEquals(-10.0, binding.get(), .001) - } - - @Test fun testIntegerPropertyPlusAssignNumber() { - val property = 0.toProperty() - property += 5 - - Assert.assertEquals(5, property.get()) - } - - @Test fun testIntegerPropertyPlusAssignNumberProperty() { - val property1 = 0.toProperty() - val property2 = 5.toProperty() - - property1 += property2 - Assert.assertEquals(5, property1.get()) - } - - @Test fun testIntegerExpressionMinusInt() { - val property = 0.toProperty() - - val binding = property - 5 - Assert.assertTrue(binding is IntegerBinding) - Assert.assertEquals(-5, binding.get()) - - property.value -= 5 - Assert.assertEquals(-10, binding.get()) - } - - @Test fun testIntegerExpressionMinusLong() { - val property = 0.toProperty() - - val binding = property - 5L - Assert.assertTrue(binding is LongBinding) - Assert.assertEquals(-5L, binding.get()) - - property.value -= 5 - Assert.assertEquals(-10L, binding.get()) - } - - @Test fun testIntegerExpressionMinusFloat() { - val property = 0.toProperty() - - val binding = property - 5f - Assert.assertTrue(binding is FloatBinding) - Assert.assertEquals(-5f, binding.get(), .001f) - - property.value -= 5 - Assert.assertEquals(-10f, binding.get(), .001f) - } - - @Test fun testIntegerExpressionMinusDouble() { - val property = 0.toProperty() - - val binding = property - 5.0 - Assert.assertTrue(binding is DoubleBinding) - Assert.assertEquals(-5.0, binding.get(), .001) - - property.value -= 5 - Assert.assertEquals(-10.0, binding.get(), .001) - } - - @Test fun testIntegerExpressionMinusIntegerProperty() { - val property1 = 0.toProperty() - val property2 = 5.toProperty() - - val binding = property1 - property2 - Assert.assertTrue(binding is IntegerBinding) - Assert.assertEquals(-5, binding.get()) - - property1.value -= 10 - Assert.assertEquals(-15, binding.get()) - - property2.value = 0 - Assert.assertEquals(-10, binding.get()) - } - - @Test fun testIntegerExpressionMinusLongProperty() { - val property1 = 0.toProperty() - val property2 = 5L.toProperty() - - val binding = property1 - property2 - Assert.assertTrue(binding is LongBinding) - Assert.assertEquals(-5L, binding.get()) - - property1.value -= 10 - Assert.assertEquals(-15L, binding.get()) - - property2.value = 0L - Assert.assertEquals(-10L, binding.get()) - } - - @Test fun testIntegerExpressionMinusFloatProperty() { - val property1 = 0.toProperty() - val property2 = 5f.toProperty() - - val binding = property1 - property2 - Assert.assertTrue(binding is FloatBinding) - Assert.assertEquals(-5f, binding.get(), .001f) - - property1.value -= 10 - Assert.assertEquals(-15f, binding.get(), .001f) - - property2.value = 0f - Assert.assertEquals(-10f, binding.get(), .001f) - } - - @Test fun testIntegerExpressionMinusDoubleProperty() { - val property1 = 0.toProperty() - val property2 = 5.0.toProperty() - - val binding = property1 - property2 - Assert.assertTrue(binding is DoubleBinding) - Assert.assertEquals(-5.0, binding.get(), .001) - - property1.value -= 10 - Assert.assertEquals(-15.0, binding.get(), .001) - - property2.value = 0.0 - Assert.assertEquals(-10.0, binding.get(), .001) - } - - @Test fun testIntegerPropertyMinusAssignNumber() { - val property = 0.toProperty() - property -= 5 - - Assert.assertEquals(-5, property.get()) - } - - @Test fun testIntegerPropertyMinusAssignNumberProperty() { - val property1 = 0.toProperty() - val property2 = 5.toProperty() - - property1 -= property2 - Assert.assertEquals(-5, property1.get()) - } - - @Test fun testIntegerPropertyUnaryMinus() { - val property = 1.toProperty() - - val binding = -property - Assert.assertEquals(-1, binding.get()) - - property += 1 - Assert.assertEquals(-2, binding.get()) - } - - @Test fun testIntegerExpressionTimesInt() { - val property = 2.toProperty() - - val binding = property * 5 - Assert.assertTrue(binding is IntegerBinding) - Assert.assertEquals(10, binding.get()) - - property.value = 5 - Assert.assertEquals(25, binding.get()) - } - - @Test fun testIntegerExpressionTimesLong() { - val property = 2.toProperty() - - val binding = property * 5L - Assert.assertTrue(binding is LongBinding) - Assert.assertEquals(10L, binding.get()) - - property.value = 5 - Assert.assertEquals(25L, binding.get()) - } - - @Test fun testIntegerExpressionTimesFloat() { - val property = 2.toProperty() - - val binding = property * 5f - Assert.assertTrue(binding is FloatBinding) - Assert.assertEquals(10f, binding.get(), .001f) - - property.value = 5 - Assert.assertEquals(25f, binding.get(), .001f) - } - - @Test fun testIntegerExpressionTimesDouble() { - val property = 2.toProperty() - - val binding = property * 5.0 - Assert.assertTrue(binding is DoubleBinding) - Assert.assertEquals(10.0, binding.get(), .001) - - property.value = 5 - Assert.assertEquals(25.0, binding.get(), .001) - } - - @Test fun testIntegerExpressionTimesIntegerProperty() { - val property1 = 2.toProperty() - val property2 = 5.toProperty() - - val binding = property1 * property2 - Assert.assertTrue(binding is IntegerBinding) - Assert.assertEquals(10, binding.get()) - - property1.value = 10 - Assert.assertEquals(50, binding.get()) - - property2.value = 0 - Assert.assertEquals(0, binding.get()) - } - - @Test fun testIntegerExpressionTimesLongProperty() { - val property1 = 2.toProperty() - val property2 = 5L.toProperty() - - val binding = property1 * property2 - Assert.assertTrue(binding is LongBinding) - Assert.assertEquals(10L, binding.get()) - - property1.value = 10 - Assert.assertEquals(50L, binding.get()) - - property2.value = 0L - Assert.assertEquals(0L, binding.get()) - } - - @Test fun testIntegerExpressionTimesFloatProperty() { - val property1 = 2.toProperty() - val property2 = 5f.toProperty() - - val binding = property1 * property2 - Assert.assertTrue(binding is FloatBinding) - Assert.assertEquals(10f, binding.get(), .001f) - - property1.value = 10 - Assert.assertEquals(50f, binding.get(), .001f) - - property2.value = 0f - Assert.assertEquals(0f, binding.get(), .001f) - } - - @Test fun testIntegerExpressionTimesDoubleProperty() { - val property1 = 2.toProperty() - val property2 = 5.0.toProperty() - - val binding = property1 * property2 - Assert.assertTrue(binding is DoubleBinding) - Assert.assertEquals(10.0, binding.get(), .001) - - property1.value = 10 - Assert.assertEquals(50.0, binding.get(), .001) - - property2.value = 0.0 - Assert.assertEquals(0.0, binding.get(), .001) - } - - @Test fun testIntegerPropertyTimesAssignNumber() { - val property = 1.toProperty() - property *= 5 - - Assert.assertEquals(5, property.get()) - } - - @Test fun testIntegerPropertyTimesAssignNumberProperty() { - val property1 = 1.toProperty() - val property2 = 5.toProperty() - - property1 *= property2 - Assert.assertEquals(5, property1.get()) - } - - @Test fun testIntegerExpressionDivInt() { - val property = 10.toProperty() - - val binding = property / 5 - Assert.assertTrue(binding is IntegerBinding) - Assert.assertEquals(2, binding.get()) - - property.value = 20 - Assert.assertEquals(4, binding.get()) - } - - @Test fun testIntegerExpressionDivLong() { - val property = 10.toProperty() - - val binding = property / 5L - Assert.assertTrue(binding is LongBinding) - Assert.assertEquals(2L, binding.get()) - - property.value = 20 - Assert.assertEquals(4L, binding.get()) - } - - @Test fun testIntegerExpressionDivFloat() { - val property = 10.toProperty() - - val binding = property / 5f - Assert.assertTrue(binding is FloatBinding) - Assert.assertEquals(2f, binding.get(), .001f) - - property.value = 20 - Assert.assertEquals(4f, binding.get(), .001f) - } - - @Test fun testIntegerExpressionDivDouble() { - val property = 10.toProperty() - - val binding = property / 5.0 - Assert.assertTrue(binding is DoubleBinding) - Assert.assertEquals(2.0, binding.get(), .001) - - property.value = 20 - Assert.assertEquals(4.0, binding.get(), .001) - } - - @Test fun testIntegerExpressionDivIntegerProperty() { - val property1 = 10.toProperty() - val property2 = 5.toProperty() - - val binding = property1 / property2 - Assert.assertTrue(binding is IntegerBinding) - Assert.assertEquals(2, binding.get()) - - property1.value = 20 - Assert.assertEquals(4, binding.get()) - - property2.value = 20 - Assert.assertEquals(1, binding.get()) - } - - @Test fun testIntegerExpressionDivLongProperty() { - val property1 = 10.toProperty() - val property2 = 5L.toProperty() - - val binding = property1 / property2 - Assert.assertTrue(binding is LongBinding) - Assert.assertEquals(2L, binding.get()) - - property1.value = 20 - Assert.assertEquals(4L, binding.get()) - - property2.value = 20L - Assert.assertEquals(1L, binding.get()) - } - - @Test fun testIntegerExpressionDivFloatProperty() { - val property1 = 10.toProperty() - val property2 = 5f.toProperty() - - val binding = property1 / property2 - Assert.assertTrue(binding is FloatBinding) - Assert.assertEquals(2f, binding.get(), .001f) - - property1.value = 20 - Assert.assertEquals(4f, binding.get(), .001f) - - property2.value = 20f - Assert.assertEquals(1f, binding.get(), .001f) - } - - @Test fun testIntegerExpressionDivDoubleProperty() { - val property1 = 10.toProperty() - val property2 = 5.0.toProperty() - - val binding = property1 / property2 - Assert.assertTrue(binding is DoubleBinding) - Assert.assertEquals(2.0, binding.get(), .001) - - property1.value = 20 - Assert.assertEquals(4.0, binding.get(), .001) - - property2.value = 20.0 - Assert.assertEquals(1.0, binding.get(), .001) - } - - @Test fun testIntegerPropertyDivAssignNumber() { - val property = 5.toProperty() - property /= 5 - - Assert.assertEquals(1, property.get()) - } - - @Test fun testIntegerPropertyDivAssignNumberProperty() { - val property1 = 5.toProperty() - val property2 = 5.toProperty() - - property1 /= property2 - Assert.assertEquals(1, property1.get()) - } - - @Test fun testIntegerExpressionRemInt() { - val property = 6.toProperty() - - val binding = property % 5 - Assert.assertTrue(binding is IntegerBinding) - Assert.assertEquals(1, binding.get()) - - property.value = 12 - Assert.assertEquals(2, binding.get()) - } - - @Test fun testIntegerExpressionRemLong() { - val property = 6.toProperty() - - val binding = property % 5L - Assert.assertTrue(binding is LongBinding) - Assert.assertEquals(1L, binding.get()) - - property.value = 12 - Assert.assertEquals(2L, binding.get()) - } - - @Test fun testIntegerExpressionRemFloat() { - val property = 6.toProperty() - - val binding = property % 5f - Assert.assertTrue(binding is FloatBinding) - Assert.assertEquals(1f, binding.get(), .001f) - - property.value = 12 - Assert.assertEquals(2f, binding.get(), .001f) - } - - @Test fun testIntegerExpressionRemDouble() { - val property = 6.toProperty() - - val binding = property % 5.0 - Assert.assertTrue(binding is DoubleBinding) - Assert.assertEquals(1.0, binding.get(), .001) - - property.value = 12 - Assert.assertEquals(2.0, binding.get(), .001) - } - - @Test fun testIntegerExpressionRemIntegerProperty() { - val property1 = 6.toProperty() - val property2 = 5.toProperty() - - val binding = property1 % property2 - Assert.assertTrue(binding is IntegerBinding) - Assert.assertEquals(1, binding.get()) - - property1.value = 12 - Assert.assertEquals(2, binding.get()) - - property2.value = 11 - Assert.assertEquals(1, binding.get()) - } - - @Test fun testIntegerExpressionRemLongProperty() { - val property1 = 6.toProperty() - val property2 = 5L.toProperty() - - val binding = property1 % property2 - Assert.assertTrue(binding is LongBinding) - Assert.assertEquals(1L, binding.get()) - - property1.value = 12 - Assert.assertEquals(2L, binding.get()) - - property2.value = 11L - Assert.assertEquals(1L, binding.get()) - } - - @Test fun testIntegerExpressionRemFloatProperty() { - val property1 = 6.toProperty() - val property2 = 5f.toProperty() - - val binding = property1 % property2 - Assert.assertTrue(binding is FloatBinding) - Assert.assertEquals(1f, binding.get(), .001f) - - property1.value = 12 - Assert.assertEquals(2f, binding.get(), .001f) - - property2.value = 11f - Assert.assertEquals(1f, binding.get(), .001f) - } - - @Test fun testIntegerExpressionRemDoubleProperty() { - val property1 = 6.toProperty() - val property2 = 5.0.toProperty() - - val binding = property1 % property2 - Assert.assertTrue(binding is DoubleBinding) - Assert.assertEquals(1.0, binding.get(), .001) - - property1.value = 12 - Assert.assertEquals(2.0, binding.get(), .001) - - property2.value = 11.0 - Assert.assertEquals(1.0, binding.get(), .001) - } - - @Test fun testIntegerPropertyRemAssignNumber() { - val property = 6.toProperty() - property %= 5 - - Assert.assertEquals(1, property.get()) - } - - @Test fun testIntegerPropertyRemAssignNumberProperty() { - val property1 = 6.toProperty() - val property2 = 5.toProperty() - - property1 %= property2 - Assert.assertEquals(1, property1.get()) - } - - @Test fun testIntegerPropertyRangeToInt() { - val property = 0.toProperty() - val sequence = property..9 - - var counter = 0 - for (i in sequence) { - Assert.assertEquals(counter++, i.get()) - } - - Assert.assertEquals(10, counter) - } - - @Test fun testIntegerPropertyRangeToIntegerProperty() { - val property1 = 0.toProperty() - val property2 = 9.toProperty() - val sequence = property1..property2 - - var counter = 0 - for (i in sequence) { - Assert.assertEquals(counter++, i.get()) - } - - Assert.assertEquals(10, counter) - } - - @Test fun testIntegerPropertyRangeToLong() { - val property = 0.toProperty() - val sequence = property..9L - - var counter = 0L - for (i in sequence) { - Assert.assertEquals(counter++, i.get()) - } - - Assert.assertEquals(10L, counter) - } - - @Test fun testIntegerPropertyRangeToLongProperty() { - val property1 = 0.toProperty() - val property2 = 9L.toProperty() - val sequence = property1..property2 - - var counter = 0L - for (i in sequence) { - Assert.assertEquals(counter++, i.get()) - } - - Assert.assertEquals(10L, counter) - } - - @Test fun testIntegerPropertyCompareToNumber() { - val property = 5.toProperty() - - Assert.assertTrue(property > 4) - Assert.assertTrue(property >= 5) - Assert.assertTrue(property >= 4) - Assert.assertTrue(property <= 5) - Assert.assertTrue(property <= 5) - Assert.assertTrue(property <= 6) - Assert.assertTrue(property < 6) - - Assert.assertFalse(property > 6) - Assert.assertFalse(property >= 6) - Assert.assertFalse(property <= 4) - Assert.assertFalse(property < 4) - } - - @Test fun testIntegerPropertyCompareToNumberProperty() { - val property = 5.toProperty() - - - Assert.assertTrue(property > 4.toProperty()) - Assert.assertTrue(property >= 5.toProperty()) - Assert.assertTrue(property >= 4.toProperty()) - Assert.assertTrue(property <= 5.toProperty()) - Assert.assertTrue(property <= 5.toProperty()) - Assert.assertTrue(property <= 6.toProperty()) - Assert.assertTrue(property < 6.toProperty()) - - Assert.assertFalse(property > 6.toProperty()) - Assert.assertFalse(property >= 6.toProperty()) - Assert.assertFalse(property <= 4.toProperty()) - Assert.assertFalse(property < 4.toProperty()) - } - - @Test fun testLongExpressionPlusNumber() { - val property = 0L.toProperty() - - val binding = property + 5 - Assert.assertTrue(binding is LongBinding) - Assert.assertEquals(5L, binding.get()) - - property.value -= 5L - Assert.assertEquals(0L, binding.get()) - } - - @Test fun testLongExpressionPlusFloat() { - val property = 0L.toProperty() - - val binding = property + 5f - Assert.assertTrue(binding is FloatBinding) - Assert.assertEquals(5f, binding.get(), .001f) - - property.value -= 5L - Assert.assertEquals(0f, binding.get(), .001f) - } - - @Test fun testLongExpressionPlusDouble() { - val property = 0L.toProperty() - - val binding = property + 5.0 - Assert.assertTrue(binding is DoubleBinding) - Assert.assertEquals(5.0, binding.get(), .001) - - property.value -= 5L - Assert.assertEquals(0.0, binding.get(), .001) - } - - @Test fun testLongExpressionPlusNumberProperty() { - val property1 = 0L.toProperty() - val property2 = 5.toProperty() - - val binding = property1 + property2 - Assert.assertTrue(binding is LongBinding) - Assert.assertEquals(5L, binding.get()) - - property1.value -= 10L - Assert.assertEquals(-5L, binding.get()) - - property2.value = 0 - Assert.assertEquals(-10L, binding.get()) - } - - @Test fun testLongExpressionPlusFloatProperty() { - val property1 = 0L.toProperty() - val property2 = 5f.toProperty() - - val binding = property1 + property2 - Assert.assertTrue(binding is FloatBinding) - Assert.assertEquals(5f, binding.get(), .001f) - - property1.value -= 10L - Assert.assertEquals(-5f, binding.get(), .001f) - - property2.value = 0f - Assert.assertEquals(-10f, binding.get(), .001f) - } - - @Test fun testLongExpressionPlusDoubleProperty() { - val property1 = 0L.toProperty() - val property2 = 5.0.toProperty() - - val binding = property1 + property2 - Assert.assertTrue(binding is DoubleBinding) - Assert.assertEquals(5.0, binding.get(), .001) - - property1.value -= 10L - Assert.assertEquals(-5.0, binding.get(), .001) - - property2.value = 0.0 - Assert.assertEquals(-10.0, binding.get(), .001) - } - - @Test fun testLongPropertyPlusAssignNumber() { - val property = 0L.toProperty() - property += 5 - - Assert.assertEquals(5L, property.get()) - } - - @Test fun testLongPropertyPlusAssignNumberProperty() { - val property1 = 0L.toProperty() - val property2 = 5.toProperty() - - property1 += property2 - Assert.assertEquals(5L, property1.get()) - } - - @Test fun testLongExpressionMinusNumber() { - val property = 0L.toProperty() - - val binding = property - 5 - Assert.assertTrue(binding is LongBinding) - Assert.assertEquals(-5L, binding.get()) - - property.value -= 5L - Assert.assertEquals(-10L, binding.get()) - } - - @Test fun testLongExpressionMinusFloat() { - val property = 0L.toProperty() - - val binding = property - 5f - Assert.assertTrue(binding is FloatBinding) - Assert.assertEquals(-5f, binding.get(), .001f) - - property.value -= 5L - Assert.assertEquals(-10f, binding.get(), .001f) - } - - @Test fun testLongExpressionMinusDouble() { - val property = 0L.toProperty() - - val binding = property - 5.0 - Assert.assertTrue(binding is DoubleBinding) - Assert.assertEquals(-5.0, binding.get(), .001) - - property.value -= 5L - Assert.assertEquals(-10.0, binding.get(), .001) - } - - @Test fun testLongExpressionMinusNumberProperty() { - val property1 = 0L.toProperty() - val property2 = 5.toProperty() - - val binding = property1 - property2 - Assert.assertTrue(binding is LongBinding) - Assert.assertEquals(-5L, binding.get()) - - property1.value -= 10L - Assert.assertEquals(-15L, binding.get()) - - property2.value = 0 - Assert.assertEquals(-10L, binding.get()) - } - - @Test fun testLongExpressionMinusFloatProperty() { - val property1 = 0L.toProperty() - val property2 = 5f.toProperty() - - val binding = property1 - property2 - Assert.assertTrue(binding is FloatBinding) - Assert.assertEquals(-5f, binding.get(), .001f) - - property1.value -= 10L - Assert.assertEquals(-15f, binding.get(), .001f) - - property2.value = 0f - Assert.assertEquals(-10f, binding.get(), .001f) - } - - @Test fun testLongExpressionMinusDoubleProperty() { - val property1 = 0L.toProperty() - val property2 = 5.0.toProperty() - - val binding = property1 - property2 - Assert.assertTrue(binding is DoubleBinding) - Assert.assertEquals(-5.0, binding.get(), .001) - - property1.value -= 10L - Assert.assertEquals(-15.0, binding.get(), .001) - - property2.value = 0.0 - Assert.assertEquals(-10.0, binding.get(), .001) - } - - @Test fun testLongPropertyMinusAssignNumber() { - val property = 0L.toProperty() - property -= 5 - - Assert.assertEquals(-5L, property.get()) - } - - @Test fun testLongPropertyMinusAssignNumberProperty() { - val property1 = 0L.toProperty() - val property2 = 5.toProperty() - - property1 -= property2 - Assert.assertEquals(-5L, property1.get()) - } - - @Test fun testLongPropertyUnaryMinus() { - val property = 1L.toProperty() - - val binding = -property - Assert.assertEquals(-1L, binding.get()) - - property += 1 - Assert.assertEquals(-2L, binding.get()) - } - - @Test fun testLongExpressionTimesNumber() { - val property = 2L.toProperty() - - val binding = property * 5 - Assert.assertTrue(binding is LongBinding) - Assert.assertEquals(10L, binding.get()) - - property.value = 5L - Assert.assertEquals(25L, binding.get()) - } - - @Test fun testLongExpressionTimesFloat() { - val property = 2L.toProperty() - - val binding = property * 5f - Assert.assertTrue(binding is FloatBinding) - Assert.assertEquals(10f, binding.get(), .001f) - - property.value = 5L - Assert.assertEquals(25f, binding.get(), .001f) - } - - @Test fun testLongExpressionTimesDouble() { - val property = 2L.toProperty() - - val binding = property * 5.0 - Assert.assertTrue(binding is DoubleBinding) - Assert.assertEquals(10.0, binding.get(), .001) - - property.value = 5L - Assert.assertEquals(25.0, binding.get(), .001) - } - - @Test fun testLongExpressionTimesNumberProperty() { - val property1 = 2L.toProperty() - val property2 = 5.toProperty() - - val binding = property1 * property2 - Assert.assertTrue(binding is LongBinding) - Assert.assertEquals(10L, binding.get()) - - property1.value = 10L - Assert.assertEquals(50L, binding.get()) - - property2.value = 0 - Assert.assertEquals(0L, binding.get()) - } - - @Test fun testLongExpressionTimesFloatProperty() { - val property1 = 2L.toProperty() - val property2 = 5f.toProperty() - - val binding = property1 * property2 - Assert.assertTrue(binding is FloatBinding) - Assert.assertEquals(10f, binding.get(), .001f) - - property1.value = 10L - Assert.assertEquals(50f, binding.get(), .001f) - - property2.value = 0f - Assert.assertEquals(0f, binding.get(), .001f) - } - - @Test fun testLongExpressionTimesDoubleProperty() { - val property1 = 2L.toProperty() - val property2 = 5.0.toProperty() - - val binding = property1 * property2 - Assert.assertTrue(binding is DoubleBinding) - Assert.assertEquals(10.0, binding.get(), .001) - - property1.value = 10L - Assert.assertEquals(50.0, binding.get(), .001) - - property2.value = 0.0 - Assert.assertEquals(0.0, binding.get(), .001) - } - - @Test fun testLongPropertyTimesAssignNumber() { - val property = 1L.toProperty() - property *= 5 - - Assert.assertEquals(5L, property.get()) - } - - @Test fun testLongPropertyTimesAssignNumberProperty() { - val property1 = 1L.toProperty() - val property2 = 5.toProperty() - - property1 *= property2 - Assert.assertEquals(5L, property1.get()) - } - - @Test fun testLongExpressionDivNumber() { - val property = 10L.toProperty() - - val binding = property / 5 - Assert.assertTrue(binding is LongBinding) - Assert.assertEquals(2L, binding.get()) - - property.value = 20L - Assert.assertEquals(4L, binding.get()) - } - - @Test fun testLongExpressionDivFloat() { - val property = 10L.toProperty() - - val binding = property / 5f - Assert.assertTrue(binding is FloatBinding) - Assert.assertEquals(2f, binding.get(), .001f) - - property.value = 20L - Assert.assertEquals(4f, binding.get(), .001f) - } - - @Test fun testLongExpressionDivDouble() { - val property = 10L.toProperty() - - val binding = property / 5.0 - Assert.assertTrue(binding is DoubleBinding) - Assert.assertEquals(2.0, binding.get(), .001) - - property.value = 20L - Assert.assertEquals(4.0, binding.get(), .001) - } - - @Test fun testLongExpressionDivNumberProperty() { - val property1 = 10L.toProperty() - val property2 = 5.toProperty() - - val binding = property1 / property2 - Assert.assertTrue(binding is LongBinding) - Assert.assertEquals(2L, binding.get()) - - property1.value = 20L - Assert.assertEquals(4L, binding.get()) - - property2.value = 20 - Assert.assertEquals(1L, binding.get()) - } - - @Test fun testLongExpressionDivFloatProperty() { - val property1 = 10L.toProperty() - val property2 = 5f.toProperty() - - val binding = property1 / property2 - Assert.assertTrue(binding is FloatBinding) - Assert.assertEquals(2f, binding.get(), .001f) - - property1.value = 20L - Assert.assertEquals(4f, binding.get(), .001f) - - property2.value = 20f - Assert.assertEquals(1f, binding.get(), .001f) - } - - @Test fun testLongExpressionDivDoubleProperty() { - val property1 = 10L.toProperty() - val property2 = 5.0.toProperty() - - val binding = property1 / property2 - Assert.assertTrue(binding is DoubleBinding) - Assert.assertEquals(2.0, binding.get(), .001) - - property1.value = 20L - Assert.assertEquals(4.0, binding.get(), .001) - - property2.value = 20.0 - Assert.assertEquals(1.0, binding.get(), .001) - } - - @Test fun testLongPropertyDivAssignNumber() { - val property = 5L.toProperty() - property /= 5 - - Assert.assertEquals(1L, property.get()) - } - - @Test fun testLongPropertyDivAssignNumberProperty() { - val property1 = 5L.toProperty() - val property2 = 5.toProperty() - - property1 /= property2 - Assert.assertEquals(1L, property1.get()) - } - - @Test fun testLongExpressionRemNumber() { - val property = 6L.toProperty() - - val binding = property % 5 - Assert.assertTrue(binding is LongBinding) - Assert.assertEquals(1L, binding.get()) - - property.value = 12L - Assert.assertEquals(2L, binding.get()) - } - - @Test fun testLongExpressionRemFloat() { - val property = 6L.toProperty() - - val binding = property % 5f - Assert.assertTrue(binding is FloatBinding) - Assert.assertEquals(1f, binding.get(), .001f) - - property.value = 12L - Assert.assertEquals(2f, binding.get(), .001f) - } - - @Test fun testLongExpressionRemDouble() { - val property = 6L.toProperty() - - val binding = property % 5.0 - Assert.assertTrue(binding is DoubleBinding) - Assert.assertEquals(1.0, binding.get(), .001) - - property.value = 12L - Assert.assertEquals(2.0, binding.get(), .001) - } - - @Test fun testLongExpressionRemNumberProperty() { - val property1 = 6L.toProperty() - val property2 = 5.toProperty() - - val binding = property1 % property2 - Assert.assertTrue(binding is LongBinding) - Assert.assertEquals(1L, binding.get()) - - property1.value = 12L - Assert.assertEquals(2L, binding.get()) - - property2.value = 11 - Assert.assertEquals(1L, binding.get()) - } - - @Test fun testLongExpressionRemFloatProperty() { - val property1 = 6L.toProperty() - val property2 = 5f.toProperty() - - val binding = property1 % property2 - Assert.assertTrue(binding is FloatBinding) - Assert.assertEquals(1f, binding.get(), .001f) - - property1.value = 12L - Assert.assertEquals(2f, binding.get(), .001f) - - property2.value = 11f - Assert.assertEquals(1f, binding.get(), .001f) - } - - @Test fun testLongExpressionRemDoubleProperty() { - val property1 = 6L.toProperty() - val property2 = 5.0.toProperty() - - val binding = property1 % property2 - Assert.assertTrue(binding is DoubleBinding) - Assert.assertEquals(1.0, binding.get(), .001) - - property1.value = 12L - Assert.assertEquals(2.0, binding.get(), .001) - - property2.value = 11.0 - Assert.assertEquals(1.0, binding.get(), .001) - } - - @Test fun testLongPropertyRemAssignNumber() { - val property = 6L.toProperty() - property %= 5 - - Assert.assertEquals(1L, property.get()) - } - - @Test fun testLongPropertyRemAssignNumberProperty() { - val property1 = 6L.toProperty() - val property2 = 5.toProperty() - - property1 %= property2 - Assert.assertEquals(1L, property1.get()) - } - - @Test fun testLongPropertyRangeToInt() { - val property = 0L.toProperty() - val sequence = property..9 - - var counter = 0L - for (i in sequence) { - Assert.assertEquals(counter++, i.get()) - } - - Assert.assertEquals(10L, counter) - } - - @Test fun testLongPropertyRangeToIntegerProperty() { - val property1 = 0L.toProperty() - val property2 = 9.toProperty() - val sequence = property1..property2 - - var counter = 0L - for (i in sequence) { - Assert.assertEquals(counter++, i.get()) - } - - Assert.assertEquals(10L, counter) - } - - @Test fun testLongPropertyRangeToLong() { - val property = 0L.toProperty() - val sequence = property..9L - - var counter = 0L - for (i in sequence) { - Assert.assertEquals(counter++, i.get()) - } - - Assert.assertEquals(10L, counter) - } - - @Test fun testLongPropertyRangeToLongProperty() { - val property1 = 0L.toProperty() - val property2 = 9L.toProperty() - val sequence = property1..property2 - - var counter = 0L - for (i in sequence) { - Assert.assertEquals(counter++, i.get()) - } - - Assert.assertEquals(10L, counter) - } - - @Test fun testLongPropertyCompareToNumber() { - val property = 5L.toProperty() - - Assert.assertTrue(property > 4) - Assert.assertTrue(property >= 5) - Assert.assertTrue(property >= 4) - Assert.assertTrue(property <= 5) - Assert.assertTrue(property <= 5) - Assert.assertTrue(property <= 6) - Assert.assertTrue(property < 6) - - Assert.assertFalse(property > 6) - Assert.assertFalse(property >= 6) - Assert.assertFalse(property <= 4) - Assert.assertFalse(property < 4) - } - - @Test fun testLongPropertyCompareToNumberProperty() { - val property = 5L.toProperty() - - - Assert.assertTrue(property > 4.toProperty()) - Assert.assertTrue(property >= 5.toProperty()) - Assert.assertTrue(property >= 4.toProperty()) - Assert.assertTrue(property <= 5.toProperty()) - Assert.assertTrue(property <= 5.toProperty()) - Assert.assertTrue(property <= 6.toProperty()) - Assert.assertTrue(property < 6.toProperty()) - - Assert.assertFalse(property > 6.toProperty()) - Assert.assertFalse(property >= 6.toProperty()) - Assert.assertFalse(property <= 4.toProperty()) - Assert.assertFalse(property < 4.toProperty()) - } - - @Test fun testNumberExpressionGtInt() { - val property = (-1).toProperty() - - val binding = property gt 0 - Assert.assertFalse(binding.get()) - - property.value = 0 - Assert.assertFalse(binding.get()) - - property.value = 1 - Assert.assertTrue(binding.get()) - } - - @Test fun testNumberExpressionGtLong() { - val property = (-1).toProperty() - - val binding = property gt 0L - Assert.assertFalse(binding.get()) - - property.value = 0 - Assert.assertFalse(binding.get()) - - property.value = 1 - Assert.assertTrue(binding.get()) - } - - @Test fun testNumberExpressionGtFloat() { - val property = (-1).toProperty() - - val binding = property gt 0f - Assert.assertFalse(binding.get()) - - property.value = 0 - Assert.assertFalse(binding.get()) - - property.value = 1 - Assert.assertTrue(binding.get()) - } - - @Test fun testNumberExpressionGtDouble() { - val property = (-1).toProperty() - - val binding = property gt 0.0 - Assert.assertFalse(binding.get()) - - property.value = 0 - Assert.assertFalse(binding.get()) - - property.value = 1 - Assert.assertTrue(binding.get()) - } - - @Test fun testNumberExpressionGtNumberProperty() { - val property = (-1).toProperty() - - val binding = property gt 0.0.toProperty() - Assert.assertFalse(binding.get()) - - property.value = 0 - Assert.assertFalse(binding.get()) - - property.value = 1 - Assert.assertTrue(binding.get()) - } - - @Test fun testNumberExpressionGeInt() { - val property = (-1).toProperty() - - val binding = property ge 0 - Assert.assertFalse(binding.get()) - - property.value = 0 - Assert.assertTrue(binding.get()) - - property.value = 1 - Assert.assertTrue(binding.get()) - } - - @Test fun testNumberExpressionGeLong() { - val property = (-1).toProperty() - - val binding = property ge 0L - Assert.assertFalse(binding.get()) - - property.value = 0 - Assert.assertTrue(binding.get()) - - property.value = 1 - Assert.assertTrue(binding.get()) - } - - @Test fun testNumberExpressionGeFloat() { - val property = (-1).toProperty() - - val binding = property ge 0f - Assert.assertFalse(binding.get()) - - property.value = 0 - Assert.assertTrue(binding.get()) - - property.value = 1 - Assert.assertTrue(binding.get()) - } - - @Test fun testNumberExpressionGeDouble() { - val property = (-1).toProperty() - - val binding = property ge 0.0 - Assert.assertFalse(binding.get()) - - property.value = 0 - Assert.assertTrue(binding.get()) - - property.value = 1 - Assert.assertTrue(binding.get()) - } - - @Test fun testNumberExpressionGeNumberProperty() { - val property = (-1).toProperty() - - val binding = property ge 0.0.toProperty() - Assert.assertFalse(binding.get()) - - property.value = 0 - Assert.assertTrue(binding.get()) - - property.value = 1 - Assert.assertTrue(binding.get()) - } - - @Test fun testNumberExpressionEqInt() { - val property = (-1).toProperty() - - val binding = property eq 0 - Assert.assertFalse(binding.get()) - - property.value = 0 - Assert.assertTrue(binding.get()) - - property.value = 1 - Assert.assertFalse(binding.get()) - } - - @Test fun testNumberExpressionEqLong() { - val property = (-1).toProperty() - - val binding = property eq 0L - Assert.assertFalse(binding.get()) - - property.value = 0 - Assert.assertTrue(binding.get()) - - property.value = 1 - Assert.assertFalse(binding.get()) - } - - @Test fun testNumberExpressionEqNumberProperty() { - val property = (-1).toProperty() - - val binding = property eq 0.0.toProperty() - Assert.assertFalse(binding.get()) - - property.value = 0 - Assert.assertTrue(binding.get()) - - property.value = 1 - Assert.assertFalse(binding.get()) - } - - @Test fun testNumberExpressionLeInt() { - val property = (-1).toProperty() - - val binding = property le 0 - Assert.assertTrue(binding.get()) - - property.value = 0 - Assert.assertTrue(binding.get()) - - property.value = 1 - Assert.assertFalse(binding.get()) - } - - @Test fun testNumberExpressionLeLong() { - val property = (-1).toProperty() - - val binding = property le 0L - Assert.assertTrue(binding.get()) - - property.value = 0 - Assert.assertTrue(binding.get()) - - property.value = 1 - Assert.assertFalse(binding.get()) - } - - @Test fun testNumberExpressionLeFloat() { - val property = (-1).toProperty() - - val binding = property le 0f - Assert.assertTrue(binding.get()) - - property.value = 0 - Assert.assertTrue(binding.get()) - - property.value = 1 - Assert.assertFalse(binding.get()) - } - - @Test fun testNumberExpressionLeDouble() { - val property = (-1).toProperty() - - val binding = property le 0.0 - Assert.assertTrue(binding.get()) - - property.value = 0 - Assert.assertTrue(binding.get()) - - property.value = 1 - Assert.assertFalse(binding.get()) - } - - @Test fun testNumberExpressionLeNumberProperty() { - val property = (-1).toProperty() - - val binding = property le 0.0.toProperty() - Assert.assertTrue(binding.get()) - - property.value = 0 - Assert.assertTrue(binding.get()) - - property.value = 1 - Assert.assertFalse(binding.get()) - } - - @Test fun testNumberExpressionLtInt() { - val property = (-1).toProperty() - - val binding = property lt 0 - Assert.assertTrue(binding.get()) - - property.value = 0 - Assert.assertFalse(binding.get()) - - property.value = 1 - Assert.assertFalse(binding.get()) - } - - @Test fun testNumberExpressionLtLong() { - val property = (-1).toProperty() - - val binding = property lt 0L - Assert.assertTrue(binding.get()) - - property.value = 0 - Assert.assertFalse(binding.get()) - - property.value = 1 - Assert.assertFalse(binding.get()) - } - - @Test fun testNumberExpressionLtFloat() { - val property = (-1).toProperty() - - val binding = property lt 0f - Assert.assertTrue(binding.get()) - - property.value = 0 - Assert.assertFalse(binding.get()) - - property.value = 1 - Assert.assertFalse(binding.get()) - } - - @Test fun testNumberExpressionLtDouble() { - val property = (-1).toProperty() - - val binding = property lt 0.0 - Assert.assertTrue(binding.get()) - - property.value = 0 - Assert.assertFalse(binding.get()) - - property.value = 1 - Assert.assertFalse(binding.get()) - } - - @Test fun testNumberExpressionLtNumberProperty() { - val property = (-1).toProperty() - - val binding = property lt 0.0.toProperty() - Assert.assertTrue(binding.get()) - - property.value = 0 - Assert.assertFalse(binding.get()) - - property.value = 1 - Assert.assertFalse(binding.get()) - } - - @Test fun testBooleanExpressionNot() { - val property = true.toProperty() - - val binding = !property - Assert.assertFalse(binding.get()) - - property.value = false - Assert.assertTrue(binding.get()) - } - - @Test fun testBooleanExpressionAndBoolean() { - val property = true.toProperty() - - val binding = property and true - Assert.assertTrue(binding.get()) - - property.value = false - Assert.assertFalse(binding.get()) - } - - @Test fun testBooleanExpressionAndBooleanProperty() { - val property1 = true.toProperty() - val property2 = true.toProperty() - - val binding = property1 and property2 - Assert.assertTrue(binding.get()) - - property1.value = false - Assert.assertFalse(binding.get()) - - property1.value = true - Assert.assertTrue(binding.get()) - - property2.value = false - Assert.assertFalse(binding.get()) - } - - @Test fun testBooleanExpressionOrBoolean() { - val property = false.toProperty() - - val binding = property or false - Assert.assertFalse(binding.get()) - - property.value = true - Assert.assertTrue(binding.get()) - } - - @Test fun testBooleanExpressionOrBooleanProperty() { - val property1 = false.toProperty() - val property2 = false.toProperty() - - val binding = property1 or property2 - Assert.assertFalse(binding.get()) - - property1.value = true - Assert.assertTrue(binding.get()) - - property2.value = true - Assert.assertTrue(binding.get()) - } - - @Test fun testBooleanExpressionXorBoolean() { - val property = false.toProperty() - - val binding = property xor true - Assert.assertTrue(binding.get()) - - property.value = true - Assert.assertFalse(binding.get()) - } - - @Test fun testBooleanExpressionXorBooleanProperty() { - val property1 = false.toProperty() - val property2 = false.toProperty() - - val binding = property1 xor property2 - Assert.assertFalse(binding.get()) - - property1.value = true - Assert.assertTrue(binding.get()) - - property2.value = true - Assert.assertFalse(binding.get()) - } - - @Test fun testBooleanExpressionEqBoolean() { - val property = false.toProperty() - - val binding = property eq false - Assert.assertTrue(binding.get()) - - property.value = true - Assert.assertFalse(binding.get()) - } - - @Test fun testBooleanExpressionEqBooleanProperty() { - val property1 = false.toProperty() - val property2 = false.toProperty() - - val binding = property1 eq property2 - Assert.assertTrue(binding.get()) - - property1.value = true - Assert.assertFalse(binding.get()) - - property2.value = true - Assert.assertTrue(binding.get()) - } - - @Test fun testStringExpressionPlusAny() { - val property = "Hello ".toProperty() - - val binding = property + "World!" - Assert.assertTrue(binding.get() == "Hello World!") - - property.value = "Bye " - Assert.assertTrue(binding.get() == "Bye World!") - } - - @Test fun testStringPropertyPlusAssignAny() { - val property = "Hello ".toProperty() - - Assert.assertTrue(property.get() == "Hello ") - - property += "World!" - Assert.assertTrue(property.get() == "Hello World!") - } - - @Test fun testStringExpressionGetInt() { - val property = "Hello World!".toProperty() - - val binding = property[0] - Assert.assertEquals('H', binding.value) - - property.value = "Bye World!" - Assert.assertEquals('B', binding.value) - } - - @Test fun testStringExpressionGetIntProperty() { - val property = "Hello World!".toProperty() - val indexProperty = 0.toProperty() - - val binding = property[indexProperty] - Assert.assertEquals('H', binding.value) - - property.value = "Bye World!" - Assert.assertEquals('B', binding.value) - - indexProperty.value = 1 - Assert.assertEquals('y', binding.value) - } - - @Test fun testStringExpressionGetIntToInt() { - val property = "foo()".toProperty() - - val binding = property[0, 3] - Assert.assertEquals("foo", binding.get()) - - property.value = "bar()" - Assert.assertEquals("bar", binding.get()) - } - - @Test fun testStringExpressionGetIntegerPropertyToInt() { - val property = "foo()".toProperty() - val startIndex = 0.toProperty() - - val binding = property[startIndex, 3] - Assert.assertEquals("foo", binding.get()) - - property.value = "bar()" - Assert.assertEquals("bar", binding.get()) - - startIndex.value = 1 - Assert.assertEquals("ar", binding.get()) - } - - @Test fun testStringExpressionGetIntToIntegerProperty() { - val property = "foo()".toProperty() - val endIndex = 3.toProperty() - - val binding = property[0, endIndex] - Assert.assertEquals("foo", binding.get()) - - property.value = "bar()" - Assert.assertEquals("bar", binding.get()) - - endIndex.value = 5 - Assert.assertEquals("bar()", binding.get()) - } - - @Test fun testStringExpressionGetIntegerPropertyToIntegerProperty() { - val property = "foo()".toProperty() - val startIndex = 0.toProperty() - val endIndex = 3.toProperty() - - val binding = property[startIndex, endIndex] - Assert.assertEquals("foo", binding.get()) - - property.value = "bar()" - Assert.assertEquals("bar", binding.get()) - - startIndex.value = 3 - endIndex.value = 5 - Assert.assertEquals("()", binding.get()) - } - - @Test fun testStringExpressionUnaryMinus() { - val property = "god a ward".toProperty() - - val binding = -property - Assert.assertEquals("draw a dog", binding.get()) - - property.value = "dog a ward" - Assert.assertEquals("draw a god", binding.get()) - } - - @Test fun testStringExpressionCompareToString() { - val property = "Bravo".toProperty() - - Assert.assertTrue(property > "Alpha") - Assert.assertTrue(property >= "Alpha") - Assert.assertTrue(property >= "Bravo") - - Assert.assertTrue(property <= "Bravo") - Assert.assertTrue(property <= "Charlie") - Assert.assertTrue(property < "Charlie") - - Assert.assertFalse(property < "Alpha") - Assert.assertFalse(property <= "Alpha") - - Assert.assertFalse(property >= "Charlie") - Assert.assertFalse(property > "Charlie") - } - - @Test fun testStringExpressionCompareToStringProperty() { - val property = "Bravo".toProperty() - - Assert.assertTrue(property > "Alpha".toProperty()) - Assert.assertTrue(property >= "Alpha".toProperty()) - Assert.assertTrue(property >= "Bravo".toProperty()) - - Assert.assertTrue(property <= "Bravo".toProperty()) - Assert.assertTrue(property <= "Charlie".toProperty()) - Assert.assertTrue(property < "Charlie".toProperty()) - - Assert.assertFalse(property < "Alpha".toProperty()) - Assert.assertFalse(property <= "Alpha".toProperty()) - - Assert.assertFalse(property >= "Charlie".toProperty()) - Assert.assertFalse(property > "Charlie".toProperty()) - } - - @Test fun testStringExpressionGtString() { - val property = "Bravo".toProperty() - - val binding = property gt "Alpha" - Assert.assertTrue(binding.get()) - - property.value = "Alpha" - Assert.assertFalse(binding.get()) - } - - @Test fun testStringExpressionGtStringProperty() { - val property1 = "Charlie".toProperty() - val property2 = "Bravo".toProperty() - - val binding = property1 gt property2 - Assert.assertTrue(binding.get()) - - property1.value = "Bravo" - Assert.assertFalse(binding.get()) - - property2.value = "Alpha" - Assert.assertTrue(binding.get()) - } - - @Test fun testStringExpressionGeString() { - val property = "Charlie".toProperty() - - val binding = property ge "Bravo" - Assert.assertTrue(binding.get()) - - property.value = "Bravo" - Assert.assertTrue(binding.get()) - - property.value = "Alpha" - Assert.assertFalse(binding.get()) - } - - @Test fun testStringExpressionGeStringProperty() { - val property1 = "Charlie".toProperty() - val property2 = "Bravo".toProperty() - - val binding = property1 ge property2 - Assert.assertTrue(binding.get()) - - property1.value = "Bravo" - Assert.assertTrue(binding.get()) - - property2.value = "Alpha" - Assert.assertTrue(binding.get()) - - property2.value = "Charlie" - Assert.assertFalse(binding.get()) - } - - @Test fun testStringExpressionEqString() { - val property = "Bravo".toProperty() - - val binding = property eq "Bravo" - Assert.assertTrue(binding.get()) - - property.value = "Alpha" - Assert.assertFalse(binding.get()) - } - - @Test fun testStringExpressionEqStringProperty() { - val property1 = "Bravo".toProperty() - val property2 = "Bravo".toProperty() - - val binding = property1 eq property2 - Assert.assertTrue(binding.get()) - - property1.value = "Alpha" - Assert.assertFalse(binding.get()) - - property2.value = "Alpha" - Assert.assertTrue(binding.get()) - } - - @Test fun testStringExpressionLeString() { - val property = "Alpha".toProperty() - - val binding = property le "Bravo" - Assert.assertTrue(binding.get()) - - property.value = "Bravo" - Assert.assertTrue(binding.get()) - - property.value = "Charlie" - Assert.assertFalse(binding.get()) - } - - @Test fun testStringExpressionLeStringProperty() { - val property1 = "Alpha".toProperty() - val property2 = "Bravo".toProperty() - - val binding = property1 le property2 - Assert.assertTrue(binding.get()) - - property1.value = "Bravo" - Assert.assertTrue(binding.get()) - - property2.value = "Charlie" - Assert.assertTrue(binding.get()) - - property2.value = "Alpha" - Assert.assertFalse(binding.get()) - } - - @Test fun testStringExpressionLtString() { - val property = "Alpha".toProperty() - - val binding = property lt "Bravo" - Assert.assertTrue(binding.get()) - - property.value = "Bravo" - Assert.assertFalse(binding.get()) - - property.value = "Charlie" - Assert.assertFalse(binding.get()) - } - - @Test fun testStringExpressionLtStringProperty() { - val property1 = "Alpha".toProperty() - val property2 = "Bravo".toProperty() - - val binding = property1 lt property2 - Assert.assertTrue(binding.get()) - - property1.value = "Bravo" - Assert.assertFalse(binding.get()) - - property2.value = "Charlie" - Assert.assertTrue(binding.get()) - - property2.value = "Alpha" - Assert.assertFalse(binding.get()) - } - - @Test fun testStringExpressionEqIgnoreCaseString() { - val property = "Hello World!".toProperty() - - val binding = property eqIgnoreCase "hello world!" - Assert.assertTrue(binding.get()) - - property.value = "Bye World!" - Assert.assertFalse(binding.get()) - } - - @Test fun testStringExpressionEqIgnoreCaseStringProperty() { - val property1 = "Hello World!".toProperty() - val property2 = "hello world!".toProperty() - - val binding = property1 eqIgnoreCase property2 - Assert.assertTrue(binding.get()) - - property1.value = "bye world!" - Assert.assertFalse(binding.get()) - - property2.value = "Bye World!" - Assert.assertTrue(binding.get()) - } - - @Test fun propertyFromMapKey() { - val map = mutableMapOf("hello" to "world", "number" to 42) - val helloProperty = map.toProperty("hello") { SimpleStringProperty(it as String?) } - val numberProperty = map.toProperty("number") { SimpleIntegerProperty(it as Int) } - helloProperty.value = "there" - numberProperty.value = 43 - Assert.assertEquals("there", map["hello"]) - Assert.assertEquals(43, map["number"]) - } - -// class ListHolder { -// val listProperty: ListProperty = SimpleListProperty(FXCollections.observableArrayList()) -// var list: MutableList by listProperty -// } -// -// @Test fun listPropertyDelegateModifyList() { -// val listHolder = ListHolder() -// var notified = false -// listHolder.listProperty.addListener { _, _, _-> notified = true } -// -// listHolder.list.add("Test") -// Assert.assertTrue(notified) -// -// notified = false -// listHolder.list.remove("Test") -// Assert.assertTrue(notified) -// -// notified = false -// listHolder.list.addAll(arrayOf("1", "2")) -// Assert.assertTrue(notified) -// -// notified = false -// listHolder.list.clear() -// Assert.assertTrue(notified) -// } -// -// @Test fun listPropertyDelegateChangeList() { -// val listHolder = ListHolder() -// var notified = false -// listHolder.listProperty.addListener { _, _, _-> notified = true } -// -// listHolder.list = mutableListOf("Test") -// Assert.assertTrue(notified) -// } -// -// class SetHolder { -// val setProperty: SetProperty = SimpleSetProperty(FXCollections.observableSet()) -// var set: MutableSet by setProperty -// } -// -// @Test fun setPropertyDelegateModifySet() { -// val setHolder = SetHolder() -// var notified = false -// setHolder.setProperty.addListener { _, _, _-> notified = true } -// -// setHolder.set.add("Test") -// Assert.assertTrue(notified) -// -// notified = false -// setHolder.set.remove("Test") -// Assert.assertTrue(notified) -// -// notified = false -// setHolder.set.addAll(arrayOf("1", "2")) -// Assert.assertTrue(notified) -// -// notified = false -// setHolder.set.clear() -// Assert.assertTrue(notified) -// } -// -// @Test fun setPropertyDelegateChangeSet() { -// val setHolder = SetHolder() -// var notified = false -// setHolder.setProperty.addListener { _, _, _-> notified = true } -// -// setHolder.set = mutableSetOf("Test") -// Assert.assertTrue(notified) -// } -// -// class MapHolder { -// val mapProperty: MapProperty = SimpleMapProperty(FXCollections.observableHashMap()) -// var map: MutableMap by mapProperty -// } -// -// @Test fun mapPropertyDelegateModifyMap() { -// val mapHolder = MapHolder() -// var notified = false -// mapHolder.mapProperty.addListener { _, _, _-> notified = true } -// -// mapHolder.map.put(0, "Test") -// Assert.assertTrue(notified) -// -// notified = false -// mapHolder.map.remove(0) -// Assert.assertTrue(notified) -// -// notified = false -// mapHolder.map.putAll(mapOf(1 to "1", 2 to "2")) -// Assert.assertTrue(notified) -// -// notified = false -// mapHolder.map.clear() -// Assert.assertTrue(notified) -// } -// -// @Test fun mapPropertyDelegateChangeMap() { -// val mapHolder = MapHolder() -// var notified = false -// mapHolder.mapProperty.addListener { _, _, _-> notified = true } -// -// mapHolder.map = mutableMapOf(0 to "Test") -// Assert.assertTrue(notified) -// } -} \ No newline at end of file diff --git a/src/test/kotlin/tornadofx/tests/RestClientTest.kt b/src/test/kotlin/tornadofx/tests/RestClientTest.kt deleted file mode 100644 index 46f613d..0000000 --- a/src/test/kotlin/tornadofx/tests/RestClientTest.kt +++ /dev/null @@ -1,98 +0,0 @@ -package tornadofx.tests - -import com.sun.net.httpserver.HttpServer -import javafx.stage.Stage -import org.junit.AfterClass -import org.junit.Assert -import org.junit.BeforeClass -import org.junit.Test -import org.testfx.api.FxToolkit -import tornadofx.* -import java.net.InetSocketAddress -import javax.json.Json -import javax.json.JsonObject - -class RestClientTest { - val primaryStage: Stage = FxToolkit.registerPrimaryStage() - - companion object { - lateinit var httpServer: HttpServer - lateinit var api: Rest - var itemPostPayload: JsonObject? = null - - @BeforeClass - @JvmStatic - fun startWebserverAndDefineAPI() { - api = Rest().apply { - baseURI = "http://localhost:8954" - } - - httpServer = HttpServer.create(InetSocketAddress("localhost", 8954), 0).apply { - createContext("/item") { exchange -> - exchange.sendResponseHeaders(200, 0) - itemPostPayload = Json.createReader(exchange.requestBody).readObject() - exchange.responseBody.use { - Json.createWriter(it).apply { - writeObject(JsonBuilder().add("success", true).build()) - } - } - exchange.requestBody.close() - } - - createContext("/category") { exchange -> - exchange.responseHeaders.add("Content-Type", "application/json") - exchange.sendResponseHeaders(200, 0) - - exchange.responseBody.use { - Json.createWriter(it).apply { - val response = Json.createArrayBuilder() - response.add(JsonBuilder().add("name", "category 1").build()) - response.add(JsonBuilder().add("name", "category 2").build()) - writeArray(response.build()) - } - } - } - start() - } - } - - @AfterClass - @JvmStatic - fun stopWebserver() { - httpServer.stop(0) - } - - } - - @Test - fun testGet() { - val categories = api.get("category").list() - Assert.assertEquals(2, categories.size) - } - - @Test - fun testPost() { - val result = api.post("/item", JsonBuilder().add("name", "test").build()).one() - Assert.assertNotNull(itemPostPayload) - Assert.assertEquals(true, result.boolean("success")) - } - - @Test - fun testAutoclose() { - val hangingResponse = api.get("/category") - FX.runAndWait { - Assert.assertEquals(1, Rest.ongoingRequests.size) - } - hangingResponse.use { - } - FX.runAndWait { - Assert.assertEquals(0, Rest.ongoingRequests.size) - } - } - - @Test - fun encodeQueryString() { - val params = mapOf("name" to "Edvin Syse", "street" to "Møllegaten 12") - Assert.assertEquals("?name=Edvin+Syse&street=M%C3%B8llegaten+12", params.queryString) - } -} diff --git a/src/test/kotlin/tornadofx/tests/ScopeTest.kt b/src/test/kotlin/tornadofx/tests/ScopeTest.kt deleted file mode 100644 index 5691977..0000000 --- a/src/test/kotlin/tornadofx/tests/ScopeTest.kt +++ /dev/null @@ -1,84 +0,0 @@ -package tornadofx.tests - -import javafx.stage.Stage -import org.junit.AfterClass -import org.junit.BeforeClass -import org.junit.Test -import org.testfx.api.FxToolkit -import tornadofx.* -import kotlin.test.assertEquals -import kotlin.test.assertNotEquals -import kotlin.test.assertTrue - - -class ScopeTest { - - companion object { - - lateinit var primaryStage: Stage - - @BeforeClass - @JvmStatic - fun beforeClass() { - primaryStage = FxToolkit.registerPrimaryStage() - } - - @AfterClass - @JvmStatic - fun afterClass() { - FxToolkit.cleanupStages() - } - } - - class PersonModel() : ItemViewModel() - - class PersonScope : Scope() { - val model = PersonModel() - } - - class C : Controller() - - class F : Fragment() { - override val root = label() - override val scope = super.scope as PersonScope - val c : C by inject() - val vm: VM by inject() - } - - class VM : ViewModel(), ScopedInstance - - @Test - fun instanceCheck() { - val scope1 = PersonScope() - - val obj_a = find(scope1) - val obj_a1 = find(scope1) - - assertEquals(obj_a, obj_a1) - - val scope2 = PersonScope() - - val obj_a2 = find(scope2) - - assertNotEquals(obj_a, obj_a2) - } - - @Test - fun controllerAndViewModelPerScopeInInjectedFragments() { - val scope1 = PersonScope() - - val f1 = find(scope1) - val f2 = find(scope1) - - assertEquals(f1.c, f2.c) - assertEquals(f1.vm, f2.vm) - - val scope2 = PersonScope() - - val f3 = find(scope2) - - assertNotEquals(f1.c, f3.c) - assertNotEquals(f1.vm, f3.vm) - } - -} \ No newline at end of file diff --git a/src/test/kotlin/tornadofx/tests/SimpleListViewTest.kt b/src/test/kotlin/tornadofx/tests/SimpleListViewTest.kt deleted file mode 100644 index 126b97f..0000000 --- a/src/test/kotlin/tornadofx/tests/SimpleListViewTest.kt +++ /dev/null @@ -1,15 +0,0 @@ -package tornadofx.tests - -import tornadofx.* - -class SimpleItem(var value: String) - -class SimpleListViewTestApp : App(SimpleListViewTest::class) - -class SimpleListViewTest : View("Simple ListCell Cache Test") { - val items = observableListOf(SimpleItem("One"), SimpleItem("Two"), SimpleItem("Three")) - - override val root = listview(items) { - cellFormat { text = it.value } - } -} \ No newline at end of file diff --git a/src/test/kotlin/tornadofx/tests/StylesheetErrorTest.kt b/src/test/kotlin/tornadofx/tests/StylesheetErrorTest.kt deleted file mode 100644 index 2782922..0000000 --- a/src/test/kotlin/tornadofx/tests/StylesheetErrorTest.kt +++ /dev/null @@ -1,45 +0,0 @@ -package tornadofx.tests - -import javafx.stage.Stage -import org.junit.AfterClass -import org.junit.BeforeClass -import org.junit.Test -import org.testfx.api.FxAssert.verifyThat -import org.testfx.api.FxToolkit -import org.testfx.matcher.control.LabeledMatchers.hasText -import tornadofx.* -import tornadofx.testapps.Styles -import tornadofx.testapps.StylesheetErrorView - -//@Ignore -class StylesheetErrorTest { - - companion object { - - val app = App(StylesheetErrorView::class, Styles::class) - @JvmStatic - @BeforeClass - fun before() { - val primaryStage: Stage = FxToolkit.registerPrimaryStage() - /** - * This will cause a stylesheet error, but should not crash the application. - */ - FX.registerApplication(FxToolkit.setupApplication { - app - }, primaryStage) - } - - @JvmStatic - @AfterClass - fun after() { - FxToolkit.cleanupApplication(app) - FX.stylesheets.clear() - } - } - - @Test - fun shouldStartApplicationWithWrongStylesheetWithoutCrashing() { - verifyThat(".my-button", hasText("Click here")) - } - -} diff --git a/src/test/kotlin/tornadofx/tests/StylesheetTest.kt b/src/test/kotlin/tornadofx/tests/StylesheetTest.kt deleted file mode 100644 index 1c1bff5..0000000 --- a/src/test/kotlin/tornadofx/tests/StylesheetTest.kt +++ /dev/null @@ -1,639 +0,0 @@ -package tornadofx.tests - -import javafx.css.PseudoClass -import javafx.css.Styleable -import javafx.scene.control.* -import javafx.scene.effect.BlurType -import javafx.scene.effect.InnerShadow -import javafx.scene.layout.BorderStrokeStyle -import javafx.scene.layout.Pane -import javafx.scene.paint.* -import javafx.scene.shape.StrokeLineCap -import javafx.scene.shape.StrokeLineJoin -import javafx.scene.shape.StrokeType -import javafx.scene.text.Font -import javafx.scene.text.FontWeight -import javafx.stage.Stage -import org.junit.Assert -import org.junit.Test -import org.testfx.api.FxToolkit -import tornadofx.* -import tornadofx.Stylesheet.Companion.armed -import tornadofx.Stylesheet.Companion.barChart -import tornadofx.Stylesheet.Companion.hover -import tornadofx.Stylesheet.Companion.imageView -import tornadofx.Stylesheet.Companion.label -import tornadofx.Stylesheet.Companion.pannable -import tornadofx.Stylesheet.Companion.star -import java.net.URI -import kotlin.test.assertEquals -import kotlin.test.assertFails -import kotlin.test.assertFalse -import kotlin.test.assertTrue - -class StylesheetTest { - val vbox by cssclass() - val wrapper by cssclass() - - val text by cssclass() - val box by cssclass() - - val a by cssclass() - val b by cssclass() - val c by cssclass() - val d by cssclass() - val e by cssclass() - val f by cssclass() - val g by cssclass() - val h by cssclass() - val i by cssclass() - - val base by cssproperty("-fx-base") - val multiProp by cssproperty>() - - val lumpyElement by csselement("LumpyElement") - val lumpyId by cssid() - val lumpyClass by cssclass() - val lumpyPseudoClass by csspseudoclass() - - val TestBox by cssclass() - val TestBox2 by cssclass("TestBox") - - val primaryStage: Stage = FxToolkit.registerPrimaryStage() - - val renderedProp by cssproperty { "${it.toUpperCase()}!!!" } - val renderedBool by cssproperty { it.name } - val renderedMulti by cssproperty> { it.elements.joinToString { "${it.toUpperCase()}!!!" } } - - enum class Bool { TRUE, FALSE, FILE_NOT_FOUND } - - @Test - fun colorLadderTest() { - val stops = arrayOf( - Stop(0.0, Color.TRANSPARENT), - Stop(1.0, Color.WHITE), - Stop(0.5, Color.RED), // Should be left side of 0.2 - Stop(0.5, Color.GREEN), // Should be ignored - Stop(0.5, Color.BLUE) // Should be right side of 0.2 - ) - Color.hsb(0.0, 1.0, 0.3).ladder(*stops) shouldEqual Color(0.6, 0.0, 0.0, 0.6) - Color.hsb(0.0, 1.0, 0.6).ladder(*stops) shouldEqual Color(0.2, 0.2, 1.0, 1.0) - Color.hsb(0.0, 1.0, 0.4999).ladder(*stops) shouldEqual Color.RED - Color.hsb(0.0, 1.0, 0.5).ladder(*stops) shouldEqual Color.BLUE - } - - @Test - fun colorDeriveTest() { - val color = Color.hsb(0.0, 1.0, 0.5, 0.8) - color.derive(0.5) shouldEqual Color(0.75, 0.5, 0.5, 0.8) - color.derive(-0.5) shouldEqual Color(0.25, 0.0, 0.0, 0.8) - } - - @Test - fun useCustomRenderer() { - stylesheet { - label { - renderedProp.value = "bang" - renderedBool.value = Bool.FILE_NOT_FOUND - renderedMulti.value += "car" - renderedMulti.value += "truck" - renderedMulti.value += "van" - renderedMulti.value += "suv" - } - }.shouldEqual { - """ - .label { - rendered-prop: BANG!!!; - rendered-bool: FILE_NOT_FOUND; - rendered-multi: CAR!!!, TRUCK!!!, VAN!!!, SUV!!!; - } - """ - } - } - - @Test - fun addRemovePseudoClass() { - val node = Label() - node.addClass(lumpyPseudoClass) - assertTrue(node.hasClass(lumpyPseudoClass)) - - assertFalse(node.styleClass.contains(lumpyPseudoClass.name)) - assertTrue(node.pseudoClassStates.contains(PseudoClass.getPseudoClass(lumpyPseudoClass.name))) - - node.toggleClass(lumpyPseudoClass, false) - assertFalse(node.hasClass(lumpyPseudoClass)) - } - - @Test - fun cssStringSnake() { - stylesheet { - "HBox > .labelThing" { - textFill = c("red") - } - }.shouldEqual { - """ - HBox > .labelThing { - -fx-text-fill: rgba(255, 0, 0, 1); - } - """ - } - } - - @Test - fun snakeCase() { - stylesheet { - TestBox { - textFill = c("red") - } - TestBox2 { - textFill = c("green") - } - } shouldEqual { - """ - .test-box { - -fx-text-fill: rgba(255, 0, 0, 1); - } - .TestBox { - -fx-text-fill: rgba(0, 128, 0, 1); - } - """ - } - } - - @Test - fun uriStyleTest() { - stylesheet { - label { - image = URI("/image.png") - backgroundImage += URI("/back1.jpg") - backgroundImage += URI("/back2.gif") - } - } shouldEqual { - """ - .label { - -fx-image: url("/image.png"); - -fx-background-image: url("/back1.jpg"), url("/back2.gif"); - } - """ - } - } - - @Test - fun dimensionalAnalysis() { - val base = 10.px - val num = 2 - val dim = 2.px - val disjoint = 5.mm - - assert((-10).px == -base) - - assert(12.px == base + num) - assert(8.px == base - num) - assert(20.px == base * num) - assert(5.px == base / num) - assert(0.px == base % num) - assert(3.px == base % 7) - - assert(12.px == base + dim) - assert(8.px == base - dim) - - assert(12.px == num + base) - assert(-8.px == num - base) - assert(20.px == num * base) - - assertFails { base + disjoint } - assertFails { base - disjoint } - } - - @Test - fun unsafeProperties() { - stylesheet { - label { - unsafe("-fx-background", raw("-fx-control-inner-background")) - textFill = Color.GREEN - unsafe(base, raw("green")) - unsafe("base", Color.GREEN) - multiProp force base - } - } shouldEqual { - """ - .label { - -fx-text-fill: rgba(0, 128, 0, 1); - -fx-background: -fx-control-inner-background; - -fx-base: green; - base: rgba(0, 128, 0, 1); - multi-prop: -fx-base; - } - """ - } - } - - @Test - fun starTest() { - stylesheet { - box child star { - textFill = Color.BLUE - } - } shouldEqual { - """ - .box > * { - -fx-text-fill: rgba(0, 0, 255, 1); - } - """ - } - } - - @Test - fun lumpySnakes() { - stylesheet { - s(lumpyElement, lumpyId, lumpyClass, lumpyPseudoClass) { - multiProp.value += Color.RED - } - } shouldEqual { - """ - LumpyElement, #lumpy-id, .lumpy-class, :lumpy-pseudo-class { - multi-prop: rgba(255, 0, 0, 1); - } - """ - } - } - - @Test - fun multiProp() { - stylesheet { - val mix = mixin { - multiProp.value += Color.GREEN - } - label { - multiProp.value += Color.RED - +mix - multiProp.value += Color.BLUE - } - } shouldEqual { - """ - .label { - multi-prop: rgba(255, 0, 0, 1), rgba(0, 128, 0, 1), rgba(0, 0, 255, 1); - } - """ - } - } - - @Test - fun propertySelectionScope() { - stylesheet { - label { - and(":hover") { - base.value = c("blue") - } - base.value = c("red") - } - } shouldEqual { - """ - .label { - -fx-base: rgba(255, 0, 0, 1); - } - .label:hover { - -fx-base: rgba(0, 0, 255, 1); - } - """ - } - } - - @Test - fun splitting() { - stylesheet { - "label >.lab #la:l ,.label,.-la-la~*:red, #fred " { - textFill = Color.BLANCHEDALMOND - and(":hover") { - backgroundColor += Color.CHARTREUSE - base.value = c("green") - } - } - } shouldEqual { - """ - label > .lab #la:l, .label, .-la-la ~ *:red, #fred { - -fx-text-fill: rgba(255, 235, 205, 1); - } - - label > .lab #la:l:hover, .label:hover, .-la-la ~ *:red:hover, #fred:hover { - -fx-background-color: rgba(127, 255, 0, 1); - -fx-base: rgba(0, 128, 0, 1); - } - """ - } - } - - @Test - fun cartesian() { - stylesheet { - s(a, b, c) { - s(d, e, f) { - s(g, h, i) { - textFill = Color.BLUE - } - } - } - } shouldEqual { - """ - .a .d .g, .a .d .h, .a .d .i, .a .e .g, .a .e .h, .a .e .i, .a .f .g, .a .f .h, .a .f .i, .b .d .g, .b .d .h, .b .d .i, .b .e .g, .b .e .h, .b .e .i, .b .f .g, .b .f .h, .b .f .i, .c .d .g, .c .d .h, .c .d .i, .c .e .g, .c .e .h, .c .e .i, .c .f .g, .c .f .h, .c .f .i { - -fx-text-fill: rgba(0, 0, 255, 1); - } - """ - } - - stylesheet { - s(a, b, c) { - and(d, e, f) { - and(g, h, i) { - textFill = Color.BLUE - } - } - } - } shouldEqual { - """ - .a.d.g, .a.d.h, .a.d.i, .a.e.g, .a.e.h, .a.e.i, .a.f.g, .a.f.h, .a.f.i, .b.d.g, .b.d.h, .b.d.i, .b.e.g, .b.e.h, .b.e.i, .b.f.g, .b.f.h, .b.f.i, .c.d.g, .c.d.h, .c.d.i, .c.e.g, .c.e.h, .c.e.i, .c.f.g, .c.f.h, .c.f.i { - -fx-text-fill: rgba(0, 0, 255, 1); - } - """ - } - - stylesheet { - s(a, b, c) { - and(d, e, f) { - s(g, h, i) { - textFill = Color.BLUE - } - } - } - } shouldEqual { - """ - .a.d .g, .a.d .h, .a.d .i, .a.e .g, .a.e .h, .a.e .i, .a.f .g, .a.f .h, .a.f .i, .b.d .g, .b.d .h, .b.d .i, .b.e .g, .b.e .h, .b.e .i, .b.f .g, .b.f .h, .b.f .i, .c.d .g, .c.d .h, .c.d .i, .c.e .g, .c.e .h, .c.e .i, .c.f .g, .c.f .h, .c.f .i { - -fx-text-fill: rgba(0, 0, 255, 1); - } - """ - } - } - - @Test - fun multiValue() { - stylesheet { - label { - backgroundColor = multi(Color.WHITE, Color.BLUE) - } - } shouldEqual { - ".label { -fx-background-color: rgba(255, 255, 255, 1), rgba(0, 0, 255, 1); }" - } - } - - @Test - fun singleValue() { - stylesheet { - label { - backgroundColor += Color.WHITE - } - } shouldEqual { - ".label { -fx-background-color: rgba(255, 255, 255, 1); }" - } - } - - @Test - fun selectorOrder() { - stylesheet { - vbox child wrapper contains label { - backgroundColor += Color.WHITE - } - } shouldEqual { - ".vbox > .wrapper .label { -fx-background-color: rgba(255, 255, 255, 1); }" - } - } - - @Test - fun multiSelect() { - stylesheet { - s(vbox child wrapper contains label, label) { - textFill = Color.BLUE - } - } shouldEqual { - """ - .vbox > .wrapper .label, .label { - -fx-text-fill: rgba(0, 0, 255, 1); - } - """ - } - } - - @Test - fun nestedModifier_1() { - stylesheet { - s(label, text) { - and(hover, armed) { - backgroundColor += c("blue", 0.25) - } - } - } shouldEqual { - """ - .label:hover, .label:armed, .text:hover, .text:armed { - -fx-background-color: rgba(0, 0, 255, 0.25); - } - """ - } - } - - @Test - fun nestedModifier_2() { - stylesheet { - vbox { - child(label) { textFill = c("#ff0000") } - contains(label) { textFill = c("#00ff00") } - next(label) { textFill = c("#0000ff") } - sibling(label) { textFill = c("#ffff00") } - } - } shouldEqual { - """ - .vbox > .label { -fx-text-fill: rgba(255, 0, 0, 1); } - .vbox .label { -fx-text-fill: rgba(0, 255, 0, 1); } - .vbox + .label { -fx-text-fill: rgba(0, 0, 255, 1); } - .vbox ~ .label { -fx-text-fill: rgba(255, 255, 0, 1); } - """ - } - } - - @Test - fun gradientsWithErrorColor() { - stylesheet { - val hover = mixin { - and(hover) { - backgroundColor += RadialGradient(90.0, 0.5, 0.5, 0.5, 0.25, true, CycleMethod.REPEAT, Stop(0.0, Color.WHITE), Stop(0.5, c("error")), Stop(1.0, Color.BLACK)) - } - } - val wrap = mixin { - padding = box(1.em) - borderColor += box(LinearGradient(0.0, 0.0, 10.0, 10.0, false, CycleMethod.REFLECT, Stop(0.0, Color.RED), Stop(1.0, c(0.0, 1.0, 0.0)))) - borderWidth += box(5.px) - backgroundRadius += box(25.px) - borderRadius += box(25.px) - +hover - } - - box { - +wrap - backgroundColor += RadialGradient(90.0, 0.5, 0.5, 0.5, 0.25, true, CycleMethod.REPEAT, Stop(0.0, Color.WHITE), Stop(1.0, Color.BLACK)) - spacing = 5.px - - label { - +wrap - font = Font.font(14.0) - fontWeight = FontWeight.BOLD - textFill = c("white") - rotate = .95.turn - translateX = .5.inches - minHeight = 6.em - scaleX = 2 - scaleY = .75 - } - } - } shouldEqual { - """ - .box { - -fx-padding: 1em 1em 1em 1em; - -fx-border-color: linear-gradient(from 0.0px 0.0px to 10.0px 10.0px, reflect, rgba(255, 0, 0, 1) 0.0%, rgba(0, 255, 0, 1) 100.0%) linear-gradient(from 0.0px 0.0px to 10.0px 10.0px, reflect, rgba(255, 0, 0, 1) 0.0%, rgba(0, 255, 0, 1) 100.0%) linear-gradient(from 0.0px 0.0px to 10.0px 10.0px, reflect, rgba(255, 0, 0, 1) 0.0%, rgba(0, 255, 0, 1) 100.0%) linear-gradient(from 0.0px 0.0px to 10.0px 10.0px, reflect, rgba(255, 0, 0, 1) 0.0%, rgba(0, 255, 0, 1) 100.0%); - -fx-border-width: 5px 5px 5px 5px; - -fx-background-radius: 25px 25px 25px 25px; - -fx-border-radius: 25px 25px 25px 25px; - -fx-background-color: radial-gradient(focus-angle 90.0deg, focus-distance 50.0% , center 50.0% 50.0%, radius 25.0%, repeat, rgba(255, 255, 255, 1) 0.0%, rgba(0, 0, 0, 1) 100.0%); - -fx-spacing: 5px; - } - .box:hover { - -fx-background-color: radial-gradient(focus-angle 90.0deg, focus-distance 50.0% , center 50.0% 50.0%, radius 25.0%, repeat, rgba(255, 255, 255, 1) 0.0%, rgba(255, 0, 255, 1) 50.0%, rgba(0, 0, 0, 1) 100.0%); - } - .box .label { - -fx-padding: 1em 1em 1em 1em; - -fx-border-color: linear-gradient(from 0.0px 0.0px to 10.0px 10.0px, reflect, rgba(255, 0, 0, 1) 0.0%, rgba(0, 255, 0, 1) 100.0%) linear-gradient(from 0.0px 0.0px to 10.0px 10.0px, reflect, rgba(255, 0, 0, 1) 0.0%, rgba(0, 255, 0, 1) 100.0%) linear-gradient(from 0.0px 0.0px to 10.0px 10.0px, reflect, rgba(255, 0, 0, 1) 0.0%, rgba(0, 255, 0, 1) 100.0%) linear-gradient(from 0.0px 0.0px to 10.0px 10.0px, reflect, rgba(255, 0, 0, 1) 0.0%, rgba(0, 255, 0, 1) 100.0%); - -fx-border-width: 5px 5px 5px 5px; - -fx-background-radius: 25px 25px 25px 25px; - -fx-border-radius: 25px 25px 25px 25px; - -fx-font: normal 14.0pt "System"; - -fx-font-weight: 700; - -fx-text-fill: rgba(255, 255, 255, 1); - -fx-rotate: 0.95turn; - -fx-translate-x: 0.5in; - -fx-min-height: 6em; - -fx-scale-x: 2; - -fx-scale-y: 0.75; - } - .box .label:hover { - -fx-background-color: radial-gradient(focus-angle 90.0deg, focus-distance 50.0% , center 50.0% 50.0%, radius 25.0%, repeat, rgba(255, 255, 255, 1) 0.0%, rgba(255, 0, 255, 1) 50.0%, rgba(0, 0, 0, 1) 100.0%); - } - """ - } - } - - @Test - fun inlineStyle() { - val arrayOfStyleables = arrayOf(Pane(), MenuItem("Click Me"), Tooltip("Click"), Tab("This Tab"), TableColumn()) - for (node in arrayOfStyleables) { - node.style { - backgroundColor += Color.RED - } - assertEquals("-fx-background-color: rgba(255, 0, 0, 1);", node.style) - node.style(append = true) { - padding = box(10.px) - } - assertEquals("-fx-background-color: rgba(255, 0, 0, 1); -fx-padding: 10px 10px 10px 10px;", node.style) - } - } - - @Test - fun innerShadowRendering() { - stylesheet { - s(imageView) { - effect = InnerShadow(BlurType.GAUSSIAN, Color.GREENYELLOW, 7.0, 1.0, 1.0, 1.0) - } - } shouldEqual { - """ - .image-view { - -fx-effect: innershadow(gaussian, rgba(173, 255, 47, 1), 7.0, 1.0, 1.0, 1.0); - } - """ - } - } - - @Test - fun barFillTest() { - stylesheet { - barChart { - barFill = Color.RED - } - } shouldEqual { - """ - .bar-chart { - -fx-bar-fill: rgba(255, 0, 0, 1); - } - """ - } - } - - @Test - fun testNameCollisions() { - stylesheet { - pannable { - pannable = false - pannable { - pannable = true - } - } - } shouldEqual { - """ - :pannable { - -fx-pannable: false; - } - :pannable :pannable { - -fx-pannable: true; - } - """ - } - } - - @Test - fun testBrokenLines() { - stylesheet { - label { - borderStyle += BorderStrokeStyle( - StrokeType.CENTERED, - StrokeLineJoin.MITER, - StrokeLineCap.BUTT, - 10.0, - 15.0, - listOf(2.0, 4.0, 6.0) - ) - strokeDashArray = listOf(5.px, 7.px, 9.px) - } - }.shouldEqual { - """ - .label { - -fx-border-style: segments(2.0, 4.0, 6.0) centered line-join miter 10.0 line-cap butt; - -fx-stroke-dash-array: 5px 7px 9px; - } - """ - } - } - - private fun stylesheet(op: Stylesheet.() -> Unit) = - Stylesheet().apply(op) - private infix fun Stylesheet.shouldEqual(op: () -> String) = - Assert.assertEquals(op().normalizeWhitespace(), render().normalizeWhitespace()) - private infix fun Color.shouldEqual(other: Color) = - Assert.assertEquals(other.toString(), toString()) - private fun String.normalizeWhitespace() = - replace(Regex("\\s+"), " ").trim() - - /** - * This is just a compile test to make sure box and c are not moved - */ - class StylesheetFunctionsTest : Stylesheet() { - companion object { - val aColor = c("#335566") - val boxDims = box(20.px) - } - } -} diff --git a/src/test/kotlin/tornadofx/tests/TableViewTest.kt b/src/test/kotlin/tornadofx/tests/TableViewTest.kt deleted file mode 100644 index ba24652..0000000 --- a/src/test/kotlin/tornadofx/tests/TableViewTest.kt +++ /dev/null @@ -1,49 +0,0 @@ -package tornadofx.tests - -import javafx.beans.property.SimpleDoubleProperty -import javafx.beans.property.SimpleIntegerProperty -import javafx.beans.property.SimpleStringProperty -import javafx.collections.FXCollections -import javafx.scene.Scene -import javafx.scene.layout.StackPane -import javafx.stage.Stage -import org.junit.Test -import org.testfx.api.FxRobot -import org.testfx.api.FxToolkit -import tornadofx.* -import java.nio.file.Paths - -class TableViewTest { - class TestObject(i: Int) { - val A = SimpleIntegerProperty(5 * i) - val B = SimpleDoubleProperty(3.14159 * i) - val C = SimpleStringProperty("Test string $i") - } - - val TestList = FXCollections.observableArrayList(Array(5, ::TestObject).asList()) - - val primaryStage: Stage = FxToolkit.registerPrimaryStage() - - @Test - fun columnTest() { - FxToolkit.setupFixture { - val root = StackPane().apply { - tableview(TestList) { - makeIndexColumn() - column("A Column", TestObject::A) - column("A Column", Boolean::class) - column("B Column", Double::class) { - value { it.value.B } - } - column("C Column", TestObject::C) - } - setPrefSize(400.0, 160.0) - } - primaryStage.scene = Scene(root) - primaryStage.show() - } - - val robot = FxRobot() - robot.robotContext().captureSupport.saveImage(robot.capture(primaryStage.scene.root).image, Paths.get("example-table.png")) - } -} \ No newline at end of file diff --git a/src/test/kotlin/tornadofx/tests/ValidationTest.kt b/src/test/kotlin/tornadofx/tests/ValidationTest.kt deleted file mode 100644 index f383a08..0000000 --- a/src/test/kotlin/tornadofx/tests/ValidationTest.kt +++ /dev/null @@ -1,44 +0,0 @@ -package tornadofx.tests - -import javafx.scene.control.TextField -import org.junit.Test -import org.testfx.api.FxToolkit -import tornadofx.FX -import tornadofx.ValidationContext -import tornadofx.ValidationMessage -import tornadofx.ValidationSeverity -import kotlin.test.assertFalse -import kotlin.test.assertNull -import kotlin.test.assertTrue - -class ValidationTest { - val primaryStage = FxToolkit.registerPrimaryStage() - val context = ValidationContext() - - @Test fun simple_validation() { - val input = TextField() - - val validator = context.addValidator(input, input.textProperty()) { - if (it!!.length < 5) error("Too short") else null - } - - // Simulate user input - FX.runAndWait { - input.text = "abc" - - // Validation should fail - assertFalse(validator.validate()) - - // Extract the validation result - val result = validator.result - - // The severity should be error - assertTrue(result is ValidationMessage && result.severity == ValidationSeverity.Error) - - // Confirm valid input passes validation - input.text = "longvalue" - assertTrue(validator.validate()) - assertNull(validator.result) - } - } -} \ No newline at end of file diff --git a/src/test/kotlin/tornadofx/tests/VectorMathTest.kt b/src/test/kotlin/tornadofx/tests/VectorMathTest.kt deleted file mode 100644 index 944a723..0000000 --- a/src/test/kotlin/tornadofx/tests/VectorMathTest.kt +++ /dev/null @@ -1,234 +0,0 @@ -package tornadofx.tests - -import javafx.geometry.Point2D -import javafx.geometry.Point3D -import org.junit.Test -import tornadofx.* -import kotlin.math.sqrt -import kotlin.test.assertEquals - -class VectorMathTest { - @Test - fun `Point2D + Point2D`() { - val p1 = Point2D(3.0, 4.0) - val p2 = Point2D(4.0, 3.0) - val result = p1 + p2 - assertEquals(Point2D(7.0, 7.0), result) - } - - @Test - fun `Point2D + Double`() { - val p1 = Point2D(3.0, 4.0) - val result = p1 + 3.0 - assertEquals(Point2D(6.0, 7.0), result) - } - - @Test - fun `Double + Point2D`() { - val p1 = Point2D(3.0, 4.0) - val result = 3.0 + p1 - assertEquals(Point2D(6.0, 7.0), result) - } - - @Test - fun `Point2D - Point2D`() { - val p1 = Point2D(3.0, 4.0) - val p2 = Point2D(4.0, 3.0) - val result = p1 - p2 - assertEquals(Point2D(-1.0, 1.0), result) - } - - @Test - fun `Point2D - Double`() { - val p1 = Point2D(3.0, 4.0) - val result = p1 - 3.0 - assertEquals(Point2D(0.0, 1.0), result) - } - - @Test - fun `Point2D * Double`() { - val p1 = Point2D(3.0, 4.0) - val result = p1 * 3.0 - assertEquals(Point2D(9.0, 12.0), result) - } - - @Test - fun `Double * Point2D`() { - val p1 = Point2D(3.0, 4.0) - val result = 3.0 * p1 - assertEquals(Point2D(9.0, 12.0), result) - } - - @Test - fun `Point2D div Double`() { - val p1 = Point2D(3.0, 12.0) - val result = p1 / 3.0 - assertEquals(Point2D(1.0, 4.0), result) - } - - @Test - fun `-Point2D`() { - val p1 = Point2D(3.0, 12.0) - val result = -p1 - assertEquals(Point2D(-3.0, -12.0), result) - } - - @Test - fun `Point2D dot Point2D`() { - val p1 = Point2D(1.0, 2.0) - val p2 = Point2D(3.0, 4.0) - val result = p1 dot p2 - assertEquals(11.0, result) - } - - @Test - fun `Point2D cross Point2D`() { - val p1 = Point2D(1.0, 2.0) - val p2 = Point2D(3.0, 4.0) - val result = p1 cross p2 - assertEquals(Point3D(0.0, 0.0, -2.0), result) - } - - @Test - fun `Point2D angle Point2D`() { - val p1 = Point2D(1.0, 0.0) - val p2 = Point2D(0.0, 1.0) - val result = p1 angle p2 - assertEquals(90.0, result) - } - - @Test - fun `Point2D distance Point2D`() { - val p1 = Point2D(1.0, 0.0) - val p2 = Point2D(0.0, 1.0) - val result = p1 distance p2 - assertEquals(sqrt(2.0), result) - } - - @Test - fun `Point2D midPoint Point2D`() { - val p1 = Point2D(1.0, 0.0) - val p2 = Point2D(0.0, 1.0) - val result = p1 midPoint p2 - assertEquals(Point2D(0.5, 0.5), result) - } - - @Test - fun `Point2D squared magnitude`() { - val p1 = Point2D(5.0, 5.0) - val result = p1.magnitude2() - assertEquals(50.0, result) - } - - @Test - fun `Point3D + Point3D`() { - val p1 = Point3D(3.0, 4.0, 2.0) - val p2 = Point3D(4.0, 3.0, 1.0) - val result = p1 + p2 - assertEquals(Point3D(7.0, 7.0, 3.0), result) - } - - @Test - fun `Point3D + Double`() { - val p1 = Point3D(3.0, 4.0, 2.0) - val result = p1 + 3.0 - assertEquals(Point3D(6.0, 7.0, 5.0), result) - } - - @Test - fun `Double + Point3D`() { - val p1 = Point3D(3.0, 4.0, 2.0) - val result = 3.0 + p1 - assertEquals(Point3D(6.0, 7.0, 5.0), result) - } - - @Test - fun `Point3D - Point3D`() { - val p1 = Point3D(3.0, 4.0, 2.0) - val p2 = Point3D(4.0, 3.0, 1.0) - val result = p1 - p2 - assertEquals(Point3D(-1.0, 1.0, 1.0), result) - } - - @Test - fun `Point3D - Double`() { - val p1 = Point3D(3.0, 4.0, 2.0) - val result = p1 - 3.0 - assertEquals(Point3D(0.0, 1.0, -1.0), result) - } - - @Test - fun `Point3D * Double`() { - val p1 = Point3D(3.0, 4.0, 2.0) - val result = p1 * 3.0 - assertEquals(Point3D(9.0, 12.0, 6.0), result) - } - - @Test - fun `Double * Point3D`() { - val p1 = Point3D(3.0, 4.0, 2.0) - val result = 3.0 * p1 - assertEquals(Point3D(9.0, 12.0, 6.0), result) - } - - @Test - fun `Point3D div Double`() { - val p1 = Point3D(3.0, 12.0, 6.0) - val result = p1 / 3.0 - assertEquals(Point3D(1.0, 4.0, 2.0), result) - } - - @Test - fun `-Point3D`() { - val p1 = Point3D(3.0, 12.0, -2.0) - val result = -p1 - assertEquals(Point3D(-3.0, -12.0, 2.0), result) - } - - @Test - fun `Point3D dot Point3D`() { - val p1 = Point3D(1.0, 2.0, 3.0) - val p2 = Point3D(4.0, 5.0, 6.0) - val result = p1 dot p2 - assertEquals(32.0, result) - } - - @Test - fun `Point3D cross Point3D`() { - val p1 = Point3D(1.0, 2.0, 3.0) - val p2 = Point3D(4.0, 5.0, 6.0) - val result = p1 cross p2 - assertEquals(Point3D(-3.0, 6.0, -3.0), result) - } - - @Test - fun `Point3D angle Point3D`() { - val p1 = Point3D(1.0, 0.0, 0.0) - val p2 = Point3D(0.0, 1.0, 0.0) - val result = p1 angle p2 - assertEquals(90.0, result) - } - - @Test - fun `Point3D distance Point3D`() { - val p1 = Point3D(1.0, 0.0, 3.0) - val p2 = Point3D(0.0, 1.0, 3.0) - val result = p1 distance p2 - assertEquals(sqrt(2.0), result) - } - - @Test - fun `Point3D midPoint Point3D`() { - val p1 = Point3D(1.0, 0.0, 0.5) - val p2 = Point3D(0.0, 1.0, 0.5) - val result = p1 midPoint p2 - assertEquals(Point3D(0.5, 0.5, 0.5), result) - } - - @Test - fun `Point3D squared magnitude`() { - val p1 = Point3D(5.0, 5.0, 5.0) - val result = p1.magnitude2() - assertEquals(75.0, result) - } -} diff --git a/src/test/kotlin/tornadofx/tests/ViewDockingTests.kt b/src/test/kotlin/tornadofx/tests/ViewDockingTests.kt deleted file mode 100644 index 8231626..0000000 --- a/src/test/kotlin/tornadofx/tests/ViewDockingTests.kt +++ /dev/null @@ -1,149 +0,0 @@ -package tornadofx.tests - -import org.junit.Test -import org.testfx.api.FxToolkit -import tornadofx.* -import tornadofx.testapps.NoPrimaryViewDockingApp -import tornadofx.testapps.ViewDockingApp -import tornadofx.testapps.PrimaryDockingView -import tornadofx.testapps.SecondaryDockingView -import kotlin.test.assertEquals -import kotlin.test.assertNotEquals - -class ViewDockingTests { - - @Test - fun itShouldDock() { - FxToolkit.registerPrimaryStage() - val app = FxToolkit.setupApplication { ViewDockingApp() } - - assertEquals( - expected = 1, - actual = find().dockCounter, - message = "view should have docked exactly once" - ) - - FxToolkit.cleanupStages() - FxToolkit.cleanupApplication(app) - } - - @Test - fun itShouldUndock() { - FxToolkit.registerPrimaryStage() - val app = FxToolkit.setupApplication { ViewDockingApp() } - val view = find() - FxToolkit.cleanupStages() - FxToolkit.cleanupApplication(app) - - assertEquals( - expected = 1, - actual = view.undockCounter, - message = "view should have undocked exactly once" - ) - } - - @Test - fun itShouldDockAndUndockAgainAfterWindowHiddenAndShown() { - val stage = FxToolkit.registerPrimaryStage() - val app = FxToolkit.setupApplication { ViewDockingApp() } - val view = find() - - FX.runAndWait { stage.hide() } - FX.runAndWait { stage.show() } - - FxToolkit.cleanupStages() - FxToolkit.cleanupApplication(app) - - assertEquals( - expected = 2, - actual = view.dockCounter, - message = "view should have docked exactly twice" - ) - assertEquals( - expected = 2, - actual = view.undockCounter, - message = "view should have undocked exactly twice" - ) - } - - @Test - fun itShouldDockAndUndockChildView() { - FxToolkit.registerPrimaryStage() - val app = FxToolkit.setupApplication { ViewDockingApp() } - val primaryView = find() - val secondaryView = find() - - FX.runAndWait { primaryView.root.add(secondaryView.root) } - - assertEquals( - expected = 1, - actual = secondaryView.dockCounter, - message = "view should have docked exactly once" - ) - - FX.runAndWait { secondaryView.removeFromParent() } - - assertEquals( - expected = 1, - actual = secondaryView.undockCounter, - message = "view should have undocked exactly once" - ) - - FxToolkit.cleanupStages() - FxToolkit.cleanupApplication(app) - } - - @Test - fun itShouldNotLeakOnDock() { - // proof of fix for https://github.com/edvin/tornadofx/issues/973 - val views = mutableListOf() - - for (i in 0..1) { - FxToolkit.registerPrimaryStage() - val app = FxToolkit.setupApplication { ViewDockingApp() } - views += find() - FxToolkit.cleanupStages() - FxToolkit.cleanupApplication(app) - } - - assertEquals( - expected = 2, - actual = views.size, - message = "view size should be 2" - ) - assertNotEquals( - illegal = views[0].instanceId, - actual = views[1].instanceId, - message = "view instance IDs should be unique" - ) - views.forEach { - assertEquals( - expected = 1, - actual = it.dockCounter, - message = "It should dock exactly once" - ) - } - } - - @Test - fun itShouldNotUninitNoPrimaryViewSpecifiedComponent() { - // proof of fix for https://github.com/edvin/tornadofx/issues/991 - FxToolkit.registerPrimaryStage() - val app = FxToolkit.setupApplication { NoPrimaryViewDockingApp() } - val primaryDockingView = find() - - FxToolkit.cleanupStages() - FxToolkit.cleanupApplication(app) - - assertEquals( - expected = 1, - actual = primaryDockingView.dockCounter, - message = "It should dock exactly once" - ) - assertEquals( - expected = 1, - actual = primaryDockingView.undockCounter, - message = "It should undock exactly once" - ) - } -} diff --git a/src/test/kotlin/tornadofx/tests/ViewModelTest.kt b/src/test/kotlin/tornadofx/tests/ViewModelTest.kt deleted file mode 100644 index fa41ed6..0000000 --- a/src/test/kotlin/tornadofx/tests/ViewModelTest.kt +++ /dev/null @@ -1,246 +0,0 @@ -package tornadofx.tests - -import javafx.beans.property.Property -import javafx.beans.property.SimpleObjectProperty -import javafx.beans.property.SimpleStringProperty -import javafx.scene.control.TableView -import javafx.scene.control.TreeItem -import javafx.scene.control.TreeView -import javafx.stage.Stage -import org.junit.Assert.* -import org.junit.Test -import org.testfx.api.FxToolkit -import tornadofx.* - -open class ViewModelTest { - val primaryStage: Stage = FxToolkit.registerPrimaryStage() - - @Test fun rebind_to_null_unbinds() { - val personProperty = SimpleObjectProperty() - - val person1 = Person("John", 37) - val person2 = Person("Jay", 32) - - val model = PersonAutoModel(null) - model.rebindOnChange(personProperty) { - model.person = it - } - - model.name.onChange { - println("Person name changed to $it") - } - - personProperty.value = person1 - assertEquals("John", model.name.value) - personProperty.value = person2 - assertEquals("Jay", model.name.value) - personProperty.value = null - assertNull(model.person) - } - - @Test fun auto_commit() { - val person = Person("John", 37) - val model = PersonAutoModel(person) - - assertEquals(person.name, "John") - model.name.value = "Jay" - assertEquals(person.name, "Jay") - } - - @Test fun default_value() { - val model = PersonAutoModel() - assertEquals(model.name.value, "Yoyo") - } - - @Test fun external_change() { - val person = Person("John", 37) - val model = PersonModel(person) - - assertEquals(model.name.value, "John") - person.name = "Jay" - assertEquals(model.name.value, "Jay") - } - - @Test fun simple_commit() { - val person = Person("John", 37) - val model = PersonModel(person) - val isNameDirty = model.dirtyStateFor(PersonModel::name) - isNameDirty.onChange { - println("Name is dirty: $it") - } - model.name.value = "Jay" - assertEquals(person.name, "John") - model.commit() - assertEquals(person.name, "Jay") - } - - @Test fun swap_source_object() { - val person1 = Person("Person 1", 37) - val person2 = Person("Person 2", 33) - - val model = PersonModel(person1) - assertEquals(model.name.value, "Person 1") - - model.item = person2 - - assertEquals(model.name.value, "Person 2") - } - - @Test fun pojo_commit() { - val person = JavaPerson() - person.name = "John" - val model = JavaPersonModel(person) - - model.name.value = "Jay" - assertEquals(model.name.value, "Jay") - assertEquals(person.name, "John") - model.commit() - assertEquals(model.name.value, "Jay") - assertEquals(person.name, "Jay") - - model.name.value = null - assertNull(model.name.value) - assertNotNull(person.name) - - model.commit() - assertNull(model.name.value) - assertNull(person.name) - } - - @Test fun poko_commit() { - val person = PersonPoko() - person.name = "John" - person.phone = "777" - val model = PersonPokoModel(person) - - //testing non-nullable field - model.name.value = "Jay" - assertEquals("Jay", model.name.value) - assertEquals("John", person.name) - model.commit() - assertEquals("Jay", model.name.value) - assertEquals("Jay", person.name) - - model.name.value = null - assertNull(model.name.value) - assertNotNull(person.name) - - /*model.commit() //IllegalArgumentException @ JavaFX Thread - assertNull(model.name.value) //null, assertion passes - assertNull(person.name) //not null, assertion fails*/ - - model.rollback() //next commit would cause IllegalArgumentException, we don't want that - - //testing nullable field - model.phone.value = "555" - assertEquals("555", model.phone.value) - assertEquals("777", person.phone) - model.commit() - assertEquals("555", model.phone.value) - assertEquals("555", person.phone) - - model.phone.value = null - assertNull(model.phone.value) - assertNotNull(person.phone) - - model.commit() - assertNull(model.phone.value) - assertNull(person.phone) - } - - @Test fun var_commit_check_dirty_state() { - val person = Person("John", 37) - val model = PersonModel(person) - - assertFalse(model.isDirty) - - model.name.value = "Jay" - assertEquals(person.name, "John") - assertTrue(model.name.isDirty) - assertTrue(model.isDirty) - - model.commit() - assertEquals(person.name, "Jay") - assertFalse(model.name.isDirty) - assertFalse(model.isDirty) - } - - @Test fun inline_viewmodel() { - val person = Person("John", 37) - - val model = object : ViewModel() { - val name = bind { person.nameProperty() } as SimpleStringProperty - } - - model.name.value = "Jay" - assertEquals(person.name, "John") - model.commit() - assertEquals(person.name, "Jay") - } - - @Test fun tableview_master_detail() { - val tableview = TableView() - tableview.items.addAll(Person("John", 37), Person("Jay", 33)) - val model = PersonModel(tableview.items.first()) - assertEquals(model.name.value, "John") - tableview.bindSelected(model) - tableview.selectionModel.select(1) - assertEquals(model.name.value, "Jay") - } - - @Test fun treeview_master_detail() { - val rootPerson = Person("John", 37) - val treeview = TreeView(TreeItem(rootPerson)) - treeview.populate { it.value.children } - rootPerson.children.add(Person("Jay", 33)) - val model = PersonModel(rootPerson) - assertEquals(model.name.value, "John") - treeview.bindSelected(model) - treeview.selectionModel.select(treeview.root.children.first()) - assertEquals(model.name.value, "Jay") - } - - @Test fun committed_properties() { - val person = Person("John", 37) - val model = object : PersonModel(person) { - override fun onCommit(commits: List) { - assertEquals(4, commits.size) - assertEquals(1, commits.count { it.changed }) - val theOnlyChange = commits.first { it.changed } - assertEquals(name, theOnlyChange.property) - assertEquals("John", theOnlyChange.oldValue) - assertEquals("Johnnie", theOnlyChange.newValue) - } - } - model.name.value = "Johnnie" - model.commit() - } -} - -class PersonAutoModel(var person: Person? = null) : ViewModel() { - val name = bind(true, defaultValue = "Yoyo") { person?.nameProperty() ?: SimpleStringProperty() as Property } -} - -// JavaFX Property -open class PersonModel(person: Person? = null) : ItemViewModel(person) { - val name = bind { item?.nameProperty() } - val age = bind { item?.ageProperty() } - val phone = bind { item?.phoneProperty() } - val email = bind { item?.emailProperty() } -} - -// Java POJO getter/setter property -class JavaPersonModel(person: JavaPerson) : ViewModel() { - val name = bind { person.observable(JavaPerson::getName, JavaPerson::setName) } -} - -// Kotlin var property -class PersonVarModel(person: Person) : ViewModel() { - val name = bind { person.observable(Person::name) } -} - -//Kotlin nullable and non-nullable property in ItemViewModel -class PersonPokoModel(item : PersonPoko): ItemViewModel(item) { - val name = bind(PersonPoko::name) - val phone = bind(PersonPoko::phone) -} diff --git a/src/test/resources/META-INF/services/tornadofx.ChildInterceptor b/src/test/resources/META-INF/services/tornadofx.ChildInterceptor deleted file mode 100644 index 26fb89c..0000000 --- a/src/test/resources/META-INF/services/tornadofx.ChildInterceptor +++ /dev/null @@ -1,2 +0,0 @@ -tornadofx.tests.FirstInterceptor -tornadofx.tests.SecondInterceptor \ No newline at end of file diff --git a/src/test/resources/teststyles.css b/src/test/resources/teststyles.css deleted file mode 100644 index 868d366..0000000 --- a/src/test/resources/teststyles.css +++ /dev/null @@ -1,5 +0,0 @@ -.testclass { - -fx-font-size: 30; - -fx-font-weight: bold; - -fx-text-fill: red; -} \ No newline at end of file diff --git a/src/test/resources/tornadofx/tests/ComposedForm.fxml b/src/test/resources/tornadofx/tests/ComposedForm.fxml deleted file mode 100644 index e98839a..0000000 --- a/src/test/resources/tornadofx/tests/ComposedForm.fxml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - -