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

« back to all changes in this revision

Viewing changes to test/active_window.cpp

  • Committer: Bileto Bot
  • Date: 2017-02-15 14:05:17 UTC
  • mfrom: (352.1.3 miral)
  • Revision ID: ci-train-bot@canonical.com-20170215140517-3h16hkkwog2nl0au
* New upstream release 1.2.0 (https://launchpad.net/miral/+milestone/1.2)
  - ABI summary:
    . miral ABI unchanged at 2
  - Enhancements:
    . New libmirclientcpp-dev package "C++ wrapper for libmirclient". (Split
      from libmiral-dev)
    . Give miral-app and miral-desktop a good default for -bindir
    . More surface to window renaming to reflect Mir name changes
    . Refresh the "Building and Using MirAL" doc
  - Bugs fixed:
    . Chrome-less shell hint does not work any more (LP: #1658117)
    . WindowSpec::set_state() wrapper for mir_window_spec_set_state()
      (LP: #1661256)
    . "$ miral-app -kiosk" fails with "Unknown command line options: 
      --desktop_file_hint=miral-shell.desktop" (LP: #1660933)
    . libmiral] Fix focus and movement rules for Input Method and Satellite
       windows. (LP: #1660691)
    

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
#include "test_server.h"
20
20
 
21
 
#include <miral/toolkit/window.h>
22
 
#include <miral/toolkit/window_spec.h>
 
21
#include <mir/client/window.h>
 
22
#include <mir/client/window_spec.h>
23
23
#include <mir_toolkit/mir_buffer_stream.h>
24
24
#include <mir_toolkit/version.h>
25
25
 
30
30
#include <gtest/gtest.h>
31
31
 
32
32
using namespace testing;
33
 
using namespace miral::toolkit;
 
33
using namespace mir::client;
34
34
using namespace std::chrono_literals;
35
35
using miral::WindowManagerTools;
36
36
 
73
73
 
74
74
    auto create_surface(Connection const& connection, char const* name, FocusChangeSync& sync) -> Window
75
75
    {
76
 
        auto const spec = WindowSpec::for_normal_surface(connection, 50, 50, mir_pixel_format_argb_8888)
 
76
        auto const spec = WindowSpec::for_normal_window(connection, 50, 50, mir_pixel_format_argb_8888)
77
77
            .set_buffer_usage(mir_buffer_usage_software)
78
78
            .set_event_handler(&FocusChangeSync::raise_signal_on_focus_change, &sync)
79
79
            .set_name(name);
80
80
 
81
 
        Window const surface{spec.create_surface()};
 
81
        Window const surface{spec.create_window()};
82
82
 
83
 
#if MIR_CLIENT_VERSION <= MIR_VERSION_NUMBER(3, 4, 0)
84
 
        sync.exec([&]{ mir_buffer_stream_swap_buffers_sync(mir_surface_get_buffer_stream(surface)); });
85
 
#else
86
83
        sync.exec([&]{ mir_buffer_stream_swap_buffers_sync(mir_window_get_buffer_stream(surface)); });
87
 
#endif
88
84
        EXPECT_TRUE(sync.signal_raised());
89
85
 
90
86
        return surface;
99
95
            .set_event_handler(&FocusChangeSync::raise_signal_on_focus_change, &sync)
100
96
            .set_name(name);
101
97
 
102
 
        Window const surface{spec.create_surface()};
 
98
        Window const surface{spec.create_window()};
103
99
 
104
100
        // Expect this to timeout: A tip should not receive focus
105
 
#if MIR_CLIENT_VERSION <= MIR_VERSION_NUMBER(3, 4, 0)
106
 
        sync.exec([&]{ mir_buffer_stream_swap_buffers_sync(mir_surface_get_buffer_stream(surface)); });
107
 
#else
108
101
        sync.exec([&]{ mir_buffer_stream_swap_buffers_sync(mir_window_get_buffer_stream(surface)); });
109
 
#endif
110
102
        EXPECT_FALSE(sync.signal_raised());
111
103
 
112
104
        return surface;
120
112
            .set_event_handler(&FocusChangeSync::raise_signal_on_focus_change, &sync)
121
113
            .set_name(name);
122
114
 
123
 
        Window const surface{spec.create_surface()};
 
115
        Window const surface{spec.create_window()};
124
116
 
125
 
#if MIR_CLIENT_VERSION <= MIR_VERSION_NUMBER(3, 4, 0)
126
 
        sync.exec([&]{ mir_buffer_stream_swap_buffers_sync(mir_surface_get_buffer_stream(surface)); });
127
 
#else
128
117
        sync.exec([&]{ mir_buffer_stream_swap_buffers_sync(mir_window_get_buffer_stream(surface)); });
129
 
#endif
130
118
        EXPECT_TRUE(sync.signal_raised());
131
119
 
132
120
        return surface;
350
338
    EXPECT_TRUE(sync2.signal_raised());
351
339
    assert_active_window_is(dialog_name);
352
340
}
 
341
 
 
342
TEST_F(ActiveWindow, input_methods_are_not_focussed)
 
343
{
 
344
    char const* const test_name = __PRETTY_FUNCTION__;
 
345
    auto const connection = connect_client(test_name);
 
346
 
 
347
    auto const parent = create_surface(connection, test_name, sync1);
 
348
    auto const input_method = WindowSpec::for_input_method(connection, 50, 50, parent).create_window();
 
349
 
 
350
    assert_active_window_is(test_name);
 
351
 
 
352
    invoke_tools([&](WindowManagerTools& tools)
 
353
        {
 
354
            auto const& info = tools.info_for(tools.active_window());
 
355
            tools.select_active_window(info.children().at(0));
 
356
        });
 
357
 
 
358
    assert_active_window_is(test_name);
 
359
}
 
360
 
 
361
TEST_F(ActiveWindow, satellites_are_not_focussed)
 
362
{
 
363
    char const* const test_name = __PRETTY_FUNCTION__;
 
364
    auto const connection = connect_client(test_name);
 
365
 
 
366
    auto const parent = create_surface(connection, test_name, sync1);
 
367
    auto const satellite = WindowSpec::for_satellite(connection, 50, 50, parent).create_window();
 
368
 
 
369
    assert_active_window_is(test_name);
 
370
 
 
371
    invoke_tools([&](WindowManagerTools& tools)
 
372
    {
 
373
        auto const& info = tools.info_for(tools.active_window());
 
374
        tools.select_active_window(info.children().at(0));
 
375
    });
 
376
 
 
377
    assert_active_window_is(test_name);
 
378
}