343721f3a850e7eefbb030c06c89c097298d1a58
[iec.git] / src / type3_AndroidCloud / anbox-master / tests / anbox / application / restricted_manager_tests.cpp
1 /*
2  * Copyright (C) 2017 Simon Fels <morphis@gravedo.de>
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License version 3, as published
6  * by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranties of
10  * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11  * PURPOSE.  See the GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License along
14  * with this program.  If not, see <http://www.gnu.org/licenses/>.
15  *
16  */
17
18 #include "anbox/application/manager.h"
19
20 #include <gmock/gmock.h>
21
22 using namespace ::testing;
23
24 namespace {
25 class MockManager : public anbox::application::Manager {
26  public:
27   MOCK_METHOD3(launch, void(const anbox::android::Intent&,
28                             const anbox::graphics::Rect&,
29                             const anbox::wm::Stack::Id&));
30   MOCK_METHOD0(ready, core::Property<bool>&());
31 };
32 }
33
34 TEST(RestrictedManager, RedirectsLaunchesToRightStack) {
35   auto mgr = std::make_shared<MockManager>();
36   anbox::application::RestrictedManager restricted_mgr(mgr, anbox::wm::Stack::Id::Freeform);
37
38   EXPECT_CALL(*mgr, launch(_, _, anbox::wm::Stack::Id::Freeform))
39       .Times(4);
40
41   restricted_mgr.launch(anbox::android::Intent{},
42                         anbox::graphics::Rect::Empty,
43                         anbox::wm::Stack::Id::Default);
44
45   restricted_mgr.launch(anbox::android::Intent{},
46                         anbox::graphics::Rect::Empty,
47                         anbox::wm::Stack::Id::Fullscreen);
48
49   restricted_mgr.launch(anbox::android::Intent{},
50                         anbox::graphics::Rect::Empty,
51                         anbox::wm::Stack::Id::Invalid);
52
53   restricted_mgr.launch(anbox::android::Intent{},
54                         anbox::graphics::Rect::Empty,
55                         anbox::wm::Stack::Id::Freeform);
56 }