| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/formats/mp4/sample_to_group_iterator.h" | 5 #include "media/formats/mp4/sample_to_group_iterator.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> |
| 11 |
| 10 #include "base/macros.h" | 12 #include "base/macros.h" |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 14 |
| 14 namespace media { | 15 namespace media { |
| 15 namespace mp4 { | 16 namespace mp4 { |
| 16 | 17 |
| 17 namespace { | 18 namespace { |
| 18 const SampleToGroupEntry kCompactSampleToGroupTable[] = | 19 const SampleToGroupEntry kCompactSampleToGroupTable[] = |
| 19 {{10, 8}, {9, 5}, {25, 7}, {48, 63}, {8, 2}}; | 20 {{10, 8}, {9, 5}, {25, 7}, {48, 63}, {8, 2}}; |
| 20 } // namespace | 21 } // namespace |
| 21 | 22 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 34 sample_to_group_.entries.assign( | 35 sample_to_group_.entries.assign( |
| 35 kCompactSampleToGroupTable, | 36 kCompactSampleToGroupTable, |
| 36 kCompactSampleToGroupTable + arraysize(kCompactSampleToGroupTable)); | 37 kCompactSampleToGroupTable + arraysize(kCompactSampleToGroupTable)); |
| 37 sample_to_group_iterator_.reset( | 38 sample_to_group_iterator_.reset( |
| 38 new SampleToGroupIterator(sample_to_group_)); | 39 new SampleToGroupIterator(sample_to_group_)); |
| 39 } | 40 } |
| 40 | 41 |
| 41 protected: | 42 protected: |
| 42 std::vector<uint32_t> sample_to_group_table_; | 43 std::vector<uint32_t> sample_to_group_table_; |
| 43 SampleToGroup sample_to_group_; | 44 SampleToGroup sample_to_group_; |
| 44 scoped_ptr<SampleToGroupIterator> sample_to_group_iterator_; | 45 std::unique_ptr<SampleToGroupIterator> sample_to_group_iterator_; |
| 45 | 46 |
| 46 private: | 47 private: |
| 47 DISALLOW_COPY_AND_ASSIGN(SampleToGroupIteratorTest); | 48 DISALLOW_COPY_AND_ASSIGN(SampleToGroupIteratorTest); |
| 48 }; | 49 }; |
| 49 | 50 |
| 50 TEST_F(SampleToGroupIteratorTest, EmptyTable) { | 51 TEST_F(SampleToGroupIteratorTest, EmptyTable) { |
| 51 SampleToGroup sample_to_group; | 52 SampleToGroup sample_to_group; |
| 52 SampleToGroupIterator iterator(sample_to_group); | 53 SampleToGroupIterator iterator(sample_to_group); |
| 53 EXPECT_FALSE(iterator.IsValid()); | 54 EXPECT_FALSE(iterator.IsValid()); |
| 54 } | 55 } |
| 55 | 56 |
| 56 TEST_F(SampleToGroupIteratorTest, Advance) { | 57 TEST_F(SampleToGroupIteratorTest, Advance) { |
| 57 ASSERT_EQ(sample_to_group_table_[0], | 58 ASSERT_EQ(sample_to_group_table_[0], |
| 58 sample_to_group_iterator_->group_description_index()); | 59 sample_to_group_iterator_->group_description_index()); |
| 59 for (uint32_t sample = 1; sample < sample_to_group_table_.size(); ++sample) { | 60 for (uint32_t sample = 1; sample < sample_to_group_table_.size(); ++sample) { |
| 60 ASSERT_TRUE(sample_to_group_iterator_->Advance()); | 61 ASSERT_TRUE(sample_to_group_iterator_->Advance()); |
| 61 ASSERT_EQ(sample_to_group_table_[sample], | 62 ASSERT_EQ(sample_to_group_table_[sample], |
| 62 sample_to_group_iterator_->group_description_index()); | 63 sample_to_group_iterator_->group_description_index()); |
| 63 ASSERT_TRUE(sample_to_group_iterator_->IsValid()); | 64 ASSERT_TRUE(sample_to_group_iterator_->IsValid()); |
| 64 } | 65 } |
| 65 ASSERT_FALSE(sample_to_group_iterator_->Advance()); | 66 ASSERT_FALSE(sample_to_group_iterator_->Advance()); |
| 66 ASSERT_FALSE(sample_to_group_iterator_->IsValid()); | 67 ASSERT_FALSE(sample_to_group_iterator_->IsValid()); |
| 67 } | 68 } |
| 68 | 69 |
| 69 } // namespace mp4 | 70 } // namespace mp4 |
| 70 } // namespace media | 71 } // namespace media |
| OLD | NEW |