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

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

Issue 3305001: Move decoder into separate thread, clean up API layering, and redo update protocl (Closed)
Patch Set: Fix compile error. Created 10 years, 2 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 | « remoting/base/protocol_decoder.cc ('k') | remoting/base/tracer.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 "base/stl_util-inl.h"
8 #include "media/base/data_buffer.h" 9 #include "media/base/data_buffer.h"
9 #include "remoting/base/protocol_decoder.h" 10 #include "remoting/base/protocol_decoder.h"
10 #include "remoting/base/protocol_util.h" 11 #include "remoting/base/protocol_util.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 13
13 namespace remoting { 14 namespace remoting {
14 15
15 static const int kWidth = 640; 16 static const int kWidth = 640;
16 static const int kHeight = 480; 17 static const int kHeight = 480;
17 static const std::string kTestData = "Chromoting rockz"; 18 static const std::string kTestData = "Chromoting rockz";
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 scoped_refptr<media::DataBuffer> buffer = new media::DataBuffer(read); 87 scoped_refptr<media::DataBuffer> buffer = new media::DataBuffer(read);
87 memcpy(buffer->GetWritableData(), test_data + i, read); 88 memcpy(buffer->GetWritableData(), test_data + i, read);
88 buffer->SetDataSize(read); 89 buffer->SetDataSize(read);
89 decoder.ParseHostMessages(buffer, &message_list); 90 decoder.ParseHostMessages(buffer, &message_list);
90 i += read; 91 i += read;
91 } 92 }
92 93
93 // Then verify the decoded messages. 94 // Then verify the decoded messages.
94 EXPECT_EQ(31u, message_list.size()); 95 EXPECT_EQ(31u, message_list.size());
95 ASSERT_TRUE(message_list.size() > 0); 96 ASSERT_TRUE(message_list.size() > 0);
96 EXPECT_TRUE(message_list[0]->has_init_client()); 97 EXPECT_TRUE(message_list.front()->has_init_client());
97 delete message_list[0]; 98 delete message_list.front();
99 message_list.pop_front();
98 100
99 for (size_t i = 1; i < message_list.size(); ++i) { 101 for (HostMessageList::iterator it = message_list.begin();
102 it != message_list.end(); ++it) {
103 ChromotingHostMessage* message = *it;
100 int type = (i - 1) % 3; 104 int type = (i - 1) % 3;
101 if (type == 0) { 105 if (type == 0) {
102 // Begin update stream. 106 // Begin update stream.
103 EXPECT_TRUE(message_list[i]->has_begin_update_stream()); 107 EXPECT_TRUE(message->has_begin_update_stream());
104 } else if (type == 1) { 108 } else if (type == 1) {
105 // Partial update stream. 109 // Partial update stream.
106 EXPECT_TRUE(message_list[i]->has_update_stream_packet()); 110 EXPECT_TRUE(message->has_update_stream_packet());
107 EXPECT_EQ(kTestData, 111 EXPECT_EQ(kTestData,
108 message_list[i]->update_stream_packet().rect_data().data()); 112 message->update_stream_packet().rect_data().data());
109 } else if (type == 2) { 113 } else if (type == 2) {
110 // End update stream. 114 // End update stream.
111 EXPECT_TRUE(message_list[i]->has_end_update_stream()); 115 EXPECT_TRUE(message->has_end_update_stream());
112 } 116 }
113 delete message_list[i];
114 } 117 }
118 STLDeleteElements(&message_list);
115 } 119 }
116 120
117 } // namespace remoting 121 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/base/protocol_decoder.cc ('k') | remoting/base/tracer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698