| 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_DRI_WRAPPER_H_ |
| 6 #define UI_OZONE_PLATFORM_DRI_TEST_MOCK_DRI_WRAPPER_H_ | 6 #define UI_OZONE_PLATFORM_DRI_TEST_MOCK_DRI_WRAPPER_H_ |
| 7 | 7 |
| 8 #include "ui/ozone/platform/dri/dri_wrapper.h" | 8 #include "ui/ozone/platform/dri/dri_wrapper.h" |
| 9 | 9 |
| 10 namespace ui { | 10 namespace ui { |
| 11 | 11 |
| 12 // The real DriWrapper makes actual DRM calls which we can't use in unit tests. | 12 // The real DriWrapper makes actual DRM calls which we can't use in unit tests. |
| 13 class MockDriWrapper : public ui::DriWrapper { | 13 class MockDriWrapper : public ui::DriWrapper { |
| 14 public: | 14 public: |
| 15 MockDriWrapper(int fd); | 15 MockDriWrapper(int fd); |
| 16 virtual ~MockDriWrapper(); | 16 virtual ~MockDriWrapper(); |
| 17 | 17 |
| 18 int get_get_crtc_call_count() const { return get_crtc_call_count_; } | 18 int get_get_crtc_call_count() const { return get_crtc_call_count_; } |
| 19 int get_restore_crtc_call_count() const { return restore_crtc_call_count_; } | 19 int get_restore_crtc_call_count() const { return restore_crtc_call_count_; } |
| 20 int get_add_framebuffer_call_count() const { | 20 int get_add_framebuffer_call_count() const { |
| 21 return add_framebuffer_call_count_; | 21 return add_framebuffer_call_count_; |
| 22 } | 22 } |
| 23 int get_remove_framebuffer_call_count() const { | 23 int get_remove_framebuffer_call_count() const { |
| 24 return remove_framebuffer_call_count_; | 24 return remove_framebuffer_call_count_; |
| 25 } | 25 } |
| 26 int get_page_flip_call_count() const { return page_flip_call_count_; } | 26 int get_page_flip_call_count() const { return page_flip_call_count_; } |
| 27 int get_overlay_flip_call_count() const { return overlay_flip_call_count_; } |
| 27 void fail_init() { fd_ = -1; } | 28 void fail_init() { fd_ = -1; } |
| 28 void set_set_crtc_expectation(bool state) { set_crtc_expectation_ = state; } | 29 void set_set_crtc_expectation(bool state) { set_crtc_expectation_ = state; } |
| 29 void set_page_flip_expectation(bool state) { page_flip_expectation_ = state; } | 30 void set_page_flip_expectation(bool state) { page_flip_expectation_ = state; } |
| 30 void set_add_framebuffer_expectation(bool state) { | 31 void set_add_framebuffer_expectation(bool state) { |
| 31 add_framebuffer_expectation_ = state; | 32 add_framebuffer_expectation_ = state; |
| 32 } | 33 } |
| 33 | 34 |
| 34 // DriWrapper: | 35 // DriWrapper: |
| 35 virtual ScopedDrmCrtcPtr GetCrtc(uint32_t crtc_id) OVERRIDE; | 36 virtual ScopedDrmCrtcPtr GetCrtc(uint32_t crtc_id) OVERRIDE; |
| 36 virtual bool SetCrtc(uint32_t crtc_id, | 37 virtual bool SetCrtc(uint32_t crtc_id, |
| 37 uint32_t framebuffer, | 38 uint32_t framebuffer, |
| 38 uint32_t* connectors, | 39 uint32_t* connectors, |
| 39 drmModeModeInfo* mode) OVERRIDE; | 40 drmModeModeInfo* mode) OVERRIDE; |
| 40 virtual bool SetCrtc(drmModeCrtc* crtc, uint32_t* connectors) OVERRIDE; | 41 virtual bool SetCrtc(drmModeCrtc* crtc, uint32_t* connectors) OVERRIDE; |
| 41 virtual bool AddFramebuffer(uint32_t width, | 42 virtual bool AddFramebuffer(uint32_t width, |
| 42 uint32_t height, | 43 uint32_t height, |
| 43 uint8_t depth, | 44 uint8_t depth, |
| 44 uint8_t bpp, | 45 uint8_t bpp, |
| 45 uint32_t stride, | 46 uint32_t stride, |
| 46 uint32_t handle, | 47 uint32_t handle, |
| 47 uint32_t* framebuffer) OVERRIDE; | 48 uint32_t* framebuffer) OVERRIDE; |
| 48 virtual bool RemoveFramebuffer(uint32_t framebuffer) OVERRIDE; | 49 virtual bool RemoveFramebuffer(uint32_t framebuffer) OVERRIDE; |
| 49 virtual bool PageFlip(uint32_t crtc_id, | 50 virtual bool PageFlip(uint32_t crtc_id, |
| 50 uint32_t framebuffer, | 51 uint32_t framebuffer, |
| 51 void* data) OVERRIDE; | 52 void* data) OVERRIDE; |
| 53 virtual bool PageFlipOverlay(uint32_t crtc_id, |
| 54 uint32_t framebuffer, |
| 55 const gfx::Rect& location, |
| 56 const gfx::RectF& source, |
| 57 int overlay_plane) OVERRIDE; |
| 52 virtual ScopedDrmPropertyPtr GetProperty(drmModeConnector* connector, | 58 virtual ScopedDrmPropertyPtr GetProperty(drmModeConnector* connector, |
| 53 const char* name) OVERRIDE; | 59 const char* name) OVERRIDE; |
| 54 virtual bool SetProperty(uint32_t connector_id, | 60 virtual bool SetProperty(uint32_t connector_id, |
| 55 uint32_t property_id, | 61 uint32_t property_id, |
| 56 uint64_t value) OVERRIDE; | 62 uint64_t value) OVERRIDE; |
| 57 virtual ScopedDrmPropertyBlobPtr GetPropertyBlob(drmModeConnector* connector, | 63 virtual ScopedDrmPropertyBlobPtr GetPropertyBlob(drmModeConnector* connector, |
| 58 const char* name) OVERRIDE; | 64 const char* name) OVERRIDE; |
| 59 virtual bool SetCursor(uint32_t crtc_id, | 65 virtual bool SetCursor(uint32_t crtc_id, |
| 60 uint32_t handle, | 66 uint32_t handle, |
| 61 uint32_t width, | 67 uint32_t width, |
| 62 uint32_t height) OVERRIDE; | 68 uint32_t height) OVERRIDE; |
| 63 virtual bool MoveCursor(uint32_t crtc_id, int x, int y) OVERRIDE; | 69 virtual bool MoveCursor(uint32_t crtc_id, int x, int y) OVERRIDE; |
| 64 virtual void HandleEvent(drmEventContext& event) OVERRIDE; | 70 virtual void HandleEvent(drmEventContext& event) OVERRIDE; |
| 65 | 71 |
| 66 private: | 72 private: |
| 67 int get_crtc_call_count_; | 73 int get_crtc_call_count_; |
| 68 int restore_crtc_call_count_; | 74 int restore_crtc_call_count_; |
| 69 int add_framebuffer_call_count_; | 75 int add_framebuffer_call_count_; |
| 70 int remove_framebuffer_call_count_; | 76 int remove_framebuffer_call_count_; |
| 71 int page_flip_call_count_; | 77 int page_flip_call_count_; |
| 78 int overlay_flip_call_count_; |
| 72 | 79 |
| 73 bool set_crtc_expectation_; | 80 bool set_crtc_expectation_; |
| 74 bool add_framebuffer_expectation_; | 81 bool add_framebuffer_expectation_; |
| 75 bool page_flip_expectation_; | 82 bool page_flip_expectation_; |
| 76 | 83 |
| 77 DISALLOW_COPY_AND_ASSIGN(MockDriWrapper); | 84 DISALLOW_COPY_AND_ASSIGN(MockDriWrapper); |
| 78 }; | 85 }; |
| 79 | 86 |
| 80 } // namespace ui | 87 } // namespace ui |
| 81 | 88 |
| 82 #endif // UI_OZONE_PLATFORM_DRI_TEST_MOCK_DRI_WRAPPER_H_ | 89 #endif // UI_OZONE_PLATFORM_DRI_TEST_MOCK_DRI_WRAPPER_H_ |
| OLD | NEW |