summaryrefslogtreecommitdiff
path: root/chromium/media/gpu/chromeos/mailbox_video_frame_converter_unittest.cc
blob: bb4a1791a09254f68f794078d9ebf7ddf542a8a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// 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/chromeos/mailbox_video_frame_converter.h"

#include "base/bind.h"
#include "base/test/task_environment.h"
#include "base/threading/thread_task_runner_handle.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

using ::testing::_;

namespace media {

namespace {

VideoFrame* UnwrapVideoFrame(const VideoFrame& frame) {
  return const_cast<VideoFrame*>(&frame);
}

base::WeakPtr<gpu::GpuChannel> GetGpuChannel() {
  return nullptr;
}

}  // anonymous namespace

class MailboxVideoFrameConverterTest : public testing::Test {
 public:
  MailboxVideoFrameConverterTest()
      : converter_(new MailboxVideoFrameConverter(
            base::BindRepeating(&UnwrapVideoFrame),
            base::ThreadTaskRunnerHandle::Get(),
            base::BindRepeating(&GetGpuChannel))) {}

  MailboxVideoFrameConverterTest(const MailboxVideoFrameConverterTest&) =
      delete;
  MailboxVideoFrameConverterTest& operator=(
      const MailboxVideoFrameConverterTest&) = delete;

  ~MailboxVideoFrameConverterTest() override = default;

  void TearDown() override {
    // |converter_| might have created resources that need to be cleaned up.
    converter_.reset();
    task_environment_.RunUntilIdle();
  }

  MOCK_METHOD1(OutputCB, void(scoped_refptr<VideoFrame>));

  base::test::TaskEnvironment task_environment_;

  std::unique_ptr<VideoFrameConverter> converter_;
};

TEST_F(MailboxVideoFrameConverterTest, Initialize) {
  EXPECT_CALL(*this, OutputCB(_)).Times(0);
  converter_->Initialize(
      base::ThreadTaskRunnerHandle::Get(),
      base::BindRepeating(&MailboxVideoFrameConverterTest::OutputCB,
                          base::Unretained(this)));
  EXPECT_FALSE(converter_->HasPendingFrames());
}

}  // namespace media