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

Side by Side Diff: media/base/data_buffer_unittest.cc

Issue 1906423005: Replace scoped_ptr with std::unique_ptr in //media/base. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scopedptr-media-base: android Created 4 years, 7 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
« no previous file with comments | « media/base/data_buffer.cc ('k') | media/base/decoder_buffer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/base/data_buffer.h" 5 #include "media/base/data_buffer.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <memory>
8 #include <utility> 9 #include <utility>
9 10
10 #include "base/macros.h" 11 #include "base/macros.h"
11 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.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 16
16 TEST(DataBufferTest, Constructor_ZeroSize) { 17 TEST(DataBufferTest, Constructor_ZeroSize) {
17 // Zero-sized buffers are valid. In practice they aren't used very much but it 18 // Zero-sized buffers are valid. In practice they aren't used very much but it
(...skipping 10 matching lines...) Expand all
28 scoped_refptr<DataBuffer> buffer = new DataBuffer(10); 29 scoped_refptr<DataBuffer> buffer = new DataBuffer(10);
29 EXPECT_TRUE(buffer->data()); 30 EXPECT_TRUE(buffer->data());
30 EXPECT_TRUE(buffer->writable_data()); 31 EXPECT_TRUE(buffer->writable_data());
31 EXPECT_EQ(0, buffer->data_size()); 32 EXPECT_EQ(0, buffer->data_size());
32 EXPECT_FALSE(buffer->end_of_stream()); 33 EXPECT_FALSE(buffer->end_of_stream());
33 } 34 }
34 35
35 TEST(DataBufferTest, Constructor_ScopedArray) { 36 TEST(DataBufferTest, Constructor_ScopedArray) {
36 // Data should be passed and both data and buffer size should be set. 37 // Data should be passed and both data and buffer size should be set.
37 const int kSize = 8; 38 const int kSize = 8;
38 scoped_ptr<uint8_t[]> data(new uint8_t[kSize]); 39 std::unique_ptr<uint8_t[]> data(new uint8_t[kSize]);
39 const uint8_t* kData = data.get(); 40 const uint8_t* kData = data.get();
40 41
41 scoped_refptr<DataBuffer> buffer = new DataBuffer(std::move(data), kSize); 42 scoped_refptr<DataBuffer> buffer = new DataBuffer(std::move(data), kSize);
42 EXPECT_TRUE(buffer->data()); 43 EXPECT_TRUE(buffer->data());
43 EXPECT_TRUE(buffer->writable_data()); 44 EXPECT_TRUE(buffer->writable_data());
44 EXPECT_EQ(kData, buffer->data()); 45 EXPECT_EQ(kData, buffer->data());
45 EXPECT_EQ(kSize, buffer->data_size()); 46 EXPECT_EQ(kSize, buffer->data_size());
46 EXPECT_FALSE(buffer->end_of_stream()); 47 EXPECT_FALSE(buffer->end_of_stream());
47 } 48 }
48 49
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 ASSERT_TRUE(data); 121 ASSERT_TRUE(data);
121 memcpy(data, kNewData, kNewDataSize); 122 memcpy(data, kNewData, kNewDataSize);
122 buffer2->set_data_size(kNewDataSize); 123 buffer2->set_data_size(kNewDataSize);
123 read_only_data = buffer2->data(); 124 read_only_data = buffer2->data();
124 EXPECT_EQ(kNewDataSize, buffer2->data_size()); 125 EXPECT_EQ(kNewDataSize, buffer2->data_size());
125 ASSERT_EQ(data, read_only_data); 126 ASSERT_EQ(data, read_only_data);
126 EXPECT_EQ(0, memcmp(read_only_data, kNewData, kNewDataSize)); 127 EXPECT_EQ(0, memcmp(read_only_data, kNewData, kNewDataSize));
127 } 128 }
128 129
129 } // namespace media 130 } // namespace media
OLDNEW
« no previous file with comments | « media/base/data_buffer.cc ('k') | media/base/decoder_buffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698