Index: media/video/capture/screen/screen_capturer_mac_unittest.cc |
diff --git a/media/video/capture/screen/screen_capturer_mac_unittest.cc b/media/video/capture/screen/screen_capturer_mac_unittest.cc |
index b8fb5d9c810b7a04930e91bcdae51d81eb6d8be8..4846b55bd92c4ae46d53acea000bd8fc795fc237 100644 |
--- a/media/video/capture/screen/screen_capturer_mac_unittest.cc |
+++ b/media/video/capture/screen/screen_capturer_mac_unittest.cc |
@@ -15,6 +15,9 @@ |
#include "media/video/capture/screen/screen_capture_data.h" |
#include "media/video/capture/screen/screen_capturer_mock_objects.h" |
#include "testing/gtest/include/gtest/gtest.h" |
+#include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" |
+#include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" |
+#include "third_party/webrtc/modules/desktop_capture/desktop_region.h" |
using ::testing::_; |
using ::testing::AnyNumber; |
@@ -25,11 +28,11 @@ namespace media { |
class ScreenCapturerMacTest : public testing::Test { |
public: |
// Verifies that the whole screen is initially dirty. |
- void CaptureDoneCallback1(scoped_refptr<ScreenCaptureData> capture_data); |
+ void CaptureDoneCallback1(webrtc::DesktopFrame* frame); |
// Verifies that a rectangle explicitly marked as dirty is propagated |
// correctly. |
- void CaptureDoneCallback2(scoped_refptr<ScreenCaptureData> capture_data); |
+ void CaptureDoneCallback2(webrtc::DesktopFrame* frame); |
protected: |
virtual void SetUp() OVERRIDE { |
@@ -37,71 +40,57 @@ class ScreenCapturerMacTest : public testing::Test { |
} |
scoped_ptr<ScreenCapturer> capturer_; |
- MockScreenCapturerDelegate delegate_; |
+ MockScreenCapturerCallback callback_; |
}; |
void ScreenCapturerMacTest::CaptureDoneCallback1( |
- scoped_refptr<ScreenCaptureData> capture_data) { |
+ webrtc::DesktopFrame* frame) { |
MacDesktopConfiguration config = MacDesktopConfiguration::GetCurrent( |
MacDesktopConfiguration::BottomLeftOrigin); |
- int width = config.pixel_bounds.width(); |
- int height = config.pixel_bounds.height(); |
- SkRegion initial_region(SkIRect::MakeXYWH(0, 0, width, height)); |
- EXPECT_EQ(initial_region, capture_data->dirty_region()); |
+ // Verify that the region contains full frame. |
+ webrtc::DesktopRegion::Iterator it(frame->updated_region()); |
+ EXPECT_TRUE(!it.IsAtEnd() && it.rect().equals(config.pixel_bounds)); |
+ |
+ delete frame; |
alexeypa (please no reviews)
2013/05/13 17:02:00
nit: Use a scoper instead.
Sergey Ulanov
2013/05/13 21:16:52
Done.
|
} |
void ScreenCapturerMacTest::CaptureDoneCallback2( |
- scoped_refptr<ScreenCaptureData> capture_data) { |
+ webrtc::DesktopFrame* frame) { |
MacDesktopConfiguration config = MacDesktopConfiguration::GetCurrent( |
MacDesktopConfiguration::BottomLeftOrigin); |
int width = config.pixel_bounds.width(); |
int height = config.pixel_bounds.height(); |
- EXPECT_EQ(width, capture_data->size().width()); |
- EXPECT_EQ(height, capture_data->size().height()); |
- EXPECT_TRUE(capture_data->data() != NULL); |
+ EXPECT_EQ(width, frame->size().width()); |
+ EXPECT_EQ(height, frame->size().height()); |
+ EXPECT_TRUE(frame->data() != NULL); |
// Depending on the capture method, the screen may be flipped or not, so |
// the stride may be positive or negative. |
EXPECT_EQ(static_cast<int>(sizeof(uint32_t) * width), |
- abs(capture_data->stride())); |
+ abs(frame->stride())); |
+ |
+ delete frame; |
alexeypa (please no reviews)
2013/05/13 17:02:00
nit: Use a scoper instead.
Sergey Ulanov
2013/05/13 21:16:52
Done.
|
} |
TEST_F(ScreenCapturerMacTest, Capture) { |
- EXPECT_CALL(delegate_, OnCaptureCompleted(_)) |
+ EXPECT_CALL(callback_, OnCaptureCompleted(_)) |
.Times(2) |
.WillOnce(Invoke(this, &ScreenCapturerMacTest::CaptureDoneCallback1)) |
.WillOnce(Invoke(this, &ScreenCapturerMacTest::CaptureDoneCallback2)); |
- EXPECT_CALL(delegate_, OnCursorShapeChangedPtr(_)) |
- .Times(AnyNumber()); |
- EXPECT_CALL(delegate_, CreateSharedBuffer(_)) |
+ EXPECT_CALL(callback_, CreateSharedMemory(_)) |
.Times(AnyNumber()) |
- .WillRepeatedly(Return(scoped_refptr<SharedBuffer>())); |
+ .WillRepeatedly(Return(static_cast<webrtc::SharedMemory*>(NULL))); |
SCOPED_TRACE(""); |
- capturer_->Start(&delegate_); |
+ capturer_->Start(&callback_); |
// Check that we get an initial full-screen updated. |
- capturer_->CaptureFrame(); |
+ capturer_->Capture(webrtc::DesktopRegion()); |
// Check that subsequent dirty rects are propagated correctly. |
- capturer_->CaptureFrame(); |
+ capturer_->Capture(webrtc::DesktopRegion()); |
} |
} // namespace media |
- |
-namespace gfx { |
- |
-std::ostream& operator<<(std::ostream& out, const SkRegion& region) { |
- out << "SkRegion("; |
- for (SkRegion::Iterator i(region); !i.done(); i.next()) { |
- const SkIRect& r = i.rect(); |
- out << "(" << r.fLeft << "," << r.fTop << "," |
- << r.fRight << "," << r.fBottom << ")"; |
- } |
- out << ")"; |
- return out; |
-} |
- |
-} // namespace gfx |