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

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

Issue 988693005: Chromium roll (https://codereview.chromium.org/976353002) (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: fixed bad android build patch Created 5 years, 9 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 | « base/win/pe_image_unittest.cc ('k') | base/win/win_util.cc » ('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) 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/process/kill.h" 10 #include "base/process/kill.h"
11 #include "base/process/process.h"
11 #include "base/test/multiprocess_test.h" 12 #include "base/test/multiprocess_test.h"
12 #include "base/win/scoped_process_information.h" 13 #include "base/win/scoped_process_information.h"
13 #include "testing/multiprocess_func_list.h" 14 #include "testing/multiprocess_func_list.h"
14 15
15 namespace { 16 namespace {
16 17
17 const DWORD kProcessId = 4321; 18 const DWORD kProcessId = 4321;
18 const DWORD kThreadId = 1234; 19 const DWORD kThreadId = 1234;
19 const HANDLE kProcessHandle = reinterpret_cast<HANDLE>(7651); 20 const HANDLE kProcessHandle = reinterpret_cast<HANDLE>(7651);
20 const HANDLE kThreadHandle = reinterpret_cast<HANDLE>(1567); 21 const HANDLE kThreadHandle = reinterpret_cast<HANDLE>(1567);
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 duplicate.DuplicateFrom(process_info); 129 duplicate.DuplicateFrom(process_info);
129 130
130 ASSERT_TRUE(process_info.IsValid()); 131 ASSERT_TRUE(process_info.IsValid());
131 ASSERT_NE(0u, process_info.process_id()); 132 ASSERT_NE(0u, process_info.process_id());
132 ASSERT_EQ(duplicate.process_id(), process_info.process_id()); 133 ASSERT_EQ(duplicate.process_id(), process_info.process_id());
133 ASSERT_NE(0u, process_info.thread_id()); 134 ASSERT_NE(0u, process_info.thread_id());
134 ASSERT_EQ(duplicate.thread_id(), process_info.thread_id()); 135 ASSERT_EQ(duplicate.thread_id(), process_info.thread_id());
135 136
136 // Validate that we have separate handles that are good. 137 // Validate that we have separate handles that are good.
137 int exit_code = 0; 138 int exit_code = 0;
138 ASSERT_TRUE(base::WaitForExitCode(process_info.TakeProcessHandle(), 139 base::Process process(process_info.TakeProcessHandle());
139 &exit_code)); 140 ASSERT_TRUE(process.WaitForExit(&exit_code));
140 ASSERT_EQ(7, exit_code); 141 ASSERT_EQ(7, exit_code);
141 142
142 exit_code = 0; 143 exit_code = 0;
143 ASSERT_TRUE(base::WaitForExitCode(duplicate.TakeProcessHandle(), 144 base::Process dup_process(duplicate.TakeProcessHandle());
144 &exit_code)); 145 ASSERT_TRUE(dup_process.WaitForExit(&exit_code));
145 ASSERT_EQ(7, exit_code); 146 ASSERT_EQ(7, exit_code);
146 147
147 ASSERT_TRUE(::CloseHandle(process_info.TakeThreadHandle())); 148 ASSERT_TRUE(::CloseHandle(process_info.TakeThreadHandle()));
148 ASSERT_TRUE(::CloseHandle(duplicate.TakeThreadHandle())); 149 ASSERT_TRUE(::CloseHandle(duplicate.TakeThreadHandle()));
149 } 150 }
150 151
151 TEST_F(ScopedProcessInformationTest, Set) { 152 TEST_F(ScopedProcessInformationTest, Set) {
152 base::win::ScopedProcessInformation base_process_info; 153 base::win::ScopedProcessInformation base_process_info;
153 MockCreateProcess(&base_process_info); 154 MockCreateProcess(&base_process_info);
154 155
155 PROCESS_INFORMATION base_struct = base_process_info.Take(); 156 PROCESS_INFORMATION base_struct = base_process_info.Take();
156 157
157 base::win::ScopedProcessInformation process_info; 158 base::win::ScopedProcessInformation process_info;
158 process_info.Set(base_struct); 159 process_info.Set(base_struct);
159 160
160 EXPECT_EQ(kProcessId, process_info.process_id()); 161 EXPECT_EQ(kProcessId, process_info.process_id());
161 EXPECT_EQ(kThreadId, process_info.thread_id()); 162 EXPECT_EQ(kThreadId, process_info.thread_id());
162 EXPECT_EQ(kProcessHandle, process_info.process_handle()); 163 EXPECT_EQ(kProcessHandle, process_info.process_handle());
163 EXPECT_EQ(kThreadHandle, process_info.thread_handle()); 164 EXPECT_EQ(kThreadHandle, process_info.thread_handle());
164 base_struct = process_info.Take(); 165 base_struct = process_info.Take();
165 } 166 }
OLDNEW
« no previous file with comments | « base/win/pe_image_unittest.cc ('k') | base/win/win_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698