~ci-train-bot/mir/mir-ubuntu-artful-3013

« back to all changes in this revision

Viewing changes to tests/unit-tests/platforms/android/server/test_server_interpreter.cpp

  • Committer: Bileto Bot
  • Date: 2017-06-30 12:00:17 UTC
  • mfrom: (1303.1.6 mir-0.27)
  • Revision ID: ci-train-bot@canonical.com-20170630120017-ha5i92o9moejk2b1
* New upstream release 0.27.0 (https://launchpad.net/mir/+milestone/0.27.0)
  - ABI summary:
    . mirclient ABI unchanged at 9
    . mirserver ABI bumped to 44
    . mircommon ABI unchanged at 7
    . mirplatform ABI bumped to 61
    . mirprotobuf ABI unchanged at 3
    . mirplatformgraphics ABI bumped to 13
    . mirclientplatform ABI unchanged at 5
    . mirinputplatform ABI bumped to 7
    . mircore ABI unchanged at 1
  - Enhancements:
    . Mostly groundwork required to support major enhancements coming in
      future Mir versions.
    . Removed android-input and eliminated the entire "3rd_party/" subtree.
      Now the Mir source tree contains original code only.
    . Added mir_prompt_session_new_fds_for_prompt_providers_sync API.
    . mirout: Added load and save options for keeping display configs
      on disk.
    . mirout: Added "--" support for applying configuration changes under
      Unity8.
    . Fixed failure of DRM hardware cursor {hide(); show(image);}
    . Added server option: "--cursor software" (MIR_SERVER_CURSOR=software)
    . Added letterboxing/black bars support to the GL renderer in preparation
      for generic output cloning.
    . Added client API for getting the logical size of an output.
    . Migrated MirCookie to use SHA-256.
    . Ensure RealKMSOutputConfiguration stays in sync with actual hardware
      state.
    . Added support for drag-and-drop.
    . Lots of other client API enhancements.
    . Minor clean-ups, optimizations and dead code removal.
    . Added support for building on Ubuntu 17.10 artful.
    . Update example code to use undeprecated API.
    . mesa-kms: Support hardware cursors in hybrid setups.
    . Rework and publish the graphics platform APIs
  - Bugs fixed:
    . [enhancement] Make able to get version information from client /
      server APIs (LP: #1195540)
    . Touch screen coordinates don't rotate with the screen (LP: #1349660)
    . Subpixel order not included in Mir display information (LP: #1393578)
    . [enhancement] Missing client API for relative surface movement (e.g.
      dragging client-decorated windows) (LP: #1420334) . Mir does not reset
      key states when paused or resumed (modifiers get stuck after VT
      switching) (LP: #1536279)
    . NBS never uses mc::MultiMonitorMode::single_monitor_fast, even when
      only a single monitor is plugged in (LP: #1561418)
    . Inconsistent behaviour of Num Lock (LP: #1588237)
    . A scaled (not panned or clipped) mirror/clone mode is desired
      (LP: #1639226)
    . Rotating an output left or right without restarting the
      compositor distorts the image (LP: #1643488)
    . support display scaling slider in unity8 (LP: #1645372)
    . [ FAILED ] NestedInputWithMouse.mouse_pointer_coordinates_in_nested_
      server_are_accumulated (LP: #1646375)
    . [ FAILED ] NestedInputWithMouse.mouse_pointer_position_is_in_sync_with_
      host_server (LP: #1646558)
    . abi_check doesn't check mircore (LP: #1649354)
    . [testsfail] PromptSessionClientAPI.client_pid_is_associated_with_
      session hangs and times out (LP: #1655929)
    . EDID does not change when hotplugging a monitor (LP: #1660017)
    . [regression] Mir 0.26.0 - spinner loading animation, minimize, maximize
      too fast (LP: #1661072)
    . [regression] Unity8 stutters constantly (like half frame rate) using
      Mir 0.26.0 (LP: #1661128)
    . [regression] mir_demo_server refuses to quit on Ctrl+Alt+Backspace or
      Ctrl+C in its terminal (deadlock in DefaultInputDeviceHub::add_device)
      (LP: #1661151)
    . [regression] mirout crashes when connecting to unity8 or any nested
      server: [libprotobuf FATAL
      /usr/include/google/protobuf/repeated_field.h:1408] CHECK failed:
      (index) < (current_size_): (LP: #1661163)
    . [ FAILED ] DefaultInputManagerTest.forwards_pause_continue_state_
      changes_to_platform (LP: #1661187)
    . [regression] Segfault on detect_fd_leaks during acceptance tests (in
      DisplayConfiguration/{DisplayFormatSetting,DisplaySubpixelSetting})
      (LP: #1661498)
    . [regression] Nested server segfaults or rapidly logs exceptions when a
      fullscreen client starts [in mir_presentation_chain_set_dropping_mode
      ... std::exception::what: Operation not permitted] (LP: #1661508)
    . [regression] Windowed clients of nested servers are all black
      (LP: #1661521)
    . mir_window_request_persistent_id_sync seg faults when called twice
      (LP: #1661704)
    . mir_acceptance_tests now takes 10 seconds longer (in r4002 compared to
      r4001) (LP: #1662044)
    . Mir graphics platform ABI broke in series 0.26 but sonames never
      changed (LP: #1662455)
    . libmirclient-dev missing build depndency on libmircore-dev
      (LP: #1662942)
    . [regression] mirscreencast hangs during screencast creation
      (LP: #1662997)
    . [regression] Software clients of nested servers with size >=480x480
      are all black in Mir 0.25.0 and later (or stretched and distorted under
      Unity8) (LP: #1663062)
    . mir_window_spec_set_cursor_name() doesn't trigger
      mir::scene::SurfaceObserver::cursor_image_set_to (LP: #1663197)
    . android complaint during mirscreencast of nested server (LP: #1664562)
    . qtubuntu sends wrong text as part of QKeyEvent (LP: #1664610)
    . Mir server crashed with SIGSEGV in
      mir::compositor::TemporaryBuffer::size() called from
      mir::gl::tessellate_renderable_into_rectangle() (LP: #1664760)
    . mirout reports logical size of a rotated display incorrectly
      (LP: #1665271)
    . Nested servers (Unity8) periodically stutter (half frame rate) with
      Mir 0.26.1 (LP: #1666372)
    . If the only surface in a session cannot take focus the server crashes
      (LP: #1667645)
    . [regression] OSK input shaping no longer works correctly (LP: #1669444)
    . GTK window functions `Always on Top, Move and Resize' don't work in
      Mir/Unity8 (LP: #1669524)
    . [regression] mir_proving_server mode hotkeys (Ctrl+Alt+=/-) cause the
      server to segfault (LP: #1669752)
    . Test takes minutes to complete: MediatingDisplayChangerTest.confirmed_
      configuration_doesnt_revert_after_timeout (LP: #1671033)
    . [ FAILED ] PosixRWMutex.prefer_writer_nonrecursive_prevents_writer_
      starvation (Timeout waiting to acquire write lock) (LP: #1671037)
    . [regression] Mixing screen rotation with mode changes makes the image
      squished (LP: #1672269)
    . unity-system-compositor crashed with SIGSEGV in
      libinput_device_config_accel_is_available() from
      libinput_device_config_accel_set_speed() from
      mir::input::evdev::LibInputDevice::apply_settings() (LP: #1672955)
    . Presentation chains should support various Vulkan presentation modes
      (LP: #1673533)
    . Need an extension for GBM buffers to replace
      mir_buffer_get_buffer_package() (LP: #1673534)
    . cross-compile-chroot.sh (to zesty) fails to build [cannot find -ludev]
      due to libudev.so being in a different directory to where libudev.pc
      searches for it (LP: #1674201)
    . Please transition to Boost 1.62 (LP: #1675138)
    . [regression] Mir is assigning the first output ID = 0 (==
      mir_display_output_id_invalid) (LP: #1675331)
    . Mir sending key repeat events continually to nested shell after VT
      switch (causes Unity8 lockup for a while) (LP: #1675357)
    . mirout commands don't work when followed by -- (LP: #1676320)
    . mir_demo_standalone_render_overlays fails to link (LP: #1677239)
    . [regression] doxygen processing for capnproto/protobuf broken
      (LP: #1679248)
    . mir_window_spec_set_cursor_render_surface does not work (LP: #1679836)
    . [regression] Some fullscreen apps render nothing until the window has
      been resized (LP: #1686620)
    . Correct eglsquare example: Don't paint from the window event handler.
      (LP: #1695221)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright © 2013 Canonical Ltd.
3
 
 *
4
 
 * This program is free software: you can redistribute it and/or modify
5
 
 * it under the terms of the GNU General Public License version 3 as
6
 
 * 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: Kevin DuBois <kevin.dubois@canonical.com>
17
 
 */
18
 
 
19
 
#include "src/platforms/android/server/server_render_window.h"
20
 
 
21
 
#include "mir/test/doubles/mock_buffer.h"
22
 
#include "mir/test/doubles/mock_fence.h"
23
 
#include "mir/test/doubles/mock_interpreter_resource_cache.h"
24
 
#include "mir/test/doubles/mock_framebuffer_bundle.h"
25
 
#include "mir/test/doubles/stub_android_native_buffer.h"
26
 
#include "mir/test/fake_shared.h"
27
 
#include "mir/test/doubles/mock_android_native_buffer.h"
28
 
#include "mir/test/doubles/null_gl_context.h"
29
 
#include "mir/test/doubles/mock_egl.h"
30
 
#include "mir_toolkit/common.h"
31
 
#include <hardware/gralloc.h>
32
 
#include <gtest/gtest.h>
33
 
#include <gmock/gmock.h>
34
 
#include <stdexcept>
35
 
 
36
 
namespace mt=mir::test;
37
 
namespace mtd=mir::test::doubles;
38
 
namespace geom=mir::geometry;
39
 
namespace mg=mir::graphics;
40
 
namespace mga=mir::graphics::android;
41
 
 
42
 
namespace
43
 
{
44
 
//krillin and arale need to clear their fences before hwc commit.
45
 
struct StubPropertiesWrapper : mga::PropertiesWrapper
46
 
{
47
 
    StubPropertiesWrapper(bool should_clear_fence) :
48
 
        name(should_clear_fence ? "arale" : "otherdevice")
49
 
    {
50
 
    }
51
 
 
52
 
    int property_get(char const* key, char* value, char const* default_value) const override
53
 
    {
54
 
        if (strncmp(key, "ro.product.device", PROP_VALUE_MAX) == 0)
55
 
            strncpy(value, name.c_str(), name.size());
56
 
        else
57
 
            strncpy(value, default_value, PROP_VALUE_MAX);
58
 
        return 0;    
59
 
    }
60
 
 
61
 
    std::string name;
62
 
};
63
 
 
64
 
struct ServerRenderWindow : public ::testing::Test
65
 
{
66
 
    std::shared_ptr<mtd::MockBuffer> mock_buffer{std::make_shared<testing::NiceMock<mtd::MockBuffer>>()};
67
 
    std::shared_ptr<mtd::MockInterpreterResourceCache> mock_cache{
68
 
        std::make_shared<testing::NiceMock<mtd::MockInterpreterResourceCache>>()};
69
 
    std::shared_ptr<mtd::MockFBBundle> mock_fb_bundle{
70
 
        std::make_shared<testing::NiceMock<mtd::MockFBBundle>>()};
71
 
    MirPixelFormat format{mir_pixel_format_abgr_8888};
72
 
    StubPropertiesWrapper wrapper{false};
73
 
    mtd::NullGLContext context;
74
 
    testing::NiceMock<mtd::MockEGL> mock_egl;
75
 
    mga::DeviceQuirks quirks{wrapper, context};
76
 
    mga::ServerRenderWindow render_window{mock_fb_bundle, format, mock_cache, quirks};
77
 
};
78
 
}
79
 
 
80
 
TEST_F(ServerRenderWindow, returns_buffer_on_request)
81
 
{
82
 
    using namespace testing;
83
 
    auto stub_buffer = std::make_shared<mtd::StubAndroidNativeBuffer>();
84
 
 
85
 
    EXPECT_CALL(*mock_fb_bundle, buffer_for_render())
86
 
        .WillOnce(Return(mock_buffer));
87
 
    EXPECT_CALL(*mock_buffer, native_buffer_handle())
88
 
        .WillOnce(Return(stub_buffer));
89
 
 
90
 
    std::shared_ptr<mg::Buffer> tmp = mock_buffer;
91
 
    std::shared_ptr<mga::NativeBuffer> tmp2 = stub_buffer;
92
 
    EXPECT_CALL(*mock_cache, store_buffer(tmp, tmp2));
93
 
 
94
 
    auto rc_buffer = render_window.driver_requests_buffer();
95
 
    EXPECT_EQ(stub_buffer.get(), rc_buffer);
96
 
}
97
 
 
98
 
TEST_F(ServerRenderWindow, updates_fences_and_returns_buffer_on_queue)
99
 
{
100
 
    using namespace testing;
101
 
    int fake_fence = 488;
102
 
    auto stub_buffer = std::make_shared<mtd::StubAndroidNativeBuffer>();
103
 
 
104
 
    EXPECT_CALL(*mock_fb_bundle, buffer_for_render())
105
 
        .WillOnce(Return(mock_buffer));
106
 
    EXPECT_CALL(*mock_buffer, native_buffer_handle())
107
 
        .WillOnce(Return(stub_buffer));
108
 
 
109
 
    render_window.driver_requests_buffer();
110
 
    Mock::VerifyAndClearExpectations(mock_fb_bundle.get());
111
 
 
112
 
    std::shared_ptr<mg::Buffer> buf1 = mock_buffer;
113
 
    EXPECT_CALL(*mock_cache, update_native_fence(stub_buffer->anwb(), fake_fence));
114
 
    EXPECT_CALL(*mock_cache, retrieve_buffer(stub_buffer->anwb()))
115
 
        .WillOnce(Return(mock_buffer));
116
 
 
117
 
    render_window.driver_returns_buffer(stub_buffer->anwb(), fake_fence);
118
 
    Mock::VerifyAndClearExpectations(mock_fb_bundle.get());
119
 
}
120
 
 
121
 
TEST_F(ServerRenderWindow, clears_fence_when_quirk_present)
122
 
{
123
 
    using namespace testing;
124
 
    StubPropertiesWrapper wrapper{true};
125
 
    mga::DeviceQuirks quirks{wrapper, context};
126
 
    mga::ServerRenderWindow render_window{mock_fb_bundle, format, mock_cache, quirks};
127
 
 
128
 
    int fake_fence = 488;
129
 
    auto stub_buffer = std::make_shared<mtd::StubAndroidNativeBuffer>();
130
 
 
131
 
    EXPECT_CALL(*mock_fb_bundle, buffer_for_render())
132
 
        .WillOnce(Return(mock_buffer));
133
 
    EXPECT_CALL(*mock_buffer, native_buffer_handle())
134
 
        .WillOnce(Return(stub_buffer));
135
 
 
136
 
    render_window.driver_requests_buffer();
137
 
    Mock::VerifyAndClearExpectations(mock_fb_bundle.get());
138
 
 
139
 
    std::shared_ptr<mg::Buffer> buf1 = mock_buffer;
140
 
    EXPECT_CALL(*mock_cache, update_native_fence(stub_buffer->anwb(), fake_fence))
141
 
        .Times(0);
142
 
    EXPECT_CALL(*mock_cache, retrieve_buffer(stub_buffer->anwb()))
143
 
        .WillOnce(Return(mock_buffer));
144
 
 
145
 
    render_window.driver_returns_buffer(stub_buffer->anwb(), fake_fence);
146
 
    Mock::VerifyAndClearExpectations(mock_fb_bundle.get());
147
 
}
148
 
 
149
 
TEST_F(ServerRenderWindow, returns_format)
150
 
{
151
 
    EXPECT_EQ(HAL_PIXEL_FORMAT_RGBA_8888, render_window.driver_requests_info(NATIVE_WINDOW_FORMAT));
152
 
}
153
 
 
154
 
TEST_F(ServerRenderWindow, returns_usage_bits_for_fb)
155
 
{
156
 
    using namespace testing;
157
 
    auto bits = GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_COMPOSER | GRALLOC_USAGE_HW_FB;
158
 
    EXPECT_THAT(render_window.driver_requests_info(NATIVE_WINDOW_CONSUMER_USAGE_BITS), Eq(bits));
159
 
}
160
 
 
161
 
TEST_F(ServerRenderWindow, returns_different_format_if_format_changes)
162
 
{
163
 
    render_window.dispatch_driver_request_format(HAL_PIXEL_FORMAT_RGBX_8888);
164
 
    EXPECT_EQ(HAL_PIXEL_FORMAT_RGBX_8888, render_window.driver_requests_info(NATIVE_WINDOW_FORMAT));
165
 
}
166
 
 
167
 
TEST_F(ServerRenderWindow, returns_sensible_size_values_without_size_having_been_set)
168
 
{
169
 
    using namespace testing;
170
 
    geom::Size test_size{4, 5};
171
 
    EXPECT_CALL(*mock_fb_bundle, fb_size())
172
 
        .Times(4)
173
 
        .WillRepeatedly(Return(test_size));
174
 
 
175
 
    unsigned int rc_width = render_window.driver_requests_info(NATIVE_WINDOW_DEFAULT_WIDTH);
176
 
    unsigned int rc_height = render_window.driver_requests_info(NATIVE_WINDOW_DEFAULT_HEIGHT);
177
 
    EXPECT_EQ(test_size.width.as_uint32_t(), rc_width);
178
 
    EXPECT_EQ(test_size.height.as_uint32_t(), rc_height);
179
 
 
180
 
    rc_width = render_window.driver_requests_info(NATIVE_WINDOW_WIDTH);
181
 
    rc_height = render_window.driver_requests_info(NATIVE_WINDOW_HEIGHT);
182
 
    EXPECT_EQ(test_size.width.as_uint32_t(), rc_width);
183
 
    EXPECT_EQ(test_size.height.as_uint32_t(), rc_height);
184
 
}
185
 
 
186
 
TEST_F(ServerRenderWindow, returns_no_transform_when_asked_for_hint)
187
 
{
188
 
    EXPECT_EQ(0, render_window.driver_requests_info(NATIVE_WINDOW_TRANSFORM_HINT));
189
 
}
190
 
 
191
 
TEST_F(ServerRenderWindow, reports_framebuffer_concrete_type)
192
 
{
193
 
    EXPECT_EQ(NATIVE_WINDOW_FRAMEBUFFER, render_window.driver_requests_info(NATIVE_WINDOW_CONCRETE_TYPE));
194
 
}
195
 
 
196
 
TEST_F(ServerRenderWindow, throws_on_driver_unknown_inquiry)
197
 
{
198
 
    EXPECT_THROW({
199
 
        render_window.driver_requests_info(NATIVE_WINDOW_CONSUMER_RUNNING_BEHIND);
200
 
    }, std::runtime_error);
201
 
}