diff options
-rw-r--r-- | components/components_tests.gyp | 2 | ||||
-rw-r--r-- | components/dom_distiller/DEPS | 2 | ||||
-rw-r--r-- | components/dom_distiller/core/distiller_unittest.cc | 15 | ||||
-rw-r--r-- | components/test/DEPS | 4 | ||||
-rw-r--r-- | components/test/run_all_unittests.cc | 43 |
5 files changed, 44 insertions, 22 deletions
diff --git a/components/components_tests.gyp b/components/components_tests.gyp index acc9526..ec5b356 100644 --- a/components/components_tests.gyp +++ b/components/components_tests.gyp @@ -79,6 +79,8 @@ '../sync/sync.gyp:sync', '../testing/gmock.gyp:gmock', '../testing/gtest.gyp:gtest', + '../ui/gfx/gfx.gyp:gfx', + '../ui/ui.gyp:ui', # Dependencies of auto_login_parser 'components.gyp:auto_login_parser', diff --git a/components/dom_distiller/DEPS b/components/dom_distiller/DEPS index 1c12a78..07b7999 100644 --- a/components/dom_distiller/DEPS +++ b/components/dom_distiller/DEPS @@ -5,9 +5,7 @@ include_rules = [ "+third_party/leveldatabase/src/include", "+net/http", "+net/url_request", - "+ui/base/android", "+ui/base/resource", - "+ui/gfx/android", # The dom distiller is a layered component; subdirectories must explicitly # introduce the ability to use the content layer as appropriate. diff --git a/components/dom_distiller/core/distiller_unittest.cc b/components/dom_distiller/core/distiller_unittest.cc index 248340b..3784fd5 100644 --- a/components/dom_distiller/core/distiller_unittest.cc +++ b/components/dom_distiller/core/distiller_unittest.cc @@ -16,13 +16,6 @@ #include "net/url_request/url_request_context_getter.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" -#include "ui/base/resource/resource_bundle.h" - -#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 using::testing::Invoke; using::testing::Return; @@ -131,14 +124,6 @@ ACTION_P2(CreateMockDistillerPage, list, kurl) { } TEST_F(DistillerTest, DistillPage) { -#if defined(OS_ANDROID) - // Register JNI bindings for android. - JNIEnv* env = base::android::AttachCurrentThread(); - gfx::android::RegisterJni(env); - ui::android::RegisterJni(env); -#endif - - ui::ResourceBundle::InitSharedInstanceWithLocale("en-US", NULL); base::MessageLoop loop(base::MessageLoop::TYPE_UI); scoped_ptr<base::ListValue> list(new base::ListValue()); list->AppendString(kTitle); 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, |