| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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 #include "content/browser/media/capture/cursor_renderer_aura.h" | 5 #include "content/browser/media/capture/cursor_renderer_aura.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 } | 61 } |
| 62 | 62 |
| 63 void SetTickClock(base::SimpleTestTickClock* clock) { | 63 void SetTickClock(base::SimpleTestTickClock* clock) { |
| 64 cursor_renderer_->tick_clock_ = clock; | 64 cursor_renderer_->tick_clock_ = clock; |
| 65 } | 65 } |
| 66 | 66 |
| 67 base::TimeTicks Now() { return cursor_renderer_->tick_clock_->NowTicks(); } | 67 base::TimeTicks Now() { return cursor_renderer_->tick_clock_->NowTicks(); } |
| 68 | 68 |
| 69 bool CursorDisplayed() { return cursor_renderer_->cursor_displayed_; } | 69 bool CursorDisplayed() { return cursor_renderer_->cursor_displayed_; } |
| 70 | 70 |
| 71 void RenderCursorOnVideoFrame( | 71 void RenderCursorOnVideoFrame(media::VideoFrame* target) { |
| 72 const scoped_refptr<media::VideoFrame>& target) { | |
| 73 cursor_renderer_->RenderOnVideoFrame(target); | 72 cursor_renderer_->RenderOnVideoFrame(target); |
| 74 } | 73 } |
| 75 | 74 |
| 76 void SnapshotCursorState(gfx::Rect region_in_frame) { | 75 void SnapshotCursorState(gfx::Rect region_in_frame) { |
| 77 cursor_renderer_->SnapshotCursorState(region_in_frame); | 76 cursor_renderer_->SnapshotCursorState(region_in_frame); |
| 78 } | 77 } |
| 79 | 78 |
| 80 void MoveMouseCursorWithinWindow() { | 79 void MoveMouseCursorWithinWindow() { |
| 81 gfx::Point point1(20, 20); | 80 gfx::Point point1(20, 20); |
| 82 ui::MouseEvent event1(ui::ET_MOUSE_MOVED, point1, point1, Now(), 0, 0); | 81 ui::MouseEvent event1(ui::ET_MOUSE_MOVED, point1, point1, Now(), 0, 0); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 scoped_refptr<media::VideoFrame> frame = | 214 scoped_refptr<media::VideoFrame> frame = |
| 216 media::VideoFrame::CreateZeroInitializedFrame(media::PIXEL_FORMAT_YV12, | 215 media::VideoFrame::CreateZeroInitializedFrame(media::PIXEL_FORMAT_YV12, |
| 217 size, gfx::Rect(size), size, | 216 size, gfx::Rect(size), size, |
| 218 base::TimeDelta()); | 217 base::TimeDelta()); |
| 219 | 218 |
| 220 MoveMouseCursorWithinWindow(gfx::Point(60, 60)); | 219 MoveMouseCursorWithinWindow(gfx::Point(60, 60)); |
| 221 SnapshotCursorState(gfx::Rect(size)); | 220 SnapshotCursorState(gfx::Rect(size)); |
| 222 EXPECT_TRUE(CursorDisplayed()); | 221 EXPECT_TRUE(CursorDisplayed()); |
| 223 | 222 |
| 224 EXPECT_FALSE(NonZeroPixelsInRegion(frame, gfx::Rect(50, 50, 70, 70))); | 223 EXPECT_FALSE(NonZeroPixelsInRegion(frame, gfx::Rect(50, 50, 70, 70))); |
| 225 RenderCursorOnVideoFrame(frame); | 224 RenderCursorOnVideoFrame(frame.get()); |
| 226 EXPECT_TRUE(NonZeroPixelsInRegion(frame, gfx::Rect(50, 50, 70, 70))); | 225 EXPECT_TRUE(NonZeroPixelsInRegion(frame, gfx::Rect(50, 50, 70, 70))); |
| 227 } | 226 } |
| 228 | 227 |
| 229 TEST_F(CursorRendererAuraTest, CursorRenderedOnRootWindow) { | 228 TEST_F(CursorRendererAuraTest, CursorRenderedOnRootWindow) { |
| 230 cursor_renderer_.reset(new CursorRendererAura(root_window(), | 229 cursor_renderer_.reset(new CursorRendererAura(root_window(), |
| 231 kCursorEnabledOnMouseMovement)); | 230 kCursorEnabledOnMouseMovement)); |
| 232 EXPECT_FALSE(CursorDisplayed()); | 231 EXPECT_FALSE(CursorDisplayed()); |
| 233 | 232 |
| 234 // Cursor displayed after mouse movement. | 233 // Cursor displayed after mouse movement. |
| 235 MoveMouseCursorWithinWindow(); | 234 MoveMouseCursorWithinWindow(); |
| 236 EXPECT_TRUE(CursorDisplayed()); | 235 EXPECT_TRUE(CursorDisplayed()); |
| 237 | 236 |
| 238 // Cursor being displayed even if another window is activated. | 237 // Cursor being displayed even if another window is activated. |
| 239 std::unique_ptr<aura::Window> window2(aura::test::CreateTestWindowWithBounds( | 238 std::unique_ptr<aura::Window> window2(aura::test::CreateTestWindowWithBounds( |
| 240 gfx::Rect(0, 0, 800, 600), root_window())); | 239 gfx::Rect(0, 0, 800, 600), root_window())); |
| 241 wm::ActivateWindow(window2.get()); | 240 wm::ActivateWindow(window2.get()); |
| 242 SnapshotCursorState(gfx::Rect(0, 0, 800, 600)); | 241 SnapshotCursorState(gfx::Rect(0, 0, 800, 600)); |
| 243 EXPECT_TRUE(CursorDisplayed()); | 242 EXPECT_TRUE(CursorDisplayed()); |
| 244 } | 243 } |
| 245 | 244 |
| 246 } // namespace content | 245 } // namespace content |
| OLD | NEW |