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

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

Issue 4017002: HostMessageDispatcher to parse control messages (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merged again 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/multiple_array_input_stream.cc ('k') | remoting/client/chromoting_client.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 "remoting/base/multiple_array_input_stream.h" 9 #include "remoting/base/multiple_array_input_stream.h"
9 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
10 11
11 namespace remoting { 12 namespace remoting {
12 13
13 // TODO(sergeyu): Add SCOPED_TRACE() for ReadFromInput() and ReadString(). 14 // TODO(sergeyu): Add SCOPED_TRACE() for ReadFromInput() and ReadString().
14 15
15 static size_t ReadFromInput(MultipleArrayInputStream* input, 16 static size_t ReadFromInput(MultipleArrayInputStream* input,
16 void* data, size_t size) { 17 void* data, size_t size) {
17 uint8* out = reinterpret_cast<uint8*>(data); 18 uint8* out = reinterpret_cast<uint8*>(data);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 if (remaining_chars == 1) 65 if (remaining_chars == 1)
65 ++segments; 66 ++segments;
66 else 67 else
67 segments += 2; 68 segments += 2;
68 } 69 }
69 70
70 MultipleArrayInputStream* mstream = new MultipleArrayInputStream(); 71 MultipleArrayInputStream* mstream = new MultipleArrayInputStream();
71 const char* data = kTestData.c_str(); 72 const char* data = kTestData.c_str();
72 for (int i = 0; i < segments; ++i) { 73 for (int i = 0; i < segments; ++i) {
73 int size = i % 2 == 0 ? 1 : 2; 74 int size = i % 2 == 0 ? 1 : 2;
74 mstream->AddBuffer(data, size); 75 mstream->AddBuffer(new net::StringIOBuffer(std::string(data, size)), size);
75 data += size; 76 data += size;
76 } 77 }
77 stream->reset(mstream); 78 stream->reset(mstream);
78 } 79 }
79 80
80 TEST(MultipleArrayInputStreamTest, BasicOperations) { 81 TEST(MultipleArrayInputStreamTest, BasicOperations) {
81 scoped_ptr<MultipleArrayInputStream> stream; 82 scoped_ptr<MultipleArrayInputStream> stream;
82 PrepareData(&stream); 83 PrepareData(&stream);
83 84
84 ReadString(stream.get(), "Hello world!"); 85 ReadString(stream.get(), "Hello world!");
85 ReadString(stream.get(), "This "); 86 ReadString(stream.get(), "This ");
86 ReadString(stream.get(), "is test"); 87 ReadString(stream.get(), "is test");
87 EXPECT_TRUE(stream->Skip(3)); 88 EXPECT_TRUE(stream->Skip(3));
88 ReadString(stream.get(), "MultipleArrayInput"); 89 ReadString(stream.get(), "MultipleArrayInput");
89 EXPECT_TRUE(stream->Skip(6)); 90 EXPECT_TRUE(stream->Skip(6));
90 ReadString(stream.get(), "f"); 91 ReadString(stream.get(), "f");
91 ReadString(stream.get(), "o"); 92 ReadString(stream.get(), "o");
92 ReadString(stream.get(), "r"); 93 ReadString(stream.get(), "r");
93 ReadString(stream.get(), " "); 94 ReadString(stream.get(), " ");
94 ReadString(stream.get(), "Chromoting"); 95 ReadString(stream.get(), "Chromoting");
95 } 96 }
96 97
97 } // namespace remoting 98 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/base/multiple_array_input_stream.cc ('k') | remoting/client/chromoting_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698