#include "content/browser/media/capture/desktop_capture_device.h"
+#include <string>
+
#include "base/basictypes.h"
-#include "base/sequenced_task_runner.h"
#include "base/synchronization/waitable_event.h"
#include "base/test/test_timeouts.h"
-#include "base/threading/sequenced_worker_pool.h"
-#include "base/threading/thread.h"
#include "base/time/time.h"
+#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_frame.h"
class InvertedDesktopFrame : public webrtc::DesktopFrame {
public:
// Takes ownership of |frame|.
- InvertedDesktopFrame(webrtc::DesktopFrame* frame)
+ explicit InvertedDesktopFrame(webrtc::DesktopFrame* frame)
: webrtc::DesktopFrame(
- frame->size(), -frame->stride(),
+ frame->size(),
+ -frame->stride(),
frame->data() + (frame->size().height() - 1) * frame->stride(),
frame->shared_memory()),
original_frame_(frame) {
class DesktopCaptureDeviceTest : public testing::Test {
public:
- virtual void SetUp() OVERRIDE {
- worker_pool_ = new base::SequencedWorkerPool(3, "TestCaptureThread");
- }
-
void CreateScreenCaptureDevice(scoped_ptr<webrtc::DesktopCapturer> capturer) {
- capture_device_.reset(new DesktopCaptureDevice(
- worker_pool_->GetSequencedTaskRunner(worker_pool_->GetSequenceToken()),
- thread_.Pass(),
- capturer.Pass(),
- DesktopMediaID::TYPE_SCREEN));
+ capture_device_.reset(
+ new DesktopCaptureDevice(capturer.Pass(), DesktopMediaID::TYPE_SCREEN));
}
protected:
- scoped_refptr<base::SequencedWorkerPool> worker_pool_;
- scoped_ptr<base::Thread> thread_;
scoped_ptr<DesktopCaptureDevice> capture_device_;
};
capture_params.requested_format.frame_size.SetSize(640, 480);
capture_params.requested_format.frame_rate = kFrameRate;
capture_params.requested_format.pixel_format = media::PIXEL_FORMAT_I420;
- capture_params.allow_resolution_change = false;
capture_device_->AllocateAndStart(
capture_params, client.PassAs<media::VideoCaptureDevice::Client>());
EXPECT_TRUE(done_event.TimedWait(TestTimeouts::action_max_timeout()));
EXPECT_EQ(media::PIXEL_FORMAT_ARGB, format.pixel_format);
EXPECT_EQ(format.frame_size.GetArea() * 4, frame_size);
- worker_pool_->FlushForTesting();
}
// Test that screen capturer behaves correctly if the source frame size changes
kTestFrameHeight1);
capture_params.requested_format.frame_rate = kFrameRate;
capture_params.requested_format.pixel_format = media::PIXEL_FORMAT_I420;
- capture_params.allow_resolution_change = false;
capture_device_->AllocateAndStart(
capture_params, client.PassAs<media::VideoCaptureDevice::Client>());
EXPECT_EQ(media::PIXEL_FORMAT_ARGB, format.pixel_format);
EXPECT_EQ(format.frame_size.GetArea() * 4, frame_size);
- worker_pool_->FlushForTesting();
}
// Test that screen capturer behaves correctly if the source frame size changes
kTestFrameHeight2);
capture_params.requested_format.frame_rate = kFrameRate;
capture_params.requested_format.pixel_format = media::PIXEL_FORMAT_I420;
- capture_params.allow_resolution_change = false;
capture_device_->AllocateAndStart(
capture_params, client.PassAs<media::VideoCaptureDevice::Client>());
EXPECT_EQ(kTestFrameHeight1, format.frame_size.height());
EXPECT_EQ(kFrameRate, format.frame_rate);
EXPECT_EQ(media::PIXEL_FORMAT_ARGB, format.pixel_format);
- worker_pool_->FlushForTesting();
}
} // namespace content