summaryrefslogtreecommitdiff
path: root/chrome/test
diff options
context:
space:
mode:
authorTorne (Richard Coles) <torne@google.com>2014-03-21 14:25:57 +0000
committerTorne (Richard Coles) <torne@google.com>2014-03-21 14:25:57 +0000
commit23730a6e56a168d1879203e4b3819bb36e3d8f1f (patch)
tree4b72bdd217f9beda1d1b975e21c9d646a9664c48 /chrome/test
parent6d6d338a36340632714f2aab9a266979b71c3442 (diff)
downloadchromium_org-23730a6e56a168d1879203e4b3819bb36e3d8f1f.tar.gz
Merge from Chromium at DEPS revision 258528
This commit was generated by merge_to_master.py. Change-Id: Id197cbdde2c2881915f096c0426c741416884783
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/base/browser_perf_tests_main.cc10
-rw-r--r--chrome/test/base/browser_tests_main.cc8
-rw-r--r--chrome/test/base/chrome_render_view_test.cc31
-rw-r--r--chrome/test/base/chrome_render_view_test.h6
-rw-r--r--chrome/test/base/chrome_test_launcher.cc7
-rw-r--r--chrome/test/base/chrome_test_suite.cc133
-rw-r--r--chrome/test/base/chrome_test_suite.h12
-rw-r--r--chrome/test/base/chrome_unit_test_suite.cc128
-rw-r--r--chrome/test/base/chrome_unit_test_suite.h16
-rw-r--r--chrome/test/base/in_process_browser_test.cc45
-rw-r--r--chrome/test/base/interactive_test_utils_win.cc2
-rw-r--r--chrome/test/base/interactive_ui_tests_main.cc2
-rw-r--r--chrome/test/base/testing_profile.cc2
-rw-r--r--chrome/test/base/view_event_test_base.cc6
-rw-r--r--chrome/test/base/view_event_test_base.h2
-rw-r--r--chrome/test/functional/OWNERS2
-rw-r--r--chrome/test/gpu/gpu_feature_browsertest.cc3
-rw-r--r--chrome/test/mini_installer/variable_expander.py4
-rw-r--r--chrome/test/nacl/nacl_browsertest.cc30
-rw-r--r--chrome/test/nacl/nacl_browsertest_util.cc2
-rw-r--r--chrome/test/nacl/nacl_browsertest_util.h2
-rw-r--r--chrome/test/ppapi/ppapi_test.cc18
-rw-r--r--chrome/test/ppapi/ppapi_test.h1
-rw-r--r--chrome/test/pyautolib/pyautolib.cc2
-rw-r--r--chrome/test/pyautolib/pyautolib.h2
-rw-r--r--chrome/test/ui/ui_test_suite.cc5
-rw-r--r--chrome/test/ui/ui_test_suite.h2
27 files changed, 248 insertions, 235 deletions
diff --git a/chrome/test/base/browser_perf_tests_main.cc b/chrome/test/base/browser_perf_tests_main.cc
index 9236b451b5..99fcdd4513 100644
--- a/chrome/test/base/browser_perf_tests_main.cc
+++ b/chrome/test/base/browser_perf_tests_main.cc
@@ -5,18 +5,10 @@
#include "chrome/test/base/chrome_test_launcher.h"
#include "chrome/test/base/chrome_test_suite.h"
-class ChromeBrowserTestSuite : public ChromeTestSuite {
- public:
- ChromeBrowserTestSuite(int argc, char** argv) : ChromeTestSuite(argc, argv) {}
-
- protected:
- virtual bool IsBrowserTestSuite() OVERRIDE { return true; }
-};
-
class ChromeBrowserTestSuiteRunner : public ChromeTestSuiteRunner {
public:
virtual int RunTestSuite(int argc, char** argv) OVERRIDE {
- return ChromeBrowserTestSuite(argc, argv).Run();
+ return ChromeTestSuite(argc, argv).Run();
}
};
diff --git a/chrome/test/base/browser_tests_main.cc b/chrome/test/base/browser_tests_main.cc
index ae99ee3550..7759a4030b 100644
--- a/chrome/test/base/browser_tests_main.cc
+++ b/chrome/test/base/browser_tests_main.cc
@@ -8,16 +8,10 @@
#include "chrome/test/base/chrome_test_launcher.h"
#include "chrome/test/base/chrome_test_suite.h"
-class ChromeBrowserTestSuite : public ChromeTestSuite {
- public:
- ChromeBrowserTestSuite(int argc, char** argv) : ChromeTestSuite(argc, argv) {}
- virtual bool IsBrowserTestSuite() OVERRIDE { return true; }
-};
-
class ChromeBrowserTestSuiteRunner : public ChromeTestSuiteRunner {
public:
virtual int RunTestSuite(int argc, char** argv) OVERRIDE {
- return ChromeBrowserTestSuite(argc, argv).Run();
+ return ChromeTestSuite(argc, argv).Run();
}
};
diff --git a/chrome/test/base/chrome_render_view_test.cc b/chrome/test/base/chrome_render_view_test.cc
index 522b4ad051..7e435a26e4 100644
--- a/chrome/test/base/chrome_render_view_test.cc
+++ b/chrome/test/base/chrome_render_view_test.cc
@@ -5,12 +5,16 @@
#include "chrome/test/base/chrome_render_view_test.h"
#include "base/debug/leak_annotations.h"
+#include "chrome/browser/chrome_content_browser_client.h"
+#include "chrome/common/chrome_content_client.h"
#include "chrome/common/render_messages.h"
+#include "chrome/renderer/chrome_content_renderer_client.h"
#include "chrome/renderer/extensions/chrome_v8_context_set.h"
#include "chrome/renderer/extensions/chrome_v8_extension.h"
#include "chrome/renderer/extensions/dispatcher.h"
#include "chrome/renderer/extensions/event_bindings.h"
#include "chrome/renderer/spellchecker/spellcheck.h"
+#include "chrome/test/base/chrome_unit_test_suite.h"
#include "components/autofill/content/renderer/autofill_agent.h"
#include "components/autofill/content/renderer/password_autofill_agent.h"
#include "components/autofill/content/renderer/test_password_autofill_agent.h"
@@ -51,15 +55,13 @@ ChromeRenderViewTest::~ChromeRenderViewTest() {
}
void ChromeRenderViewTest::SetUp() {
+ ChromeUnitTestSuite::InitializeProviders();
+ ChromeUnitTestSuite::InitializeResourceBundle();
+
chrome_render_thread_ = new ChromeMockRenderThread();
render_thread_.reset(chrome_render_thread_);
- content::SetRendererClientForTesting(&chrome_content_renderer_client_);
extension_dispatcher_ = new extensions::Dispatcher();
- chrome_content_renderer_client_.SetExtensionDispatcher(extension_dispatcher_);
-#if defined(ENABLE_SPELLCHECK)
- chrome_content_renderer_client_.SetSpellcheck(new SpellCheck());
-#endif
content::RenderViewTest::SetUp();
@@ -83,3 +85,22 @@ void ChromeRenderViewTest::TearDown() {
#endif
content::RenderViewTest::TearDown();
}
+
+content::ContentClient* ChromeRenderViewTest::CreateContentClient() {
+ return new ChromeContentClient();
+}
+
+content::ContentBrowserClient*
+ ChromeRenderViewTest::CreateContentBrowserClient() {
+ return new chrome::ChromeContentBrowserClient();
+}
+
+content::ContentRendererClient*
+ ChromeRenderViewTest::CreateContentRendererClient() {
+ ChromeContentRendererClient* client = new ChromeContentRendererClient();
+ client->SetExtensionDispatcher(extension_dispatcher_);
+#if defined(ENABLE_SPELLCHECK)
+ client->SetSpellcheck(new SpellCheck());
+#endif
+ return client;
+}
diff --git a/chrome/test/base/chrome_render_view_test.h b/chrome/test/base/chrome_render_view_test.h
index aff4c5dcff..69bd244d76 100644
--- a/chrome/test/base/chrome_render_view_test.h
+++ b/chrome/test/base/chrome_render_view_test.h
@@ -7,7 +7,6 @@
#include <string>
-#include "chrome/renderer/chrome_content_renderer_client.h"
#include "chrome/renderer/chrome_mock_render_thread.h"
#include "content/public/test/render_view_test.h"
@@ -30,8 +29,11 @@ class ChromeRenderViewTest : public content::RenderViewTest {
// testing::Test
virtual void SetUp() OVERRIDE;
virtual void TearDown() OVERRIDE;
+ virtual content::ContentClient* CreateContentClient() OVERRIDE;
+ virtual content::ContentBrowserClient* CreateContentBrowserClient() OVERRIDE;
+ virtual content::ContentRendererClient*
+ CreateContentRendererClient() OVERRIDE;
- ChromeContentRendererClient chrome_content_renderer_client_;
extensions::Dispatcher* extension_dispatcher_;
autofill::TestPasswordAutofillAgent* password_autofill_;
diff --git a/chrome/test/base/chrome_test_launcher.cc b/chrome/test/base/chrome_test_launcher.cc
index 4508ab40c1..b2ee566c98 100644
--- a/chrome/test/base/chrome_test_launcher.cc
+++ b/chrome/test/base/chrome_test_launcher.cc
@@ -85,14 +85,7 @@ class ChromeTestLauncherDelegate : public content::TestLauncherDelegate {
protected:
virtual content::ContentMainDelegate* CreateContentMainDelegate() OVERRIDE {
-#if defined(OS_WIN) || defined (OS_LINUX)
return new ChromeMainDelegate();
-#else
- // This delegate is only guaranteed to link on linux and windows, so just
- // bail out if we are on any other platform.
- NOTREACHED();
- return NULL;
-#endif
}
virtual void AdjustDefaultParallelJobs(int* default_jobs) OVERRIDE {
diff --git a/chrome/test/base/chrome_test_suite.cc b/chrome/test/base/chrome_test_suite.cc
index e8c425daa6..6292b85d7a 100644
--- a/chrome/test/base/chrome_test_suite.cc
+++ b/chrome/test/base/chrome_test_suite.cc
@@ -11,24 +11,14 @@
#include "base/command_line.h"
#include "base/memory/ref_counted.h"
-#include "base/metrics/stats_table.h"
#include "base/path_service.h"
-#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/browser_process.h"
-#include "chrome/browser/chrome_content_browser_client.h"
-#include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h"
#include "chrome/common/chrome_constants.h"
-#include "chrome/common/chrome_content_client.h"
#include "chrome/common/chrome_paths.h"
-#include "chrome/common/extensions/chrome_extensions_client.h"
#include "chrome/common/url_constants.h"
-#include "chrome/utility/chrome_content_utility_client.h"
#include "content/public/test/test_launcher.h"
-#include "extensions/common/extension_paths.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "ui/base/resource/resource_bundle.h"
-#include "ui/base/resource/resource_handle.h"
#if defined(OS_ANDROID)
#include "base/android/jni_android.h"
@@ -44,10 +34,6 @@
#include "chromeos/chromeos_paths.h"
#endif
-#if !defined(OS_IOS)
-#include "ui/gl/gl_surface.h"
-#endif
-
#if defined(OS_MACOSX)
#include "base/mac/bundle_locations.h"
#include "base/mac/scoped_nsautorelease_pool.h"
@@ -57,21 +43,12 @@
#endif // !defined(OS_IOS)
#endif
-#if defined(OS_POSIX)
-#include "base/memory/shared_memory.h"
+#if !defined(OS_IOS)
+#include "media/base/media.h"
#endif
namespace {
-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(filename);
-#endif
-}
-
bool IsCrosPythonProcess() {
#if defined(OS_CHROMEOS)
char buf[80];
@@ -86,47 +63,6 @@ bool IsCrosPythonProcess() {
#endif // defined(OS_CHROMEOS)
}
-// Initializes services needed by both unit tests and browser tests.
-// See also ChromeUnitTestSuite for additional services created for unit tests.
-class ChromeTestSuiteInitializer : public testing::EmptyTestEventListener {
- public:
- ChromeTestSuiteInitializer() {
- }
-
- virtual void OnTestStart(const testing::TestInfo& test_info) OVERRIDE {
- content_client_.reset(new ChromeContentClient);
- content::SetContentClient(content_client_.get());
- // TODO(ios): Bring this back once ChromeContentBrowserClient is building.
-#if !defined(OS_IOS)
- browser_content_client_.reset(new chrome::ChromeContentBrowserClient());
- content::SetBrowserClientForTesting(browser_content_client_.get());
- utility_content_client_.reset(new chrome::ChromeContentUtilityClient());
- content::SetUtilityClientForTesting(utility_content_client_.get());
-#endif
- }
-
- virtual void OnTestEnd(const testing::TestInfo& test_info) OVERRIDE {
- // TODO(ios): Bring this back once ChromeContentBrowserClient is building.
-#if !defined(OS_IOS)
- browser_content_client_.reset();
- utility_content_client_.reset();
-#endif
- content_client_.reset();
- content::SetContentClient(NULL);
- }
-
- private:
- // Client implementations for the content module.
- scoped_ptr<ChromeContentClient> content_client_;
- // TODO(ios): Bring this back once ChromeContentBrowserClient is building.
-#if !defined(OS_IOS)
- scoped_ptr<chrome::ChromeContentBrowserClient> browser_content_client_;
- scoped_ptr<chrome::ChromeContentUtilityClient> utility_content_client_;
-#endif
-
- DISALLOW_COPY_AND_ASSIGN(ChromeTestSuiteInitializer);
-};
-
} // namespace
ChromeTestSuite::ChromeTestSuite(int argc, char** argv)
@@ -153,48 +89,23 @@ void ChromeTestSuite::Initialize() {
chrome::android::RegisterJni(base::android::AttachCurrentThread());
#endif
- chrome::RegisterPathProvider();
-#if defined(OS_CHROMEOS)
- chromeos::RegisterPathProvider();
-#endif
if (!browser_dir_.empty()) {
PathService::Override(base::DIR_EXE, browser_dir_);
PathService::Override(base::DIR_MODULE, browser_dir_);
}
#if !defined(OS_IOS)
- extensions::RegisterPathProvider();
-
- extensions::ExtensionsClient::Set(
- extensions::ChromeExtensionsClient::GetInstance());
-
- // Only want to do this for unit tests.
- if (!content::GetCurrentTestLauncherDelegate()) {
- // For browser tests, this won't create the right object since
- // TestChromeWebUIControllerFactory is used. That's created and
- // registered in ChromeBrowserMainParts as in normal startup.
- content::WebUIControllerFactory::RegisterFactory(
- ChromeWebUIControllerFactory::GetInstance());
- }
-#endif
-
// Disable external libraries load if we are under python process in
// ChromeOS. That means we are autotest and, if ASAN is used,
// external libraries load crashes.
- content::ContentTestSuiteBase::set_external_libraries_enabled(
- !IsCrosPythonProcess());
+ if (!IsCrosPythonProcess())
+ media::InitializeMediaLibraryForTesting();
+#endif
// Initialize after overriding paths as some content paths depend on correct
// values for DIR_EXE and DIR_MODULE.
content::ContentTestSuiteBase::Initialize();
-#if !defined(OS_IOS)
- // For browser tests, a full chrome instance is initialized which will set up
- // GLSurface itself. For unit tests, we need to set this up for them.
- if (!IsBrowserTestSuite())
- gfx::GLSurface::InitializeOneOffForTests();
-#endif
-
#if defined(OS_MACOSX) && !defined(OS_IOS)
// Look in the framework bundle for resources.
base::FilePath path;
@@ -202,46 +113,12 @@ void ChromeTestSuite::Initialize() {
path = path.Append(chrome::kFrameworkName);
base::mac::SetOverrideFrameworkBundlePath(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::InitSharedInstanceWithLocale("en-US", NULL);
- base::FilePath resources_pack_path;
-#if defined(OS_MACOSX) && !defined(OS_IOS)
- PathService::Get(base::DIR_MODULE, &resources_pack_path);
- resources_pack_path =
- resources_pack_path.Append(FILE_PATH_LITERAL("resources.pak"));
-#else
- PathService::Get(chrome::FILE_RESOURCES_PACK, &resources_pack_path);
-#endif
- ResourceBundle::GetSharedInstance().AddDataPackFromPath(
- resources_pack_path, ui::SCALE_FACTOR_NONE);
-
- stats_filename_ = base::StringPrintf("unit_tests-%d",
- base::GetCurrentProcId());
- RemoveSharedMemoryFile(stats_filename_);
- stats_table_.reset(new base::StatsTable(stats_filename_, 20, 200));
- base::StatsTable::set_current(stats_table_.get());
-
- testing::TestEventListeners& listeners =
- testing::UnitTest::GetInstance()->listeners();
- listeners.Append(new ChromeTestSuiteInitializer);
-}
-
-content::ContentClient* ChromeTestSuite::CreateClientForInitialization() {
- return new ChromeContentClient();
}
void ChromeTestSuite::Shutdown() {
- ResourceBundle::CleanupSharedInstance();
-
#if defined(OS_MACOSX) && !defined(OS_IOS)
base::mac::SetOverrideFrameworkBundle(NULL);
#endif
- base::StatsTable::set_current(NULL);
- stats_table_.reset();
- RemoveSharedMemoryFile(stats_filename_);
-
content::ContentTestSuiteBase::Shutdown();
}
diff --git a/chrome/test/base/chrome_test_suite.h b/chrome/test/base/chrome_test_suite.h
index 45db32b3c7..7c24d76b30 100644
--- a/chrome/test/base/chrome_test_suite.h
+++ b/chrome/test/base/chrome_test_suite.h
@@ -11,10 +11,6 @@
#include "base/memory/scoped_ptr.h"
#include "content/public/test/content_test_suite_base.h"
-namespace base {
-class StatsTable;
-}
-
// Test suite for unit and browser tests. Creates services needed by both.
// See also ChromeUnitTestSuite for additional services created for unit tests.
class ChromeTestSuite : public content::ContentTestSuiteBase {
@@ -27,12 +23,6 @@ class ChromeTestSuite : public content::ContentTestSuiteBase {
virtual void Initialize() OVERRIDE;
virtual void Shutdown() OVERRIDE;
- virtual content::ContentClient* CreateClientForInitialization() OVERRIDE;
-
- // Should return true if the test suite will be running the full chrome
- // browser, false if the test suite is unit tests.
- virtual bool IsBrowserTestSuite() = 0;
-
void SetBrowserDirectory(const base::FilePath& browser_dir) {
browser_dir_ = browser_dir;
}
@@ -40,8 +30,6 @@ class ChromeTestSuite : public content::ContentTestSuiteBase {
// Alternative path to browser binaries.
base::FilePath browser_dir_;
- std::string stats_filename_;
- scoped_ptr<base::StatsTable> stats_table_;
DISALLOW_COPY_AND_ASSIGN(ChromeTestSuite);
};
diff --git a/chrome/test/base/chrome_unit_test_suite.cc b/chrome/test/base/chrome_unit_test_suite.cc
index dcade4a71b..65f453b4b9 100644
--- a/chrome/test/base/chrome_unit_test_suite.cc
+++ b/chrome/test/base/chrome_unit_test_suite.cc
@@ -4,11 +4,47 @@
#include "chrome/test/base/chrome_unit_test_suite.h"
+#include "base/path_service.h"
+#include "base/process/process_handle.h"
+#include "base/metrics/stats_table.h"
+#include "base/strings/stringprintf.h"
+#include "chrome/browser/chrome_content_browser_client.h"
+#include "chrome/common/chrome_content_client.h"
+#include "chrome/common/chrome_paths.h"
#include "chrome/test/base/testing_browser_process.h"
+#include "chrome/utility/chrome_content_utility_client.h"
+#include "content/public/common/content_paths.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/base/resource/resource_bundle.h"
+#include "ui/base/resource/resource_handle.h"
+#include "ui/base/ui_base_paths.h"
+
+#if defined(OS_CHROMEOS)
+#include "chromeos/chromeos_paths.h"
+#endif
+
+#if !defined(OS_IOS)
+#include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h"
+#include "chrome/common/extensions/chrome_extensions_client.h"
+#include "extensions/common/extension_paths.h"
+#include "ui/gl/gl_surface.h"
+#endif
+
+#if defined(OS_POSIX)
+#include "base/memory/shared_memory.h"
+#endif
namespace {
+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(filename);
+#endif
+}
+
// Creates a TestingBrowserProcess for each test.
class ChromeUnitTestSuiteInitializer : public testing::EmptyTestEventListener {
public:
@@ -16,14 +52,40 @@ class ChromeUnitTestSuiteInitializer : public testing::EmptyTestEventListener {
virtual ~ChromeUnitTestSuiteInitializer() {}
virtual void OnTestStart(const testing::TestInfo& test_info) OVERRIDE {
+ content_client_.reset(new ChromeContentClient);
+ content::SetContentClient(content_client_.get());
+ // TODO(ios): Bring this back once ChromeContentBrowserClient is building.
+#if !defined(OS_IOS)
+ browser_content_client_.reset(new chrome::ChromeContentBrowserClient());
+ content::SetBrowserClientForTesting(browser_content_client_.get());
+ utility_content_client_.reset(new chrome::ChromeContentUtilityClient());
+ content::SetUtilityClientForTesting(utility_content_client_.get());
+#endif
+
TestingBrowserProcess::CreateInstance();
}
virtual void OnTestEnd(const testing::TestInfo& test_info) OVERRIDE {
+ // TODO(ios): Bring this back once ChromeContentBrowserClient is building.
+#if !defined(OS_IOS)
+ browser_content_client_.reset();
+ utility_content_client_.reset();
+#endif
+ content_client_.reset();
+ content::SetContentClient(NULL);
+
TestingBrowserProcess::DeleteInstance();
}
private:
+ // Client implementations for the content module.
+ scoped_ptr<ChromeContentClient> content_client_;
+ // TODO(ios): Bring this back once ChromeContentBrowserClient is building.
+#if !defined(OS_IOS)
+ scoped_ptr<chrome::ChromeContentBrowserClient> browser_content_client_;
+ scoped_ptr<chrome::ChromeContentUtilityClient> utility_content_client_;
+#endif
+
DISALLOW_COPY_AND_ASSIGN(ChromeUnitTestSuiteInitializer);
};
@@ -42,7 +104,71 @@ void ChromeUnitTestSuite::Initialize() {
testing::UnitTest::GetInstance()->listeners();
listeners.Append(new ChromeUnitTestSuiteInitializer);
+ InitializeProviders();
+ RegisterInProcessThreads();
+
+ stats_filename_ = base::StringPrintf("unit_tests-%d",
+ base::GetCurrentProcId());
+ RemoveSharedMemoryFile(stats_filename_);
+ stats_table_.reset(new base::StatsTable(stats_filename_, 20, 200));
+ base::StatsTable::set_current(stats_table_.get());
+
ChromeTestSuite::Initialize();
+
+ // This needs to run after ChromeTestSuite::Initialize which calls content's
+ // intialization which calls base's which initializes ICU.
+ InitializeResourceBundle();
}
-bool ChromeUnitTestSuite::IsBrowserTestSuite() { return false; }
+void ChromeUnitTestSuite::Shutdown() {
+ ResourceBundle::CleanupSharedInstance();
+
+ base::StatsTable::set_current(NULL);
+ stats_table_.reset();
+ RemoveSharedMemoryFile(stats_filename_);
+
+ ChromeTestSuite::Shutdown();
+}
+
+void ChromeUnitTestSuite::InitializeProviders() {
+ {
+ ChromeContentClient content_client;
+ RegisterContentSchemes(&content_client);
+ }
+
+ chrome::RegisterPathProvider();
+ content::RegisterPathProvider();
+ ui::RegisterPathProvider();
+
+#if defined(OS_CHROMEOS)
+ chromeos::RegisterPathProvider();
+#endif
+
+#if !defined(OS_IOS)
+ extensions::RegisterPathProvider();
+
+ extensions::ExtensionsClient::Set(
+ extensions::ChromeExtensionsClient::GetInstance());
+
+ content::WebUIControllerFactory::RegisterFactory(
+ ChromeWebUIControllerFactory::GetInstance());
+
+ gfx::GLSurface::InitializeOneOffForTests();
+#endif
+}
+
+void ChromeUnitTestSuite::InitializeResourceBundle() {
+ // Force unittests to run using en-US so if we test against string
+ // output, it'll pass regardless of the system language.
+ ResourceBundle::InitSharedInstanceWithLocale("en-US", NULL);
+ base::FilePath resources_pack_path;
+#if defined(OS_MACOSX) && !defined(OS_IOS)
+ PathService::Get(base::DIR_MODULE, &resources_pack_path);
+ resources_pack_path =
+ resources_pack_path.Append(FILE_PATH_LITERAL("resources.pak"));
+#else
+ PathService::Get(chrome::FILE_RESOURCES_PACK, &resources_pack_path);
+#endif
+ ResourceBundle::GetSharedInstance().AddDataPackFromPath(
+ resources_pack_path, ui::SCALE_FACTOR_NONE);
+}
diff --git a/chrome/test/base/chrome_unit_test_suite.h b/chrome/test/base/chrome_unit_test_suite.h
index 22e722e721..70eabe9c6d 100644
--- a/chrome/test/base/chrome_unit_test_suite.h
+++ b/chrome/test/base/chrome_unit_test_suite.h
@@ -7,8 +7,13 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
+#include "base/files/file_path.h"
#include "chrome/test/base/chrome_test_suite.h"
+namespace base {
+class StatsTable;
+}
+
// Test suite for unit tests. Creates additional stub services that are not
// needed for browser tests (e.g. a TestingBrowserProcess).
class ChromeUnitTestSuite : public ChromeTestSuite {
@@ -18,11 +23,18 @@ class ChromeUnitTestSuite : public ChromeTestSuite {
// base::TestSuite overrides:
virtual void Initialize() OVERRIDE;
+ virtual void Shutdown() OVERRIDE;
- // ChromeTestSuite overrides:
- virtual bool IsBrowserTestSuite() OVERRIDE;
+ // These methods allow unit tests which run in the browser_test binary, and so
+ // which don't exercise the initialization in this test suite, to do basic
+ // setup which this class does.
+ static void InitializeProviders();
+ static void InitializeResourceBundle();
private:
+ std::string stats_filename_;
+ scoped_ptr<base::StatsTable> stats_table_;
+
DISALLOW_COPY_AND_ASSIGN(ChromeUnitTestSuite);
};
diff --git a/chrome/test/base/in_process_browser_test.cc b/chrome/test/base/in_process_browser_test.cc
index a8cd6e1624..67555edadb 100644
--- a/chrome/test/base/in_process_browser_test.cc
+++ b/chrome/test/base/in_process_browser_test.cc
@@ -75,10 +75,6 @@ namespace {
// Passed as value of kTestType.
const char kBrowserTestType[] = "browser";
-// Used when running in single-process mode.
-base::LazyInstance<ChromeContentRendererClient>::Leaky
- g_chrome_content_renderer_client = LAZY_INSTANCE_INITIALIZER;
-
// A BrowserListObserver that makes sure that all browsers created are on the
// |allowed_desktop_|.
class SingleDesktopTestObserver : public chrome::BrowserListObserver,
@@ -133,11 +129,17 @@ InProcessBrowserTest::InProcessBrowserTest()
chrome_path = chrome_path.Append(chrome::kBrowserProcessExecutablePath);
CHECK(PathService::Override(base::FILE_EXE, chrome_path));
#endif // defined(OS_MACOSX)
+
CreateTestServer(base::FilePath(FILE_PATH_LITERAL("chrome/test/data")));
base::FilePath src_dir;
CHECK(PathService::Get(base::DIR_SOURCE_ROOT, &src_dir));
- embedded_test_server()->ServeFilesFromDirectory(
- src_dir.AppendASCII("chrome/test/data"));
+ base::FilePath test_data_dir = src_dir.AppendASCII("chrome/test/data");
+ embedded_test_server()->ServeFilesFromDirectory(test_data_dir);
+
+ // chrome::DIR_TEST_DATA isn't going to be setup until after we call
+ // ContentMain. However that is after tests' constructors or SetUp methods,
+ // which sometimes need it. So just override it.
+ CHECK(PathService::Override(chrome::DIR_TEST_DATA, test_data_dir));
}
InProcessBrowserTest::~InProcessBrowserTest() {
@@ -162,13 +164,6 @@ void InProcessBrowserTest::SetUp() {
ASSERT_TRUE(SetUpUserDataDirectory())
<< "Could not set up user data directory.";
- // Single-process mode is not set in BrowserMain, so process it explicitly,
- // and set up renderer.
- if (command_line->HasSwitch(switches::kSingleProcess)) {
- content::SetRendererClientForTesting(
- g_chrome_content_renderer_client.Pointer());
- }
-
#if defined(OS_CHROMEOS)
// Make sure that the log directory exists.
base::FilePath log_dir = logging::GetSessionLogFile(*command_line).DirName();
@@ -176,15 +171,6 @@ void InProcessBrowserTest::SetUp() {
#endif // defined(OS_CHROMEOS)
#if defined(OS_MACOSX)
- // On Mac, without the following autorelease pool, code which is directly
- // executed (as opposed to executed inside a message loop) would autorelease
- // objects into a higher-level pool. This pool is not recycled in-sync with
- // the message loops' pools and causes problems with code relying on
- // deallocation via an autorelease pool (such as browser window closure and
- // browser shutdown). To avoid this, the following pool is recycled after each
- // time code is directly executed.
- autorelease_pool_ = new base::mac::ScopedNSAutoreleasePool;
-
// Always use the MockKeychain if OS encription is used (which is when
// anything sensitive gets stored, including Cookies). Without this,
// many tests will hang waiting for a user to approve KeyChain access.
@@ -382,10 +368,6 @@ void InProcessBrowserTest::RunTestOnMainThreadLoop() {
// Pump startup related events.
content::RunAllPendingInMessageLoop();
-#if defined(OS_MACOSX)
- autorelease_pool_->Recycle();
-#endif
-
chrome::HostDesktopType active_desktop = chrome::GetActiveDesktop();
// Self-adds/removes itself from the BrowserList observers.
scoped_ptr<SingleDesktopTestObserver> single_desktop_test_observer;
@@ -413,6 +395,17 @@ void InProcessBrowserTest::RunTestOnMainThreadLoop() {
ASSERT_TRUE(storage_monitor::TestStorageMonitor::CreateForBrowserTests());
#endif
+#if defined(OS_MACOSX)
+ // On Mac, without the following autorelease pool, code which is directly
+ // executed (as opposed to executed inside a message loop) would autorelease
+ // objects into a higher-level pool. This pool is not recycled in-sync with
+ // the message loops' pools and causes problems with code relying on
+ // deallocation via an autorelease pool (such as browser window closure and
+ // browser shutdown). To avoid this, the following pool is recycled after each
+ // time code is directly executed.
+ autorelease_pool_ = new base::mac::ScopedNSAutoreleasePool;
+#endif
+
// Pump any pending events that were created as a result of creating a
// browser.
content::RunAllPendingInMessageLoop();
diff --git a/chrome/test/base/interactive_test_utils_win.cc b/chrome/test/base/interactive_test_utils_win.cc
index af33eddfb9..3c973832b9 100644
--- a/chrome/test/base/interactive_test_utils_win.cc
+++ b/chrome/test/base/interactive_test_utils_win.cc
@@ -16,7 +16,7 @@
#if defined(USE_AURA)
#include "chrome/browser/ui/host_desktop.h"
#include "chrome/test/base/interactive_test_utils_aura.h"
-#include "ui/aura/window_event_dispatcher.h"
+#include "ui/aura/window_tree_host.h"
#endif
namespace ui_test_utils {
diff --git a/chrome/test/base/interactive_ui_tests_main.cc b/chrome/test/base/interactive_ui_tests_main.cc
index e2106ea1c9..f16f4562c8 100644
--- a/chrome/test/base/interactive_ui_tests_main.cc
+++ b/chrome/test/base/interactive_ui_tests_main.cc
@@ -60,8 +60,6 @@ class InteractiveUITestSuite : public ChromeTestSuite {
#endif
}
- virtual bool IsBrowserTestSuite() OVERRIDE { return false; }
-
private:
#if defined(OS_WIN)
scoped_ptr<base::win::ScopedCOMInitializer> com_initializer_;
diff --git a/chrome/test/base/testing_profile.cc b/chrome/test/base/testing_profile.cc
index 13f270e215..63522621b8 100644
--- a/chrome/test/base/testing_profile.cc
+++ b/chrome/test/base/testing_profile.cc
@@ -32,8 +32,6 @@
#include "chrome/browser/history/history_db_task.h"
#include "chrome/browser/history/history_service.h"
#include "chrome/browser/history/history_service_factory.h"
-#include "chrome/browser/history/shortcuts_backend.h"
-#include "chrome/browser/history/shortcuts_backend_factory.h"
#include "chrome/browser/history/top_sites.h"
#include "chrome/browser/history/web_history_service_factory.h"
#include "chrome/browser/net/pref_proxy_config_tracker.h"
diff --git a/chrome/test/base/view_event_test_base.cc b/chrome/test/base/view_event_test_base.cc
index da226f6b22..faf6fe4879 100644
--- a/chrome/test/base/view_event_test_base.cc
+++ b/chrome/test/base/view_event_test_base.cc
@@ -8,6 +8,7 @@
#include "base/bind_helpers.h"
#include "base/message_loop/message_loop.h"
#include "base/strings/string_number_conversions.h"
+#include "chrome/test/base/chrome_unit_test_suite.h"
#include "chrome/test/base/interactive_test_utils.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/ui_test_utils.h"
@@ -94,6 +95,11 @@ void ViewEventTestBase::Done() {
base::MessageLoop::QuitClosure());
}
+void ViewEventTestBase::SetUpTestCase() {
+ ChromeUnitTestSuite::InitializeProviders();
+ ChromeUnitTestSuite::InitializeResourceBundle();
+}
+
void ViewEventTestBase::SetUp() {
#if defined(USE_AURA)
wm_state_.reset(new wm::WMState);
diff --git a/chrome/test/base/view_event_test_base.h b/chrome/test/base/view_event_test_base.h
index 8c7e68634d..302409d2c6 100644
--- a/chrome/test/base/view_event_test_base.h
+++ b/chrome/test/base/view_event_test_base.h
@@ -84,6 +84,8 @@ class ViewEventTestBase : public views::WidgetDelegate,
// loop.
void Done();
+ static void SetUpTestCase();
+
// Creates a window.
virtual void SetUp() OVERRIDE;
diff --git a/chrome/test/functional/OWNERS b/chrome/test/functional/OWNERS
index 43e031bd07..54bfe2c76d 100644
--- a/chrome/test/functional/OWNERS
+++ b/chrome/test/functional/OWNERS
@@ -1,4 +1,4 @@
-craigdh@chromium.org
+stgao@chromium.org
# for media stuff
dalecurtis@chromium.org
diff --git a/chrome/test/gpu/gpu_feature_browsertest.cc b/chrome/test/gpu/gpu_feature_browsertest.cc
index fa4268a56f..9b575bc6ab 100644
--- a/chrome/test/gpu/gpu_feature_browsertest.cc
+++ b/chrome/test/gpu/gpu_feature_browsertest.cc
@@ -215,7 +215,8 @@ class AcceleratedCompositingBlockedTest : public GpuFeatureTest {
// Compositing is always on for Aura and Mac.
#define MAYBE_AcceleratedCompositingBlocked DISABLED_AcceleratedCompositingBlocked
#else
-#define MAYBE_AcceleratedCompositingBlocked AcceleratedCompositingBlocked
+// TODO(jam): http://crbug.com/350550
+#define MAYBE_AcceleratedCompositingBlocked DISABLED_AcceleratedCompositingBlocked
#endif
IN_PROC_BROWSER_TEST_F(AcceleratedCompositingBlockedTest,
diff --git a/chrome/test/mini_installer/variable_expander.py b/chrome/test/mini_installer/variable_expander.py
index 3233d73176..a240bfae78 100644
--- a/chrome/test/mini_installer/variable_expander.py
+++ b/chrome/test/mini_installer/variable_expander.py
@@ -94,14 +94,14 @@ class VariableExpander:
# This string will be converted to a tuple once injected in eval() through
# conditional checks. Tuples are compared lexicographically.
windows_version = '(%s, %s)' % (windows_major_ver, windows_minor_ver)
- if mini_installer_product_name == 'Google Chrome':
+ if mini_installer_product_name == 'Google Chrome Installer':
chrome_short_name = 'Chrome'
chrome_long_name = 'Google Chrome'
chrome_dir = 'Google\\Chrome'
chrome_update_registry_subkey = ('Software\\Google\\Update\\Clients\\'
'{8A69D345-D564-463c-AFF1-A69D9E530F96}')
chrome_html_prog_id = 'ChromeHTML'
- elif mini_installer_product_name == 'Chromium':
+ elif mini_installer_product_name == 'Chromium Installer':
chrome_short_name = 'Chromium'
chrome_long_name = 'Chromium'
chrome_dir = 'Chromium'
diff --git a/chrome/test/nacl/nacl_browsertest.cc b/chrome/test/nacl/nacl_browsertest.cc
index ef5b37342a..46a12b5998 100644
--- a/chrome/test/nacl/nacl_browsertest.cc
+++ b/chrome/test/nacl/nacl_browsertest.cc
@@ -14,6 +14,7 @@
#include "base/command_line.h"
#include "base/environment.h"
#include "base/path_service.h"
+#include "base/win/windows_version.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/test/nacl/nacl_browsertest_util.h"
#include "components/nacl/common/nacl_switches.h"
@@ -206,22 +207,33 @@ class NaClBrowserTestPnaclDebugURL : public NaClBrowserTestPnacl {
}
};
+IN_PROC_BROWSER_TEST_F(NaClBrowserTestPnaclDebugURL,
+ MAYBE_PNACL(PnaclDebugURLFlagAndURL)) {
+ // TODO(jvoung): Make this test work on Windows 32-bit. When --no-sandbox
+ // is used, the required 1GB sandbox address space is not reserved.
+ // (see note in chrome/browser/nacl_host/test/nacl_gdb_browsertest.cc)
#if defined(OS_WIN)
-#define MAYBE_PnaclDebugURLFlagAndURL DISABLED_PnaclDebugURLFlagAndURL
-#define MAYBE_PnaclDebugURLFlagNoURL DISABLED_PnaclDebugURLFlagNoURL
-#else
-#define MAYBE_PnaclDebugURLFlagAndURL PnaclDebugURLFlagAndURL
-#define MAYBE_PnaclDebugURLFlagNoURL PnaclDebugURLFlagNoURL
+ if (base::win::OSInfo::GetInstance()->wow64_status() ==
+ base::win::OSInfo::WOW64_DISABLED &&
+ base::win::OSInfo::GetInstance()->architecture() ==
+ base::win::OSInfo::X86_ARCHITECTURE) {
+ return;
+ }
#endif
-
-IN_PROC_BROWSER_TEST_F(NaClBrowserTestPnaclDebugURL,
- MAYBE_PnaclDebugURLFlagAndURL) {
RunLoadTest(FILE_PATH_LITERAL(
"pnacl_debug_url.html?nmf_file=pnacl_has_debug.nmf"));
}
IN_PROC_BROWSER_TEST_F(NaClBrowserTestPnaclDebugURL,
- MAYBE_PnaclDebugURLFlagNoURL) {
+ MAYBE_PNACL(PnaclDebugURLFlagNoURL)) {
+#if defined(OS_WIN)
+ if (base::win::OSInfo::GetInstance()->wow64_status() ==
+ base::win::OSInfo::WOW64_DISABLED &&
+ base::win::OSInfo::GetInstance()->architecture() ==
+ base::win::OSInfo::X86_ARCHITECTURE) {
+ return;
+ }
+#endif
RunLoadTest(FILE_PATH_LITERAL(
"pnacl_debug_url.html?nmf_file=pnacl_no_debug.nmf"));
}
diff --git a/chrome/test/nacl/nacl_browsertest_util.cc b/chrome/test/nacl/nacl_browsertest_util.cc
index 902bc733dd..2d92ea9434 100644
--- a/chrome/test/nacl/nacl_browsertest_util.cc
+++ b/chrome/test/nacl/nacl_browsertest_util.cc
@@ -205,7 +205,7 @@ void NaClBrowserTestBase::SetUpCommandLine(CommandLine* command_line) {
command_line->AppendSwitch(switches::kEnableNaCl);
}
-void NaClBrowserTestBase::SetUpInProcessBrowserTestFixture() {
+void NaClBrowserTestBase::SetUpOnMainThread() {
// Sanity check.
base::FilePath plugin_lib;
ASSERT_TRUE(PathService::Get(chrome::FILE_NACL_PLUGIN, &plugin_lib));
diff --git a/chrome/test/nacl/nacl_browsertest_util.h b/chrome/test/nacl/nacl_browsertest_util.h
index b4ed58ad89..2f2d73dd09 100644
--- a/chrome/test/nacl/nacl_browsertest_util.h
+++ b/chrome/test/nacl/nacl_browsertest_util.h
@@ -64,7 +64,7 @@ class NaClBrowserTestBase : public InProcessBrowserTest {
virtual void SetUpCommandLine(base::CommandLine* command_line) OVERRIDE;
- virtual void SetUpInProcessBrowserTestFixture() OVERRIDE;
+ virtual void SetUpOnMainThread() OVERRIDE;
// What variant are we running - newlib, glibc, pnacl, etc?
// This is used to compute what directory we're pulling data from, but it can
diff --git a/chrome/test/ppapi/ppapi_test.cc b/chrome/test/ppapi/ppapi_test.cc
index 0074c9fac4..117c9742e5 100644
--- a/chrome/test/ppapi/ppapi_test.cc
+++ b/chrome/test/ppapi/ppapi_test.cc
@@ -360,10 +360,6 @@ void PPAPINaClTest::SetUpCommandLine(base::CommandLine* command_line) {
RETURN_IF_NO_NACL();
PPAPITestBase::SetUpCommandLine(command_line);
- base::FilePath plugin_lib;
- EXPECT_TRUE(PathService::Get(chrome::FILE_NACL_PLUGIN, &plugin_lib));
- EXPECT_TRUE(base::PathExists(plugin_lib));
-
// Enable running (non-portable) NaCl outside of the Chrome web store.
command_line->AppendSwitch(switches::kEnableNaCl);
command_line->AppendSwitchASCII(switches::kAllowNaClSocketAPI, "127.0.0.1");
@@ -371,6 +367,12 @@ void PPAPINaClTest::SetUpCommandLine(base::CommandLine* command_line) {
command_line->AppendSwitch(switches::kUseFakeUIForMediaStream);
}
+void PPAPINaClTest::SetUpOnMainThread() {
+ base::FilePath plugin_lib;
+ EXPECT_TRUE(PathService::Get(chrome::FILE_NACL_PLUGIN, &plugin_lib));
+ EXPECT_TRUE(base::PathExists(plugin_lib));
+}
+
void PPAPINaClTest::RunTest(const std::string& test_case) {
RETURN_IF_NO_NACL();
PPAPITestBase::RunTest(test_case);
@@ -451,10 +453,6 @@ void PPAPINaClTestDisallowedSockets::SetUpCommandLine(
base::CommandLine* command_line) {
PPAPITestBase::SetUpCommandLine(command_line);
- base::FilePath plugin_lib;
- EXPECT_TRUE(PathService::Get(chrome::FILE_NACL_PLUGIN, &plugin_lib));
- EXPECT_TRUE(base::PathExists(plugin_lib));
-
// Enable running (non-portable) NaCl outside of the Chrome web store.
command_line->AppendSwitch(switches::kEnableNaCl);
}
@@ -470,4 +468,8 @@ std::string PPAPINaClTestDisallowedSockets::BuildQuery(
void PPAPIBrokerInfoBarTest::SetUpOnMainThread() {
// The default content setting for the PPAPI broker is ASK. We purposefully
// don't call PPAPITestBase::SetUpOnMainThread() to keep it that way.
+
+ base::FilePath plugin_lib;
+ EXPECT_TRUE(PathService::Get(chrome::FILE_NACL_PLUGIN, &plugin_lib));
+ EXPECT_TRUE(base::PathExists(plugin_lib));
}
diff --git a/chrome/test/ppapi/ppapi_test.h b/chrome/test/ppapi/ppapi_test.h
index ef76639e1b..fca7538aac 100644
--- a/chrome/test/ppapi/ppapi_test.h
+++ b/chrome/test/ppapi/ppapi_test.h
@@ -130,6 +130,7 @@ class OutOfProcessPPAPIPrivateTest : public OutOfProcessPPAPITest {
class PPAPINaClTest : public PPAPITestBase {
public:
virtual void SetUpCommandLine(base::CommandLine* command_line) OVERRIDE;
+ virtual void SetUpOnMainThread() OVERRIDE;
// PPAPITestBase overrides.
virtual void RunTest(const std::string& test_case) OVERRIDE;
virtual void RunTestAndReload(const std::string& test_case) OVERRIDE;
diff --git a/chrome/test/pyautolib/pyautolib.cc b/chrome/test/pyautolib/pyautolib.cc
index ae12e2fd44..1a523953d6 100644
--- a/chrome/test/pyautolib/pyautolib.cc
+++ b/chrome/test/pyautolib/pyautolib.cc
@@ -40,8 +40,6 @@ void PyUITestSuiteBase::SetCrSourceRoot(const base::FilePath& path) {
PathService::Override(base::DIR_SOURCE_ROOT, path);
}
-bool PyUITestSuiteBase::IsBrowserTestSuite() { return true; }
-
// PyUITestBase
PyUITestBase::PyUITestBase(bool clear_profile, std::wstring homepage)
: UITestBase() {
diff --git a/chrome/test/pyautolib/pyautolib.h b/chrome/test/pyautolib/pyautolib.h
index a27b8d224d..f4bcb27687 100644
--- a/chrome/test/pyautolib/pyautolib.h
+++ b/chrome/test/pyautolib/pyautolib.h
@@ -38,8 +38,6 @@ class PyUITestSuiteBase : public UITestSuite {
void SetCrSourceRoot(const base::FilePath& path);
- virtual bool IsBrowserTestSuite() OVERRIDE;
-
private:
#if defined(OS_MACOSX)
base::mac::ScopedNSAutoreleasePool pool_;
diff --git a/chrome/test/ui/ui_test_suite.cc b/chrome/test/ui/ui_test_suite.cc
index 24caf938d3..66d2c485c7 100644
--- a/chrome/test/ui/ui_test_suite.cc
+++ b/chrome/test/ui/ui_test_suite.cc
@@ -16,6 +16,7 @@
#include "base/process/process_iterator.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/env_vars.h"
+#include "chrome/test/base/chrome_unit_test_suite.h"
UITestSuite::UITestSuite(int argc, char** argv) : ChromeTestSuite(argc, argv) {
#if defined(OS_WIN)
@@ -25,6 +26,8 @@ UITestSuite::UITestSuite(int argc, char** argv) : ChromeTestSuite(argc, argv) {
void UITestSuite::Initialize() {
ChromeTestSuite::Initialize();
+ ChromeUnitTestSuite::InitializeProviders();
+ ChromeUnitTestSuite::InitializeResourceBundle();
#if defined(OS_WIN)
LoadCrashService();
#endif
@@ -39,8 +42,6 @@ void UITestSuite::Shutdown() {
ChromeTestSuite::Shutdown();
}
-bool UITestSuite::IsBrowserTestSuite() { return false; }
-
#if defined(OS_WIN)
void UITestSuite::LoadCrashService() {
scoped_ptr<base::Environment> env(base::Environment::Create());
diff --git a/chrome/test/ui/ui_test_suite.h b/chrome/test/ui/ui_test_suite.h
index 5e6254446c..e93de67c32 100644
--- a/chrome/test/ui/ui_test_suite.h
+++ b/chrome/test/ui/ui_test_suite.h
@@ -20,8 +20,6 @@ class UITestSuite : public ChromeTestSuite {
virtual void Initialize() OVERRIDE;
virtual void Shutdown() OVERRIDE;
- virtual bool IsBrowserTestSuite() OVERRIDE;
-
private:
#if defined(OS_WIN)
void LoadCrashService();