Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(505)

Side by Side Diff: media/filters/ffmpeg_glue_unittest.cc

Issue 1904213003: Convert //media/filters from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/filters/ffmpeg_glue.h"
6
5 #include <stdint.h> 7 #include <stdint.h>
6 8
9 #include <memory>
10
7 #include "base/logging.h" 11 #include "base/logging.h"
8 #include "base/macros.h" 12 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "media/base/mock_filters.h" 13 #include "media/base/mock_filters.h"
11 #include "media/base/test_data_util.h" 14 #include "media/base/test_data_util.h"
12 #include "media/ffmpeg/ffmpeg_common.h" 15 #include "media/ffmpeg/ffmpeg_common.h"
13 #include "media/filters/ffmpeg_glue.h"
14 #include "media/filters/in_memory_url_protocol.h" 16 #include "media/filters/in_memory_url_protocol.h"
15 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
16 18
17 using ::testing::_; 19 using ::testing::_;
18 using ::testing::DoAll; 20 using ::testing::DoAll;
19 using ::testing::InSequence; 21 using ::testing::InSequence;
20 using ::testing::Return; 22 using ::testing::Return;
21 using ::testing::SetArgumentPointee; 23 using ::testing::SetArgumentPointee;
22 using ::testing::StrictMock; 24 using ::testing::StrictMock;
23 25
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 int ReadPacket(int size, uint8_t* data) { 62 int ReadPacket(int size, uint8_t* data) {
61 return glue_->format_context()->pb->read_packet( 63 return glue_->format_context()->pb->read_packet(
62 protocol_.get(), data, size); 64 protocol_.get(), data, size);
63 } 65 }
64 66
65 int64_t Seek(int64_t offset, int whence) { 67 int64_t Seek(int64_t offset, int whence) {
66 return glue_->format_context()->pb->seek(protocol_.get(), offset, whence); 68 return glue_->format_context()->pb->seek(protocol_.get(), offset, whence);
67 } 69 }
68 70
69 protected: 71 protected:
70 scoped_ptr<FFmpegGlue> glue_; 72 std::unique_ptr<FFmpegGlue> glue_;
71 scoped_ptr< StrictMock<MockProtocol> > protocol_; 73 std::unique_ptr<StrictMock<MockProtocol>> protocol_;
72 74
73 private: 75 private:
74 DISALLOW_COPY_AND_ASSIGN(FFmpegGlueTest); 76 DISALLOW_COPY_AND_ASSIGN(FFmpegGlueTest);
75 }; 77 };
76 78
77 class FFmpegGlueDestructionTest : public ::testing::Test { 79 class FFmpegGlueDestructionTest : public ::testing::Test {
78 public: 80 public:
79 FFmpegGlueDestructionTest() {} 81 FFmpegGlueDestructionTest() {}
80 82
81 void Initialize(const char* filename) { 83 void Initialize(const char* filename) {
(...skipping 12 matching lines...) Expand all
94 96
95 // |glue_| should be destroyed before |protocol_|. 97 // |glue_| should be destroyed before |protocol_|.
96 glue_.reset(); 98 glue_.reset();
97 99
98 // |protocol_| should be destroyed before |data_|. 100 // |protocol_| should be destroyed before |data_|.
99 protocol_.reset(); 101 protocol_.reset();
100 data_ = NULL; 102 data_ = NULL;
101 } 103 }
102 104
103 protected: 105 protected:
104 scoped_ptr<FFmpegGlue> glue_; 106 std::unique_ptr<FFmpegGlue> glue_;
105 107
106 private: 108 private:
107 scoped_ptr<InMemoryUrlProtocol> protocol_; 109 std::unique_ptr<InMemoryUrlProtocol> protocol_;
108 scoped_refptr<DecoderBuffer> data_; 110 scoped_refptr<DecoderBuffer> data_;
109 111
110 DISALLOW_COPY_AND_ASSIGN(FFmpegGlueDestructionTest); 112 DISALLOW_COPY_AND_ASSIGN(FFmpegGlueDestructionTest);
111 }; 113 };
112 114
113 // Ensure writing has been disabled. 115 // Ensure writing has been disabled.
114 TEST_F(FFmpegGlueTest, Write) { 116 TEST_F(FFmpegGlueTest, Write) {
115 ASSERT_FALSE(glue_->format_context()->pb->write_packet); 117 ASSERT_FALSE(glue_->format_context()->pb->write_packet);
116 ASSERT_FALSE(glue_->format_context()->pb->write_flag); 118 ASSERT_FALSE(glue_->format_context()->pb->write_flag);
117 } 119 }
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 ASSERT_GT(glue_->format_context()->nb_streams, 0u); 241 ASSERT_GT(glue_->format_context()->nb_streams, 0u);
240 242
241 // Pick the audio stream (1) so this works when the ffmpeg video decoders are 243 // Pick the audio stream (1) so this works when the ffmpeg video decoders are
242 // disabled. 244 // disabled.
243 AVCodecContext* context = glue_->format_context()->streams[1]->codec; 245 AVCodecContext* context = glue_->format_context()->streams[1]->codec;
244 ASSERT_EQ(0, avcodec_open2( 246 ASSERT_EQ(0, avcodec_open2(
245 context, avcodec_find_decoder(context->codec_id), NULL)); 247 context, avcodec_find_decoder(context->codec_id), NULL));
246 } 248 }
247 249
248 } // namespace media 250 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698