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/void_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/id.h"
16 #include "webm/status.h"
17
18 using testing::NotNull;
19
20 using webm::ElementParserTest;
21 using webm::Id;
22 using webm::kUnknownElementSize;
23 using webm::Status;
24 using webm::VoidParser;
25
26 namespace {
27
28 class VoidParserTest : public ElementParserTest<VoidParser, Id::kVoid> {};
29
TEST_F(VoidParserTest,InvalidSize)30 TEST_F(VoidParserTest, InvalidSize) {
31 TestInit(kUnknownElementSize, Status::kInvalidElementSize);
32 }
33
TEST_F(VoidParserTest,Empty)34 TEST_F(VoidParserTest, Empty) {
35 EXPECT_CALL(callback_, OnVoid(metadata_, NotNull(), NotNull())).Times(1);
36
37 ParseAndVerify();
38 }
39
TEST_F(VoidParserTest,Valid)40 TEST_F(VoidParserTest, Valid) {
41 SetReaderData({0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07});
42
43 EXPECT_CALL(callback_, OnVoid(metadata_, NotNull(), NotNull())).Times(1);
44
45 ParseAndVerify();
46 }
47
TEST_F(VoidParserTest,IncrementalParse)48 TEST_F(VoidParserTest, IncrementalParse) {
49 SetReaderData({0x00, 0x01, 0x02, 0x03});
50
51 EXPECT_CALL(callback_, OnVoid(metadata_, NotNull(), NotNull())).Times(4);
52
53 IncrementalParseAndVerify();
54 }
55
56 } // namespace
57