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

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

Issue 1544313002: Convert Pass()→std::move() in //media (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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"
6
5 #include <stdint.h> 7 #include <stdint.h>
8 #include <utility>
6 9
7 #include "base/macros.h" 10 #include "base/macros.h"
8 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
9 #include "media/base/data_buffer.h"
10 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
11 13
12 namespace media { 14 namespace media {
13 15
14 TEST(DataBufferTest, Constructor_ZeroSize) { 16 TEST(DataBufferTest, Constructor_ZeroSize) {
15 // Zero-sized buffers are valid. In practice they aren't used very much but it 17 // Zero-sized buffers are valid. In practice they aren't used very much but it
16 // eliminates clients from worrying about null data pointers. 18 // eliminates clients from worrying about null data pointers.
17 scoped_refptr<DataBuffer> buffer = new DataBuffer(0); 19 scoped_refptr<DataBuffer> buffer = new DataBuffer(0);
18 EXPECT_TRUE(buffer->data()); 20 EXPECT_TRUE(buffer->data());
19 EXPECT_TRUE(buffer->writable_data()); 21 EXPECT_TRUE(buffer->writable_data());
20 EXPECT_EQ(0, buffer->data_size()); 22 EXPECT_EQ(0, buffer->data_size());
21 EXPECT_FALSE(buffer->end_of_stream()); 23 EXPECT_FALSE(buffer->end_of_stream());
22 } 24 }
23 25
24 TEST(DataBufferTest, Constructor_NonZeroSize) { 26 TEST(DataBufferTest, Constructor_NonZeroSize) {
25 // Buffer size should be set. 27 // Buffer size should be set.
26 scoped_refptr<DataBuffer> buffer = new DataBuffer(10); 28 scoped_refptr<DataBuffer> buffer = new DataBuffer(10);
27 EXPECT_TRUE(buffer->data()); 29 EXPECT_TRUE(buffer->data());
28 EXPECT_TRUE(buffer->writable_data()); 30 EXPECT_TRUE(buffer->writable_data());
29 EXPECT_EQ(0, buffer->data_size()); 31 EXPECT_EQ(0, buffer->data_size());
30 EXPECT_FALSE(buffer->end_of_stream()); 32 EXPECT_FALSE(buffer->end_of_stream());
31 } 33 }
32 34
33 TEST(DataBufferTest, Constructor_ScopedArray) { 35 TEST(DataBufferTest, Constructor_ScopedArray) {
34 // Data should be passed and both data and buffer size should be set. 36 // Data should be passed and both data and buffer size should be set.
35 const int kSize = 8; 37 const int kSize = 8;
36 scoped_ptr<uint8_t[]> data(new uint8_t[kSize]); 38 scoped_ptr<uint8_t[]> data(new uint8_t[kSize]);
37 const uint8_t* kData = data.get(); 39 const uint8_t* kData = data.get();
38 40
39 scoped_refptr<DataBuffer> buffer = new DataBuffer(data.Pass(), kSize); 41 scoped_refptr<DataBuffer> buffer = new DataBuffer(std::move(data), kSize);
40 EXPECT_TRUE(buffer->data()); 42 EXPECT_TRUE(buffer->data());
41 EXPECT_TRUE(buffer->writable_data()); 43 EXPECT_TRUE(buffer->writable_data());
42 EXPECT_EQ(kData, buffer->data()); 44 EXPECT_EQ(kData, buffer->data());
43 EXPECT_EQ(kSize, buffer->data_size()); 45 EXPECT_EQ(kSize, buffer->data_size());
44 EXPECT_FALSE(buffer->end_of_stream()); 46 EXPECT_FALSE(buffer->end_of_stream());
45 } 47 }
46 48
47 TEST(DataBufferTest, CopyFrom) { 49 TEST(DataBufferTest, CopyFrom) {
48 const uint8_t kTestData[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77}; 50 const uint8_t kTestData[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77};
49 const int kTestDataSize = arraysize(kTestData); 51 const int kTestDataSize = arraysize(kTestData);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 ASSERT_TRUE(data); 120 ASSERT_TRUE(data);
119 memcpy(data, kNewData, kNewDataSize); 121 memcpy(data, kNewData, kNewDataSize);
120 buffer2->set_data_size(kNewDataSize); 122 buffer2->set_data_size(kNewDataSize);
121 read_only_data = buffer2->data(); 123 read_only_data = buffer2->data();
122 EXPECT_EQ(kNewDataSize, buffer2->data_size()); 124 EXPECT_EQ(kNewDataSize, buffer2->data_size());
123 ASSERT_EQ(data, read_only_data); 125 ASSERT_EQ(data, read_only_data);
124 EXPECT_EQ(0, memcmp(read_only_data, kNewData, kNewDataSize)); 126 EXPECT_EQ(0, memcmp(read_only_data, kNewData, kNewDataSize));
125 } 127 }
126 128
127 } // namespace media 129 } // 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