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

Side by Side Diff: remoting/base/multiple_array_input_stream_unittest.cc

Issue 4255001: Revert 64672 - Cleanups in the video encoding decoding code. Reenable VP8.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « remoting/base/encoder_zlib.cc ('k') | remoting/base/util.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <string> 5 #include <string>
6 6
7 #include "base/scoped_ptr.h" 7 #include "base/scoped_ptr.h"
8 #include "net/base/io_buffer.h" 8 #include "net/base/io_buffer.h"
9 #include "remoting/base/multiple_array_input_stream.h" 9 #include "remoting/base/multiple_array_input_stream.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 28 matching lines...) Expand all
39 out += in_size; 39 out += in_size;
40 out_size -= in_size; 40 out_size -= in_size;
41 } 41 }
42 } 42 }
43 43
44 static void ReadString(MultipleArrayInputStream* input, 44 static void ReadString(MultipleArrayInputStream* input,
45 const std::string& str) { 45 const std::string& str) {
46 scoped_array<char> buffer(new char[str.size() + 1]); 46 scoped_array<char> buffer(new char[str.size() + 1]);
47 buffer[str.size()] = '\0'; 47 buffer[str.size()] = '\0';
48 EXPECT_EQ(ReadFromInput(input, buffer.get(), str.size()), str.size()); 48 EXPECT_EQ(ReadFromInput(input, buffer.get(), str.size()), str.size());
49 EXPECT_STREQ(str.data(), buffer.get()); 49 EXPECT_STREQ(str.c_str(), buffer.get());
50 } 50 }
51 51
52 // Construct and prepare data in the |output_stream|. 52 // Construct and prepare data in the |output_stream|.
53 static void PrepareData(scoped_ptr<MultipleArrayInputStream>* stream) { 53 static void PrepareData(scoped_ptr<MultipleArrayInputStream>* stream) {
54 static const std::string kTestData = 54 static const std::string kTestData =
55 "Hello world!" 55 "Hello world!"
56 "This is testing" 56 "This is testing"
57 "MultipleArrayInputStream" 57 "MultipleArrayInputStream"
58 "for Chromoting"; 58 "for Chromoting";
59 59
60 // Determine how many segments to split kTestData. We split the data in 60 // Determine how many segments to split kTestData. We split the data in
61 // 1 character, 2 characters, 1 character, 2 characters ... 61 // 1 character, 2 characters, 1 character, 2 characters ...
62 int segments = (kTestData.length() / 3) * 2; 62 int segments = (kTestData.length() / 3) * 2;
63 int remaining_chars = kTestData.length() % 3; 63 int remaining_chars = kTestData.length() % 3;
64 if (remaining_chars) { 64 if (remaining_chars) {
65 if (remaining_chars == 1) 65 if (remaining_chars == 1)
66 ++segments; 66 ++segments;
67 else 67 else
68 segments += 2; 68 segments += 2;
69 } 69 }
70 70
71 MultipleArrayInputStream* mstream = new MultipleArrayInputStream(); 71 MultipleArrayInputStream* mstream = new MultipleArrayInputStream();
72 const char* data = kTestData.data(); 72 const char* data = kTestData.c_str();
73 for (int i = 0; i < segments; ++i) { 73 for (int i = 0; i < segments; ++i) {
74 int size = i % 2 == 0 ? 1 : 2; 74 int size = i % 2 == 0 ? 1 : 2;
75 mstream->AddBuffer(new net::StringIOBuffer(std::string(data, size)), size); 75 mstream->AddBuffer(new net::StringIOBuffer(std::string(data, size)), size);
76 data += size; 76 data += size;
77 } 77 }
78 stream->reset(mstream); 78 stream->reset(mstream);
79 } 79 }
80 80
81 TEST(MultipleArrayInputStreamTest, BasicOperations) { 81 TEST(MultipleArrayInputStreamTest, BasicOperations) {
82 scoped_ptr<MultipleArrayInputStream> stream; 82 scoped_ptr<MultipleArrayInputStream> stream;
83 PrepareData(&stream); 83 PrepareData(&stream);
84 84
85 ReadString(stream.get(), "Hello world!"); 85 ReadString(stream.get(), "Hello world!");
86 ReadString(stream.get(), "This "); 86 ReadString(stream.get(), "This ");
87 ReadString(stream.get(), "is test"); 87 ReadString(stream.get(), "is test");
88 EXPECT_TRUE(stream->Skip(3)); 88 EXPECT_TRUE(stream->Skip(3));
89 ReadString(stream.get(), "MultipleArrayInput"); 89 ReadString(stream.get(), "MultipleArrayInput");
90 EXPECT_TRUE(stream->Skip(6)); 90 EXPECT_TRUE(stream->Skip(6));
91 ReadString(stream.get(), "f"); 91 ReadString(stream.get(), "f");
92 ReadString(stream.get(), "o"); 92 ReadString(stream.get(), "o");
93 ReadString(stream.get(), "r"); 93 ReadString(stream.get(), "r");
94 ReadString(stream.get(), " "); 94 ReadString(stream.get(), " ");
95 ReadString(stream.get(), "Chromoting"); 95 ReadString(stream.get(), "Chromoting");
96 } 96 }
97 97
98 } // namespace remoting 98 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/base/encoder_zlib.cc ('k') | remoting/base/util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698