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

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

Issue 12047101: Move screen capturers from remoting/capturer to media/video/capturer/screen (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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
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/capturer/video_frame_capturer.h" 5 #include "media/video/capture/screen/screen_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/capturer/capture_data.h" 11 #include "media/video/capture/screen/screen_capture_data.h"
12 #include "remoting/capturer/shared_buffer_factory.h" 12 #include "media/video/capture/screen/screen_capturer_mock_objects.h"
13 #include "remoting/capturer/video_capturer_mock_objects.h" 13 #include "media/video/capture/screen/shared_buffer_factory.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::_; 17 using ::testing::_;
18 using ::testing::AnyNumber; 18 using ::testing::AnyNumber;
19 19
20 namespace remoting { 20 namespace media {
21 21
22 class MockSharedBufferFactory : public SharedBufferFactory { 22 class MockSharedBufferFactory : public SharedBufferFactory {
23 public: 23 public:
24 MockSharedBufferFactory() {} 24 MockSharedBufferFactory() {}
25 virtual ~MockSharedBufferFactory() {} 25 virtual ~MockSharedBufferFactory() {}
26 26
27 MOCK_METHOD1(CreateSharedBuffer, scoped_refptr<SharedBuffer>(uint32)); 27 MOCK_METHOD1(CreateSharedBuffer, scoped_refptr<SharedBuffer>(uint32));
28 MOCK_METHOD1(ReleaseSharedBuffer, void(scoped_refptr<SharedBuffer>)); 28 MOCK_METHOD1(ReleaseSharedBuffer, void(scoped_refptr<SharedBuffer>));
29 29
30 private: 30 private:
31 DISALLOW_COPY_AND_ASSIGN(MockSharedBufferFactory); 31 DISALLOW_COPY_AND_ASSIGN(MockSharedBufferFactory);
32 }; 32 };
33 33
34 MATCHER(DirtyRegionIsNonEmptyRect, "") { 34 MATCHER(DirtyRegionIsNonEmptyRect, "") {
35 const SkRegion& dirty_region = arg->dirty_region(); 35 const SkRegion& dirty_region = arg->dirty_region();
36 const SkIRect& dirty_region_bounds = dirty_region.getBounds(); 36 const SkIRect& dirty_region_bounds = dirty_region.getBounds();
37 if (dirty_region_bounds.isEmpty()) { 37 if (dirty_region_bounds.isEmpty()) {
38 return false; 38 return false;
39 } 39 }
40 return dirty_region == SkRegion(dirty_region_bounds); 40 return dirty_region == SkRegion(dirty_region_bounds);
41 } 41 }
42 42
43 class VideoFrameCapturerTest : public testing::Test { 43 class ScreenCapturerTest : public testing::Test {
44 public: 44 public:
45 scoped_refptr<SharedBuffer> CreateSharedBuffer(uint32 size); 45 scoped_refptr<SharedBuffer> CreateSharedBuffer(uint32 size);
46 46
47 protected: 47 protected:
48 scoped_ptr<VideoFrameCapturer> capturer_; 48 scoped_ptr<ScreenCapturer> capturer_;
49 MockSharedBufferFactory shared_buffer_factory_; 49 MockSharedBufferFactory shared_buffer_factory_;
50 MockVideoFrameCapturerDelegate delegate_; 50 MockScreenCapturerDelegate delegate_;
51 }; 51 };
52 52
53 scoped_refptr<SharedBuffer> VideoFrameCapturerTest::CreateSharedBuffer( 53 scoped_refptr<SharedBuffer> ScreenCapturerTest::CreateSharedBuffer(
54 uint32 size) { 54 uint32 size) {
55 return scoped_refptr<SharedBuffer>(new SharedBuffer(size)); 55 return scoped_refptr<SharedBuffer>(new SharedBuffer(size));
56 } 56 }
57 57
58 TEST_F(VideoFrameCapturerTest, StartCapturer) { 58 TEST_F(ScreenCapturerTest, StartCapturer) {
59 capturer_ = VideoFrameCapturer::Create(); 59 capturer_ = ScreenCapturer::Create();
60 capturer_->Start(&delegate_); 60 capturer_->Start(&delegate_);
61 capturer_->Stop(); 61 capturer_->Stop();
62 } 62 }
63 63
64 #if defined(THREAD_SANITIZER) 64 #if defined(THREAD_SANITIZER)
65 // ThreadSanitizer v2 reports a use-after-free, see http://crbug.com/163641. 65 // ThreadSanitizer v2 reports a use-after-free, see http://crbug.com/163641.
66 #define MAYBE_Capture DISABLED_Capture 66 #define MAYBE_Capture DISABLED_Capture
67 #else 67 #else
68 #define MAYBE_Capture Capture 68 #define MAYBE_Capture Capture
69 #endif 69 #endif
70 TEST_F(VideoFrameCapturerTest, MAYBE_Capture) { 70 TEST_F(ScreenCapturerTest, MAYBE_Capture) {
71 // Assume that Start() treats the screen as invalid initially. 71 // Assume that Start() treats the screen as invalid initially.
72 EXPECT_CALL(delegate_, 72 EXPECT_CALL(delegate_,
73 OnCaptureCompleted(DirtyRegionIsNonEmptyRect())); 73 OnCaptureCompleted(DirtyRegionIsNonEmptyRect()));
74 EXPECT_CALL(delegate_, OnCursorShapeChangedPtr(_)) 74 EXPECT_CALL(delegate_, OnCursorShapeChangedPtr(_))
75 .Times(AnyNumber()); 75 .Times(AnyNumber());
76 76
77 capturer_ = VideoFrameCapturer::Create(); 77 capturer_ = ScreenCapturer::Create();
78 capturer_->Start(&delegate_); 78 capturer_->Start(&delegate_);
79 capturer_->CaptureFrame(); 79 capturer_->CaptureFrame();
80 capturer_->Stop(); 80 capturer_->Stop();
81 } 81 }
82 82
83 #if defined(OS_WIN) 83 #if defined(OS_WIN)
84 84
85 TEST_F(VideoFrameCapturerTest, UseSharedBuffers) { 85 TEST_F(ScreenCapturerTest, UseSharedBuffers) {
86 EXPECT_CALL(delegate_, 86 EXPECT_CALL(delegate_,
87 OnCaptureCompleted(DirtyRegionIsNonEmptyRect())); 87 OnCaptureCompleted(DirtyRegionIsNonEmptyRect()));
88 EXPECT_CALL(delegate_, OnCursorShapeChangedPtr(_)) 88 EXPECT_CALL(delegate_, OnCursorShapeChangedPtr(_))
89 .Times(AnyNumber()); 89 .Times(AnyNumber());
90 90
91 EXPECT_CALL(shared_buffer_factory_, CreateSharedBuffer(_)) 91 EXPECT_CALL(shared_buffer_factory_, CreateSharedBuffer(_))
92 .Times(1) 92 .Times(1)
93 .WillOnce(Invoke(this, &VideoFrameCapturerTest::CreateSharedBuffer)); 93 .WillOnce(Invoke(this, &ScreenCapturerTest::CreateSharedBuffer));
94 EXPECT_CALL(shared_buffer_factory_, ReleaseSharedBuffer(_)) 94 EXPECT_CALL(shared_buffer_factory_, ReleaseSharedBuffer(_))
95 .Times(1); 95 .Times(1);
96 96
97 capturer_ = VideoFrameCapturer::CreateWithFactory(&shared_buffer_factory_); 97 capturer_ = ScreenCapturer::CreateWithFactory(&shared_buffer_factory_);
98 capturer_->Start(&delegate_); 98 capturer_->Start(&delegate_);
99 capturer_->CaptureFrame(); 99 capturer_->CaptureFrame();
100 capturer_->Stop(); 100 capturer_->Stop();
101 capturer_.reset(); 101 capturer_.reset();
102 } 102 }
103 103
104 #endif // defined(OS_WIN) 104 #endif // defined(OS_WIN)
105 105
106 } // namespace remoting 106 } // namespace media
OLDNEW
« no previous file with comments | « media/video/capture/screen/screen_capturer_mock_objects.cc ('k') | media/video/capture/screen/screen_capturer_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698