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

Side by Side Diff: remoting/host/video_frame_capturer_unittest.cc

Issue 11363128: Converted VideoFrameCapturer callbacks into a VideoFrameCapturer::Delegate interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More Mac compilation issues. Created 8 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "remoting/host/video_frame_capturer.h" 5 #include "remoting/host/video_frame_capturer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #if defined(OS_MACOSX) 8 #if defined(OS_MACOSX)
9 #include "base/mac/mac_util.h" 9 #include "base/mac/mac_util.h"
10 #endif // defined(OS_MACOSX) 10 #endif // defined(OS_MACOSX)
11 #include "remoting/base/capture_data.h" 11 #include "remoting/base/capture_data.h"
12 #include "remoting/host/host_mock_objects.h" 12 #include "remoting/host/host_mock_objects.h"
13 #include "remoting/protocol/protocol_mock_objects.h" 13 #include "remoting/protocol/protocol_mock_objects.h"
14 #include "testing/gmock/include/gmock/gmock.h" 14 #include "testing/gmock/include/gmock/gmock.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 16
17 using ::testing::_;
18 using ::testing::AnyNumber;
19
17 namespace remoting { 20 namespace remoting {
18 21
19 namespace {
20
21 void IgnoreCursorShapeChanged(scoped_ptr<protocol::CursorShapeInfo> info) {
22 }
23
24 } // namespace
25
26 MATCHER(DirtyRegionIsNonEmptyRect, "") { 22 MATCHER(DirtyRegionIsNonEmptyRect, "") {
27 const SkRegion& dirty_region = arg->dirty_region(); 23 const SkRegion& dirty_region = arg->dirty_region();
28 const SkIRect& dirty_region_bounds = dirty_region.getBounds(); 24 const SkIRect& dirty_region_bounds = dirty_region.getBounds();
29 if (dirty_region_bounds.isEmpty()) { 25 if (dirty_region_bounds.isEmpty()) {
30 return false; 26 return false;
31 } 27 }
32 return dirty_region == SkRegion(dirty_region_bounds); 28 return dirty_region == SkRegion(dirty_region_bounds);
33 } 29 }
34 30
35 class VideoFrameCapturerTest : public testing::Test { 31 class VideoFrameCapturerTest : public testing::Test {
36 protected: 32 protected:
37 virtual void SetUp() OVERRIDE { 33 virtual void SetUp() OVERRIDE {
38 capturer_.reset(VideoFrameCapturer::Create()); 34 capturer_.reset(VideoFrameCapturer::Create());
39 } 35 }
40 36
41 scoped_ptr<VideoFrameCapturer> capturer_; 37 scoped_ptr<VideoFrameCapturer> capturer_;
42 MockCaptureCompletedCallback capture_completed_callback_; 38 MockVideoFrameCapturerDelegate delegate_;
43 }; 39 };
44 40
45 TEST_F(VideoFrameCapturerTest, StartCapturer) { 41 TEST_F(VideoFrameCapturerTest, StartCapturer) {
46 capturer_->Start(base::Bind(&IgnoreCursorShapeChanged)); 42 capturer_->Start(&delegate_);
47 capturer_->Stop(); 43 capturer_->Stop();
48 } 44 }
49 45
50 TEST_F(VideoFrameCapturerTest, Capture) { 46 TEST_F(VideoFrameCapturerTest, Capture) {
51 // Assume that Start() treats the screen as invalid initially. 47 // Assume that Start() treats the screen as invalid initially.
52 EXPECT_CALL(capture_completed_callback_, 48 EXPECT_CALL(delegate_,
53 CaptureCompletedPtr(DirtyRegionIsNonEmptyRect())); 49 OnCaptureCompleted(DirtyRegionIsNonEmptyRect()));
50 EXPECT_CALL(delegate_, OnCursorShapeChangedPtr(_))
51 .Times(AnyNumber());
54 52
55 capturer_->Start(base::Bind(&IgnoreCursorShapeChanged)); 53 capturer_->Start(&delegate_);
56 capturer_->CaptureInvalidRegion(base::Bind( 54 capturer_->CaptureInvalidRegion();
57 &MockCaptureCompletedCallback::CaptureCompleted,
58 base::Unretained(&capture_completed_callback_)));
59 capturer_->Stop(); 55 capturer_->Stop();
60 } 56 }
61 57
62 } // namespace remoting 58 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/video_frame_capturer_mac_unittest.cc ('k') | remoting/host/video_frame_capturer_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698