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/seek_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::ElementParserTest;
17 using webm::Id;
18 using webm::Seek;
19 using webm::SeekParser;
20
21 namespace {
22
23 class SeekParserTest : public ElementParserTest<SeekParser, Id::kSeek> {};
24
TEST_F(SeekParserTest,DefaultParse)25 TEST_F(SeekParserTest, DefaultParse) {
26 EXPECT_CALL(callback_, OnSeek(metadata_, Seek{})).Times(1);
27
28 ParseAndVerify();
29 }
30
TEST_F(SeekParserTest,DefaultValues)31 TEST_F(SeekParserTest, DefaultValues) {
32 SetReaderData({
33 // A SeekID element with a length of 0 isn't valid, so we don't test it.
34
35 0x53, 0xAC, // ID = 0x53AC (SeekPosition).
36 0x80, // Size = 0.
37 });
38
39 Seek seek;
40 seek.position.Set(0, true);
41
42 EXPECT_CALL(callback_, OnSeek(metadata_, seek)).Times(1);
43
44 ParseAndVerify();
45 }
46
TEST_F(SeekParserTest,CustomValues)47 TEST_F(SeekParserTest, CustomValues) {
48 SetReaderData({
49 0x53, 0xAB, // ID = 0x53AB (SeekID).
50 0x81, // Size = 1.
51 0x01, // Body.
52
53 0x53, 0xAC, // ID = 0x53AC (SeekPosition).
54 0x81, // Size = 1.
55 0x02, // Body (value = 2).
56 });
57
58 Seek seek;
59 seek.id.Set(static_cast<Id>(0x01), true);
60 seek.position.Set(2, true);
61
62 EXPECT_CALL(callback_, OnSeek(metadata_, seek)).Times(1);
63
64 ParseAndVerify();
65 }
66
67 } // namespace
68