Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Side by Side Diff: ui/ozone/platform/dri/test/mock_dri_wrapper.h

Issue 851853002: It is time. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Trying to reup because the last upload failed. Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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.
4
5 #ifndef UI_OZONE_PLATFORM_DRI_TEST_MOCK_DRI_WRAPPER_H_
6 #define UI_OZONE_PLATFORM_DRI_TEST_MOCK_DRI_WRAPPER_H_
7
8 #include <queue>
9 #include <vector>
10
11 #include "skia/ext/refptr.h"
12 #include "third_party/skia/include/core/SkSurface.h"
13 #include "ui/ozone/platform/dri/dri_wrapper.h"
14
15 namespace ui {
16
17 class CrtcController;
18
19 // The real DriWrapper makes actual DRM calls which we can't use in unit tests.
20 class MockDriWrapper : public ui::DriWrapper {
21 public:
22 MockDriWrapper(int fd);
23 virtual ~MockDriWrapper();
24
25 int get_get_crtc_call_count() const { return get_crtc_call_count_; }
26 int get_set_crtc_call_count() const { return set_crtc_call_count_; }
27 int get_restore_crtc_call_count() const { return restore_crtc_call_count_; }
28 int get_add_framebuffer_call_count() const {
29 return add_framebuffer_call_count_;
30 }
31 int get_remove_framebuffer_call_count() const {
32 return remove_framebuffer_call_count_;
33 }
34 int get_page_flip_call_count() const { return page_flip_call_count_; }
35 int get_overlay_flip_call_count() const { return overlay_flip_call_count_; }
36 int get_handle_events_count() const { return handle_events_count_; }
37 void fail_init() { fd_ = -1; }
38 void set_set_crtc_expectation(bool state) { set_crtc_expectation_ = state; }
39 void set_page_flip_expectation(bool state) { page_flip_expectation_ = state; }
40 void set_add_framebuffer_expectation(bool state) {
41 add_framebuffer_expectation_ = state;
42 }
43 void set_create_dumb_buffer_expectation(bool state) {
44 create_dumb_buffer_expectation_ = state;
45 }
46
47 uint32_t current_framebuffer() const { return current_framebuffer_; }
48
49 const std::vector<skia::RefPtr<SkSurface> > buffers() const {
50 return buffers_;
51 }
52
53 // Overwrite the list of controllers used when serving the PageFlip requests.
54 void set_controllers(const std::queue<CrtcController*>& controllers) {
55 controllers_ = controllers;
56 }
57
58 // DriWrapper:
59 virtual ScopedDrmCrtcPtr GetCrtc(uint32_t crtc_id) override;
60 virtual bool SetCrtc(uint32_t crtc_id,
61 uint32_t framebuffer,
62 std::vector<uint32_t> connectors,
63 drmModeModeInfo* mode) override;
64 virtual bool SetCrtc(drmModeCrtc* crtc,
65 std::vector<uint32_t> connectors) override;
66 virtual ScopedDrmConnectorPtr GetConnector(uint32_t connector_id) override;
67 virtual bool AddFramebuffer(uint32_t width,
68 uint32_t height,
69 uint8_t depth,
70 uint8_t bpp,
71 uint32_t stride,
72 uint32_t handle,
73 uint32_t* framebuffer) override;
74 virtual bool RemoveFramebuffer(uint32_t framebuffer) override;
75 virtual bool PageFlip(uint32_t crtc_id,
76 uint32_t framebuffer,
77 void* data) override;
78 virtual bool PageFlipOverlay(uint32_t crtc_id,
79 uint32_t framebuffer,
80 const gfx::Rect& location,
81 const gfx::RectF& source,
82 int overlay_plane) override;
83 virtual ScopedDrmPropertyPtr GetProperty(drmModeConnector* connector,
84 const char* name) override;
85 virtual bool SetProperty(uint32_t connector_id,
86 uint32_t property_id,
87 uint64_t value) override;
88 virtual ScopedDrmPropertyBlobPtr GetPropertyBlob(drmModeConnector* connector,
89 const char* name) override;
90 virtual bool SetCursor(uint32_t crtc_id,
91 uint32_t handle,
92 const gfx::Size& size) override;
93 virtual bool MoveCursor(uint32_t crtc_id, const gfx::Point& point) override;
94 virtual void HandleEvent(drmEventContext& event) override;
95 virtual bool CreateDumbBuffer(const SkImageInfo& info,
96 uint32_t* handle,
97 uint32_t* stride,
98 void** pixels) override;
99 virtual void DestroyDumbBuffer(const SkImageInfo& info,
100 uint32_t handle,
101 uint32_t stride,
102 void* pixels) override;
103
104 private:
105 int get_crtc_call_count_;
106 int set_crtc_call_count_;
107 int restore_crtc_call_count_;
108 int add_framebuffer_call_count_;
109 int remove_framebuffer_call_count_;
110 int page_flip_call_count_;
111 int overlay_flip_call_count_;
112 int handle_events_count_;
113
114 bool set_crtc_expectation_;
115 bool add_framebuffer_expectation_;
116 bool page_flip_expectation_;
117 bool create_dumb_buffer_expectation_;
118
119 uint32_t current_framebuffer_;
120
121 std::vector<skia::RefPtr<SkSurface> > buffers_;
122
123 std::queue<CrtcController*> controllers_;
124
125 DISALLOW_COPY_AND_ASSIGN(MockDriWrapper);
126 };
127
128 } // namespace ui
129
130 #endif // UI_OZONE_PLATFORM_DRI_TEST_MOCK_DRI_WRAPPER_H_
OLDNEW
« no previous file with comments | « ui/ozone/platform/dri/screen_manager_unittest.cc ('k') | ui/ozone/platform/dri/test/mock_dri_wrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698