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

Unified Diff: content/renderer/media/video_capture_message_filter_unittest.cc

Issue 2410383002: VideoCapture: more migration IPC-->mojo, part 6 (Closed)
Patch Set: Comment correction Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/media/video_capture_message_filter_unittest.cc
diff --git a/content/renderer/media/video_capture_message_filter_unittest.cc b/content/renderer/media/video_capture_message_filter_unittest.cc
index b8a9b36726cff7fe4e6a17a41f65c1f360d0d769..4c71c14e4609431990cd3af55f4863db25ce6e07 100644
--- a/content/renderer/media/video_capture_message_filter_unittest.cc
+++ b/content/renderer/media/video_capture_message_filter_unittest.cc
@@ -4,60 +4,43 @@
#include <stdint.h>
-#include "base/memory/shared_memory.h"
#include "base/process/process_handle.h"
#include "build/build_config.h"
-#include "content/common/media/video_capture_messages.h"
#include "content/renderer/media/video_capture_message_filter.h"
#include "ipc/ipc_test_sink.h"
-#include "media/base/video_capture_types.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
using ::testing::_;
-using ::testing::AnyNumber;
-using ::testing::DoAll;
using ::testing::Invoke;
using ::testing::Mock;
-using ::testing::Return;
-using ::testing::SaveArg;
using ::testing::StrictMock;
-using ::testing::WithArg;
+using ::testing::WithArgs;
namespace content {
namespace {
class MockVideoCaptureDelegate : public VideoCaptureMessageFilter::Delegate {
public:
- MockVideoCaptureDelegate() : device_id_(0) {}
-
- // VideoCaptureMessageFilter::Delegate implementation.
- MOCK_METHOD3(OnBufferCreated,
- void(base::SharedMemoryHandle handle,
- int length,
- int buffer_id));
- MOCK_METHOD7(OnBufferReceived,
- void(int buffer_id,
- base::TimeDelta timestamp,
- const base::DictionaryValue& metadata,
- media::VideoPixelFormat pixel_format,
- media::VideoFrame::StorageType storage_type,
- const gfx::Size& coded_size,
- const gfx::Rect& visible_rect));
-
- void OnDelegateAdded(int32_t device_id) override {
- ASSERT_TRUE(device_id != 0);
- ASSERT_TRUE(device_id_ == 0);
- device_id_ = device_id;
+ MockVideoCaptureDelegate() : device_id_(0) {
+ ON_CALL(*this, OnDelegateAdded(_))
+ .WillByDefault(WithArgs<0>(
+ Invoke(this, &MockVideoCaptureDelegate::DoOnDelegateAdded)));
}
+ MOCK_METHOD1(OnDelegateAdded, void(int32_t));
+ void DoOnDelegateAdded(int32_t device_id) {
+ ASSERT_NE(0, device_id);
+ ASSERT_EQ(0, device_id_);
+ device_id_ = device_id;
+ }
int device_id() { return device_id_; }
private:
int device_id_;
};
-} // namespace
+} // anonymous namespace
TEST(VideoCaptureMessageFilterTest, Basic) {
scoped_refptr<VideoCaptureMessageFilter> filter(
@@ -66,30 +49,11 @@ TEST(VideoCaptureMessageFilterTest, Basic) {
IPC::TestSink channel;
filter->OnFilterAdded(&channel);
MockVideoCaptureDelegate delegate;
+
+ EXPECT_CALL(delegate, OnDelegateAdded(1));
filter->AddDelegate(&delegate);
ASSERT_EQ(1, delegate.device_id());
- // VideoCaptureMsg_NewBuffer
-#if defined(OS_WIN)
- HANDLE h = reinterpret_cast<HANDLE>(10);
- // Passing a process ID that is not the current process's to prevent
- // attachment brokering.
- const base::SharedMemoryHandle handle =
- base::SharedMemoryHandle(h, base::GetCurrentProcId() + 1);
- EXPECT_CALL(delegate,
- OnBufferCreated(
- ::testing::Property(&base::SharedMemoryHandle::GetHandle, h),
- 100, 1));
-#elif defined(OS_MACOSX) && !defined(OS_IOS)
- const base::SharedMemoryHandle handle =
- base::SharedMemoryHandle(10, 100, base::GetCurrentProcId());
- EXPECT_CALL(delegate, OnBufferCreated(handle, 100, 1));
-#else
- const base::SharedMemoryHandle handle = base::SharedMemoryHandle(10, true);
- EXPECT_CALL(delegate, OnBufferCreated(handle, 100, 1));
-#endif
- filter->OnMessageReceived(VideoCaptureMsg_NewBuffer(
- delegate.device_id(), handle, 100, 1));
Mock::VerifyAndClearExpectations(&delegate);
}
@@ -100,9 +64,11 @@ TEST(VideoCaptureMessageFilterTest, Delegates) {
IPC::TestSink channel;
filter->OnFilterAdded(&channel);
- StrictMock<MockVideoCaptureDelegate> delegate1;
- StrictMock<MockVideoCaptureDelegate> delegate2;
+ MockVideoCaptureDelegate delegate1;
+ MockVideoCaptureDelegate delegate2;
+ EXPECT_CALL(delegate1, OnDelegateAdded(1));
+ EXPECT_CALL(delegate2, OnDelegateAdded(2));
filter->AddDelegate(&delegate1);
filter->AddDelegate(&delegate2);
ASSERT_EQ(1, delegate1.device_id());

Powered by Google App Engine
This is Rietveld 408576698