diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-28 23:54:03 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-28 23:54:03 +0000 |
commit | 497d8a9857e7383f979b89694aff8dd403c176fe (patch) | |
tree | 2f07bb42d4a7a8e94e959c90dacbfa62eed1debd /media/video/capture/screen/shared_buffer_unittest.cc | |
parent | bac4ae80a786d68bfc18ca46f0adfcc4a1c43b0f (diff) | |
download | chromium_src-497d8a9857e7383f979b89694aff8dd403c176fe.zip chromium_src-497d8a9857e7383f979b89694aff8dd403c176fe.tar.gz chromium_src-497d8a9857e7383f979b89694aff8dd403c176fe.tar.bz2 |
Move screen capturers from remoting/capturer to media/video/capturer/screen
Screen capturers will be used in content, and so they have to be moved to
avoid dependency on remoting/capturer in content.
Beside moving the files this CL also renames classes as follows:
remoting::VideoFrameCapturer -> media::ScreenCapturer
remoting::VideoFrame -> media::ScreenCaptureFrame
remoting::CaptureData -> media::ScreenCaptureData
BUG=134249
Review URL: https://codereview.chromium.org/12047101
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@179218 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/video/capture/screen/shared_buffer_unittest.cc')
-rw-r--r-- | media/video/capture/screen/shared_buffer_unittest.cc | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/media/video/capture/screen/shared_buffer_unittest.cc b/media/video/capture/screen/shared_buffer_unittest.cc new file mode 100644 index 0000000..1efc798 --- /dev/null +++ b/media/video/capture/screen/shared_buffer_unittest.cc @@ -0,0 +1,55 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/process_util.h" +#include "media/video/capture/screen/shared_buffer.h" +#include "testing/gtest/include/gtest/gtest.h" + +const uint32 kBufferSize = 4096; +const int kPattern = 0x12345678; + +const int kIdZero = 0; +const int kIdOne = 1; + +namespace media { + +TEST(SharedBufferTest, Basic) { + scoped_refptr<SharedBuffer> source(new SharedBuffer(kBufferSize)); + + // Make sure that the buffer is allocated, the size is recorded correctly and + // its ID is reset. + EXPECT_TRUE(source->ptr() != NULL); + EXPECT_EQ(source->id(), kIdZero); + EXPECT_EQ(source->size(), kBufferSize); + + // See if setting of the ID works. + source->set_id(kIdOne); + EXPECT_EQ(source->id(), kIdOne); + + base::SharedMemoryHandle copied_handle; + EXPECT_TRUE(source->ShareToProcess( + base::GetCurrentProcessHandle(), &copied_handle)); + + scoped_refptr<SharedBuffer> dest( + new SharedBuffer(kIdZero, copied_handle, kBufferSize)); + + // Make sure that the buffer is allocated, the size is recorded correctly and + // its ID is reset. + EXPECT_TRUE(dest->ptr() != NULL); + EXPECT_EQ(dest->id(), kIdZero); + EXPECT_EQ(dest->size(), kBufferSize); + + // Verify that the memory contents are the same for the two buffers. + int* source_ptr = reinterpret_cast<int*>(source->ptr()); + *source_ptr = kPattern; + int* dest_ptr = reinterpret_cast<int*>(dest->ptr()); + EXPECT_EQ(*source_ptr, *dest_ptr); + + // Check that the destination buffer is still mapped even when the source + // buffer is destroyed. + source = NULL; + EXPECT_EQ(0x12345678, *dest_ptr); +} + +} // namespace media |