OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_OZONE_PLATFORM_DRI_TEST_MOCK_DRI_WRAPPER_H_ | 5 #ifndef UI_OZONE_PLATFORM_DRI_TEST_MOCK_DRM_DEVICE_H_ |
6 #define UI_OZONE_PLATFORM_DRI_TEST_MOCK_DRI_WRAPPER_H_ | 6 #define UI_OZONE_PLATFORM_DRI_TEST_MOCK_DRM_DEVICE_H_ |
7 | 7 |
8 #include <queue> | 8 #include <queue> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "skia/ext/refptr.h" | 11 #include "skia/ext/refptr.h" |
12 #include "third_party/skia/include/core/SkSurface.h" | 12 #include "third_party/skia/include/core/SkSurface.h" |
13 #include "ui/ozone/platform/dri/dri_wrapper.h" | 13 #include "ui/ozone/platform/dri/drm_device.h" |
14 | 14 |
15 namespace ui { | 15 namespace ui { |
16 | 16 |
17 class CrtcController; | 17 class CrtcController; |
18 | 18 |
19 // The real DriWrapper makes actual DRM calls which we can't use in unit tests. | 19 // The real DrmDevice makes actual DRM calls which we can't use in unit tests. |
20 class MockDriWrapper : public ui::DriWrapper { | 20 class MockDrmDevice : public ui::DrmDevice { |
21 public: | 21 public: |
22 MockDriWrapper(); | 22 MockDrmDevice(); |
23 MockDriWrapper(bool use_sync_flips, | 23 MockDrmDevice(bool use_sync_flips, |
24 std::vector<uint32_t> crtcs, | 24 std::vector<uint32_t> crtcs, |
25 size_t planes_per_crtc); | 25 size_t planes_per_crtc); |
26 | 26 |
27 int get_get_crtc_call_count() const { return get_crtc_call_count_; } | 27 int get_get_crtc_call_count() const { return get_crtc_call_count_; } |
28 int get_set_crtc_call_count() const { return set_crtc_call_count_; } | 28 int get_set_crtc_call_count() const { return set_crtc_call_count_; } |
29 int get_restore_crtc_call_count() const { return restore_crtc_call_count_; } | 29 int get_restore_crtc_call_count() const { return restore_crtc_call_count_; } |
30 int get_add_framebuffer_call_count() const { | 30 int get_add_framebuffer_call_count() const { |
31 return add_framebuffer_call_count_; | 31 return add_framebuffer_call_count_; |
32 } | 32 } |
33 int get_remove_framebuffer_call_count() const { | 33 int get_remove_framebuffer_call_count() const { |
34 return remove_framebuffer_call_count_; | 34 return remove_framebuffer_call_count_; |
35 } | 35 } |
36 int get_page_flip_call_count() const { return page_flip_call_count_; } | 36 int get_page_flip_call_count() const { return page_flip_call_count_; } |
37 int get_overlay_flip_call_count() const { return overlay_flip_call_count_; } | 37 int get_overlay_flip_call_count() const { return overlay_flip_call_count_; } |
38 int get_overlay_clear_call_count() const { return overlay_clear_call_count_; } | 38 int get_overlay_clear_call_count() const { return overlay_clear_call_count_; } |
39 void set_set_crtc_expectation(bool state) { set_crtc_expectation_ = state; } | 39 void set_set_crtc_expectation(bool state) { set_crtc_expectation_ = state; } |
40 void set_page_flip_expectation(bool state) { page_flip_expectation_ = state; } | 40 void set_page_flip_expectation(bool state) { page_flip_expectation_ = state; } |
41 void set_add_framebuffer_expectation(bool state) { | 41 void set_add_framebuffer_expectation(bool state) { |
42 add_framebuffer_expectation_ = state; | 42 add_framebuffer_expectation_ = state; |
43 } | 43 } |
44 void set_create_dumb_buffer_expectation(bool state) { | 44 void set_create_dumb_buffer_expectation(bool state) { |
45 create_dumb_buffer_expectation_ = state; | 45 create_dumb_buffer_expectation_ = state; |
46 } | 46 } |
47 | 47 |
48 uint32_t current_framebuffer() const { return current_framebuffer_; } | 48 uint32_t current_framebuffer() const { return current_framebuffer_; } |
49 | 49 |
50 const std::vector<skia::RefPtr<SkSurface> > buffers() const { | 50 const std::vector<skia::RefPtr<SkSurface>> buffers() const { |
51 return buffers_; | 51 return buffers_; |
52 } | 52 } |
53 | 53 |
54 void RunCallbacks(); | 54 void RunCallbacks(); |
55 | 55 |
56 // DriWrapper: | 56 // DrmDevice: |
57 ScopedDrmCrtcPtr GetCrtc(uint32_t crtc_id) override; | 57 ScopedDrmCrtcPtr GetCrtc(uint32_t crtc_id) override; |
58 bool SetCrtc(uint32_t crtc_id, | 58 bool SetCrtc(uint32_t crtc_id, |
59 uint32_t framebuffer, | 59 uint32_t framebuffer, |
60 std::vector<uint32_t> connectors, | 60 std::vector<uint32_t> connectors, |
61 drmModeModeInfo* mode) override; | 61 drmModeModeInfo* mode) override; |
62 bool SetCrtc(drmModeCrtc* crtc, std::vector<uint32_t> connectors) override; | 62 bool SetCrtc(drmModeCrtc* crtc, std::vector<uint32_t> connectors) override; |
63 bool DisableCrtc(uint32_t crtc_id) override; | 63 bool DisableCrtc(uint32_t crtc_id) override; |
64 ScopedDrmConnectorPtr GetConnector(uint32_t connector_id) override; | 64 ScopedDrmConnectorPtr GetConnector(uint32_t connector_id) override; |
65 bool AddFramebuffer(uint32_t width, | 65 bool AddFramebuffer(uint32_t width, |
66 uint32_t height, | 66 uint32_t height, |
(...skipping 28 matching lines...) Expand all Loading... |
95 bool CreateDumbBuffer(const SkImageInfo& info, | 95 bool CreateDumbBuffer(const SkImageInfo& info, |
96 uint32_t* handle, | 96 uint32_t* handle, |
97 uint32_t* stride, | 97 uint32_t* stride, |
98 void** pixels) override; | 98 void** pixels) override; |
99 void DestroyDumbBuffer(const SkImageInfo& info, | 99 void DestroyDumbBuffer(const SkImageInfo& info, |
100 uint32_t handle, | 100 uint32_t handle, |
101 uint32_t stride, | 101 uint32_t stride, |
102 void* pixels) override; | 102 void* pixels) override; |
103 | 103 |
104 private: | 104 private: |
105 ~MockDriWrapper() override; | 105 ~MockDrmDevice() override; |
106 | 106 |
107 int get_crtc_call_count_; | 107 int get_crtc_call_count_; |
108 int set_crtc_call_count_; | 108 int set_crtc_call_count_; |
109 int restore_crtc_call_count_; | 109 int restore_crtc_call_count_; |
110 int add_framebuffer_call_count_; | 110 int add_framebuffer_call_count_; |
111 int remove_framebuffer_call_count_; | 111 int remove_framebuffer_call_count_; |
112 int page_flip_call_count_; | 112 int page_flip_call_count_; |
113 int overlay_flip_call_count_; | 113 int overlay_flip_call_count_; |
114 int overlay_clear_call_count_; | 114 int overlay_clear_call_count_; |
115 | 115 |
116 bool set_crtc_expectation_; | 116 bool set_crtc_expectation_; |
117 bool add_framebuffer_expectation_; | 117 bool add_framebuffer_expectation_; |
118 bool page_flip_expectation_; | 118 bool page_flip_expectation_; |
119 bool create_dumb_buffer_expectation_; | 119 bool create_dumb_buffer_expectation_; |
120 | 120 |
121 bool use_sync_flips_; | 121 bool use_sync_flips_; |
122 | 122 |
123 uint32_t current_framebuffer_; | 123 uint32_t current_framebuffer_; |
124 | 124 |
125 std::vector<skia::RefPtr<SkSurface> > buffers_; | 125 std::vector<skia::RefPtr<SkSurface>> buffers_; |
126 | 126 |
127 std::queue<PageFlipCallback> callbacks_; | 127 std::queue<PageFlipCallback> callbacks_; |
128 | 128 |
129 DISALLOW_COPY_AND_ASSIGN(MockDriWrapper); | 129 DISALLOW_COPY_AND_ASSIGN(MockDrmDevice); |
130 }; | 130 }; |
131 | 131 |
132 } // namespace ui | 132 } // namespace ui |
133 | 133 |
134 #endif // UI_OZONE_PLATFORM_DRI_TEST_MOCK_DRI_WRAPPER_H_ | 134 #endif // UI_OZONE_PLATFORM_DRI_TEST_MOCK_DRM_DEVICE_H_ |
OLD | NEW |