diff options
Diffstat (limited to 'components/test')
-rw-r--r-- | components/test/DEPS | 4 | ||||
-rw-r--r-- | components/test/run_all_unittests.cc | 43 |
2 files changed, 42 insertions, 5 deletions
diff --git a/components/test/DEPS b/components/test/DEPS index c220939..f3e2ad7 100644 --- a/components/test/DEPS +++ b/components/test/DEPS @@ -1,4 +1,6 @@ include_rules = [ "+content/public/test", - "+ui/compositor", + "+ui/base/android/ui_base_jni_registrar.h", + "+ui/base/resource/resource_bundle.h", + "+ui/gfx/android/gfx_jni_registrar.h", ] diff --git a/components/test/run_all_unittests.cc b/components/test/run_all_unittests.cc index a509a82..b59285f 100644 --- a/components/test/run_all_unittests.cc +++ b/components/test/run_all_unittests.cc @@ -8,8 +8,43 @@ #include "base/test/test_suite.h" #include "content/public/test/test_content_client_initializer.h" #include "testing/gtest/include/gtest/gtest.h" +#include "ui/base/resource/resource_bundle.h" -namespace components { +#if defined(OS_ANDROID) +#include "base/android/jni_android.h" +#include "ui/base/android/ui_base_jni_registrar.h" +#include "ui/gfx/android/gfx_jni_registrar.h" +#endif + +namespace { + +class ComponentsTestSuite : public base::TestSuite { + public: + ComponentsTestSuite(int argc, char** argv) : base::TestSuite(argc, argv) {} + + private: + virtual void Initialize() OVERRIDE { + base::TestSuite::Initialize(); + +#if defined(OS_ANDROID) + // Register JNI bindings for android. + JNIEnv* env = base::android::AttachCurrentThread(); + gfx::android::RegisterJni(env); + ui::android::RegisterJni(env); +#endif + + // TODO(tfarina): This should be changed to InitSharedInstanceWithPakFile() + // so we can load our pak file instead of chrome.pak. + ui::ResourceBundle::InitSharedInstanceWithLocale("en-US", NULL); + } + + virtual void Shutdown() OVERRIDE { + ui::ResourceBundle::CleanupSharedInstance(); + base::TestSuite::Shutdown(); + } + + DISALLOW_COPY_AND_ASSIGN(ComponentsTestSuite); +}; class ComponentsUnitTestEventListener : public testing::EmptyTestEventListener { public: @@ -30,16 +65,16 @@ class ComponentsUnitTestEventListener : public testing::EmptyTestEventListener { DISALLOW_COPY_AND_ASSIGN(ComponentsUnitTestEventListener); }; -} // namespace components +} // namespace int main(int argc, char** argv) { - base::TestSuite test_suite(argc, argv); + ComponentsTestSuite test_suite(argc, argv); // The listener will set up common test environment for all components unit // tests. testing::TestEventListeners& listeners = testing::UnitTest::GetInstance()->listeners(); - listeners.Append(new components::ComponentsUnitTestEventListener()); + listeners.Append(new ComponentsUnitTestEventListener()); return base::LaunchUnitTests( argc, argv, base::Bind(&base::TestSuite::Run, |