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> |
| 8 |
7 #include "base/command_line.h" | 9 #include "base/command_line.h" |
8 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
9 #include "base/process/process_handle.h" | 11 #include "base/process/process_handle.h" |
10 #include "base/win/scoped_handle.h" | 12 #include "base/win/scoped_handle.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
12 | 14 |
13 TEST(ChromeWatcherCommandLineTest, BasicTest) { | 15 TEST(ChromeWatcherCommandLineTest, BasicTest) { |
| 16 // Ownership of these handles is passed to the ScopedHandles below via |
| 17 // InterpretChromeWatcherCommandLine(). |
14 base::ProcessHandle current = nullptr; | 18 base::ProcessHandle current = nullptr; |
15 ASSERT_TRUE(base::OpenProcessHandle(base::GetCurrentProcId(), ¤t)); | 19 ASSERT_TRUE(base::OpenProcessHandle(base::GetCurrentProcId(), ¤t)); |
16 base::CommandLine cmd_line = | 20 HANDLE event = ::CreateEvent(nullptr, FALSE, FALSE, nullptr); |
17 GenerateChromeWatcherCommandLine(base::FilePath(L"example.exe"), current); | 21 |
18 base::win::ScopedHandle result = InterpretChromeWatcherCommandLine(cmd_line); | 22 base::CommandLine cmd_line = GenerateChromeWatcherCommandLine( |
19 ASSERT_EQ(current, result.Get()); | 23 base::FilePath(L"example.exe"), current, event); |
| 24 |
| 25 base::win::ScopedHandle current_result; |
| 26 base::win::ScopedHandle event_result; |
| 27 ASSERT_TRUE(InterpretChromeWatcherCommandLine(cmd_line, ¤t_result, |
| 28 &event_result)); |
| 29 ASSERT_EQ(current, current_result.Get()); |
| 30 ASSERT_EQ(event, event_result.Get()); |
20 } | 31 } |
OLD | NEW |