diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-09 22:44:57 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-09 22:44:57 +0000 |
commit | 6aa9349ef5c1110d9c096945840e6a105e8a8295 (patch) | |
tree | 8afce0e1f3aae77e05105cfbe0d24ea3bdae9106 /chrome/test | |
parent | b61236c6679615af0811d59d130c91397d8c6be7 (diff) | |
download | chromium_src-6aa9349ef5c1110d9c096945840e6a105e8a8295.zip chromium_src-6aa9349ef5c1110d9c096945840e6a105e8a8295.tar.gz chromium_src-6aa9349ef5c1110d9c096945840e6a105e8a8295.tar.bz2 |
Replace chrome_process_filter with chrome_process_util.
- move code only used by tests to chrome/test
- make a better, more portable abstraction
For now, it still only works on Windows. But this is the first step
to porting this part of code.
Patch by phajdan.jr@chromium.org: <http://codereview.chromium.org/54003>
Review URL: http://codereview.chromium.org/67004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13476 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r-- | chrome/test/automated_ui_tests/automated_ui_tests.vcproj | 12 | ||||
-rw-r--r-- | chrome/test/chrome_process_util.cc | 50 | ||||
-rw-r--r-- | chrome/test/chrome_process_util.h | 26 | ||||
-rw-r--r-- | chrome/test/chrome_process_util_win.cc | 63 | ||||
-rw-r--r-- | chrome/test/interactive_ui/interactive_ui.vcproj | 12 | ||||
-rw-r--r-- | chrome/test/memory_test/memory_test.cc | 49 | ||||
-rw-r--r-- | chrome/test/memory_test/memory_test.vcproj | 12 | ||||
-rw-r--r-- | chrome/test/page_cycler/page_cycler_test.cc | 54 | ||||
-rw-r--r-- | chrome/test/page_cycler/page_cycler_tests.vcproj | 12 | ||||
-rw-r--r-- | chrome/test/perf/mem_usage.cc | 22 | ||||
-rw-r--r-- | chrome/test/plugin/plugin_tests.vcproj | 12 | ||||
-rw-r--r-- | chrome/test/reliability/reliability_tests.vcproj | 12 | ||||
-rw-r--r-- | chrome/test/selenium/selenium_tests.vcproj | 12 | ||||
-rw-r--r-- | chrome/test/startup/startup_tests.vcproj | 12 | ||||
-rw-r--r-- | chrome/test/tab_switching/tab_switching.vcproj | 12 | ||||
-rw-r--r-- | chrome/test/ui/ui_test.cc | 29 | ||||
-rw-r--r-- | chrome/test/ui/ui_tests.vcproj | 12 | ||||
-rw-r--r-- | chrome/test/url_fetch_test/url_fetch_test.vcproj | 12 |
18 files changed, 342 insertions, 83 deletions
diff --git a/chrome/test/automated_ui_tests/automated_ui_tests.vcproj b/chrome/test/automated_ui_tests/automated_ui_tests.vcproj index ff233cc..002596e 100644 --- a/chrome/test/automated_ui_tests/automated_ui_tests.vcproj +++ b/chrome/test/automated_ui_tests/automated_ui_tests.vcproj @@ -162,6 +162,18 @@ > </File> <File + RelativePath="..\chrome_process_util.cc" + > + </File> + <File + RelativePath="..\chrome_process_util.h" + > + </File> + <File + RelativePath="..\chrome_process_util_win.cc" + > + </File> + <File RelativePath="..\testing_browser_process.h" > </File> diff --git a/chrome/test/chrome_process_util.cc b/chrome/test/chrome_process_util.cc new file mode 100644 index 0000000..128ec33 --- /dev/null +++ b/chrome/test/chrome_process_util.cc @@ -0,0 +1,50 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/test/chrome_process_util.h" + +#include <vector> + +#include "base/process_util.h" +#include "base/time.h" +#include "chrome/common/result_codes.h" + +using base::Time; +using base::TimeDelta; + +void TerminateAllChromeProcesses(const FilePath& data_dir) { + // Total time the function will wait for chrome processes + // to terminate after it told them to do so. + const TimeDelta kExitTimeout = TimeDelta::FromMilliseconds(5000); + + ChromeProcessList process_pids(GetRunningChromeProcesses(data_dir)); + + std::vector<base::ProcessHandle> handles; + { + ChromeProcessList::const_iterator it; + for (it = process_pids.begin(); it != process_pids.end(); ++it) { + base::ProcessHandle handle; + // Ignore processes for which we can't open the handle. We don't guarantee + // that all processes will terminate, only try to do so. + if (base::OpenProcessHandle(*it, &handle)) + handles.push_back(handle); + } + } + + std::vector<base::ProcessHandle>::const_iterator it; + for (it = handles.begin(); it != handles.end(); ++it) + base::KillProcess(*it, ResultCodes::TASKMAN_KILL, false); + + const Time start = Time::Now(); + for (it = handles.begin(); + it != handles.end() && Time::Now() - start < kExitTimeout; + ++it) { + // TODO(phajdan.jr): Fix int/int64 problems with TimeDelta::InMilliseconds. + int wait_time_ms = static_cast<int>((Time::Now() - start).InMilliseconds()); + base::WaitForSingleProcess(*it, wait_time_ms); + } + + for (it = handles.begin(); it != handles.end(); ++it) + base::CloseProcessHandle(*it); +} diff --git a/chrome/test/chrome_process_util.h b/chrome/test/chrome_process_util.h new file mode 100644 index 0000000..31f3b5f --- /dev/null +++ b/chrome/test/chrome_process_util.h @@ -0,0 +1,26 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_TEST_CHROME_PROCESS_UTIL_H_ +#define CHROME_TEST_CHROME_PROCESS_UTIL_H_ + +#include <vector> + +#include "base/file_path.h" +#include "base/process_util.h" + +typedef std::vector<base::ProcessId> ChromeProcessList; + +// Returns PID of browser process running with user data dir |data_dir|. +// Returns -1 on error. +base::ProcessId ChromeBrowserProcessId(const FilePath& data_dir); + +// Returns a vector of PIDs of chrome processes (main and renderers etc) +// associated with user data dir |data_dir|. On error returns empty vector. +ChromeProcessList GetRunningChromeProcesses(const FilePath& data_dir); + +// Attempts to terminate all chrome processes associated with |data_dir|. +void TerminateAllChromeProcesses(const FilePath& data_dir); + +#endif // CHROME_TEST_CHROME_PROCESS_UTIL_H_ diff --git a/chrome/test/chrome_process_util_win.cc b/chrome/test/chrome_process_util_win.cc new file mode 100644 index 0000000..b0e2e40 --- /dev/null +++ b/chrome/test/chrome_process_util_win.cc @@ -0,0 +1,63 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/test/chrome_process_util.h" + +#include <windows.h> + +#include <vector> + +#include "base/logging.h" +#include "base/process_util.h" +#include "chrome/common/chrome_constants.h" + +namespace { + +class ChromeProcessFilter : public base::ProcessFilter { + public: + explicit ChromeProcessFilter(base::ProcessId browser_pid) + : browser_pid_(browser_pid) {} + + virtual bool Includes(base::ProcessId pid, base::ProcessId parent_pid) const { + // Match browser process itself and its children. + return browser_pid_ == pid || browser_pid_ == parent_pid; + } + + private: + base::ProcessId browser_pid_; + + DISALLOW_COPY_AND_ASSIGN(ChromeProcessFilter); +}; + +} // namespace + +base::ProcessId ChromeBrowserProcessId(const FilePath& data_dir) { + HWND message_window = FindWindowEx(HWND_MESSAGE, NULL, + chrome::kMessageWindowClass, + data_dir.value().c_str()); + if (!message_window) + return -1; + + DWORD browser_pid = -1; + GetWindowThreadProcessId(message_window, &browser_pid); + + return browser_pid; +} + +ChromeProcessList GetRunningChromeProcesses(const FilePath& data_dir) { + ChromeProcessList result; + + base::ProcessId browser_pid = ChromeBrowserProcessId(data_dir); + if (browser_pid < 0) + return result; + + ChromeProcessFilter filter(browser_pid); + base::NamedProcessIterator it(chrome::kBrowserProcessExecutableName, &filter); + + const ProcessEntry* process_entry; + while (process_entry = it.NextProcessEntry()) + result.push_back(process_entry->th32ProcessID); + + return result; +} diff --git a/chrome/test/interactive_ui/interactive_ui.vcproj b/chrome/test/interactive_ui/interactive_ui.vcproj index 5d2f9f0..ade66f2 100644 --- a/chrome/test/interactive_ui/interactive_ui.vcproj +++ b/chrome/test/interactive_ui/interactive_ui.vcproj @@ -192,6 +192,18 @@ > </File> <File + RelativePath="..\chrome_process_util.cc" + > + </File> + <File + RelativePath="..\chrome_process_util.h" + > + </File> + <File + RelativePath="..\chrome_process_util_win.cc" + > + </File> + <File RelativePath="..\testing_profile.cc" > </File> diff --git a/chrome/test/memory_test/memory_test.cc b/chrome/test/memory_test/memory_test.cc index b437353..51be538 100644 --- a/chrome/test/memory_test/memory_test.cc +++ b/chrome/test/memory_test/memory_test.cc @@ -11,11 +11,11 @@ #include "chrome/browser/net/url_fixer_upper.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_paths.h" -#include "chrome/common/chrome_process_filter.h" #include "chrome/common/chrome_switches.h" #include "chrome/test/automation/browser_proxy.h" #include "chrome/test/automation/tab_proxy.h" #include "chrome/test/automation/window_proxy.h" +#include "chrome/test/chrome_process_util.h" #include "chrome/test/ui/ui_test.h" #include "chrome/test/perf/mem_usage.h" #include "googleurl/src/gurl.h" @@ -269,31 +269,25 @@ class MemoryTest : public UITest { void PrintIOPerfInfo(const char* test_name) { printf("\n"); - BrowserProcessFilter chrome_filter(user_data_dir_); - base::NamedProcessIterator - chrome_process_itr(chrome::kBrowserProcessExecutableName, - &chrome_filter); - - const PROCESSENTRY32* chrome_entry; - while (chrome_entry = chrome_process_itr.NextProcessEntry()) { - uint32 pid = chrome_entry->th32ProcessID; - HANDLE process_handle = OpenProcess(PROCESS_QUERY_INFORMATION, - false, - pid); - if (process_handle == NULL) { - wprintf(L"Error opening process %d: %d\n", pid, GetLastError()); - continue; - } + FilePath data_dir(FilePath::FromWStringHack(user_data_dir())); + int browser_process_pid = ChromeBrowserProcessId(data_dir); + ChromeProcessList chrome_processes(GetRunningChromeProcesses(data_dir)); + + ChromeProcessList::const_iterator it; + for (it = chrome_processes.begin(); it != chrome_processes.end(); ++it) { scoped_ptr<base::ProcessMetrics> process_metrics; IO_COUNTERS io_counters; + base::ProcessHandle process_handle; + if (!base::OpenProcessHandle(*it, &process_handle)) { + NOTREACHED(); + } process_metrics.reset( base::ProcessMetrics::CreateProcessMetrics(process_handle)); ZeroMemory(&io_counters, sizeof(io_counters)); if (process_metrics.get()->GetIOCounters(&io_counters)) { - std::string chrome_name = - (pid == chrome_filter.browser_process_id()) ? "_b" : "_r"; + std::string chrome_name = (*it == browser_process_pid) ? "_b" : "_r"; // Print out IO performance. We assume that the values can be // converted to size_t (they're reported as ULONGLONG, 64-bit numbers). @@ -316,31 +310,32 @@ class MemoryTest : public UITest { static_cast<size_t>(io_counters.OtherTransferCount / 1024), "kb", false /* not important */); } + + base::CloseProcessHandle(process_handle); } } void PrintMemoryUsageInfo(const char* test_name) { printf("\n"); - BrowserProcessFilter chrome_filter(user_data_dir_); - base::NamedProcessIterator - chrome_process_itr(chrome::kBrowserProcessExecutableName, - &chrome_filter); + + FilePath data_dir(FilePath::FromWStringHack(user_data_dir())); + int browser_process_pid = ChromeBrowserProcessId(data_dir); + ChromeProcessList chrome_processes(GetRunningChromeProcesses(data_dir)); size_t browser_virtual_size = 0; size_t browser_working_set_size = 0; size_t virtual_size = 0; size_t working_set_size = 0; size_t num_chrome_processes = 0; - const PROCESSENTRY32* chrome_entry; - while (chrome_entry = chrome_process_itr.NextProcessEntry()) { - uint32 pid = chrome_entry->th32ProcessID; + ChromeProcessList::const_iterator it; + for (it = chrome_processes.begin(); it != chrome_processes.end(); ++it) { size_t peak_virtual_size; size_t current_virtual_size; size_t peak_working_set_size; size_t current_working_set_size; - if (GetMemoryInfo(pid, &peak_virtual_size, ¤t_virtual_size, + if (GetMemoryInfo(*it, &peak_virtual_size, ¤t_virtual_size, &peak_working_set_size, ¤t_working_set_size)) { - if (pid == chrome_filter.browser_process_id()) { + if (*it == browser_process_pid) { browser_virtual_size = current_virtual_size; browser_working_set_size = current_working_set_size; } diff --git a/chrome/test/memory_test/memory_test.vcproj b/chrome/test/memory_test/memory_test.vcproj index 9de4326..d276fda 100644 --- a/chrome/test/memory_test/memory_test.vcproj +++ b/chrome/test/memory_test/memory_test.vcproj @@ -164,6 +164,18 @@ > </File> <File + RelativePath="..\chrome_process_util.cc" + > + </File> + <File + RelativePath="..\chrome_process_util.h" + > + </File> + <File + RelativePath="..\chrome_process_util_win.cc" + > + </File> + <File RelativePath="..\testing_browser_process.h" > </File> diff --git a/chrome/test/page_cycler/page_cycler_test.cc b/chrome/test/page_cycler/page_cycler_test.cc index 45a769c..91708cf 100644 --- a/chrome/test/page_cycler/page_cycler_test.cc +++ b/chrome/test/page_cycler/page_cycler_test.cc @@ -11,13 +11,10 @@ #include "chrome/browser/net/url_fixer_upper.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_paths.h" -#if defined(OS_WIN) -// TODO(port): Enable when chrome_process_filter.h is ported. -#include "chrome/common/chrome_process_filter.h" -#endif // defined(OS_WIN) #include "chrome/common/chrome_switches.h" #include "chrome/test/automation/tab_proxy.h" #include "chrome/test/automation/window_proxy.h" +#include "chrome/test/chrome_process_util.h" #include "chrome/test/ui/ui_test.h" #include "chrome/test/perf/mem_usage.h" #include "googleurl/src/gurl.h" @@ -88,19 +85,19 @@ class PageCyclerTest : public UITest { } #if defined(OS_WIN) - // TODO(port): Code below depends on BrowserProcessFilter and has windowsisms. + // TODO(port): Port chrome_process_util and remove windowsisms. void PrintIOPerfInfo(const char* test_name) { - BrowserProcessFilter chrome_filter(L""); - base::NamedProcessIterator - chrome_process_itr(chrome::kBrowserProcessExecutableName, - &chrome_filter); - - const PROCESSENTRY32* chrome_entry; - while(chrome_entry = chrome_process_itr.NextProcessEntry()) { - uint32 pid = chrome_entry->th32ProcessID; - HANDLE process_handle = OpenProcess(PROCESS_QUERY_INFORMATION, - false, - pid); + FilePath data_dir; + PathService::Get(chrome::DIR_USER_DATA, &data_dir); + int browser_process_pid = ChromeBrowserProcessId(data_dir); + ChromeProcessList chrome_processes(GetRunningChromeProcesses(data_dir)); + + ChromeProcessList::const_iterator it; + for (it = chrome_processes.begin(); it != chrome_processes.end(); ++it) { + base::ProcessHandle process_handle; + if (!base::OpenProcessHandle(*it, &process_handle)) { + NOTREACHED(); + } scoped_ptr<base::ProcessMetrics> process_metrics; IO_COUNTERS io_counters; @@ -111,8 +108,7 @@ class PageCyclerTest : public UITest { if (process_metrics.get()->GetIOCounters(&io_counters)) { // Print out IO performance. We assume that the values can be // converted to size_t (they're reported as ULONGLONG, 64-bit numbers). - std::string chrome_name = - (pid == chrome_filter.browser_process_id()) ? "_b" : "_r"; + std::string chrome_name = (*it == browser_process_pid) ? "_b" : "_r"; PrintResult("read_op", chrome_name, "r_op" + chrome_name + test_name, @@ -156,27 +152,27 @@ class PageCyclerTest : public UITest { } + + base::CloseProcessHandle(process_handle); } } void PrintMemoryUsageInfo(const char* test_name) { - BrowserProcessFilter chrome_filter(L""); - base::NamedProcessIterator - chrome_process_itr(chrome::kBrowserProcessExecutableName, - &chrome_filter); - - const PROCESSENTRY32* chrome_entry; - while(chrome_entry = chrome_process_itr.NextProcessEntry()) { - uint32 pid = chrome_entry->th32ProcessID; + FilePath data_dir; + PathService::Get(chrome::DIR_USER_DATA, &data_dir); + int browser_process_pid = ChromeBrowserProcessId(data_dir); + ChromeProcessList chrome_processes(GetRunningChromeProcesses(data_dir)); + + ChromeProcessList::const_iterator it; + for (it = chrome_processes.begin(); it != chrome_processes.end(); ++it) { size_t peak_virtual_size; size_t current_virtual_size; size_t peak_working_set_size; size_t current_working_set_size; - if (GetMemoryInfo(pid, &peak_virtual_size, ¤t_virtual_size, + if (GetMemoryInfo(*it, &peak_virtual_size, ¤t_virtual_size, &peak_working_set_size, ¤t_working_set_size)) { - std::string chrome_name = - (pid == chrome_filter.browser_process_id()) ? "_b" : "_r"; + std::string chrome_name = (*it == browser_process_pid) ? "_b" : "_r"; std::string trace_name(test_name); PrintResult("vm_peak", chrome_name, diff --git a/chrome/test/page_cycler/page_cycler_tests.vcproj b/chrome/test/page_cycler/page_cycler_tests.vcproj index d3a7717..2f1a4d5 100644 --- a/chrome/test/page_cycler/page_cycler_tests.vcproj +++ b/chrome/test/page_cycler/page_cycler_tests.vcproj @@ -164,6 +164,18 @@ > </File> <File + RelativePath="..\chrome_process_util.cc" + > + </File> + <File + RelativePath="..\chrome_process_util.h" + > + </File> + <File + RelativePath="..\chrome_process_util_win.cc" + > + </File> + <File RelativePath="..\testing_browser_process.h" > </File> diff --git a/chrome/test/perf/mem_usage.cc b/chrome/test/perf/mem_usage.cc index 853bfac..f67e56a 100644 --- a/chrome/test/perf/mem_usage.cc +++ b/chrome/test/perf/mem_usage.cc @@ -6,9 +6,12 @@ #include <psapi.h> #include "base/basictypes.h" +#include "base/file_path.h" +#include "base/path_service.h" #include "base/process_util.h" #include "chrome/common/chrome_constants.h" -#include "chrome/common/chrome_process_filter.h" +#include "chrome/common/chrome_paths.h" +#include "chrome/test/chrome_process_util.h" #include "chrome/test/perf/mem_usage.h" bool GetMemoryInfo(uint32 process_id, @@ -80,20 +83,21 @@ size_t GetSystemCommitCharge() { void PrintChromeMemoryUsageInfo() { printf("\n"); - BrowserProcessFilter chrome_filter(L""); - base::NamedProcessIterator - chrome_process_itr(chrome::kBrowserProcessExecutableName, &chrome_filter); - const PROCESSENTRY32* chrome_entry; - while (chrome_entry = chrome_process_itr.NextProcessEntry()) { - uint32 pid = chrome_entry->th32ProcessID; + FilePath data_dir; + PathService::Get(chrome::DIR_USER_DATA, &data_dir); + int browser_process_pid = ChromeBrowserProcessId(data_dir); + ChromeProcessList chrome_processes(GetRunningChromeProcesses(data_dir)); + + ChromeProcessList::const_iterator it; + for (it = chrome_processes.begin(); it != chrome_processes.end(); ++it) { size_t peak_virtual_size; size_t current_virtual_size; size_t peak_working_set_size; size_t current_working_set_size; - if (GetMemoryInfo(pid, &peak_virtual_size, ¤t_virtual_size, + if (GetMemoryInfo(*it, &peak_virtual_size, ¤t_virtual_size, &peak_working_set_size, ¤t_working_set_size)) { - if (pid == chrome_filter.browser_process_id()) { + if (*it == browser_process_pid) { wprintf(L"browser_vm_peak = %d\n", peak_virtual_size); wprintf(L"browser_vm_current = %d\n", current_virtual_size); wprintf(L"browser_ws_peak = %d\n", peak_working_set_size); diff --git a/chrome/test/plugin/plugin_tests.vcproj b/chrome/test/plugin/plugin_tests.vcproj index 0e43ea8..8898adc 100644 --- a/chrome/test/plugin/plugin_tests.vcproj +++ b/chrome/test/plugin/plugin_tests.vcproj @@ -165,6 +165,18 @@ > </File> <File + RelativePath="..\chrome_process_util.cc" + > + </File> + <File + RelativePath="..\chrome_process_util.h" + > + </File> + <File + RelativePath="..\chrome_process_util_win.cc" + > + </File> + <File RelativePath="..\testing_browser_process.h" > </File> diff --git a/chrome/test/reliability/reliability_tests.vcproj b/chrome/test/reliability/reliability_tests.vcproj index 1e443a7f..49a5600 100644 --- a/chrome/test/reliability/reliability_tests.vcproj +++ b/chrome/test/reliability/reliability_tests.vcproj @@ -168,6 +168,18 @@ > </File> <File + RelativePath="..\chrome_process_util.cc" + > + </File> + <File + RelativePath="..\chrome_process_util.h" + > + </File> + <File + RelativePath="..\chrome_process_util_win.cc" + > + </File> + <File RelativePath="..\testing_browser_process.h" > </File> diff --git a/chrome/test/selenium/selenium_tests.vcproj b/chrome/test/selenium/selenium_tests.vcproj index 727dfa0..42c95fc 100644 --- a/chrome/test/selenium/selenium_tests.vcproj +++ b/chrome/test/selenium/selenium_tests.vcproj @@ -164,6 +164,18 @@ > </File> <File + RelativePath="..\chrome_process_util.cc" + > + </File> + <File + RelativePath="..\chrome_process_util.h" + > + </File> + <File + RelativePath="..\chrome_process_util_win.cc" + > + </File> + <File RelativePath="..\testing_browser_process.h" > </File> diff --git a/chrome/test/startup/startup_tests.vcproj b/chrome/test/startup/startup_tests.vcproj index 1ebb980..6087ede3 100644 --- a/chrome/test/startup/startup_tests.vcproj +++ b/chrome/test/startup/startup_tests.vcproj @@ -164,6 +164,18 @@ > </File> <File + RelativePath="..\chrome_process_util.cc" + > + </File> + <File + RelativePath="..\chrome_process_util.h" + > + </File> + <File + RelativePath="..\chrome_process_util_win.cc" + > + </File> + <File RelativePath="..\testing_browser_process.h" > </File> diff --git a/chrome/test/tab_switching/tab_switching.vcproj b/chrome/test/tab_switching/tab_switching.vcproj index bdc2836..81e185f 100644 --- a/chrome/test/tab_switching/tab_switching.vcproj +++ b/chrome/test/tab_switching/tab_switching.vcproj @@ -164,6 +164,18 @@ > </File> <File + RelativePath="..\chrome_process_util.cc" + > + </File> + <File + RelativePath="..\chrome_process_util.h" + > + </File> + <File + RelativePath="..\chrome_process_util_win.cc" + > + </File> + <File RelativePath="..\testing_browser_process.h" > </File> diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc index d273175..d30643b2 100644 --- a/chrome/test/ui/ui_test.cc +++ b/chrome/test/ui/ui_test.cc @@ -11,6 +11,7 @@ #include "base/command_line.h" #include "base/file_path.h" #include "base/file_util.h" +#include "base/path_service.h" #include "base/platform_thread.h" #include "base/process_util.h" #include "base/scoped_ptr.h" @@ -28,12 +29,12 @@ #include "chrome/test/automation/automation_proxy.h" #include "chrome/test/automation/browser_proxy.h" #include "chrome/test/automation/tab_proxy.h" +#include "chrome/test/chrome_process_util.h" #include "googleurl/src/gurl.h" #include "net/base/net_util.h" #if defined(OS_WIN) -// TODO(port): these just need to be ported. -#include "chrome/common/chrome_process_filter.h" +// TODO(port): this just needs to be ported. #include "chrome/test/automation/window_proxy.h" #endif @@ -448,30 +449,22 @@ void UITest::AssertAppNotRunning(const std::wstring& error_message) { #if defined(OS_WIN) ASSERT_EQ(0, GetBrowserProcessCount()) << error_message; #else - // TODO(port): Enable when chrome_process_filter is ported. + // TODO(port): Enable when chrome_process_util is ported. NOTIMPLEMENTED(); #endif } void UITest::CleanupAppProcesses() { #if defined(OS_WIN) - BrowserProcessFilter filter(L""); - - // Make sure that no instances of the browser remain. - const int kExitTimeoutMs = 5000; - const int kExitCode = 1; - base::CleanupProcesses( - chrome::kBrowserProcessExecutableName, kExitTimeoutMs, kExitCode, - &filter); + TerminateAllChromeProcesses(FilePath::FromWStringHack(user_data_dir())); // Suppress spammy failures that seem to be occurring when running // the UI tests in single-process mode. // TODO(jhughes): figure out why this is necessary at all, and fix it - if (!in_process_renderer_) { + if (!in_process_renderer_) AssertAppNotRunning(L"Unable to quit all browser processes."); - } #else - // TODO(port): depends on BrowserProcessFilter. + // TODO(port): depends on chrome_process_util. NOTIMPLEMENTED(); #endif } @@ -593,13 +586,13 @@ bool UITest::CrashAwareSleep(int time_out_ms) { } #if defined(OS_WIN) -// TODO(port): Port BrowserProcessFilter and sort out one wstring/string issue. +// TODO(port): Port GetRunningChromeProcesses and sort out one w/string issue. /*static*/ int UITest::GetBrowserProcessCount() { - BrowserProcessFilter filter(L""); - return base::GetProcessCount(chrome::kBrowserProcessExecutableName, - &filter); + FilePath data_dir; + PathService::Get(chrome::DIR_USER_DATA, &data_dir); + return GetRunningChromeProcesses(data_dir).size(); } static DictionaryValue* LoadDictionaryValueFromPath(const FilePath& path) { diff --git a/chrome/test/ui/ui_tests.vcproj b/chrome/test/ui/ui_tests.vcproj index 48df244..ea13ea6 100644 --- a/chrome/test/ui/ui_tests.vcproj +++ b/chrome/test/ui/ui_tests.vcproj @@ -174,6 +174,18 @@ > </File> <File + RelativePath="..\chrome_process_util.cc" + > + </File> + <File + RelativePath="..\chrome_process_util.h" + > + </File> + <File + RelativePath="..\chrome_process_util_win.cc" + > + </File> + <File RelativePath="..\testing_browser_process.h" > </File> diff --git a/chrome/test/url_fetch_test/url_fetch_test.vcproj b/chrome/test/url_fetch_test/url_fetch_test.vcproj index a704ff0..61906f1 100644 --- a/chrome/test/url_fetch_test/url_fetch_test.vcproj +++ b/chrome/test/url_fetch_test/url_fetch_test.vcproj @@ -174,6 +174,18 @@ >
</File>
<File
+ RelativePath="..\chrome_process_util.cc"
+ >
+ </File>
+ <File
+ RelativePath="..\chrome_process_util.h"
+ >
+ </File>
+ <File
+ RelativePath="..\chrome_process_util_win.cc"
+ >
+ </File>
+ <File
RelativePath="..\testing_browser_process.h"
>
</File>
|