Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 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 "chrome/app/chrome_watcher_command_line_win.h" | 5 #include "chrome/app/chrome_watcher_command_line_win.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/process/process.h" | 11 #include "base/process/process.h" |
|
rvargas (doing something else)
2015/02/12 21:05:16
This should not be needed anymore.
| |
| 12 #include "base/win/scoped_handle.h" | 12 #include "base/win/scoped_handle.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 14 |
| 15 TEST(ChromeWatcherCommandLineTest, BasicTest) { | 15 TEST(ChromeWatcherCommandLineTest, BasicTest) { |
| 16 base::Process current = base::Process::Open(base::GetCurrentProcId()); | 16 // Ownership of these handles is passed to the ScopedHandles below via |
| 17 ASSERT_TRUE(current.IsValid()); | 17 // InterpretChromeWatcherCommandLine(). |
| 18 base::ProcessHandle current = | |
| 19 ::OpenProcess(PROCESS_QUERY_INFORMATION | SYNCHRONIZE, | |
| 20 TRUE, // Inheritable | |
| 21 ::GetCurrentProcessId()); | |
| 22 ASSERT_NE(nullptr, current); | |
| 23 | |
| 18 HANDLE event = ::CreateEvent(nullptr, FALSE, FALSE, nullptr); | 24 HANDLE event = ::CreateEvent(nullptr, FALSE, FALSE, nullptr); |
| 25 ASSERT_NE(nullptr, event); | |
| 19 | 26 |
| 20 base::CommandLine cmd_line = GenerateChromeWatcherCommandLine( | 27 base::CommandLine cmd_line = GenerateChromeWatcherCommandLine( |
| 21 base::FilePath(L"example.exe"), current.Handle(), event); | 28 base::FilePath(L"example.exe"), current, event); |
| 22 | 29 |
| 23 base::win::ScopedHandle current_result; | 30 base::win::ScopedHandle current_result; |
| 24 base::win::ScopedHandle event_result; | 31 base::win::ScopedHandle event_result; |
| 25 ASSERT_TRUE(InterpretChromeWatcherCommandLine(cmd_line, ¤t_result, | 32 ASSERT_TRUE(InterpretChromeWatcherCommandLine(cmd_line, ¤t_result, |
| 26 &event_result)); | 33 &event_result)); |
| 27 ASSERT_EQ(current.Handle(), current_result.Get()); | 34 ASSERT_EQ(current, current_result.Get()); |
| 28 ASSERT_EQ(event, event_result.Get()); | 35 ASSERT_EQ(event, event_result.Get()); |
| 29 } | 36 } |
| OLD | NEW |