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/edition_entry_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/id.h"
15
16 using webm::ChapterAtom;
17 using webm::EditionEntry;
18 using webm::EditionEntryParser;
19 using webm::ElementParserTest;
20 using webm::Id;
21
22 namespace {
23
24 class EditionEntryParserTest
25 : public ElementParserTest<EditionEntryParser, Id::kEditionEntry> {};
26
TEST_F(EditionEntryParserTest,DefaultParse)27 TEST_F(EditionEntryParserTest, DefaultParse) {
28 EXPECT_CALL(callback_, OnEditionEntry(metadata_, EditionEntry{})).Times(1);
29
30 ParseAndVerify();
31 }
32
TEST_F(EditionEntryParserTest,DefaultValues)33 TEST_F(EditionEntryParserTest, DefaultValues) {
34 SetReaderData({
35 0xB6, // ID = 0xB6 (ChapterAtom).
36 0x80, // Size = 0.
37 });
38
39 EditionEntry edition_entry;
40 edition_entry.atoms.emplace_back();
41 edition_entry.atoms[0].Set({}, true);
42
43 EXPECT_CALL(callback_, OnEditionEntry(metadata_, edition_entry)).Times(1);
44
45 ParseAndVerify();
46 }
47
TEST_F(EditionEntryParserTest,CustomValues)48 TEST_F(EditionEntryParserTest, CustomValues) {
49 SetReaderData({
50 0xB6, // ID = 0xB6 (ChapterAtom).
51 0x40, 0x04, // Size = 4.
52
53 0x73, 0xC4, // ID = 0x73C4 (ChapterUID).
54 0x81, // Size = 1.
55 0x01, // Body (value = 1).
56
57 0xB6, // ID = 0xB6 (ChapterAtom).
58 0x40, 0x04, // Size = 4.
59
60 0x73, 0xC4, // ID = 0x73C4 (ChapterUID).
61 0x81, // Size = 1.
62 0x02, // Body (value = 2).
63 });
64
65 EditionEntry edition_entry;
66 ChapterAtom chapter_atom;
67 chapter_atom.uid.Set(1, true);
68 edition_entry.atoms.emplace_back(chapter_atom, true);
69 chapter_atom.uid.Set(2, true);
70 edition_entry.atoms.emplace_back(chapter_atom, true);
71
72 EXPECT_CALL(callback_, OnEditionEntry(metadata_, edition_entry)).Times(1);
73
74 ParseAndVerify();
75 }
76
77 } // namespace
78