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

Side by Side Diff: base/win/startup_information_unittest.cc

Issue 10870093: Rename ScopedStartupInfoEx to StartupInformation and cleanup accesors (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « base/win/startup_information.cc ('k') | no next file » | 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) 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 <windows.h> 5 #include <windows.h>
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/test/multiprocess_test.h" 10 #include "base/test/multiprocess_test.h"
11 #include "base/win/scoped_handle.h" 11 #include "base/win/scoped_handle.h"
12 #include "base/win/scoped_process_information.h" 12 #include "base/win/scoped_process_information.h"
13 #include "base/win/scoped_startup_info_ex.h" 13 #include "base/win/startup_information.h"
14 #include "base/win/windows_version.h" 14 #include "base/win/windows_version.h"
15 #include "testing/multiprocess_func_list.h" 15 #include "testing/multiprocess_func_list.h"
16 16
17 const wchar_t kSectionName[] = L"EventTestSection"; 17 const wchar_t kSectionName[] = L"EventTestSection";
18 const size_t kSectionSize = 4096; 18 const size_t kSectionSize = 4096;
19 19
20 MULTIPROCESS_TEST_MAIN(FireInheritedEvents) { 20 MULTIPROCESS_TEST_MAIN(FireInheritedEvents) {
21 HANDLE section = ::OpenFileMappingW(PAGE_READWRITE, false, kSectionName); 21 HANDLE section = ::OpenFileMappingW(PAGE_READWRITE, false, kSectionName);
22 HANDLE* events = reinterpret_cast<HANDLE*>(::MapViewOfFile(section, 22 HANDLE* events = reinterpret_cast<HANDLE*>(::MapViewOfFile(section,
23 PAGE_READWRITE, 0, 0, kSectionSize)); 23 PAGE_READWRITE, 0, 0, kSectionSize));
24 // This event should not be valid because it wasn't explicitly inherited. 24 // This event should not be valid because it wasn't explicitly inherited.
25 if (::SetEvent(events[1])) 25 if (::SetEvent(events[1]))
26 return -1; 26 return -1;
27 // This event should be valid because it was explicitly inherited. 27 // This event should be valid because it was explicitly inherited.
28 if (!::SetEvent(events[0])) 28 if (!::SetEvent(events[0]))
29 return -1; 29 return -1;
30 30
31 return 0; 31 return 0;
32 } 32 }
33 33
34 class ScopedStartupInfoExTest : public base::MultiProcessTest {}; 34 class StartupInformationTest : public base::MultiProcessTest {};
35 35
36 // Verify that only the explicitly specified event is inherited. 36 // Verify that only the explicitly specified event is inherited.
37 TEST_F(ScopedStartupInfoExTest, InheritStdOut) { 37 TEST_F(StartupInformationTest, InheritStdOut) {
38 if (base::win::GetVersion() < base::win::VERSION_VISTA) 38 if (base::win::GetVersion() < base::win::VERSION_VISTA)
39 return; 39 return;
40 40
41 base::win::ScopedProcessInformation process_info; 41 base::win::ScopedProcessInformation process_info;
42 base::win::ScopedStartupInfoEx startup_info; 42 base::win::StartupInformation startup_info;
43 43
44 HANDLE section = ::CreateFileMappingW(INVALID_HANDLE_VALUE, NULL, 44 HANDLE section = ::CreateFileMappingW(INVALID_HANDLE_VALUE, NULL,
45 PAGE_READWRITE, 0, kSectionSize, 45 PAGE_READWRITE, 0, kSectionSize,
46 kSectionName); 46 kSectionName);
47 ASSERT_TRUE(section); 47 ASSERT_TRUE(section);
48 48
49 HANDLE* events = reinterpret_cast<HANDLE*>(::MapViewOfFile(section, 49 HANDLE* events = reinterpret_cast<HANDLE*>(::MapViewOfFile(section,
50 FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, kSectionSize)); 50 FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, kSectionSize));
51 51
52 // Make two inheritable events. 52 // Make two inheritable events.
(...skipping 14 matching lines...) Expand all
67 67
68 ASSERT_TRUE(::CreateProcess(NULL, const_cast<wchar_t*>(cmd_line.c_str()), 68 ASSERT_TRUE(::CreateProcess(NULL, const_cast<wchar_t*>(cmd_line.c_str()),
69 NULL, NULL, true, EXTENDED_STARTUPINFO_PRESENT, 69 NULL, NULL, true, EXTENDED_STARTUPINFO_PRESENT,
70 NULL, NULL, startup_info.startup_info(), 70 NULL, NULL, startup_info.startup_info(),
71 process_info.Receive())) << ::GetLastError(); 71 process_info.Receive())) << ::GetLastError();
72 // Only the first event should be signalled 72 // Only the first event should be signalled
73 EXPECT_EQ(WAIT_OBJECT_0, ::WaitForMultipleObjects(2, events, false, 73 EXPECT_EQ(WAIT_OBJECT_0, ::WaitForMultipleObjects(2, events, false,
74 4000)); 74 4000));
75 } 75 }
76 76
OLDNEW
« no previous file with comments | « base/win/startup_information.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698