Index: webrtc/modules/desktop_capture/screen_capturer_integration_test.cc |
diff --git a/webrtc/modules/desktop_capture/screen_capturer_unittest.cc b/webrtc/modules/desktop_capture/screen_capturer_integration_test.cc |
similarity index 62% |
copy from webrtc/modules/desktop_capture/screen_capturer_unittest.cc |
copy to webrtc/modules/desktop_capture/screen_capturer_integration_test.cc |
index ce18812fd5fa18369ee79aae64fcd3ebe34cc40b..f208f14f595b719259045c552a3c431723cdfc96 100644 |
--- a/webrtc/modules/desktop_capture/screen_capturer_unittest.cc |
+++ b/webrtc/modules/desktop_capture/screen_capturer_integration_test.cc |
@@ -1,5 +1,5 @@ |
/* |
- * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
+ * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
* |
* Use of this source code is governed by a BSD-style license |
* that can be found in the LICENSE file in the root of the source |
@@ -28,17 +28,12 @@ |
#include "webrtc/modules/desktop_capture/desktop_region.h" |
#include "webrtc/modules/desktop_capture/screen_capturer_mock_objects.h" |
#include "webrtc/modules/desktop_capture/screen_drawer.h" |
-#include "webrtc/system_wrappers/include/sleep.h" |
#if defined(WEBRTC_WIN) |
#include "webrtc/modules/desktop_capture/win/screen_capturer_win_directx.h" |
#endif // defined(WEBRTC_WIN) |
using ::testing::_; |
-using ::testing::AnyNumber; |
-using ::testing::Return; |
- |
-const int kTestSharedMemoryId = 123; |
namespace webrtc { |
@@ -79,7 +74,7 @@ bool ArePixelsColoredBy(const DesktopFrame& frame, |
} // namespace |
-class ScreenCapturerTest : public testing::Test { |
+class ScreenCapturerIntegrationTest : public testing::Test { |
public: |
void SetUp() override { |
capturer_.reset( |
@@ -226,82 +221,11 @@ class ScreenCapturerTest : public testing::Test { |
} |
}; |
-class FakeSharedMemory : public SharedMemory { |
- public: |
- FakeSharedMemory(char* buffer, size_t size) |
- : SharedMemory(buffer, size, 0, kTestSharedMemoryId), |
- buffer_(buffer) { |
- } |
- virtual ~FakeSharedMemory() { |
- delete[] buffer_; |
- } |
- private: |
- char* buffer_; |
- RTC_DISALLOW_COPY_AND_ASSIGN(FakeSharedMemory); |
-}; |
- |
-class FakeSharedMemoryFactory : public SharedMemoryFactory { |
- public: |
- FakeSharedMemoryFactory() {} |
- ~FakeSharedMemoryFactory() override {} |
- |
- std::unique_ptr<SharedMemory> CreateSharedMemory(size_t size) override { |
- return std::unique_ptr<SharedMemory>( |
- new FakeSharedMemory(new char[size], size)); |
- } |
- |
- private: |
- RTC_DISALLOW_COPY_AND_ASSIGN(FakeSharedMemoryFactory); |
-}; |
- |
-TEST_F(ScreenCapturerTest, GetScreenListAndSelectScreen) { |
- webrtc::ScreenCapturer::ScreenList screens; |
- EXPECT_TRUE(capturer_->GetScreenList(&screens)); |
- for (webrtc::ScreenCapturer::ScreenList::iterator it = screens.begin(); |
- it != screens.end(); ++it) { |
- EXPECT_TRUE(capturer_->SelectScreen(it->id)); |
- } |
-} |
- |
-TEST_F(ScreenCapturerTest, StartCapturer) { |
- capturer_->Start(&callback_); |
-} |
- |
-TEST_F(ScreenCapturerTest, Capture) { |
- // Assume that Start() treats the screen as invalid initially. |
- std::unique_ptr<DesktopFrame> frame; |
- EXPECT_CALL(callback_, |
- OnCaptureResultPtr(DesktopCapturer::Result::SUCCESS, _)) |
- .WillOnce(SaveUniquePtrArg(&frame)); |
- |
- capturer_->Start(&callback_); |
- capturer_->CaptureFrame(); |
- |
- ASSERT_TRUE(frame); |
- EXPECT_GT(frame->size().width(), 0); |
- EXPECT_GT(frame->size().height(), 0); |
- EXPECT_GE(frame->stride(), |
- frame->size().width() * DesktopFrame::kBytesPerPixel); |
- EXPECT_TRUE(frame->shared_memory() == NULL); |
- |
- // Verify that the region contains whole screen. |
- EXPECT_FALSE(frame->updated_region().is_empty()); |
- DesktopRegion::Iterator it(frame->updated_region()); |
- ASSERT_TRUE(!it.IsAtEnd()); |
- EXPECT_TRUE(it.rect().equals(DesktopRect::MakeSize(frame->size()))); |
- it.Advance(); |
- EXPECT_TRUE(it.IsAtEnd()); |
-} |
- |
-// Disabled due to being flaky due to the fact that it uses rendering / UI, see |
-// webrtc/6366. |
-TEST_F(ScreenCapturerTest, DISABLED_CaptureUpdatedRegion) { |
+TEST_F(ScreenCapturerIntegrationTest, CaptureUpdatedRegion) { |
TestCaptureUpdatedRegion(); |
} |
-// Disabled due to being flaky due to the fact that it uses rendering / UI, see |
-// webrtc/6366. |
-TEST_F(ScreenCapturerTest, DISABLED_TwoCapturers) { |
+TEST_F(ScreenCapturerIntegrationTest, TwoCapturers) { |
std::unique_ptr<ScreenCapturer> capturer2 = std::move(capturer_); |
SetUp(); |
TestCaptureUpdatedRegion({capturer_.get(), capturer2.get()}); |
@@ -309,72 +233,7 @@ TEST_F(ScreenCapturerTest, DISABLED_TwoCapturers) { |
#if defined(WEBRTC_WIN) |
-TEST_F(ScreenCapturerTest, UseSharedBuffers) { |
- std::unique_ptr<DesktopFrame> frame; |
- EXPECT_CALL(callback_, |
- OnCaptureResultPtr(DesktopCapturer::Result::SUCCESS, _)) |
- .WillOnce(SaveUniquePtrArg(&frame)); |
- |
- capturer_->Start(&callback_); |
- capturer_->SetSharedMemoryFactory( |
- std::unique_ptr<SharedMemoryFactory>(new FakeSharedMemoryFactory())); |
- capturer_->CaptureFrame(); |
- |
- ASSERT_TRUE(frame); |
- ASSERT_TRUE(frame->shared_memory()); |
- EXPECT_EQ(frame->shared_memory()->id(), kTestSharedMemoryId); |
-} |
- |
-TEST_F(ScreenCapturerTest, UseMagnifier) { |
- CreateMagnifierCapturer(); |
- |
- std::unique_ptr<DesktopFrame> frame; |
- EXPECT_CALL(callback_, |
- OnCaptureResultPtr(DesktopCapturer::Result::SUCCESS, _)) |
- .WillOnce(SaveUniquePtrArg(&frame)); |
- |
- capturer_->Start(&callback_); |
- capturer_->CaptureFrame(); |
- ASSERT_TRUE(frame); |
-} |
- |
-TEST_F(ScreenCapturerTest, UseDirectxCapturer) { |
- if (!CreateDirectxCapturer()) { |
- return; |
- } |
- |
- std::unique_ptr<DesktopFrame> frame; |
- EXPECT_CALL(callback_, |
- OnCaptureResultPtr(DesktopCapturer::Result::SUCCESS, _)) |
- .WillOnce(SaveUniquePtrArg(&frame)); |
- |
- capturer_->Start(&callback_); |
- capturer_->CaptureFrame(); |
- ASSERT_TRUE(frame); |
-} |
- |
-TEST_F(ScreenCapturerTest, UseDirectxCapturerWithSharedBuffers) { |
- if (!CreateDirectxCapturer()) { |
- return; |
- } |
- |
- std::unique_ptr<DesktopFrame> frame; |
- EXPECT_CALL(callback_, |
- OnCaptureResultPtr(DesktopCapturer::Result::SUCCESS, _)) |
- .WillOnce(SaveUniquePtrArg(&frame)); |
- |
- capturer_->Start(&callback_); |
- capturer_->SetSharedMemoryFactory( |
- std::unique_ptr<SharedMemoryFactory>(new FakeSharedMemoryFactory())); |
- capturer_->CaptureFrame(); |
- ASSERT_TRUE(frame); |
- ASSERT_TRUE(frame->shared_memory()); |
- EXPECT_EQ(frame->shared_memory()->id(), kTestSharedMemoryId); |
-} |
- |
-// Disabled due to being flaky due to the fact that it uses rendering / UI, see |
-// webrtc/6366. |
-TEST_F(ScreenCapturerTest, DISABLED_CaptureUpdatedRegionWithDirectxCapturer) { |
+TEST_F(ScreenCapturerIntegrationTest, CaptureUpdatedRegionWithDirectxCapturer) { |
if (!CreateDirectxCapturer()) { |
return; |
} |
@@ -382,9 +241,7 @@ TEST_F(ScreenCapturerTest, DISABLED_CaptureUpdatedRegionWithDirectxCapturer) { |
TestCaptureUpdatedRegion(); |
} |
-// Disabled due to being flaky due to the fact that it uses rendering / UI, see |
-// webrtc/6366. |
-TEST_F(ScreenCapturerTest, DISABLED_TwoDirectxCapturers) { |
+TEST_F(ScreenCapturerIntegrationTest, TwoDirectxCapturers) { |
if (!CreateDirectxCapturer()) { |
return; |
} |
@@ -394,26 +251,21 @@ TEST_F(ScreenCapturerTest, DISABLED_TwoDirectxCapturers) { |
TestCaptureUpdatedRegion({capturer_.get(), capturer2.get()}); |
} |
-// Disabled due to being flaky due to the fact that it uses rendering / UI, see |
-// webrtc/6366. |
-TEST_F(ScreenCapturerTest, DISABLED_CaptureUpdatedRegionWithMagnifierCapturer) { |
+TEST_F(ScreenCapturerIntegrationTest, |
+ CaptureUpdatedRegionWithMagnifierCapturer) { |
CreateMagnifierCapturer(); |
TestCaptureUpdatedRegion(); |
} |
-// Disabled due to being flaky due to the fact that it uses rendering / UI, see |
-// webrtc/6366. |
-TEST_F(ScreenCapturerTest, DISABLED_TwoMagnifierCapturers) { |
+TEST_F(ScreenCapturerIntegrationTest, TwoMagnifierCapturers) { |
CreateMagnifierCapturer(); |
std::unique_ptr<ScreenCapturer> capturer2 = std::move(capturer_); |
CreateMagnifierCapturer(); |
TestCaptureUpdatedRegion({capturer_.get(), capturer2.get()}); |
} |
-// Disabled due to being flaky due to the fact that it uses rendering / UI, see |
-// webrtc/6366. |
-TEST_F(ScreenCapturerTest, |
- DISABLED_MaybeCaptureUpdatedRegionWithDirectxCapturer) { |
+TEST_F(ScreenCapturerIntegrationTest, |
+ MaybeCaptureUpdatedRegionWithDirectxCapturer) { |
// Even DirectX capturer is not supported in current system, we should be able |
// to select a usable capturer. |
MaybeCreateDirectxCapturer(); |