Commit 8861028d authored by Vikas Soni's avatar Vikas Soni Committed by Commit Bot

Move MockCodecBufferWaitCoordinator in a separate file.

Move MockCodecBufferWaitCoordinator in a separate file. This will be
helpful in refactoring current media code to merge SurfaceOwner and
TextureOwner which will requires reorganising and moving some files
and unittests to different locations/directories.

Bug: 989344
Change-Id: Ie25bad59174de86b5b4c623c9f94a365becdccce
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1744640Reviewed-by: default avatarThomas Guilbert <tguilbert@chromium.org>
Commit-Queue: vikas soni <vikassoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#685418}
parent 02ff9bf1
......@@ -475,6 +475,8 @@ source_set("android_video_decode_accelerator_unittests") {
"android/mock_abstract_texture.h",
"android/mock_android_video_surface_chooser.cc",
"android/mock_android_video_surface_chooser.h",
"android/mock_codec_buffer_wait_coordinator.cc",
"android/mock_codec_buffer_wait_coordinator.h",
"android/mock_codec_image.cc",
"android/mock_codec_image.h",
"android/mock_device_info.cc",
......
......@@ -15,6 +15,7 @@
#include "media/base/android/mock_media_codec_bridge.h"
#include "media/gpu/android/codec_image.h"
#include "media/gpu/android/mock_abstract_texture.h"
#include "media/gpu/android/mock_codec_buffer_wait_coordinator.h"
#include "media/gpu/android/mock_texture_owner.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
......
// Copyright 2019 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 "media/gpu/android/mock_codec_buffer_wait_coordinator.h"
namespace media {
using testing::Invoke;
using testing::Return;
MockCodecBufferWaitCoordinator::MockCodecBufferWaitCoordinator(
scoped_refptr<NiceMock<MockTextureOwner>> texture_owner)
: CodecBufferWaitCoordinator(texture_owner),
mock_texture_owner(std::move(texture_owner)),
expecting_frame_available(false) {
ON_CALL(*this, texture_owner()).WillByDefault(Return(mock_texture_owner));
ON_CALL(*this, SetReleaseTimeToNow())
.WillByDefault(Invoke(
this, &MockCodecBufferWaitCoordinator::FakeSetReleaseTimeToNow));
ON_CALL(*this, IsExpectingFrameAvailable())
.WillByDefault(Invoke(
this,
&MockCodecBufferWaitCoordinator::FakeIsExpectingFrameAvailable));
ON_CALL(*this, WaitForFrameAvailable())
.WillByDefault(Invoke(
this, &MockCodecBufferWaitCoordinator::FakeWaitForFrameAvailable));
}
MockCodecBufferWaitCoordinator::~MockCodecBufferWaitCoordinator() = default;
} // namespace media
// Copyright 2019 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.
#ifndef MEDIA_GPU_ANDROID_MOCK_CODEC_BUFFER_WAIT_COORDINATOR_H_
#define MEDIA_GPU_ANDROID_MOCK_CODEC_BUFFER_WAIT_COORDINATOR_H_
#include "media/gpu/android/codec_buffer_wait_coordinator.h"
#include "media/gpu/android/mock_texture_owner.h"
namespace media {
// Mock class with mostly fake functions.
class MockCodecBufferWaitCoordinator : public CodecBufferWaitCoordinator {
public:
MockCodecBufferWaitCoordinator(
scoped_refptr<NiceMock<MockTextureOwner>> texture_owner);
MOCK_CONST_METHOD0(texture_owner,
scoped_refptr<NiceMock<MockTextureOwner>>());
MOCK_METHOD0(SetReleaseTimeToNow, void());
MOCK_METHOD0(IsExpectingFrameAvailable, bool());
MOCK_METHOD0(WaitForFrameAvailable, void());
// Fake implementations that the mocks will call by default.
void FakeSetReleaseTimeToNow() { expecting_frame_available = true; }
bool FakeIsExpectingFrameAvailable() { return expecting_frame_available; }
void FakeWaitForFrameAvailable() { expecting_frame_available = false; }
scoped_refptr<NiceMock<MockTextureOwner>> mock_texture_owner;
bool expecting_frame_available;
protected:
~MockCodecBufferWaitCoordinator();
};
} // namespace media
#endif // MEDIA_GPU_ANDROID_MOCK_CODEC_BUFFER_WAIT_COORDINATOR_H_
......@@ -33,25 +33,4 @@ MockTextureOwner::~MockTextureOwner() {
ClearAbstractTexture();
}
MockCodecBufferWaitCoordinator::MockCodecBufferWaitCoordinator(
scoped_refptr<NiceMock<MockTextureOwner>> texture_owner)
: CodecBufferWaitCoordinator(texture_owner),
mock_texture_owner(std::move(texture_owner)),
expecting_frame_available(false) {
ON_CALL(*this, texture_owner()).WillByDefault(Return(mock_texture_owner));
ON_CALL(*this, SetReleaseTimeToNow())
.WillByDefault(Invoke(
this, &MockCodecBufferWaitCoordinator::FakeSetReleaseTimeToNow));
ON_CALL(*this, IsExpectingFrameAvailable())
.WillByDefault(Invoke(
this,
&MockCodecBufferWaitCoordinator::FakeIsExpectingFrameAvailable));
ON_CALL(*this, WaitForFrameAvailable())
.WillByDefault(Invoke(
this, &MockCodecBufferWaitCoordinator::FakeWaitForFrameAvailable));
}
MockCodecBufferWaitCoordinator::~MockCodecBufferWaitCoordinator() = default;
} // namespace media
......@@ -8,7 +8,6 @@
#include <memory>
#include "base/android/scoped_hardware_buffer_fence_sync.h"
#include "media/gpu/android/codec_buffer_wait_coordinator.h"
#include "media/gpu/android/texture_owner.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
......@@ -54,30 +53,6 @@ class MockTextureOwner : public TextureOwner {
~MockTextureOwner();
};
// Mock class with mostly fake functions.
class MockCodecBufferWaitCoordinator : public CodecBufferWaitCoordinator {
public:
MockCodecBufferWaitCoordinator(
scoped_refptr<NiceMock<MockTextureOwner>> texture_owner);
MOCK_CONST_METHOD0(texture_owner,
scoped_refptr<NiceMock<MockTextureOwner>>());
MOCK_METHOD0(SetReleaseTimeToNow, void());
MOCK_METHOD0(IsExpectingFrameAvailable, bool());
MOCK_METHOD0(WaitForFrameAvailable, void());
// Fake implementations that the mocks will call by default.
void FakeSetReleaseTimeToNow() { expecting_frame_available = true; }
bool FakeIsExpectingFrameAvailable() { return expecting_frame_available; }
void FakeWaitForFrameAvailable() { expecting_frame_available = false; }
scoped_refptr<NiceMock<MockTextureOwner>> mock_texture_owner;
bool expecting_frame_available;
protected:
~MockCodecBufferWaitCoordinator();
};
} // namespace media
#endif // MEDIA_GPU_ANDROID_MOCK_TEXTURE_OWNER_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment