diff options
author | dmaclach@chromium.org <dmaclach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-01 15:02:53 +0000 |
---|---|---|
committer | dmaclach@chromium.org <dmaclach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-01 15:02:53 +0000 |
commit | 804c99625cc375da683a6c1a681178b0014e02fe (patch) | |
tree | 444c6deffd05f7744f0d2b50077aeabde0cc7170 /remoting/host/session_manager_unittest.cc | |
parent | 9da1cedf45ee5bb54cc5558ca044dc24b999b8d9 (diff) | |
download | chromium_src-804c99625cc375da683a6c1a681178b0014e02fe.zip chromium_src-804c99625cc375da683a6c1a681178b0014e02fe.tar.gz chromium_src-804c99625cc375da683a6c1a681178b0014e02fe.tar.bz2 |
Revamp capturer to clean up the interface, and to keep data as atomic as possible when making calls across threads.
TEST=build remoting
BUG=none
Review URL: http://codereview.chromium.org/2805025
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51363 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/host/session_manager_unittest.cc')
-rw-r--r-- | remoting/host/session_manager_unittest.cc | 57 |
1 files changed, 23 insertions, 34 deletions
diff --git a/remoting/host/session_manager_unittest.cc b/remoting/host/session_manager_unittest.cc index a4134a8..5a4e4eb 100644 --- a/remoting/host/session_manager_unittest.cc +++ b/remoting/host/session_manager_unittest.cc @@ -18,16 +18,6 @@ namespace remoting { static const int kWidth = 640; static const int kHeight = 480; -static int kStride[3] = { - kWidth * 4, - kWidth * 4, - kWidth * 4, -}; -static uint8* kData[3] = { - reinterpret_cast<uint8*>(0x01), - reinterpret_cast<uint8*>(0x02), - reinterpret_cast<uint8*>(0x03), -}; static const PixelFormat kFormat = PixelFormatRgb32; static const UpdateStreamEncoding kEncoding = EncodingNone; @@ -53,7 +43,6 @@ class SessionManagerTest : public testing::Test { MockCapturer* capturer_; MockEncoder* encoder_; MessageLoop message_loop_; - private: DISALLOW_COPY_AND_ASSIGN(SessionManagerTest); }; @@ -62,8 +51,10 @@ TEST_F(SessionManagerTest, Init) { Init(); } -ACTION(RunSimpleTask) { - arg0->Run(); +ACTION_P2(RunCallback, rects, data) { + RectVector& dirty_rects = data->mutable_dirty_rects(); + dirty_rects.insert(dirty_rects.end(), rects.begin(), rects.end()); + arg0->Run(data); delete arg0; } @@ -78,7 +69,7 @@ ACTION_P3(FinishDecode, rects, buffer, header) { header->set_height(rect.height()); header->set_encoding(kEncoding); header->set_pixel_format(kFormat); - arg4->Run(header, *buffer, state); + arg2->Run(header, *buffer, state); } ACTION_P(AssignCaptureData, data) { @@ -94,38 +85,36 @@ ACTION_P(AssignDirtyRect, rects) { TEST_F(SessionManagerTest, OneRecordCycle) { Init(); + RectVector update_rects; + update_rects.push_back(gfx::Rect(0, 0, 10, 10)); + Capturer::DataPlanes planes; + for (int i = 0; i < Capturer::DataPlanes::kPlaneCount; ++i) { + planes.data[i] = reinterpret_cast<uint8*>(i); + planes.strides[i] = kWidth * 4; + } + scoped_refptr<Capturer::CaptureData> data(new Capturer::CaptureData(planes, + kWidth, + kHeight, + kFormat)); // Set the recording rate to very low to avoid capture twice. record_->SetMaxRate(0.01); // Add the mock client connection to the session. - EXPECT_CALL(*capturer_, GetWidth()).WillRepeatedly(Return(kWidth)); - EXPECT_CALL(*capturer_, GetHeight()).WillRepeatedly(Return(kHeight)); + EXPECT_CALL(*capturer_, width()).WillRepeatedly(Return(kWidth)); + EXPECT_CALL(*capturer_, height()).WillRepeatedly(Return(kHeight)); EXPECT_CALL(*client_, SendInitClientMessage(kWidth, kHeight)); record_->AddClient(client_); // First the capturer is called. - EXPECT_CALL(*capturer_, CaptureDirtyRects(NotNull())) - .WillOnce(RunSimpleTask()); - - // Create a dirty rect that can be verified. - DirtyRects rects; - rects.push_back(gfx::Rect(0, 0, 10, 10)); - EXPECT_CALL(*capturer_, GetDirtyRects(NotNull())) - .WillOnce(AssignDirtyRect(&rects)); - EXPECT_CALL(*capturer_, GetData(NotNull())) - .WillOnce(AssignCaptureData(kData)); - EXPECT_CALL(*capturer_, GetDataStride(NotNull())) - .WillOnce(AssignCaptureData(kStride)); - EXPECT_CALL(*capturer_, GetPixelFormat()) - .WillOnce(Return(kFormat)); + EXPECT_CALL(*capturer_, InvalidateFullScreen()); + EXPECT_CALL(*capturer_, CaptureInvalidRects(NotNull())) + .WillOnce(RunCallback(update_rects, data)); // Expect the encoder be called. scoped_refptr<media::DataBuffer> buffer = new media::DataBuffer(0); - EXPECT_CALL(*encoder_, SetSize(kWidth, kHeight)); - EXPECT_CALL(*encoder_, SetPixelFormat(kFormat)); UpdateStreamPacketHeader *header = new UpdateStreamPacketHeader; - EXPECT_CALL(*encoder_, Encode(rects, NotNull(), NotNull(), false, NotNull())) - .WillOnce(FinishDecode(&rects, &buffer, header)); + EXPECT_CALL(*encoder_, Encode(data, false, NotNull())) + .WillOnce(FinishDecode(&update_rects, &buffer, header)); // Expect the client be notified. EXPECT_CALL(*client_, SendBeginUpdateStreamMessage()); |