2
* Copyright © 2016 Canonical Ltd.
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,
6
* as published by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
* Authored by: Alan Griffiths <alan@octopull.co.uk>
19
#include "test_window_manager_tools.h"
20
#include <mir/event_printer.h>
22
using namespace miral;
23
using namespace testing;
24
namespace mt = mir::test;
25
using mir::operator<<;
29
X const display_left{0};
30
Y const display_top{0};
31
Width const display_width{640};
32
Height const display_height{480};
34
Rectangle const display_area{{display_left, display_top},
35
{display_width, display_height}};
37
auto const null_window = Window{};
39
struct ModifyWindowState : TestWindowManagerTools, WithParamInterface<MirSurfaceType>
41
Size const initial_parent_size{600, 400};
47
basic_window_manager.add_display(display_area);
48
basic_window_manager.add_session(session);
51
void create_window_of_type(MirSurfaceType type)
53
mir::scene::SurfaceCreationParameters creation_parameters;
54
creation_parameters.type = type;
55
creation_parameters.size = initial_parent_size;
57
EXPECT_CALL(*window_manager_policy, advise_new_window(_))
60
[this](WindowInfo const& window_info)
61
{ window = window_info.window(); }));
63
basic_window_manager.add_surface(session, creation_parameters, &create_surface);
64
basic_window_manager.select_active_window(window);
66
// Clear the expectations used to capture parent & child
67
Mock::VerifyAndClearExpectations(window_manager_policy);
71
using ForNormalSurface = ModifyWindowState;
73
TEST_P(ForNormalSurface, state)
75
auto const original_state = mir_surface_state_restored;
76
auto const new_state = MirSurfaceState(GetParam());
77
auto const state_is_visible = (new_state != mir_surface_state_minimized) && (new_state != mir_surface_state_hidden);
79
create_window_of_type(mir_surface_type_normal);
80
auto const& info = window_manager_tools.info_for(window);
82
WindowSpecification mods;
83
mods.state() = new_state;
84
window_manager_tools.modify_window(window, mods);
85
EXPECT_THAT(std::shared_ptr<mir::scene::Surface>(window)->state(), Eq(new_state));
86
EXPECT_THAT(info.state(), Eq(new_state));
87
EXPECT_THAT(info.is_visible(), Eq(state_is_visible)) << "State is " << new_state;
89
mods.state() = original_state;
90
window_manager_tools.modify_window(window, mods);
91
EXPECT_THAT(std::shared_ptr<mir::scene::Surface>(window)->state(), Eq(original_state));
92
EXPECT_THAT(info.state(), Eq(original_state));
93
EXPECT_TRUE(info.is_visible());
97
INSTANTIATE_TEST_CASE_P(ModifyWindowState, ForNormalSurface, ::testing::Values(
98
// mir_surface_state_unknown,
99
mir_surface_state_restored,
100
mir_surface_state_minimized,
101
mir_surface_state_maximized,
102
mir_surface_state_vertmaximized,
103
mir_surface_state_fullscreen,
104
mir_surface_state_horizmaximized,
105
mir_surface_state_hidden
106
// mir_surface_states