~ci-train-bot/miral/miral-ubuntu-zesty-2299

« back to all changes in this revision

Viewing changes to test/modify_window_state.cpp

  • Committer: Bileto Bot
  • Date: 2016-11-30 08:40:00 UTC
  • mfrom: (340.1.2 miral-release)
  • Revision ID: ci-train-bot@canonical.com-20161130084000-q9mfvwqsbdr078ec
* New upstream release 0.5.0 (https://launchpad.net/miral/+milestone/0.5)
  - ABI summary:
    . miral ABI unchanged at 1
  - Enhancements:
    . Add miral::DebugExtension allowing shells to enable & disable support
      for debug extension API(s) dynamically
    . Improve handling of fullscreen surfaces when switching outputs, or
      specified output doesn't exist (any more)
    . Initial tests and some fixes for tracking of active window.
    . Document the order of windows passed to
      WindowManagementPolicy::advise_raise() so clients can rely on it.
    . [examples] Add miral-desktop script for launching a pseudo-desktop
    . [examples] Add miral-screencast - a utility script to assist with
      creating a screencast
    . [examples: miral-shell --window-manager tiling] implement the layout
      suggested in "Tasks for the interested reader"
    . [examples: miral-shell --window-manager tiling] Don't place a tile
      until the first window is ready
    . [examples: miral-kiosk] Provide configuration options for kiosk:
      --keymap --kiosk-maximize-root-windows & --kiosk-startup-apps-only
  - Bugs fixed:
    . Display configuration changes may cause "fatal errors" when there are
      fullscreen windows (LP: #1640557)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright © 2016 Canonical Ltd.
 
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,
 
6
 * as published by the Free Software Foundation.
 
7
 *
 
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.
 
12
 *
 
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/>.
 
15
 *
 
16
 * Authored by: Alan Griffiths <alan@octopull.co.uk>
 
17
 */
 
18
 
 
19
#include "test_window_manager_tools.h"
 
20
#include <mir/event_printer.h>
 
21
 
 
22
using namespace miral;
 
23
using namespace testing;
 
24
namespace mt = mir::test;
 
25
using mir::operator<<;
 
26
 
 
27
namespace
 
28
{
 
29
X const display_left{0};
 
30
Y const display_top{0};
 
31
Width const display_width{640};
 
32
Height const display_height{480};
 
33
 
 
34
Rectangle const display_area{{display_left,  display_top},
 
35
                             {display_width, display_height}};
 
36
 
 
37
auto const null_window = Window{};
 
38
 
 
39
struct ModifyWindowState : TestWindowManagerTools, WithParamInterface<MirSurfaceType>
 
40
{
 
41
    Size const initial_parent_size{600, 400};
 
42
 
 
43
    Window window;
 
44
 
 
45
    void SetUp() override
 
46
    {
 
47
        basic_window_manager.add_display(display_area);
 
48
        basic_window_manager.add_session(session);
 
49
    }
 
50
 
 
51
    void create_window_of_type(MirSurfaceType type)
 
52
    {
 
53
        mir::scene::SurfaceCreationParameters creation_parameters;
 
54
        creation_parameters.type = type;
 
55
        creation_parameters.size = initial_parent_size;
 
56
 
 
57
        EXPECT_CALL(*window_manager_policy, advise_new_window(_))
 
58
            .WillOnce(
 
59
                Invoke(
 
60
                    [this](WindowInfo const& window_info)
 
61
                        { window = window_info.window(); }));
 
62
 
 
63
        basic_window_manager.add_surface(session, creation_parameters, &create_surface);
 
64
        basic_window_manager.select_active_window(window);
 
65
 
 
66
        // Clear the expectations used to capture parent & child
 
67
        Mock::VerifyAndClearExpectations(window_manager_policy);
 
68
    }
 
69
};
 
70
 
 
71
using ForNormalSurface = ModifyWindowState;
 
72
 
 
73
TEST_P(ForNormalSurface, state)
 
74
{
 
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);
 
78
 
 
79
    create_window_of_type(mir_surface_type_normal);
 
80
    auto const& info = window_manager_tools.info_for(window);
 
81
 
 
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;
 
88
 
 
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());
 
94
}
 
95
}
 
96
 
 
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
 
107
));