Commit bdd7d1be authored by Wan-Teh Chang's avatar Wan-Teh Chang Committed by Commit Bot

Put decoder error log MATCHER in unnamed namespace

Put MATCHER(ContainsDecoderErrorLog, "") in the unnamed namespace.
aom_video_decoder_unittest.cc, dav1d_video_decoder_unittest.cc, and
gav1_video_decoder_unittest.cc all have a MATCHER class with this name.
Putting them in the unnamed namespace avoids name conflicts. Strangely,
the linker did not warn about duplicate symbols.

Include <memory> and <utility> in aom_video_decoder_unittest.cc and
gav1_video_decoder_unittest.cc.

Use the correct base::Bind variants (Repeating or Once) for the OutputCB
and DecodeCB callbacks.

  $ gn args out/Default
  # In the editor, add the following lines:
  # enable_libgav1_decoder = true
  # enable_libaom_decoder = true
  $ autoninja -C out/Default media_unittests
  $ out/Default/media_unittests

Tested: 
Change-Id: I535ba5847717b736074bf7a29ffae1e897fd0acb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2081243
Commit-Queue: Wan-Teh Chang <wtc@google.com>
Reviewed-by: default avatarDale Curtis <dalecurtis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#746121}
parent 7a166102
...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include <memory>
#include <string> #include <string>
#include <utility>
#include <vector> #include <vector>
#include "base/bind.h" #include "base/bind.h"
...@@ -25,10 +27,14 @@ using ::testing::_; ...@@ -25,10 +27,14 @@ using ::testing::_;
namespace media { namespace media {
namespace {
MATCHER(ContainsDecoderErrorLog, "") { MATCHER(ContainsDecoderErrorLog, "") {
return CONTAINS_STRING(arg, "aom_codec_decode() failed"); return CONTAINS_STRING(arg, "aom_codec_decode() failed");
} }
} // namespace
class AomVideoDecoderTest : public testing::Test { class AomVideoDecoderTest : public testing::Test {
public: public:
AomVideoDecoderTest() AomVideoDecoderTest()
...@@ -43,10 +49,10 @@ class AomVideoDecoderTest : public testing::Test { ...@@ -43,10 +49,10 @@ class AomVideoDecoderTest : public testing::Test {
void InitializeWithConfigWithResult(const VideoDecoderConfig& config, void InitializeWithConfigWithResult(const VideoDecoderConfig& config,
bool success) { bool success) {
decoder_->Initialize( decoder_->Initialize(config, false, nullptr, NewExpectedBoolCB(success),
config, false, nullptr, NewExpectedBoolCB(success), base::BindRepeating(&AomVideoDecoderTest::FrameReady,
base::Bind(&AomVideoDecoderTest::FrameReady, base::Unretained(this)), base::Unretained(this)),
base::NullCallback()); base::NullCallback());
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
} }
...@@ -147,9 +153,9 @@ class AomVideoDecoderTest : public testing::Test { ...@@ -147,9 +153,9 @@ class AomVideoDecoderTest : public testing::Test {
DecodeStatus status; DecodeStatus status;
EXPECT_CALL(*this, DecodeDone(_)).WillOnce(testing::SaveArg<0>(&status)); EXPECT_CALL(*this, DecodeDone(_)).WillOnce(testing::SaveArg<0>(&status));
decoder_->Decode( decoder_->Decode(std::move(buffer),
std::move(buffer), base::BindOnce(&AomVideoDecoderTest::DecodeDone,
base::Bind(&AomVideoDecoderTest::DecodeDone, base::Unretained(this))); base::Unretained(this)));
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
return status; return status;
......
...@@ -27,14 +27,14 @@ using ::testing::_; ...@@ -27,14 +27,14 @@ using ::testing::_;
namespace media { namespace media {
// TODO(dalecurtis): There is some weird collision going on with this matcher namespace {
// and the one defined in the AomVideoDecoder unittest. Somehow only one ends
// up in the final binary so one test or the other will fail. To workaround this MATCHER(ContainsDecoderErrorLog, "") {
// give it a unique name for now...
MATCHER(ContainsDav1dDecoderErrorLog, "") {
return CONTAINS_STRING(arg, "dav1d_get_picture() failed"); return CONTAINS_STRING(arg, "dav1d_get_picture() failed");
} }
} // namespace
class Dav1dVideoDecoderTest : public testing::Test { class Dav1dVideoDecoderTest : public testing::Test {
public: public:
Dav1dVideoDecoderTest() Dav1dVideoDecoderTest()
...@@ -156,8 +156,8 @@ class Dav1dVideoDecoderTest : public testing::Test { ...@@ -156,8 +156,8 @@ class Dav1dVideoDecoderTest : public testing::Test {
EXPECT_CALL(*this, DecodeDone(_)).WillOnce(testing::SaveArg<0>(&status)); EXPECT_CALL(*this, DecodeDone(_)).WillOnce(testing::SaveArg<0>(&status));
decoder_->Decode(std::move(buffer), decoder_->Decode(std::move(buffer),
base::BindRepeating(&Dav1dVideoDecoderTest::DecodeDone, base::BindOnce(&Dav1dVideoDecoderTest::DecodeDone,
base::Unretained(this))); base::Unretained(this)));
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
return status; return status;
...@@ -222,7 +222,7 @@ TEST_F(Dav1dVideoDecoderTest, DISABLED_DecodeFrame_LargerWidth) { ...@@ -222,7 +222,7 @@ TEST_F(Dav1dVideoDecoderTest, DISABLED_DecodeFrame_LargerWidth) {
// Decode a VP9 frame which should trigger a decoder error. // Decode a VP9 frame which should trigger a decoder error.
TEST_F(Dav1dVideoDecoderTest, DecodeFrame_Error) { TEST_F(Dav1dVideoDecoderTest, DecodeFrame_Error) {
Initialize(); Initialize();
EXPECT_MEDIA_LOG(ContainsDav1dDecoderErrorLog()); EXPECT_MEDIA_LOG(ContainsDecoderErrorLog());
DecodeSingleFrame(ReadTestDataFile("vp9-I-frame-320x240")); DecodeSingleFrame(ReadTestDataFile("vp9-I-frame-320x240"));
} }
......
...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include <memory>
#include <string> #include <string>
#include <utility>
#include <vector> #include <vector>
#include "base/bind.h" #include "base/bind.h"
...@@ -25,10 +27,14 @@ using ::testing::_; ...@@ -25,10 +27,14 @@ using ::testing::_;
namespace media { namespace media {
namespace {
MATCHER(ContainsDecoderErrorLog, "") { MATCHER(ContainsDecoderErrorLog, "") {
return CONTAINS_STRING(arg, "libgav1::Decoder::DequeueFrame failed"); return CONTAINS_STRING(arg, "libgav1::Decoder::DequeueFrame failed");
} }
} // namespace
class Gav1VideoDecoderTest : public testing::Test { class Gav1VideoDecoderTest : public testing::Test {
public: public:
Gav1VideoDecoderTest() Gav1VideoDecoderTest()
...@@ -43,10 +49,10 @@ class Gav1VideoDecoderTest : public testing::Test { ...@@ -43,10 +49,10 @@ class Gav1VideoDecoderTest : public testing::Test {
void InitializeWithConfigWithResult(const VideoDecoderConfig& config, void InitializeWithConfigWithResult(const VideoDecoderConfig& config,
bool success) { bool success) {
decoder_->Initialize( decoder_->Initialize(config, false, nullptr, NewExpectedBoolCB(success),
config, false, nullptr, NewExpectedBoolCB(success), base::BindRepeating(&Gav1VideoDecoderTest::FrameReady,
base::Bind(&Gav1VideoDecoderTest::FrameReady, base::Unretained(this)), base::Unretained(this)),
base::NullCallback()); base::NullCallback());
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
} }
...@@ -147,9 +153,9 @@ class Gav1VideoDecoderTest : public testing::Test { ...@@ -147,9 +153,9 @@ class Gav1VideoDecoderTest : public testing::Test {
DecodeStatus status; DecodeStatus status;
EXPECT_CALL(*this, DecodeDone(_)).WillOnce(testing::SaveArg<0>(&status)); EXPECT_CALL(*this, DecodeDone(_)).WillOnce(testing::SaveArg<0>(&status));
decoder_->Decode( decoder_->Decode(std::move(buffer),
std::move(buffer), base::BindOnce(&Gav1VideoDecoderTest::DecodeDone,
base::Bind(&Gav1VideoDecoderTest::DecodeDone, base::Unretained(this))); base::Unretained(this)));
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
return status; return status;
......
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