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

Unified 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: 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 side-by-side diff with in-line comments
Download patch
Index: remoting/host/video_frame_capturer_unittest.cc
diff --git a/remoting/host/video_frame_capturer_unittest.cc b/remoting/host/video_frame_capturer_unittest.cc
index 4ad0a1b8ca5a937056883a01a6823f0cc49da4fa..35ff24b2622816fa1189f223b1e6d01d345686a8 100644
--- a/remoting/host/video_frame_capturer_unittest.cc
+++ b/remoting/host/video_frame_capturer_unittest.cc
@@ -14,11 +14,37 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
+using ::testing::_;
+
namespace remoting {
namespace {
-void IgnoreCursorShapeChanged(scoped_ptr<protocol::CursorShapeInfo> info) {
+class MockCapturerDelegate : public VideoFrameCapturer::Delegate {
+ public:
+ MockCapturerDelegate();
+ virtual ~MockCapturerDelegate();
+
+ virtual void OnCursorShapeChanged(
+ scoped_ptr<protocol::CursorShapeInfo> cursor_shape) OVERRIDE;
+
+ MOCK_METHOD1(OnCaptureCompleted, void(scoped_refptr<CaptureData>));
+ MOCK_METHOD1(OnCursorShapeChangedPtr, void(protocol::CursorShapeInfo*));
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(MockCapturerDelegate);
+};
+
+MockCapturerDelegate::MockCapturerDelegate() {
+}
+
+MockCapturerDelegate::~MockCapturerDelegate() {
+}
+
+void MockCapturerDelegate::OnCursorShapeChanged(
+ scoped_ptr<protocol::CursorShapeInfo> cursor_shape) {
+ // Notify the mock method.
+ OnCursorShapeChangedPtr(cursor_shape.get());
}
} // namespace
@@ -39,23 +65,22 @@ class VideoFrameCapturerTest : public testing::Test {
}
scoped_ptr<VideoFrameCapturer> capturer_;
- MockCaptureCompletedCallback capture_completed_callback_;
+ MockCapturerDelegate delegate_;
};
TEST_F(VideoFrameCapturerTest, StartCapturer) {
- capturer_->Start(base::Bind(&IgnoreCursorShapeChanged));
+ capturer_->Start(&delegate_);
capturer_->Stop();
}
TEST_F(VideoFrameCapturerTest, Capture) {
// Assume that Start() treats the screen as invalid initially.
- EXPECT_CALL(capture_completed_callback_,
- CaptureCompletedPtr(DirtyRegionIsNonEmptyRect()));
+ EXPECT_CALL(delegate_,
+ OnCaptureCompleted(DirtyRegionIsNonEmptyRect()));
+ EXPECT_CALL(delegate_, OnCursorShapeChangedPtr(_));
- capturer_->Start(base::Bind(&IgnoreCursorShapeChanged));
- capturer_->CaptureInvalidRegion(base::Bind(
- &MockCaptureCompletedCallback::CaptureCompleted,
- base::Unretained(&capture_completed_callback_)));
+ capturer_->Start(&delegate_);
+ capturer_->CaptureInvalidRegion();
capturer_->Stop();
}

Powered by Google App Engine
This is Rietveld 408576698