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

Unified Diff: media/video/capture/screen/screen_capturer_mac_unittest.cc

Issue 13983010: Use webrtc::DesktopCapturer for screen capturer implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 months 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: 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..72f2d69f4625f339596a706b112c534b60490daf 100644
--- a/media/video/capture/screen/screen_capturer_mac_unittest.cc
+++ b/media/video/capture/screen/screen_capturer_mac_unittest.cc
@@ -12,9 +12,11 @@
#include "base/callback.h"
#include "base/memory/scoped_ptr.h"
#include "media/video/capture/screen/mac/desktop_configuration.h"
-#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 +27,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 +39,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) {
+ scoped_ptr<webrtc::DesktopFrame> owned_frame(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));
}
void ScreenCapturerMacTest::CaptureDoneCallback2(
- scoped_refptr<ScreenCaptureData> capture_data) {
+ webrtc::DesktopFrame* frame) {
+ scoped_ptr<webrtc::DesktopFrame> owned_frame(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()));
}
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
« no previous file with comments | « media/video/capture/screen/screen_capturer_mac.mm ('k') | media/video/capture/screen/screen_capturer_mock_objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698