Fix search results being clipped in app list.
[chromium-blink-merge.git] / ui / ozone / platform / drm / test / mock_drm_device.h
blob7745a05df8d5d688a02ea8a724fbf9913ad25a69
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
3 // found in the LICENSE file.
5 #ifndef UI_OZONE_PLATFORM_DRM_TEST_MOCK_DRM_DEVICE_H_
6 #define UI_OZONE_PLATFORM_DRM_TEST_MOCK_DRM_DEVICE_H_
8 #include <map>
9 #include <queue>
10 #include <vector>
12 #include "skia/ext/refptr.h"
13 #include "third_party/skia/include/core/SkSurface.h"
14 #include "ui/ozone/platform/drm/gpu/drm_device.h"
16 namespace ui {
18 class CrtcController;
20 // The real DrmDevice makes actual DRM calls which we can't use in unit tests.
21 class MockDrmDevice : public ui::DrmDevice {
22 public:
23 MockDrmDevice();
24 MockDrmDevice(bool use_sync_flips,
25 std::vector<uint32_t> crtcs,
26 size_t planes_per_crtc);
28 int get_get_crtc_call_count() const { return get_crtc_call_count_; }
29 int get_set_crtc_call_count() const { return set_crtc_call_count_; }
30 int get_restore_crtc_call_count() const { return restore_crtc_call_count_; }
31 int get_add_framebuffer_call_count() const {
32 return add_framebuffer_call_count_;
34 int get_remove_framebuffer_call_count() const {
35 return remove_framebuffer_call_count_;
37 int get_page_flip_call_count() const { return page_flip_call_count_; }
38 int get_overlay_flip_call_count() const { return overlay_flip_call_count_; }
39 int get_overlay_clear_call_count() const { return overlay_clear_call_count_; }
40 void set_set_crtc_expectation(bool state) { set_crtc_expectation_ = state; }
41 void set_page_flip_expectation(bool state) { page_flip_expectation_ = state; }
42 void set_add_framebuffer_expectation(bool state) {
43 add_framebuffer_expectation_ = state;
45 void set_create_dumb_buffer_expectation(bool state) {
46 create_dumb_buffer_expectation_ = state;
49 uint32_t current_framebuffer() const { return current_framebuffer_; }
51 const std::vector<skia::RefPtr<SkSurface>> buffers() const {
52 return buffers_;
55 uint32_t get_cursor_handle_for_crtc(uint32_t crtc) const {
56 const auto it = crtc_cursor_map_.find(crtc);
57 return it != crtc_cursor_map_.end() ? it->second : 0;
60 void RunCallbacks();
62 // DrmDevice:
63 ScopedDrmCrtcPtr GetCrtc(uint32_t crtc_id) override;
64 bool SetCrtc(uint32_t crtc_id,
65 uint32_t framebuffer,
66 std::vector<uint32_t> connectors,
67 drmModeModeInfo* mode) override;
68 bool SetCrtc(drmModeCrtc* crtc, std::vector<uint32_t> connectors) override;
69 bool DisableCrtc(uint32_t crtc_id) override;
70 ScopedDrmConnectorPtr GetConnector(uint32_t connector_id) override;
71 bool AddFramebuffer(uint32_t width,
72 uint32_t height,
73 uint8_t depth,
74 uint8_t bpp,
75 uint32_t stride,
76 uint32_t handle,
77 uint32_t* framebuffer) override;
78 bool RemoveFramebuffer(uint32_t framebuffer) override;
79 ScopedDrmFramebufferPtr GetFramebuffer(uint32_t framebuffer) override;
80 bool PageFlip(uint32_t crtc_id,
81 uint32_t framebuffer,
82 bool is_sync,
83 const PageFlipCallback& callback) override;
84 bool PageFlipOverlay(uint32_t crtc_id,
85 uint32_t framebuffer,
86 const gfx::Rect& location,
87 const gfx::Rect& source,
88 int overlay_plane) override;
89 ScopedDrmPropertyPtr GetProperty(drmModeConnector* connector,
90 const char* name) override;
91 bool SetProperty(uint32_t connector_id,
92 uint32_t property_id,
93 uint64_t value) override;
94 bool GetCapability(uint64_t capability, uint64_t* value) override;
95 ScopedDrmPropertyBlobPtr GetPropertyBlob(drmModeConnector* connector,
96 const char* name) override;
97 bool SetCursor(uint32_t crtc_id,
98 uint32_t handle,
99 const gfx::Size& size) override;
100 bool MoveCursor(uint32_t crtc_id, const gfx::Point& point) override;
101 bool CreateDumbBuffer(const SkImageInfo& info,
102 uint32_t* handle,
103 uint32_t* stride,
104 void** pixels) override;
105 void DestroyDumbBuffer(const SkImageInfo& info,
106 uint32_t handle,
107 uint32_t stride,
108 void* pixels) override;
109 bool CommitProperties(drmModePropertySet* properties,
110 uint32_t flags,
111 const PageFlipCallback& callback) override;
113 private:
114 ~MockDrmDevice() override;
116 int get_crtc_call_count_;
117 int set_crtc_call_count_;
118 int restore_crtc_call_count_;
119 int add_framebuffer_call_count_;
120 int remove_framebuffer_call_count_;
121 int page_flip_call_count_;
122 int overlay_flip_call_count_;
123 int overlay_clear_call_count_;
124 int allocate_buffer_count_;
126 bool set_crtc_expectation_;
127 bool add_framebuffer_expectation_;
128 bool page_flip_expectation_;
129 bool create_dumb_buffer_expectation_;
131 bool use_sync_flips_;
133 uint32_t current_framebuffer_;
135 std::vector<skia::RefPtr<SkSurface>> buffers_;
137 std::map<uint32_t, uint32_t> crtc_cursor_map_;
139 std::queue<PageFlipCallback> callbacks_;
141 DISALLOW_COPY_AND_ASSIGN(MockDrmDevice);
144 } // namespace ui
146 #endif // UI_OZONE_PLATFORM_DRM_TEST_MOCK_DRM_DEVICE_H_