~ubuntu-branches/ubuntu/vivid/mir/vivid-proposed

« back to all changes in this revision

Viewing changes to tests/unit-tests/graphics/android/test_hwc_common_device.cpp

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release, Daniel van Vugt, std::exception::what: Invalid or inconsistent display configuration, Ubuntu daily release
  • Date: 2015-01-07 23:50:16 UTC
  • mfrom: (1.1.81)
  • Revision ID: package-import@ubuntu.com-20150107235016-lg89f9zrh5qa92s0
Tags: 0.10.0+15.04.20150107.2-0ubuntu1
[ Daniel van Vugt ]
* New upstream release 0.10.0 (https://launchpad.net/mir/+milestone/0.10.0)
  - Enhancements:
    . Added support for Android HWC 1.3 devices.
    . Plumbing/preparation to support external displays on Android devices.
    . Reduced build dependencies.
    . Client API: Added version macros.
    . Began work on automatic driver probing, to intelligently choose the
      best driver for you.
    . Demo shell (mir_proving_server): Added desktop zoom feature using
      Super + mouse wheel.
    . Demo renamed: mir_demo_server_shell -> mir_proving_server
    . Other demo servers merged into -> mir_demo_server
    . Wider support for display buffer pixel formats in the mesa driver, for
      wider hardware support.
    . Performance: On mesa/desktop at least; only hold compositor buffers
      for the duration of the render, instead of the duration of the frame.
      Following this change the compositor report can now finally report
      render time instead of frame time.
    . Mir now starts reliably when a TV is connected by HDMI, and up to
      4K resolution (2160p) is known to work.
    . Plenty more enhancements logged in the bugs list below.
  - ABI summary: Servers need rebuilding, but clients do not;
    . Mirclient ABI unchanged at 8
    . Mircommon ABI unchanged at 3
    . Mirplatform ABI bumped to 5 
    . Mirserver ABI bumped to 28
  - Bug fixes:
    . [regression] Mir servers (since 0.9) randomly crash in malloc due to
      heap corruption (LP: #1401488)
    . USC - mouse cursor on AMD graphics is drawing incorrectly
      (LP: #1391975)
    . Mir fails to start when a TV is connected by HDMI
      [std::exception::what: Invalid or inconsistent display configuration]
      (LP: #1395405)
    . Input/event driven clients may freeze indefinitely (LP: #1396006)
    . Mir server crashes with "std::exception::what: Failed to get front
      buffer object" when trying to fullscreen a surface (LP: #1398296)
    . Switching windows with a Trusted Prompt Session active loses the
      trusted prompt session (LP: #1355173)
    . CI test failure in multiple tests (LP: #1401364)
    . dh_install: usr/bin/mir_demo_server exists in debian/tmp but is not
      installed to anywhere (LP: #1401365)
    . [regression] demo-shell: Instead of moving surfaces they now fly
      off-screen (LP: #1403702)
    . [regression] Binaries are no longer runnable on other machines (or in
      other directories) (LP: #1406073)
    . [i865] unity-system-compositor fails to start: Failed to choose ARGB
      EGL config (LP: #1212753)
    . Mir's compositor holds buffers (blocking clients) for the duration of
      the frame, even when not necessary. (LP: #1264934)
    . Screen goes blank (black) briefly during display config changes which
      don't affect the display mode (LP: #1274359)
    . [enhancement] There should be a quit signal sent to sessions instead
      of killing them directly (LP: #1304257)
    . MirMotionEvent.action needs stronger typing (to MirMotionAction etc)
      (LP: #1311699)
    . CompositorReport as used by DefaultDisplayBufferCompositor can't
      measure render time (LP: #1350716)
    . Full screen (bypassed) surfaces (e.g. GLMark2Test) are missing frames
      and appear to freeze or judder with swap interval 0 (LP: #1379685)
    . Trusted prompts need to be part of the lifecycle (LP: #1384950)
    . [testfail] BasicThreadPool.recycles_threads in CI (LP: #1391488)
    . acceptance_tests are too chatty (LP: #1394221)
    . mir_connection_create_surface callback is sometimes called twice on
      error (LP: #1394873)
    . File descriptor leaks in tests using UsingStubClientPlatform
      (LP: #1395762)
    . DisplayLayout resizes a surface to 1x1 if you ask it to fullscreen a
      surface that's partially offscreen (LP: #1398294)
    . Surfaces can consume input events before they're visible.
      (LP: #1400218)
    . dpkg-shlibdeps: Lots of warnings about libmirplatformstub.so
      (LP: #1401373)
    . Leaks in death tests can cause subsequent tests in the same process to
      fail (LP: #1402160)
    . [regression] lintian: E: mir-demos: binary-or-shlib-defines-rpath ...
      (LP: #1406098)
    . [regression] Mir utils can't run from the build tree any more
      (LP: #1407557)
    . fd reception code is not exeception-safe when unexpected numbers of
      fds are received (LP: #1394362)
    . Mir reports vertical refresh rates slightly inaccurately (LP: #1407558)
    . [Enhancement] Add an API to lock surface orientation (LP: #1382209)
    . Bootloop with system language Turkish on the Nexus 4 (LP: #1398984)
    . Remove the implicit assumption that there every surface can be mapped
      to an input handle. (LP: #1216727)
    . When revealing hidden surfaces wait for them to become exposed before
      sending events which we expect them to receive (LP: #1407783)

[ Ubuntu daily release ]
* New rebuild forced

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 */
18
18
 
19
19
#include "mir/graphics/android/sync_fence.h"
20
 
#include "src/platform/graphics/android/hwc_fb_device.h"
21
 
#include "src/platform/graphics/android/hwc_device.h"
22
 
#include "src/platform/graphics/android/hwc_wrapper.h"
23
 
#include "src/platform/graphics/android/hwc_layerlist.h"
24
 
#include "src/platform/graphics/android/hwc_vsync_coordinator.h"
 
20
#include "src/platforms/android/hwc_fb_device.h"
 
21
#include "src/platforms/android/hwc_device.h"
 
22
#include "src/platforms/android/hwc_wrapper.h"
 
23
#include "src/platforms/android/hwc_layerlist.h"
 
24
#include "src/platforms/android/hwc_vsync_coordinator.h"
 
25
#include "src/platforms/android/hwc_configuration.h"
25
26
#include "mir_test_doubles/mock_hwc_composer_device_1.h"
26
27
#include "mir_test_doubles/mock_hwc_vsync_coordinator.h"
27
28
#include "mir_test_doubles/mock_hwc_device_wrapper.h"
40
41
namespace mtd=mir::test::doubles;
41
42
namespace geom=mir::geometry;
42
43
 
43
 
template<class T>
44
 
std::shared_ptr<mga::HWCCommonDevice> make_hwc_device(
45
 
    std::shared_ptr<mga::HwcWrapper> const& hwc_device,
46
 
    std::shared_ptr<framebuffer_device_t> const& fb_device,
47
 
    std::shared_ptr<mga::HWCVsyncCoordinator> const& coordinator);
48
 
 
49
 
template <>
50
 
std::shared_ptr<mga::HWCCommonDevice> make_hwc_device<mga::HwcFbDevice>(
51
 
    std::shared_ptr<mga::HwcWrapper> const& hwc_device,
52
 
    std::shared_ptr<framebuffer_device_t> const& fb_device,
53
 
    std::shared_ptr<mga::HWCVsyncCoordinator> const& coordinator)
54
 
{
55
 
    return std::make_shared<mga::HwcFbDevice>(hwc_device, fb_device, coordinator);
56
 
}
57
 
 
58
 
template <>
59
 
std::shared_ptr<mga::HWCCommonDevice> make_hwc_device<mga::HwcDevice>(
60
 
    std::shared_ptr<mga::HwcWrapper> const& hwc_device,
61
 
    std::shared_ptr<framebuffer_device_t> const&,
62
 
    std::shared_ptr<mga::HWCVsyncCoordinator> const& coordinator)
63
 
{
64
 
    auto file_ops = std::make_shared<mga::RealSyncFileOps>();
65
 
    return std::make_shared<mga::HwcDevice>(hwc_device, coordinator, file_ops);
 
44
namespace
 
45
{
 
46
struct MockDisplayConfiguration : mga::HwcConfiguration
 
47
{
 
48
    MOCK_METHOD2(power_mode, void(mga::DisplayName, MirPowerMode));
 
49
    MOCK_METHOD1(active_attribs_for, mga::DisplayAttribs(mga::DisplayName));
 
50
};
66
51
}
67
52
 
68
53
template<typename T>
71
56
protected:
72
57
    virtual void SetUp()
73
58
    {
74
 
        using namespace testing;
75
 
 
76
59
        mock_fbdev = std::make_shared<mtd::MockFBHalDevice>();
77
60
        mock_device = std::make_shared<testing::NiceMock<mtd::MockHWCDeviceWrapper>>();
78
61
        mock_vsync = std::make_shared<testing::NiceMock<mtd::MockVsyncCoordinator>>();
 
62
        mock_config = std::make_shared<testing::NiceMock<MockDisplayConfiguration>>();
79
63
    }
80
64
 
 
65
    std::shared_ptr<mga::DisplayDevice> make_display_device();
 
66
 
81
67
    testing::NiceMock<mtd::MockEGL> mock_egl;
82
68
    std::shared_ptr<mtd::MockVsyncCoordinator> mock_vsync;
83
69
    std::shared_ptr<mtd::MockHWCDeviceWrapper> mock_device;
84
70
    std::shared_ptr<mtd::MockFBHalDevice> mock_fbdev;
 
71
    std::shared_ptr<MockDisplayConfiguration> mock_config;
85
72
};
86
73
 
 
74
template <>
 
75
std::shared_ptr<mga::DisplayDevice> HWCCommon<mga::HwcFbDevice>::make_display_device()
 
76
{
 
77
    return std::make_shared<mga::HwcFbDevice>(mock_device, mock_fbdev, mock_config, mock_vsync);
 
78
}
 
79
 
 
80
template <>
 
81
std::shared_ptr<mga::DisplayDevice> HWCCommon<mga::HwcDevice>::make_display_device()
 
82
{
 
83
    return std::make_shared<mga::HwcDevice>(mock_device, mock_config, mock_vsync, std::make_shared<mga::IntegerSourceCrop>());
 
84
}
 
85
 
87
86
typedef ::testing::Types<mga::HwcFbDevice, mga::HwcDevice> HWCDeviceTestTypes;
88
87
TYPED_TEST_CASE(HWCCommon, HWCDeviceTestTypes);
89
88
 
95
94
        .Times(1)
96
95
        .WillOnce(SaveArg<0>(&callbacks));
97
96
 
98
 
    auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_fbdev, this->mock_vsync);
 
97
    auto device = this->make_display_device();
99
98
 
100
99
    ASSERT_THAT(callbacks, Ne(nullptr));
101
100
    EXPECT_THAT(callbacks->hooks.invalidate, Ne(nullptr));
111
110
        .Times(1)
112
111
        .WillOnce(SaveArg<0>(&callbacks));
113
112
 
114
 
    auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_fbdev, this->mock_vsync);
 
113
    auto device = this->make_display_device();
115
114
 
116
115
    ASSERT_THAT(callbacks, Ne(nullptr));
117
116
    EXPECT_THAT(callbacks->self, Eq(device.get()));
119
118
    EXPECT_THAT(callbacks->self, Eq(nullptr));    
120
119
}
121
120
 
122
 
TYPED_TEST(HWCCommon, registerst_hooks_and_turns_on_display)
 
121
TYPED_TEST(HWCCommon, registers_hooks_before_turning_on_display)
123
122
{
124
123
    using namespace testing;
125
124
 
126
125
    Sequence seq;
127
126
    EXPECT_CALL(*this->mock_device, register_hooks(_))
128
127
        .InSequence(seq);
129
 
    EXPECT_CALL(*this->mock_device, display_on())
130
 
        .InSequence(seq);
131
 
    EXPECT_CALL(*this->mock_device, vsync_signal_on())
132
 
        .InSequence(seq);
133
 
 
134
 
    auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_fbdev, this->mock_vsync);
135
 
    testing::Mock::VerifyAndClearExpectations(this->mock_device.get());
136
 
}
137
 
 
138
 
TYPED_TEST(HWCCommon, test_hwc_suspend_standby_throw)
139
 
{
140
 
    using namespace testing;
141
 
    auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_fbdev, this->mock_vsync);
142
 
 
143
 
    EXPECT_THROW({
144
 
        device->mode(mir_power_mode_suspend);
145
 
    }, std::runtime_error);
146
 
    EXPECT_THROW({
147
 
        device->mode(mir_power_mode_standby);
148
 
    }, std::runtime_error);
149
 
}
150
 
 
151
 
TYPED_TEST(HWCCommon, test_hwc_deactivates_vsync_on_blank)
152
 
{
153
 
    using namespace testing;
154
 
 
155
 
    InSequence seq;
156
 
    EXPECT_CALL(*this->mock_device, display_on())
157
 
        .Times(1);
158
 
    EXPECT_CALL(*this->mock_device, vsync_signal_on())
159
 
        .Times(1);
160
 
    EXPECT_CALL(*this->mock_device, vsync_signal_off())
161
 
        .Times(1);
162
 
    EXPECT_CALL(*this->mock_device, display_off())
163
 
        .Times(1);
164
 
 
165
 
    auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_fbdev, this->mock_vsync);
166
 
    device->mode(mir_power_mode_off);
 
128
    EXPECT_CALL(*this->mock_config, power_mode(mga::DisplayName::primary, mir_power_mode_on))
 
129
        .InSequence(seq);
 
130
 
 
131
    auto device = this->make_display_device();
 
132
    testing::Mock::VerifyAndClearExpectations(this->mock_config.get());
167
133
}
168
134
 
169
135
TYPED_TEST(HWCCommon, test_hwc_display_is_deactivated_on_destroy)
170
136
{
171
 
    auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_fbdev, this->mock_vsync);
172
 
 
173
 
    testing::InSequence seq;
174
 
    EXPECT_CALL(*this->mock_device, vsync_signal_off())
175
 
        .Times(1);
176
 
    EXPECT_CALL(*this->mock_device, display_off())
177
 
        .Times(1);
 
137
    auto device = this->make_display_device();
 
138
    EXPECT_CALL(*this->mock_config, power_mode(mga::DisplayName::primary, mir_power_mode_off));
178
139
    device.reset();
179
140
}
180
141
 
181
142
TYPED_TEST(HWCCommon, catches_exception_during_destruction)
182
143
{
183
 
    auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_fbdev, this->mock_vsync);
184
 
    EXPECT_CALL(*this->mock_device, display_off())
 
144
    auto device = this->make_display_device();
 
145
    EXPECT_CALL(*this->mock_config, power_mode(mga::DisplayName::primary, mir_power_mode_off))
185
146
        .WillOnce(testing::Throw(std::runtime_error("")));
186
147
    device.reset();
187
148
}
194
155
        .Times(1)
195
156
        .WillOnce(SaveArg<0>(&callbacks));
196
157
 
197
 
    auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_fbdev, this->mock_vsync);
 
158
    auto device = this->make_display_device();
198
159
 
199
160
    EXPECT_CALL(*this->mock_vsync, notify_vsync())
200
161
        .Times(1);
205
166
    callbacks->hooks.vsync(&callbacks->hooks, 0, 0);
206
167
}
207
168
 
208
 
TYPED_TEST(HWCCommon, set_orientation)
209
 
{
210
 
    auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_fbdev, this->mock_vsync);
211
 
    EXPECT_FALSE(device->apply_orientation(mir_orientation_left));
212
 
}
213
 
 
214
 
TYPED_TEST(HWCCommon, first_unblank_failure_is_not_fatal) //lp:1345533
215
 
{
216
 
    ON_CALL(*this->mock_device, display_on())
217
 
        .WillByDefault(testing::Throw(std::runtime_error("error")));
218
 
    EXPECT_NO_THROW({
219
 
        auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_fbdev, this->mock_vsync);
220
 
    });
221
 
}
222
 
 
223
 
TYPED_TEST(HWCCommon, first_vsync_failure_is_not_fatal) //lp:1345533
224
 
{
225
 
    ON_CALL(*this->mock_device, vsync_signal_on())
226
 
        .WillByDefault(testing::Throw(std::runtime_error("error")));
227
 
    EXPECT_NO_THROW({
228
 
        auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_fbdev, this->mock_vsync);
 
169
TYPED_TEST(HWCCommon, first_power_on_is_not_fatal) //lp:1345533
 
170
{
 
171
    ON_CALL(*this->mock_config, power_mode(testing::_, mir_power_mode_on))
 
172
        .WillByDefault(testing::Throw(std::runtime_error("error")));
 
173
    EXPECT_NO_THROW({
 
174
        auto device = this->make_display_device();
229
175
    });
230
176
}