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

Side by Side Diff: media/video/capture/screen/screen_capturer_mac_unittest.cc

Issue 15692018: Remove screen capturers from media/video/capture/screen. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "media/video/capture/screen/screen_capturer.h"
6
7 #include <ApplicationServices/ApplicationServices.h>
8
9 #include <ostream>
10
11 #include "base/bind.h"
12 #include "base/callback.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "media/video/capture/screen/mac/desktop_configuration.h"
15 #include "media/video/capture/screen/screen_capturer_mock_objects.h"
16 #include "testing/gtest/include/gtest/gtest.h"
17 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h"
18 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
19 #include "third_party/webrtc/modules/desktop_capture/desktop_region.h"
20
21 using ::testing::_;
22 using ::testing::AnyNumber;
23 using ::testing::Return;
24
25 namespace media {
26
27 class ScreenCapturerMacTest : public testing::Test {
28 public:
29 // Verifies that the whole screen is initially dirty.
30 void CaptureDoneCallback1(webrtc::DesktopFrame* frame);
31
32 // Verifies that a rectangle explicitly marked as dirty is propagated
33 // correctly.
34 void CaptureDoneCallback2(webrtc::DesktopFrame* frame);
35
36 protected:
37 virtual void SetUp() OVERRIDE {
38 capturer_ = ScreenCapturer::Create();
39 }
40
41 scoped_ptr<ScreenCapturer> capturer_;
42 MockScreenCapturerCallback callback_;
43 };
44
45 void ScreenCapturerMacTest::CaptureDoneCallback1(
46 webrtc::DesktopFrame* frame) {
47 scoped_ptr<webrtc::DesktopFrame> owned_frame(frame);
48
49 MacDesktopConfiguration config = MacDesktopConfiguration::GetCurrent(
50 MacDesktopConfiguration::BottomLeftOrigin);
51
52 // Verify that the region contains full frame.
53 webrtc::DesktopRegion::Iterator it(frame->updated_region());
54 EXPECT_TRUE(!it.IsAtEnd() && it.rect().equals(config.pixel_bounds));
55 }
56
57 void ScreenCapturerMacTest::CaptureDoneCallback2(
58 webrtc::DesktopFrame* frame) {
59 scoped_ptr<webrtc::DesktopFrame> owned_frame(frame);
60
61 MacDesktopConfiguration config = MacDesktopConfiguration::GetCurrent(
62 MacDesktopConfiguration::BottomLeftOrigin);
63 int width = config.pixel_bounds.width();
64 int height = config.pixel_bounds.height();
65
66 EXPECT_EQ(width, frame->size().width());
67 EXPECT_EQ(height, frame->size().height());
68 EXPECT_TRUE(frame->data() != NULL);
69 // Depending on the capture method, the screen may be flipped or not, so
70 // the stride may be positive or negative.
71 EXPECT_EQ(static_cast<int>(sizeof(uint32_t) * width),
72 abs(frame->stride()));
73 }
74
75 TEST_F(ScreenCapturerMacTest, Capture) {
76 EXPECT_CALL(callback_, OnCaptureCompleted(_))
77 .Times(2)
78 .WillOnce(Invoke(this, &ScreenCapturerMacTest::CaptureDoneCallback1))
79 .WillOnce(Invoke(this, &ScreenCapturerMacTest::CaptureDoneCallback2));
80
81 EXPECT_CALL(callback_, CreateSharedMemory(_))
82 .Times(AnyNumber())
83 .WillRepeatedly(Return(static_cast<webrtc::SharedMemory*>(NULL)));
84
85 SCOPED_TRACE("");
86 capturer_->Start(&callback_);
87
88 // Check that we get an initial full-screen updated.
89 capturer_->Capture(webrtc::DesktopRegion());
90
91 // Check that subsequent dirty rects are propagated correctly.
92 capturer_->Capture(webrtc::DesktopRegion());
93 }
94
95 } // namespace media
OLDNEW
« 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