1 // Copyright (c) 2016 The WebM project authors. All Rights Reserved.
2 //
3 // Use of this source code is governed by a BSD-style license
4 // that can be found in the LICENSE file in the root of the source
5 // tree. An additional intellectual property rights grant can be found
6 // in the file PATENTS.  All contributing project authors may
7 // be found in the AUTHORS file in the root of the source tree.
8 #include "src/unknown_parser.h"
9 
10 #include "gmock/gmock.h"
11 #include "gtest/gtest.h"
12 
13 #include "test_utils/element_parser_test.h"
14 #include "webm/element.h"
15 #include "webm/status.h"
16 
17 using testing::NotNull;
18 
19 using webm::ElementParserTest;
20 using webm::kUnknownElementSize;
21 using webm::Status;
22 using webm::UnknownParser;
23 
24 namespace {
25 
26 class UnknownParserTest : public ElementParserTest<UnknownParser> {};
27 
TEST_F(UnknownParserTest,InvalidSize)28 TEST_F(UnknownParserTest, InvalidSize) {
29   TestInit(kUnknownElementSize, Status::kIndefiniteUnknownElement);
30 }
31 
TEST_F(UnknownParserTest,Empty)32 TEST_F(UnknownParserTest, Empty) {
33   EXPECT_CALL(callback_, OnUnknownElement(metadata_, NotNull(), NotNull()))
34       .Times(1);
35 
36   ParseAndVerify();
37 }
38 
TEST_F(UnknownParserTest,Valid)39 TEST_F(UnknownParserTest, Valid) {
40   SetReaderData({0x00, 0x01, 0x02, 0x04});
41 
42   EXPECT_CALL(callback_, OnUnknownElement(metadata_, NotNull(), NotNull()))
43       .Times(1);
44 
45   ParseAndVerify();
46 }
47 
TEST_F(UnknownParserTest,IncrementalSkip)48 TEST_F(UnknownParserTest, IncrementalSkip) {
49   SetReaderData({0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x10});
50 
51   EXPECT_CALL(callback_, OnUnknownElement(metadata_, NotNull(), NotNull()))
52       .Times(8);
53 
54   IncrementalParseAndVerify();
55 }
56 
57 }  // namespace
58