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

Unified Diff: media/formats/webm/webm_content_encodings_client_unittest.cc

Issue 1300943002: MSE: Verify MediaLog events created by existing WebM unit tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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: media/formats/webm/webm_content_encodings_client_unittest.cc
diff --git a/media/formats/webm/webm_content_encodings_client_unittest.cc b/media/formats/webm/webm_content_encodings_client_unittest.cc
index 22049ebfce74ec0bf1faaa84132342de180a3a7f..b5f2b7e3713fe798bc08a6f98dec99fdba37866c 100644
--- a/media/formats/webm/webm_content_encodings_client_unittest.cc
+++ b/media/formats/webm/webm_content_encodings_client_unittest.cc
@@ -2,18 +2,58 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "media/formats/webm/webm_content_encodings_client.h"
+
+#include <string>
+
#include "base/bind.h"
+#include "base/strings/string_number_conversions.h"
+#include "media/base/mock_media_log.h"
#include "media/formats/webm/webm_constants.h"
-#include "media/formats/webm/webm_content_encodings_client.h"
#include "media/formats/webm/webm_parser.h"
+#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
+using ::testing::StrictMock;
+
namespace media {
+// Matchers for verifying common media log entry strings.
+#define CONTAINS_STRING(arg, x) (std::string::npos != (arg).find(x))
+
+MATCHER(MissingContentEncoding, "") {
+ return CONTAINS_STRING(arg, "Missing ContentEncoding.");
+}
+
+MATCHER(UnexpectedContentEncodingOrder, "") {
+ return CONTAINS_STRING(arg, "Unexpected ContentEncodingOrder.");
+}
+
+MATCHER(UnexpectedContentEncodingScope, "") {
+ return CONTAINS_STRING(arg, "Unexpected ContentEncodingScope.");
+}
+
+MATCHER(ContentCompressionNotSupported, "") {
+ return CONTAINS_STRING(arg, "ContentCompression not supported.");
+}
+
+MATCHER(MissingContentEncryption, "") {
+ return CONTAINS_STRING(
+ arg,
+ "ContentEncodingType is encryption but ContentEncryption is missing.");
+}
+
+MATCHER_P(UnexpectedContentEncAlgo, algo, "") {
+ return CONTAINS_STRING(
+ arg, "Unexpected ContentEncAlgo " + base::IntToString(algo) + ".");
+}
+
class WebMContentEncodingsClientTest : public testing::Test {
public:
WebMContentEncodingsClientTest()
- : client_(new MediaLog()), parser_(kWebMIdContentEncodings, &client_) {}
+ : media_log_(new StrictMock<MockMediaLog>()),
+ client_(media_log_),
+ parser_(kWebMIdContentEncodings, &client_) {}
void ParseAndExpectToFail(const uint8* buf, int size) {
int result = parser_.Parse(buf, size);
@@ -21,6 +61,7 @@ class WebMContentEncodingsClientTest : public testing::Test {
}
protected:
+ scoped_refptr<StrictMock<MockMediaLog>> media_log_;
WebMContentEncodingsClient client_;
WebMListParser parser_;
};
@@ -30,6 +71,7 @@ TEST_F(WebMContentEncodingsClientTest, EmptyContentEncodings) {
0x6D, 0x80, 0x80, // ContentEncodings (size = 0)
};
int size = sizeof(kContentEncodings);
+ EXPECT_MEDIA_LOG_STRING(MissingContentEncoding());
xhwang 2015/08/19 00:25:05 nit: hmm, can we just use EXPECT_MEDIA_LOG() which
wolenetz 2015/08/24 19:34:02 SGTM. Done. In this CL, I also responded to depend
ParseAndExpectToFail(kContentEncodings, size);
}
@@ -182,6 +224,7 @@ TEST_F(WebMContentEncodingsClientTest, InvalidContentEncodingOrder) {
0x50, 0x35, 0x80, // ContentEncryption (size = 0)
};
int size = sizeof(kContentEncodings);
+ EXPECT_MEDIA_LOG_STRING(UnexpectedContentEncodingOrder());
ParseAndExpectToFail(kContentEncodings, size);
}
@@ -194,6 +237,7 @@ TEST_F(WebMContentEncodingsClientTest, InvalidContentEncodingScope) {
0x50, 0x35, 0x80, // ContentEncryption (size = 0)
};
int size = sizeof(kContentEncodings);
+ EXPECT_MEDIA_LOG_STRING(UnexpectedContentEncodingScope());
ParseAndExpectToFail(kContentEncodings, size);
}
@@ -205,6 +249,7 @@ TEST_F(WebMContentEncodingsClientTest, InvalidContentEncodingType) {
0x50, 0x35, 0x80, // ContentEncryption (size = 0)
};
int size = sizeof(kContentEncodings);
+ EXPECT_MEDIA_LOG_STRING(ContentCompressionNotSupported());
ParseAndExpectToFail(kContentEncodings, size);
}
@@ -217,6 +262,7 @@ TEST_F(WebMContentEncodingsClientTest, MissingContentEncryption) {
// ContentEncryption missing
};
int size = sizeof(kContentEncodings);
+ EXPECT_MEDIA_LOG_STRING(MissingContentEncryption());
ParseAndExpectToFail(kContentEncodings, size);
}
@@ -231,6 +277,7 @@ TEST_F(WebMContentEncodingsClientTest, InvalidContentEncAlgo) {
0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
};
int size = sizeof(kContentEncodings);
+ EXPECT_MEDIA_LOG_STRING(UnexpectedContentEncAlgo(0xEE));
ParseAndExpectToFail(kContentEncodings, size);
}

Powered by Google App Engine
This is Rietveld 408576698