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

Side by Side Diff: components/nacl/loader/nacl_ipc_adapter_unittest.cc

Issue 57783006: Revert https://src.chromium.org/viewvc/chrome?view=rev&revision=231330 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile (cc perftest). Created 7 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/nacl/loader/nacl_ipc_adapter.h" 5 #include "components/nacl/loader/nacl_ipc_adapter.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 // destroyed on the right thread. 68 // destroyed on the right thread.
69 IPC::TestSink* sink_; 69 IPC::TestSink* sink_;
70 }; 70 };
71 71
72 } // namespace 72 } // namespace
73 73
74 // Tests a simple message getting rewritten sent from native code to NaCl. 74 // Tests a simple message getting rewritten sent from native code to NaCl.
75 TEST_F(NaClIPCAdapterTest, SimpleReceiveRewriting) { 75 TEST_F(NaClIPCAdapterTest, SimpleReceiveRewriting) {
76 int routing_id = 0x89898989; 76 int routing_id = 0x89898989;
77 uint32 type = 0x55555555; 77 uint32 type = 0x55555555;
78 IPC::Message input(routing_id, type); 78 IPC::Message input(routing_id, type, IPC::Message::PRIORITY_NORMAL);
79 uint32 flags = input.flags(); 79 uint32 flags = input.flags();
80 80
81 int value = 0x12345678; 81 int value = 0x12345678;
82 input.WriteInt(value); 82 input.WriteInt(value);
83 adapter_->OnMessageReceived(input); 83 adapter_->OnMessageReceived(input);
84 84
85 // Buffer just need to be big enough for our message with one int. 85 // Buffer just need to be big enough for our message with one int.
86 const int kBufSize = 64; 86 const int kBufSize = 64;
87 char buf[kBufSize]; 87 char buf[kBufSize];
88 88
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 msg = sink_->GetMessageAt(0); 168 msg = sink_->GetMessageAt(0);
169 EXPECT_EQ(sizeof(int), msg->payload_size()); 169 EXPECT_EQ(sizeof(int), msg->payload_size());
170 EXPECT_EQ(header->routing, msg->routing_id()); 170 EXPECT_EQ(header->routing, msg->routing_id());
171 EXPECT_EQ(header->type, msg->type()); 171 EXPECT_EQ(header->type, msg->type());
172 } 172 }
173 173
174 // Tests when a buffer is too small to receive the entire message. 174 // Tests when a buffer is too small to receive the entire message.
175 TEST_F(NaClIPCAdapterTest, PartialReceive) { 175 TEST_F(NaClIPCAdapterTest, PartialReceive) {
176 int routing_id_1 = 0x89898989; 176 int routing_id_1 = 0x89898989;
177 uint32 type_1 = 0x55555555; 177 uint32 type_1 = 0x55555555;
178 IPC::Message input_1(routing_id_1, type_1); 178 IPC::Message input_1(routing_id_1, type_1, IPC::Message::PRIORITY_NORMAL);
179 int value_1 = 0x12121212; 179 int value_1 = 0x12121212;
180 input_1.WriteInt(value_1); 180 input_1.WriteInt(value_1);
181 adapter_->OnMessageReceived(input_1); 181 adapter_->OnMessageReceived(input_1);
182 182
183 int routing_id_2 = 0x90909090; 183 int routing_id_2 = 0x90909090;
184 uint32 type_2 = 0x66666666; 184 uint32 type_2 = 0x66666666;
185 IPC::Message input_2(routing_id_2, type_2); 185 IPC::Message input_2(routing_id_2, type_2, IPC::Message::PRIORITY_NORMAL);
186 int value_2 = 0x23232323; 186 int value_2 = 0x23232323;
187 input_2.WriteInt(value_2); 187 input_2.WriteInt(value_2);
188 adapter_->OnMessageReceived(input_2); 188 adapter_->OnMessageReceived(input_2);
189 189
190 const int kBufSize = 64; 190 const int kBufSize = 64;
191 char buf[kBufSize]; 191 char buf[kBufSize];
192 192
193 // Read part of the first message. 193 // Read part of the first message.
194 int bytes_requested = 7; 194 int bytes_requested = 7;
195 int bytes_read = BlockingReceive(buf, bytes_requested); 195 int bytes_read = BlockingReceive(buf, bytes_requested);
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 EXPECT_EQ(NACL_ABI_O_RDONLY, 348 EXPECT_EQ(NACL_ABI_O_RDONLY,
349 TranslatePepperFileReadWriteOpenFlagsForTesting( 349 TranslatePepperFileReadWriteOpenFlagsForTesting(
350 PP_FILEOPENFLAG_CREATE)); 350 PP_FILEOPENFLAG_CREATE));
351 EXPECT_EQ(NACL_ABI_O_RDONLY, 351 EXPECT_EQ(NACL_ABI_O_RDONLY,
352 TranslatePepperFileReadWriteOpenFlagsForTesting( 352 TranslatePepperFileReadWriteOpenFlagsForTesting(
353 PP_FILEOPENFLAG_TRUNCATE)); 353 PP_FILEOPENFLAG_TRUNCATE));
354 EXPECT_EQ(NACL_ABI_O_RDONLY, 354 EXPECT_EQ(NACL_ABI_O_RDONLY,
355 TranslatePepperFileReadWriteOpenFlagsForTesting( 355 TranslatePepperFileReadWriteOpenFlagsForTesting(
356 PP_FILEOPENFLAG_EXCLUSIVE)); 356 PP_FILEOPENFLAG_EXCLUSIVE));
357 } 357 }
OLDNEW
« no previous file with comments | « components/nacl/loader/nacl_ipc_adapter.cc ('k') | content/browser/renderer_host/render_view_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698