diff --git a/.idea/rg3d-core.iml b/.idea/rg3d-core.iml index b0c9311c9..d2e2656b3 100644 --- a/.idea/rg3d-core.iml +++ b/.idea/rg3d-core.iml @@ -52,6 +52,8 @@ + + diff --git a/editor/src/lib.rs b/editor/src/lib.rs index 912b3e19c..96a13a149 100644 --- a/editor/src/lib.rs +++ b/editor/src/lib.rs @@ -50,13 +50,11 @@ pub mod scene; pub mod scene_viewer; pub mod settings; pub mod stats; +pub mod test; pub mod ui_scene; pub mod utils; pub mod world; -#[cfg(test)] -mod test; - pub use fyrox; use crate::{ diff --git a/editor/src/test/mod.rs b/editor/src/test/mod.rs index 6c86b9a0f..bbe718e7e 100644 --- a/editor/src/test/mod.rs +++ b/editor/src/test/mod.rs @@ -18,94 +18,5 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#![allow(dead_code)] - -//! Automated tests for the entire editor. -//! WARNING: This is experimental functionality and currently in development. - -mod macros; -mod utils; - -use crate::{ - menu::file::FileMenu, - test::{macros::Macro, utils::TestPlugin}, - SaveSceneConfirmationDialog, -}; - -#[test] -fn test_open() { - utils::run_editor_test( - "Menu/File/NewScene", - TestPlugin::new( - Macro::begin() - .click_at(FileMenu::FILE) - .click_at(FileMenu::NEW_SCENE) - .then(|editor| assert_eq!(editor.scenes.len(), 1)), - ), - ); -} - -#[test] -fn test_close_no_save() { - utils::run_editor_test( - "Menu/File/CloseNoSave", - TestPlugin::new( - Macro::begin() - .click_at(FileMenu::FILE) - .click_at(FileMenu::NEW_SCENE) - .then(|editor| assert_eq!(editor.scenes.len(), 1)) - .click_at(FileMenu::FILE) - .click_at(FileMenu::CLOSE_SCENE) - .click_at_text(SaveSceneConfirmationDialog::DIALOG_ID, "No") - .then(|editor| assert_eq!(editor.scenes.len(), 0)), - ), - ); -} - -#[test] -fn test_close_with_save() { - utils::run_editor_test( - "Menu/File/CloseWithSave", - TestPlugin::new( - Macro::begin() - .click_at(FileMenu::FILE) - .click_at(FileMenu::NEW_SCENE) - .then(|editor| assert_eq!(editor.scenes.len(), 1)) - .click_at(FileMenu::FILE) - .click_at(FileMenu::CLOSE_SCENE) - .click_at_text(SaveSceneConfirmationDialog::DIALOG_ID, "Yes") - .click_at_text(FileMenu::SAVE_FILE_SELECTOR, "Save") - .skip_frame() - .then(|editor| assert_eq!(editor.scenes.len(), 0)), - ), - ); -} - -#[test] -fn test_exit_with_save() { - utils::run_editor_test( - "Menu/File/ExitWithSave", - TestPlugin::new( - Macro::begin() - .click_at(FileMenu::FILE) - .click_at(FileMenu::NEW_SCENE) - .then(|editor| assert_eq!(editor.scenes.len(), 1)) - .click_at(FileMenu::FILE) - .click_at(FileMenu::SAVE_SCENE) - .click_at_text(FileMenu::SAVE_FILE_SELECTOR, "Save") - .then(|editor| assert_eq!(editor.scenes.len(), 1)), - ), - ); -} - -#[test] -fn test_exit() { - utils::run_editor_test( - "Menu/File/Exit", - TestPlugin::new( - Macro::begin() - .click_at(FileMenu::FILE) - .click_at(FileMenu::EXIT), - ), - ); -} +pub mod macros; +pub mod utils; diff --git a/editor/tests/close_no_save.rs b/editor/tests/close_no_save.rs new file mode 100644 index 000000000..829b917ee --- /dev/null +++ b/editor/tests/close_no_save.rs @@ -0,0 +1,42 @@ +// Copyright (c) 2019-present Dmitry Stepanov and Fyrox Engine contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +use fyroxed_base::menu::file::FileMenu; +use fyroxed_base::test::macros::Macro; +use fyroxed_base::test::utils; +use fyroxed_base::test::utils::TestPlugin; +use fyroxed_base::SaveSceneConfirmationDialog; + +#[test] +fn test_close_no_save() { + utils::run_editor_test( + "Menu/File/CloseNoSave", + TestPlugin::new( + Macro::begin() + .click_at(FileMenu::FILE) + .click_at(FileMenu::NEW_SCENE) + .then(|editor| assert_eq!(editor.scenes.len(), 1)) + .click_at(FileMenu::FILE) + .click_at(FileMenu::CLOSE_SCENE) + .click_at_text(SaveSceneConfirmationDialog::DIALOG_ID, "No") + .then(|editor| assert_eq!(editor.scenes.len(), 0)), + ), + ); +} diff --git a/editor/tests/close_with_save.rs b/editor/tests/close_with_save.rs new file mode 100644 index 000000000..45acb286a --- /dev/null +++ b/editor/tests/close_with_save.rs @@ -0,0 +1,44 @@ +// Copyright (c) 2019-present Dmitry Stepanov and Fyrox Engine contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +use fyroxed_base::menu::file::FileMenu; +use fyroxed_base::test::macros::Macro; +use fyroxed_base::test::utils; +use fyroxed_base::test::utils::TestPlugin; +use fyroxed_base::SaveSceneConfirmationDialog; + +#[test] +fn test_close_with_save() { + utils::run_editor_test( + "Menu/File/CloseWithSave", + TestPlugin::new( + Macro::begin() + .click_at(FileMenu::FILE) + .click_at(FileMenu::NEW_SCENE) + .then(|editor| assert_eq!(editor.scenes.len(), 1)) + .click_at(FileMenu::FILE) + .click_at(FileMenu::CLOSE_SCENE) + .click_at_text(SaveSceneConfirmationDialog::DIALOG_ID, "Yes") + .click_at_text(FileMenu::SAVE_FILE_SELECTOR, "Save") + .skip_frame() + .then(|editor| assert_eq!(editor.scenes.len(), 0)), + ), + ); +} diff --git a/editor/tests/exit.rs b/editor/tests/exit.rs new file mode 100644 index 000000000..6cfc9cc91 --- /dev/null +++ b/editor/tests/exit.rs @@ -0,0 +1,36 @@ +// Copyright (c) 2019-present Dmitry Stepanov and Fyrox Engine contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +use fyroxed_base::menu::file::FileMenu; +use fyroxed_base::test::macros::Macro; +use fyroxed_base::test::utils; +use fyroxed_base::test::utils::TestPlugin; + +#[test] +fn test_exit() { + utils::run_editor_test( + "Menu/File/Exit", + TestPlugin::new( + Macro::begin() + .click_at(FileMenu::FILE) + .click_at(FileMenu::EXIT), + ), + ); +} diff --git a/editor/tests/exit_with_save.rs b/editor/tests/exit_with_save.rs new file mode 100644 index 000000000..bda983975 --- /dev/null +++ b/editor/tests/exit_with_save.rs @@ -0,0 +1,41 @@ +// Copyright (c) 2019-present Dmitry Stepanov and Fyrox Engine contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +use fyroxed_base::menu::file::FileMenu; +use fyroxed_base::test::macros::Macro; +use fyroxed_base::test::utils; +use fyroxed_base::test::utils::TestPlugin; + +#[test] +fn test_exit_with_save() { + utils::run_editor_test( + "Menu/File/ExitWithSave", + TestPlugin::new( + Macro::begin() + .click_at(FileMenu::FILE) + .click_at(FileMenu::NEW_SCENE) + .then(|editor| assert_eq!(editor.scenes.len(), 1)) + .click_at(FileMenu::FILE) + .click_at(FileMenu::SAVE_SCENE) + .click_at_text(FileMenu::SAVE_FILE_SELECTOR, "Save") + .then(|editor| assert_eq!(editor.scenes.len(), 1)), + ), + ); +} diff --git a/editor/tests/main.rs b/editor/tests/main.rs new file mode 100644 index 000000000..269847ebf --- /dev/null +++ b/editor/tests/main.rs @@ -0,0 +1,19 @@ +// Copyright (c) 2019-present Dmitry Stepanov and Fyrox Engine contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. diff --git a/editor/tests/open.rs b/editor/tests/open.rs new file mode 100644 index 000000000..535cd4949 --- /dev/null +++ b/editor/tests/open.rs @@ -0,0 +1,37 @@ +// Copyright (c) 2019-present Dmitry Stepanov and Fyrox Engine contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +use fyroxed_base::menu::file::FileMenu; +use fyroxed_base::test::macros::Macro; +use fyroxed_base::test::utils; +use fyroxed_base::test::utils::TestPlugin; + +#[test] +fn test_open() { + utils::run_editor_test( + "Menu/File/NewScene", + TestPlugin::new( + Macro::begin() + .click_at(FileMenu::FILE) + .click_at(FileMenu::NEW_SCENE) + .then(|editor| assert_eq!(editor.scenes.len(), 1)), + ), + ); +}