Commit 77caa668 authored by jam@chromium.org's avatar jam@chromium.org

Convert ProcessSingleton ui_test to browser_test.

BUG=121574
Review URL: https://chromiumcodereview.appspot.com/10161016

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133452 0039d316-1c4b-4281-b951-d872f2087c98
parent 73b83d64
......@@ -10,9 +10,8 @@
// makes sense to test that the system services are giving the behavior we
// want?)
#include <list>
#include "base/bind.h"
#include "base/command_line.h"
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/memory/ref_counted.h"
......@@ -26,8 +25,7 @@
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/test/base/test_launcher_utils.h"
#include "chrome/test/ui/ui_test.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "chrome/test/base/in_process_browser_test.h"
namespace {
......@@ -60,11 +58,9 @@ class ChromeStarter : public base::RefCountedThreadSafe<ChromeStarter> {
void StartChrome(base::WaitableEvent* start_event, bool first_run) {
// TODO(mattm): maybe stuff should be refactored to use
// UITest::LaunchBrowserHelper somehow?
FilePath browser_directory;
PathService::Get(chrome::DIR_APP, &browser_directory);
CommandLine command_line(browser_directory.Append(
chrome::kBrowserProcessExecutablePath));
FilePath program;
ASSERT_TRUE(PathService::Get(base::FILE_EXE, &program));
CommandLine command_line(program);
command_line.AppendSwitchPath(switches::kUserDataDir, user_data_dir_);
if (first_run)
......@@ -130,8 +126,10 @@ class ChromeStarter : public base::RefCountedThreadSafe<ChromeStarter> {
DISALLOW_COPY_AND_ASSIGN(ChromeStarter);
};
} // namespace
// Our test fixture that initializes and holds onto a few global vars.
class ProcessSingletonTest : public UITest {
class ProcessSingletonTest : public InProcessBrowserTest {
public:
ProcessSingletonTest()
// We use a manual reset so that all threads wake up at once when signaled
......@@ -190,10 +188,12 @@ class ProcessSingletonTest : public UITest {
// But don't try more than kNbTries times...
static const int kNbTries = 10;
int num_tries = 0;
while (base::GetProcessCount(chrome::kBrowserProcessExecutablePath,
&process_tree_filter) > 0 && num_tries++ < kNbTries) {
base::KillProcesses(chrome::kBrowserProcessExecutablePath,
kExitCode, &process_tree_filter);
FilePath program;
ASSERT_TRUE(PathService::Get(base::FILE_EXE, &program));
FilePath::StringType exe_name = program.BaseName().value();
while (base::GetProcessCount(exe_name, &process_tree_filter) > 0 &&
num_tries++ < kNbTries) {
base::KillProcesses(exe_name, kExitCode, &process_tree_filter);
}
DLOG_IF(ERROR, num_tries >= kNbTries) << "Failed to kill all processes!";
}
......@@ -223,7 +223,7 @@ class ProcessSingletonTest : public UITest {
#else
#define MAYBE_StartupRaceCondition StartupRaceCondition
#endif
TEST_F(ProcessSingletonTest, MAYBE_StartupRaceCondition) {
IN_PROC_BROWSER_TEST_F(ProcessSingletonTest, MAYBE_StartupRaceCondition) {
// We use this to stop the attempts loop on the first failure.
bool failed = false;
for (size_t attempt = 0; attempt < kNbAttempts && !failed; ++attempt) {
......@@ -323,5 +323,3 @@ TEST_F(ProcessSingletonTest, MAYBE_StartupRaceCondition) {
}
}
}
} // namespace
......@@ -715,7 +715,6 @@
# New tests should be browser_tests. browser_tests are sharded and are
# less flakier.
'browser/process_singleton_linux_uitest.cc',
'browser/process_singleton_uitest.cc',
'browser/session_history_uitest.cc',
'browser/sessions/session_restore_uitest.cc',
'browser/ui/tests/browser_uitest.cc',
......@@ -757,12 +756,6 @@
'../ui/aura/aura.gyp:aura',
],
}],
['OS=="mac"', {
'sources!': [
# ProcessSingletonMac doesn't do anything.
'browser/process_singleton_uitest.cc',
],
}],
['OS=="win"', {
'include_dirs': [
'<(DEPTH)/third_party/wtl/include',
......@@ -2885,6 +2878,7 @@
'browser/printing/cloud_print/test/cloud_print_proxy_process_browsertest.cc',
'browser/printing/printing_layout_browsertest.cc',
'browser/printing/print_preview_tab_controller_browsertest.cc',
'browser/process_singleton_browsertest.cc',
'browser/profiles/profile_browsertest.cc',
'browser/profiles/profile_manager_browsertest.cc',
'browser/protector/default_search_provider_change_browsertest.cc',
......@@ -3323,6 +3317,8 @@
# TODO(hbono): This test depends on hunspell and we cannot run it on
# Mac, which does not use hunspell by default.
'browser/spellchecker/spellcheck_host_browsertest.cc',
# ProcessSingletonMac doesn't do anything.
'browser/process_singleton_browsertest.cc',
],
}, { # else: OS != "mac"
'sources!': [
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment