summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorerg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-30 20:15:25 +0000
committererg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-30 20:15:25 +0000
commitdcd869cd5cc3d237e76608126094240c09fc3632 (patch)
tree28bc5af2ab3440952b3316ec38ca5d39e77890e2
parent50d6e170a47305a393a07e7f2244e9045fd0ea07 (diff)
downloadchromium_src-dcd869cd5cc3d237e76608126094240c09fc3632.zip
chromium_src-dcd869cd5cc3d237e76608126094240c09fc3632.tar.gz
chromium_src-dcd869cd5cc3d237e76608126094240c09fc3632.tar.bz2
FBTF: Move some heavy, repeatedly emitted symbols to implementation files.
BUG=none TEST=compiles Review URL: http://codereview.chromium.org/3162047 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57896 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--app/app_paths.cc7
-rw-r--r--app/gfx/gl/gl_implementation.cc1
-rw-r--r--base/command_line.cc12
-rw-r--r--base/command_line.h11
-rw-r--r--base/process_util_unittest.cc1
-rw-r--r--chrome/browser/prefs/command_line_pref_store.cc1
-rw-r--r--chrome/browser/search_engines/template_url.cc30
-rw-r--r--chrome/browser/search_engines/template_url.h25
-rw-r--r--chrome/chrome_tests.gypi3
-rw-r--r--chrome/common/sandbox_init_wrapper_mac.cc1
-rw-r--r--chrome/nacl/nacl_main_platform_delegate_mac.mm1
-rw-r--r--chrome/nacl/nacl_main_platform_delegate_win.cc2
-rw-r--r--chrome/renderer/renderer_main_platform_delegate_win.cc1
-rw-r--r--chrome/test/test_launcher/out_of_proc_test_runner.cc1
-rw-r--r--chrome/test/ui/ui_test_suite.cc1
-rw-r--r--chrome/test/unit/chrome_test_suite.cc163
-rw-r--r--chrome/test/unit/chrome_test_suite.h151
-rw-r--r--chrome_frame/chrome_frame.gyp1
18 files changed, 238 insertions, 175 deletions
diff --git a/app/app_paths.cc b/app/app_paths.cc
index b3efb09..ad10dad 100644
--- a/app/app_paths.cc
+++ b/app/app_paths.cc
@@ -1,12 +1,13 @@
-// 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.
+// Copyright (c) 2010 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 "app/app_paths.h"
#include "base/command_line.h"
#include "base/file_path.h"
#include "base/file_util.h"
+#include "base/logging.h"
#include "base/path_service.h"
namespace app {
diff --git a/app/gfx/gl/gl_implementation.cc b/app/gfx/gl/gl_implementation.cc
index 3739611..21a4455 100644
--- a/app/gfx/gl/gl_implementation.cc
+++ b/app/gfx/gl/gl_implementation.cc
@@ -10,6 +10,7 @@
#include "app/app_switches.h"
#include "base/at_exit.h"
#include "base/command_line.h"
+#include "base/logging.h"
namespace gfx {
namespace {
diff --git a/base/command_line.cc b/base/command_line.cc
index 9b531fa..d34bcb9 100644
--- a/base/command_line.cc
+++ b/base/command_line.cc
@@ -273,6 +273,12 @@ void CommandLine::Reset() {
current_process_commandline_ = NULL;
}
+// static
+CommandLine* CommandLine::ForCurrentProcess() {
+ DCHECK(current_process_commandline_);
+ return current_process_commandline_;
+}
+
bool CommandLine::HasSwitch(const std::string& switch_string) const {
std::string lowercased_switch(switch_string);
#if defined(OS_WIN)
@@ -530,3 +536,9 @@ void CommandLine::CopySwitchesFrom(const CommandLine& source,
// private
CommandLine::CommandLine() {
}
+
+// static
+CommandLine* CommandLine::ForCurrentProcessMutable() {
+ DCHECK(current_process_commandline_);
+ return current_process_commandline_;
+}
diff --git a/base/command_line.h b/base/command_line.h
index e4ac08b..ce10d65 100644
--- a/base/command_line.h
+++ b/base/command_line.h
@@ -24,7 +24,6 @@
#include <vector>
#include "base/basictypes.h"
-#include "base/logging.h"
class FilePath;
class InProcessBrowserTest;
@@ -83,10 +82,7 @@ class CommandLine {
// Get the singleton CommandLine representing the current process's
// command line. Note: returned value is mutable, but not thread safe;
// only mutate if you know what you're doing!
- static CommandLine* ForCurrentProcess() {
- DCHECK(current_process_commandline_);
- return current_process_commandline_;
- }
+ static CommandLine* ForCurrentProcess();
// Returns true if this command line contains the given switch.
// (Switch names are case-insensitive.)
@@ -180,10 +176,7 @@ class CommandLine {
CommandLine();
// Used by InProcessBrowserTest.
- static CommandLine* ForCurrentProcessMutable() {
- DCHECK(current_process_commandline_);
- return current_process_commandline_;
- }
+ static CommandLine* ForCurrentProcessMutable();
// The singleton CommandLine instance representing the current process's
// command line.
diff --git a/base/process_util_unittest.cc b/base/process_util_unittest.cc
index bea84c7..e92459c 100644
--- a/base/process_util_unittest.cc
+++ b/base/process_util_unittest.cc
@@ -9,6 +9,7 @@
#include "base/command_line.h"
#include "base/eintr_wrapper.h"
#include "base/file_path.h"
+#include "base/logging.h"
#include "base/path_service.h"
#include "base/platform_thread.h"
#include "base/process_util.h"
diff --git a/chrome/browser/prefs/command_line_pref_store.cc b/chrome/browser/prefs/command_line_pref_store.cc
index 41770e9..3331ed5b 100644
--- a/chrome/browser/prefs/command_line_pref_store.cc
+++ b/chrome/browser/prefs/command_line_pref_store.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/prefs/command_line_pref_store.h"
#include "app/app_switches.h"
+#include "base/logging.h"
#include "base/values.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
diff --git a/chrome/browser/search_engines/template_url.cc b/chrome/browser/search_engines/template_url.cc
index a289826f..98d80fb 100644
--- a/chrome/browser/search_engines/template_url.cc
+++ b/chrome/browser/search_engines/template_url.cc
@@ -79,6 +79,17 @@ TemplateURLRef::TemplateURLRef() {
Set(std::string(), 0, 0);
}
+TemplateURLRef::TemplateURLRef(const std::string& url,
+ int index_offset,
+ int page_offset)
+ : url_(url),
+ index_offset_(index_offset),
+ page_offset_(page_offset),
+ parsed_(false),
+ valid_(false),
+ supports_replacements_(false) {
+}
+
void TemplateURLRef::Set(const std::string& url,
int index_offset,
int page_offset) {
@@ -88,6 +99,9 @@ void TemplateURLRef::Set(const std::string& url,
InvalidateCachedValues();
}
+TemplateURLRef::~TemplateURLRef() {
+}
+
bool TemplateURLRef::ParseParameter(size_t start,
size_t end,
std::string* url,
@@ -555,6 +569,22 @@ bool TemplateURL::SupportsReplacement(const TemplateURL* turl) {
return turl && turl->url() && turl->url()->SupportsReplacement();
}
+TemplateURL::TemplateURL()
+ : autogenerate_keyword_(false),
+ keyword_generated_(false),
+ show_in_default_list_(false),
+ safe_for_autoreplace_(false),
+ id_(0),
+ date_created_(base::Time::Now()),
+ usage_count_(0),
+ search_engine_type_(TemplateURLPrepopulateData::SEARCH_ENGINE_OTHER),
+ logo_id_(0),
+ prepopulate_id_(0) {
+}
+
+TemplateURL::~TemplateURL() {
+}
+
std::wstring TemplateURL::AdjustedShortNameForLocaleDirection() const {
std::wstring bidi_safe_short_name;
if (base::i18n::AdjustStringForLocaleDirection(short_name_,
diff --git a/chrome/browser/search_engines/template_url.h b/chrome/browser/search_engines/template_url.h
index 584626b..fbcdd8b 100644
--- a/chrome/browser/search_engines/template_url.h
+++ b/chrome/browser/search_engines/template_url.h
@@ -49,14 +49,9 @@ class TemplateURLRef {
TemplateURLRef();
- TemplateURLRef(const std::string& url, int index_offset, int page_offset)
- : url_(url),
- index_offset_(index_offset),
- page_offset_(page_offset),
- parsed_(false),
- valid_(false),
- supports_replacements_(false) {
- }
+ TemplateURLRef(const std::string& url, int index_offset, int page_offset);
+
+ ~TemplateURLRef();
// Returns true if this URL supports replacement.
bool SupportsReplacement() const;
@@ -270,18 +265,8 @@ class TemplateURL {
// replacement.
static bool SupportsReplacement(const TemplateURL* turl);
- TemplateURL()
- : autogenerate_keyword_(false),
- keyword_generated_(false),
- show_in_default_list_(false),
- safe_for_autoreplace_(false),
- id_(0),
- date_created_(base::Time::Now()),
- usage_count_(0),
- search_engine_type_(TemplateURLPrepopulateData::SEARCH_ENGINE_OTHER),
- logo_id_(0),
- prepopulate_id_(0) {}
- ~TemplateURL() {}
+ TemplateURL();
+ ~TemplateURL();
// A short description of the template. This is the name we show to the user
// in various places that use keywords. For example, the location bar shows
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index 6d2982e..bcdb6bb 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -128,6 +128,8 @@
'test/ui_test_utils_linux.cc',
'test/ui_test_utils_mac.mm',
'test/ui_test_utils_win.cc',
+ 'test/unit/chrome_test_suite.cc',
+ 'test/unit/chrome_test_suite.h',
],
'conditions': [
['OS=="linux"', {
@@ -1787,7 +1789,6 @@
'test/test_launcher/out_of_proc_test_runner.cc',
'test/test_launcher/test_runner.cc',
'test/test_launcher/test_runner.h',
- 'test/unit/chrome_test_suite.h',
],
'conditions': [
['chromeos==0', {
diff --git a/chrome/common/sandbox_init_wrapper_mac.cc b/chrome/common/sandbox_init_wrapper_mac.cc
index aaa69eb..d3017b7 100644
--- a/chrome/common/sandbox_init_wrapper_mac.cc
+++ b/chrome/common/sandbox_init_wrapper_mac.cc
@@ -6,6 +6,7 @@
#include "base/command_line.h"
#include "base/file_path.h"
+#include "base/logging.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/sandbox_mac.h"
diff --git a/chrome/nacl/nacl_main_platform_delegate_mac.mm b/chrome/nacl/nacl_main_platform_delegate_mac.mm
index 61a2ed7..c2373cb 100644
--- a/chrome/nacl/nacl_main_platform_delegate_mac.mm
+++ b/chrome/nacl/nacl_main_platform_delegate_mac.mm
@@ -8,6 +8,7 @@
#include <dlfcn.h>
#import "base/chrome_application_mac.h"
#include "base/command_line.h"
+#include "base/logging.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/sandbox_mac.h"
#include "third_party/WebKit/WebKit/mac/WebCoreSupport/WebSystemInterface.h"
diff --git a/chrome/nacl/nacl_main_platform_delegate_win.cc b/chrome/nacl/nacl_main_platform_delegate_win.cc
index 3cf140ca..2d90ec9 100644
--- a/chrome/nacl/nacl_main_platform_delegate_win.cc
+++ b/chrome/nacl/nacl_main_platform_delegate_win.cc
@@ -3,7 +3,9 @@
// found in the LICENSE file.
#include "chrome/nacl/nacl_main_platform_delegate.h"
+
#include "base/command_line.h"
+#include "base/logging.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_switches.h"
#include "sandbox/src/sandbox.h"
diff --git a/chrome/renderer/renderer_main_platform_delegate_win.cc b/chrome/renderer/renderer_main_platform_delegate_win.cc
index 104eba5..3af2793 100644
--- a/chrome/renderer/renderer_main_platform_delegate_win.cc
+++ b/chrome/renderer/renderer_main_platform_delegate_win.cc
@@ -5,6 +5,7 @@
#include "chrome/renderer/renderer_main_platform_delegate.h"
#include "base/command_line.h"
+#include "base/logging.h"
#include "base/scoped_ptr.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_switches.h"
diff --git a/chrome/test/test_launcher/out_of_proc_test_runner.cc b/chrome/test/test_launcher/out_of_proc_test_runner.cc
index 786863a..47be495 100644
--- a/chrome/test/test_launcher/out_of_proc_test_runner.cc
+++ b/chrome/test/test_launcher/out_of_proc_test_runner.cc
@@ -15,6 +15,7 @@
#if defined(OS_WIN)
#include "base/base_switches.h"
#include "chrome/common/chrome_constants.h"
+#include "chrome/common/chrome_switches.h"
#include "chrome/common/sandbox_policy.h"
#include "sandbox/src/dep.h"
#include "sandbox/src/sandbox_factory.h"
diff --git a/chrome/test/ui/ui_test_suite.cc b/chrome/test/ui/ui_test_suite.cc
index fd83857..6cc32e5 100644
--- a/chrome/test/ui/ui_test_suite.cc
+++ b/chrome/test/ui/ui_test_suite.cc
@@ -10,6 +10,7 @@
#include "base/path_service.h"
#include "base/process_util.h"
#include "base/string_number_conversions.h"
+#include "chrome/common/chrome_switches.h"
#include "chrome/common/env_vars.h"
// Timeout for the test in milliseconds. UI tests only.
diff --git a/chrome/test/unit/chrome_test_suite.cc b/chrome/test/unit/chrome_test_suite.cc
new file mode 100644
index 0000000..d9d08cf
--- /dev/null
+++ b/chrome/test/unit/chrome_test_suite.cc
@@ -0,0 +1,163 @@
+// Copyright (c) 2010 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/unit/chrome_test_suite.h"
+
+#include "app/app_paths.h"
+#include "app/resource_bundle.h"
+#include "base/command_line.h"
+#include "base/process_util.h"
+#include "base/scoped_nsautorelease_pool.h"
+#include "base/stats_table.h"
+#include "base/utf_string_conversions.h"
+#include "chrome/browser/browser_process.h"
+#include "chrome/common/chrome_constants.h"
+#include "chrome/common/chrome_paths.h"
+#include "chrome/common/chrome_switches.h"
+#include "chrome/common/url_constants.h"
+#include "chrome/test/testing_browser_process.h"
+
+#if defined(OS_MACOSX)
+#include "base/mac_util.h"
+#endif
+
+#if defined(OS_POSIX)
+#include "base/shared_memory.h"
+#endif
+
+static void RemoveSharedMemoryFile(const std::string& filename) {
+ // Stats uses SharedMemory under the hood. On posix, this results in a file
+ // on disk.
+#if defined(OS_POSIX)
+ base::SharedMemory memory;
+ memory.Delete(UTF8ToWide(filename));
+#endif
+}
+
+WarningHostResolverProc::WarningHostResolverProc()
+ : HostResolverProc(NULL) {
+}
+
+WarningHostResolverProc::~WarningHostResolverProc() {
+}
+
+int WarningHostResolverProc::Resolve(const std::string& host,
+ net::AddressFamily address_family,
+ net::HostResolverFlags host_resolver_flags,
+ net::AddressList* addrlist,
+ int* os_error) {
+ const char* kLocalHostNames[] = {"localhost", "127.0.0.1"};
+ bool local = false;
+
+ if (host == net::GetHostName()) {
+ local = true;
+ } else {
+ for (size_t i = 0; i < arraysize(kLocalHostNames); i++)
+ if (host == kLocalHostNames[i]) {
+ local = true;
+ break;
+ }
+ }
+
+ // Make the test fail so it's harder to ignore.
+ // If you really need to make real DNS query, use
+ // net::RuleBasedHostResolverProc and its AllowDirectLookup method.
+ EXPECT_TRUE(local) << "Making external DNS lookup of " << host;
+
+ return ResolveUsingPrevious(host, address_family, host_resolver_flags,
+ addrlist, os_error);
+}
+
+ChromeTestSuite::ChromeTestSuite(int argc, char** argv)
+ : base::TestSuite(argc, argv),
+ stats_table_(NULL),
+ created_user_data_dir_(false) {
+}
+
+ChromeTestSuite::~ChromeTestSuite() {
+}
+
+void ChromeTestSuite::Initialize() {
+ base::ScopedNSAutoreleasePool autorelease_pool;
+
+ base::TestSuite::Initialize();
+
+ chrome::RegisterChromeSchemes();
+ host_resolver_proc_ = new WarningHostResolverProc();
+ scoped_host_resolver_proc_.Init(host_resolver_proc_.get());
+
+ chrome::RegisterPathProvider();
+ app::RegisterPathProvider();
+ g_browser_process = new TestingBrowserProcess;
+
+ // Notice a user data override, and otherwise default to using a custom
+ // user data directory that lives alongside the current app.
+ // NOTE: The user data directory will be erased before each UI test that
+ // uses it, in order to ensure consistency.
+ FilePath user_data_dir =
+ CommandLine::ForCurrentProcess()->GetSwitchValuePath(
+ switches::kUserDataDir);
+ if (user_data_dir.empty() &&
+ file_util::CreateNewTempDirectory(FILE_PATH_LITERAL("chrome_test_"),
+ &user_data_dir)) {
+ user_data_dir = user_data_dir.AppendASCII("test_user_data");
+ created_user_data_dir_ = true;
+ }
+ if (!user_data_dir.empty())
+ PathService::Override(chrome::DIR_USER_DATA, user_data_dir);
+
+ if (!browser_dir_.empty()) {
+ PathService::Override(base::DIR_EXE, browser_dir_);
+ PathService::Override(base::DIR_MODULE, browser_dir_);
+ }
+
+#if defined(OS_MACOSX)
+ // Look in the framework bundle for resources.
+ FilePath path;
+ PathService::Get(base::DIR_EXE, &path);
+ path = path.Append(chrome::kFrameworkName);
+ mac_util::SetOverrideAppBundlePath(path);
+#endif
+
+ // Force unittests to run using en-US so if we test against string
+ // output, it'll pass regardless of the system language.
+ ResourceBundle::InitSharedInstance("en-US");
+
+ // initialize the global StatsTable for unit_tests (make sure the file
+ // doesn't exist before opening it so the test gets a clean slate)
+ stats_filename_ = "unit_tests";
+ std::string pid_string = StringPrintf("-%d", base::GetCurrentProcId());
+ stats_filename_ += pid_string;
+ RemoveSharedMemoryFile(stats_filename_);
+ stats_table_ = new StatsTable(stats_filename_, 20, 200);
+ StatsTable::set_current(stats_table_);
+}
+
+void ChromeTestSuite::Shutdown() {
+ ResourceBundle::CleanupSharedInstance();
+
+#if defined(OS_MACOSX)
+ mac_util::SetOverrideAppBundle(NULL);
+#endif
+
+ delete g_browser_process;
+ g_browser_process = NULL;
+
+ // Tear down shared StatsTable; prevents unit_tests from leaking it.
+ StatsTable::set_current(NULL);
+ delete stats_table_;
+ RemoveSharedMemoryFile(stats_filename_);
+
+ // Delete the test_user_data dir recursively
+ // NOTE: user_data_dir will be deleted only if it was automatically
+ // created.
+ FilePath user_data_dir;
+ if (created_user_data_dir_ &&
+ PathService::Get(chrome::DIR_USER_DATA, &user_data_dir) &&
+ !user_data_dir.empty()) {
+ file_util::Delete(user_data_dir, true);
+ file_util::Delete(user_data_dir.DirName(), false);
+ }
+ base::TestSuite::Shutdown();
+}
diff --git a/chrome/test/unit/chrome_test_suite.h b/chrome/test/unit/chrome_test_suite.h
index 1cdd90f..7af42cc 100644
--- a/chrome/test/unit/chrome_test_suite.h
+++ b/chrome/test/unit/chrome_test_suite.h
@@ -10,173 +10,40 @@
#include "build/build_config.h"
-#include "app/app_paths.h"
-#include "app/resource_bundle.h"
-#include "base/command_line.h"
-#include "base/stats_table.h"
#include "base/file_util.h"
#include "base/path_service.h"
-#include "base/process_util.h"
#include "base/ref_counted.h"
-#include "base/scoped_nsautorelease_pool.h"
#include "base/test/test_suite.h"
-#include "base/utf_string_conversions.h"
#include "chrome/app/scoped_ole_initializer.h"
-#include "chrome/browser/browser_process.h"
-#include "chrome/common/chrome_constants.h"
-#include "chrome/common/chrome_paths.h"
-#include "chrome/common/chrome_switches.h"
-#include "chrome/common/url_constants.h"
-#include "chrome/test/testing_browser_process.h"
+#include "testing/gtest/include/gtest/gtest.h"
#include "net/base/mock_host_resolver.h"
#include "net/base/net_util.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-#if defined(OS_MACOSX)
-#include "base/mac_util.h"
-#endif
-
-#if defined(OS_POSIX)
-#include "base/shared_memory.h"
-#endif
-static void RemoveSharedMemoryFile(const std::string& filename) {
- // Stats uses SharedMemory under the hood. On posix, this results in a file
- // on disk.
-#if defined(OS_POSIX)
- base::SharedMemory memory;
- memory.Delete(UTF8ToWide(filename));
-#endif
-}
+class StatsTable;
// In many cases it may be not obvious that a test makes a real DNS lookup.
// We generally don't want to rely on external DNS servers for our tests,
// so this host resolver procedure catches external queries.
class WarningHostResolverProc : public net::HostResolverProc {
public:
- WarningHostResolverProc() : HostResolverProc(NULL) {}
+ WarningHostResolverProc();
+ virtual ~WarningHostResolverProc();
virtual int Resolve(const std::string& host,
net::AddressFamily address_family,
net::HostResolverFlags host_resolver_flags,
net::AddressList* addrlist,
- int* os_error) {
- const char* kLocalHostNames[] = {"localhost", "127.0.0.1"};
- bool local = false;
-
- if (host == net::GetHostName()) {
- local = true;
- } else {
- for (size_t i = 0; i < arraysize(kLocalHostNames); i++)
- if (host == kLocalHostNames[i]) {
- local = true;
- break;
- }
- }
-
- // Make the test fail so it's harder to ignore.
- // If you really need to make real DNS query, use
- // net::RuleBasedHostResolverProc and its AllowDirectLookup method.
- EXPECT_TRUE(local) << "Making external DNS lookup of " << host;
-
- return ResolveUsingPrevious(host, address_family, host_resolver_flags,
- addrlist, os_error);
- }
+ int* os_error);
};
class ChromeTestSuite : public base::TestSuite {
public:
- ChromeTestSuite(int argc, char** argv)
- : base::TestSuite(argc, argv),
- stats_table_(NULL),
- created_user_data_dir_(false) {
- }
+ ChromeTestSuite(int argc, char** argv);
+ virtual ~ChromeTestSuite();
protected:
-
- virtual void Initialize() {
- base::ScopedNSAutoreleasePool autorelease_pool;
-
- base::TestSuite::Initialize();
-
- chrome::RegisterChromeSchemes();
- host_resolver_proc_ = new WarningHostResolverProc();
- scoped_host_resolver_proc_.Init(host_resolver_proc_.get());
-
- chrome::RegisterPathProvider();
- app::RegisterPathProvider();
- g_browser_process = new TestingBrowserProcess;
-
- // Notice a user data override, and otherwise default to using a custom
- // user data directory that lives alongside the current app.
- // NOTE: The user data directory will be erased before each UI test that
- // uses it, in order to ensure consistency.
- FilePath user_data_dir =
- CommandLine::ForCurrentProcess()->GetSwitchValuePath(
- switches::kUserDataDir);
- if (user_data_dir.empty() &&
- file_util::CreateNewTempDirectory(FILE_PATH_LITERAL("chrome_test_"),
- &user_data_dir)) {
- user_data_dir = user_data_dir.AppendASCII("test_user_data");
- created_user_data_dir_ = true;
- }
- if (!user_data_dir.empty())
- PathService::Override(chrome::DIR_USER_DATA, user_data_dir);
-
- if (!browser_dir_.empty()) {
- PathService::Override(base::DIR_EXE, browser_dir_);
- PathService::Override(base::DIR_MODULE, browser_dir_);
- }
-
-#if defined(OS_MACOSX)
- // Look in the framework bundle for resources.
- FilePath path;
- PathService::Get(base::DIR_EXE, &path);
- path = path.Append(chrome::kFrameworkName);
- mac_util::SetOverrideAppBundlePath(path);
-#endif
-
- // Force unittests to run using en-US so if we test against string
- // output, it'll pass regardless of the system language.
- ResourceBundle::InitSharedInstance("en-US");
-
- // initialize the global StatsTable for unit_tests (make sure the file
- // doesn't exist before opening it so the test gets a clean slate)
- stats_filename_ = "unit_tests";
- std::string pid_string = StringPrintf("-%d", base::GetCurrentProcId());
- stats_filename_ += pid_string;
- RemoveSharedMemoryFile(stats_filename_);
- stats_table_ = new StatsTable(stats_filename_, 20, 200);
- StatsTable::set_current(stats_table_);
- }
-
- virtual void Shutdown() {
- ResourceBundle::CleanupSharedInstance();
-
-#if defined(OS_MACOSX)
- mac_util::SetOverrideAppBundle(NULL);
-#endif
-
- delete g_browser_process;
- g_browser_process = NULL;
-
- // Tear down shared StatsTable; prevents unit_tests from leaking it.
- StatsTable::set_current(NULL);
- delete stats_table_;
- RemoveSharedMemoryFile(stats_filename_);
-
- // Delete the test_user_data dir recursively
- // NOTE: user_data_dir will be deleted only if it was automatically
- // created.
- FilePath user_data_dir;
- if (created_user_data_dir_ &&
- PathService::Get(chrome::DIR_USER_DATA, &user_data_dir) &&
- !user_data_dir.empty()) {
- file_util::Delete(user_data_dir, true);
- file_util::Delete(user_data_dir.DirName(), false);
- }
- base::TestSuite::Shutdown();
- }
+ virtual void Initialize();
+ virtual void Shutdown();
void SetBrowserDirectory(const FilePath& browser_dir) {
browser_dir_ = browser_dir;
diff --git a/chrome_frame/chrome_frame.gyp b/chrome_frame/chrome_frame.gyp
index c005104..13f61f1 100644
--- a/chrome_frame/chrome_frame.gyp
+++ b/chrome_frame/chrome_frame.gyp
@@ -458,6 +458,7 @@
'../base/base.gyp:test_support_base',
'../chrome/chrome.gyp:browser',
'../chrome/chrome.gyp:renderer',
+ '../chrome/chrome.gyp:test_support_common',
'../testing/gtest.gyp:gtest',
'base_noicu',
'chrome_frame_ie',