diff --git a/tests/anbox/CMakeLists.txt b/tests/anbox/CMakeLists.txt index ca13908..c0211bd 100644 --- a/tests/anbox/CMakeLists.txt +++ b/tests/anbox/CMakeLists.txt @@ -1,4 +1,5 @@ add_subdirectory(android) +add_subdirectory(application) add_subdirectory(support) add_subdirectory(common) add_subdirectory(graphics) diff --git a/tests/anbox/application/CMakeLists.txt b/tests/anbox/application/CMakeLists.txt new file mode 100644 index 0000000..f0277c9 --- /dev/null +++ b/tests/anbox/application/CMakeLists.txt @@ -0,0 +1 @@ +ANBOX_ADD_TEST(restricted_manager_tests restricted_manager_tests.cpp) diff --git a/tests/anbox/application/restricted_manager_tests.cpp b/tests/anbox/application/restricted_manager_tests.cpp new file mode 100644 index 0000000..343721f --- /dev/null +++ b/tests/anbox/application/restricted_manager_tests.cpp @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2017 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#include "anbox/application/manager.h" + +#include + +using namespace ::testing; + +namespace { +class MockManager : public anbox::application::Manager { + public: + MOCK_METHOD3(launch, void(const anbox::android::Intent&, + const anbox::graphics::Rect&, + const anbox::wm::Stack::Id&)); + MOCK_METHOD0(ready, core::Property&()); +}; +} + +TEST(RestrictedManager, RedirectsLaunchesToRightStack) { + auto mgr = std::make_shared(); + anbox::application::RestrictedManager restricted_mgr(mgr, anbox::wm::Stack::Id::Freeform); + + EXPECT_CALL(*mgr, launch(_, _, anbox::wm::Stack::Id::Freeform)) + .Times(4); + + restricted_mgr.launch(anbox::android::Intent{}, + anbox::graphics::Rect::Empty, + anbox::wm::Stack::Id::Default); + + restricted_mgr.launch(anbox::android::Intent{}, + anbox::graphics::Rect::Empty, + anbox::wm::Stack::Id::Fullscreen); + + restricted_mgr.launch(anbox::android::Intent{}, + anbox::graphics::Rect::Empty, + anbox::wm::Stack::Id::Invalid); + + restricted_mgr.launch(anbox::android::Intent{}, + anbox::graphics::Rect::Empty, + anbox::wm::Stack::Id::Freeform); +}