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

Side by Side Diff: chrome/browser/extensions/api/messaging/native_message_process_host_unittest.cc

Issue 1148383003: Only support seeking file streams from the beginning of the file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Win DBG build by Pass()-ing file out of CreateForAsyncHandle. Created 5 years, 6 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
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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/files/file.h" 6 #include "base/files/file.h"
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/files/scoped_file.h" 9 #include "base/files/scoped_file.h"
10 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 194
195 // Tests sending a single message. The message should get written to 195 // Tests sending a single message. The message should get written to
196 // |temp_file| and should match the contents of single_message_request.msg. 196 // |temp_file| and should match the contents of single_message_request.msg.
197 TEST_F(NativeMessagingTest, SingleSendMessageWrite) { 197 TEST_F(NativeMessagingTest, SingleSendMessageWrite) {
198 base::FilePath temp_output_file = temp_dir_.path().AppendASCII("output"); 198 base::FilePath temp_output_file = temp_dir_.path().AppendASCII("output");
199 199
200 base::File read_file; 200 base::File read_file;
201 #if defined(OS_WIN) 201 #if defined(OS_WIN)
202 base::string16 pipe_name = base::StringPrintf( 202 base::string16 pipe_name = base::StringPrintf(
203 L"\\\\.\\pipe\\chrome.nativeMessaging.out.%llx", base::RandUint64()); 203 L"\\\\.\\pipe\\chrome.nativeMessaging.out.%llx", base::RandUint64());
204 base::File write_handle( 204 base::File write_handle = base::File::CreateForAsyncHandle(
205 CreateNamedPipeW(pipe_name.c_str(), 205 CreateNamedPipeW(pipe_name.c_str(),
206 PIPE_ACCESS_OUTBOUND | FILE_FLAG_OVERLAPPED | 206 PIPE_ACCESS_OUTBOUND | FILE_FLAG_OVERLAPPED |
207 FILE_FLAG_FIRST_PIPE_INSTANCE, 207 FILE_FLAG_FIRST_PIPE_INSTANCE,
208 PIPE_TYPE_BYTE, 1, 0, 0, 5000, NULL)); 208 PIPE_TYPE_BYTE, 1, 0, 0, 5000, NULL));
209 ASSERT_TRUE(write_handle.IsValid()); 209 ASSERT_TRUE(write_handle.IsValid());
210 base::File read_handle( 210 base::File read_handle = base::File::CreateForAsyncHandle(
211 CreateFileW(pipe_name.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, 211 CreateFileW(pipe_name.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING,
212 FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL)); 212 FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL));
213 ASSERT_TRUE(read_handle.IsValid()); 213 ASSERT_TRUE(read_handle.IsValid());
214 214
215 read_file = read_handle.Pass(); 215 read_file = read_handle.Pass();
216 #else // defined(OS_WIN) 216 #else // defined(OS_WIN)
217 base::PlatformFile pipe_handles[2]; 217 base::PlatformFile pipe_handles[2];
218 ASSERT_EQ(0, pipe(pipe_handles)); 218 ASSERT_EQ(0, pipe(pipe_handles));
219 read_file = base::File(pipe_handles[0]); 219 read_file = base::File(pipe_handles[0]);
220 base::File write_file(pipe_handles[1]); 220 base::File write_file(pipe_handles[1]);
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 native_message_host_->Start(this); 325 native_message_host_->Start(this);
326 ASSERT_TRUE(native_message_host_.get()); 326 ASSERT_TRUE(native_message_host_.get());
327 run_loop_.reset(new base::RunLoop()); 327 run_loop_.reset(new base::RunLoop());
328 run_loop_->Run(); 328 run_loop_->Run();
329 329
330 // The host should fail to start. 330 // The host should fail to start.
331 ASSERT_TRUE(channel_closed_); 331 ASSERT_TRUE(channel_closed_);
332 } 332 }
333 333
334 } // namespace extensions 334 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698