diff options
author | John Abd-El-Malek <jam@chromium.org> | 2015-01-20 22:03:13 -0800 |
---|---|---|
committer | John Abd-El-Malek <jam@chromium.org> | 2015-01-21 06:05:23 +0000 |
commit | 045c9bf1d36f35643a077891dedf24054f2032a3 (patch) | |
tree | 34d04302888fcf48264d7c1cc90a84e58022f343 /components | |
parent | aa928ff8aa04cba903718f2bad61bce06b763343 (diff) | |
download | chromium_src-045c9bf1d36f35643a077891dedf24054f2032a3.zip chromium_src-045c9bf1d36f35643a077891dedf24054f2032a3.tar.gz chromium_src-045c9bf1d36f35643a077891dedf24054f2032a3.tar.bz2 |
Eliminate components_unittests' dependence on chrome resources.
This CL changes components_unittests to create its own pakfile rather than
relying on the chrome pakfile. To do this it adds a repack step that repacks
the pakfiles that components_unittests needs into a
components_unittests_resources.pak file, and then loads that pakfile
explicitly.
This change means that components_unittests now passes after a clean build,
whereas before it would fail due to missing resources.
This is based on blundell's change: https://codereview.chromium.org/258043003/
BUG=348563,450464
R=thakis@chromium.org
Review URL: https://codereview.chromium.org/856163002
Cr-Commit-Position: refs/heads/master@{#312306}
Diffstat (limited to 'components')
-rw-r--r-- | components/bookmarks/browser/bookmark_model_unittest.cc | 2 | ||||
-rw-r--r-- | components/components_tests.gyp | 27 | ||||
-rw-r--r-- | components/components_unittests.isolate | 4 | ||||
-rw-r--r-- | components/test/run_all_unittests.cc | 44 |
4 files changed, 31 insertions, 46 deletions
diff --git a/components/bookmarks/browser/bookmark_model_unittest.cc b/components/bookmarks/browser/bookmark_model_unittest.cc index bdf0a97..eefdd47 100644 --- a/components/bookmarks/browser/bookmark_model_unittest.cc +++ b/components/bookmarks/browser/bookmark_model_unittest.cc @@ -986,6 +986,7 @@ TEST_F(BookmarkModelTestWithProfile, CreateAndRestore) { } } +#if !defined(OS_ANDROID) && !defined(OS_IOS) // http://crbug.com/450464 TEST_F(BookmarkModelTest, Sort) { // Populate the bookmark bar node with nodes for 'B', 'a', 'd' and 'C'. // 'C' and 'a' are folders. @@ -1016,6 +1017,7 @@ TEST_F(BookmarkModelTest, Sort) { EXPECT_EQ(parent->GetChild(2)->GetTitle(), ASCIIToUTF16("B")); EXPECT_EQ(parent->GetChild(3)->GetTitle(), ASCIIToUTF16("d")); } +#endif TEST_F(BookmarkModelTest, Reorder) { // Populate the bookmark bar node with nodes 'A', 'B', 'C' and 'D'. diff --git a/components/components_tests.gyp b/components/components_tests.gyp index 77cfc0b..bc2dab2 100644 --- a/components/components_tests.gyp +++ b/components/components_tests.gyp @@ -311,9 +311,6 @@ 'dependencies': [ '../base/base.gyp:base_prefs_test_support', '../base/base.gyp:test_support_base', - # TODO(blundell): Eliminate this dependency by having - # components_unittests have its own pakfile. crbug.com/348563 - '../chrome/chrome_resources.gyp:packed_extra_resources', # TODO(blundell): Eliminate the need for this dependency in code # that iOS shares. crbug.com/325243 '../content/content_shell_and_tests.gyp:test_support_content', @@ -325,6 +322,8 @@ '../ui/base/ui_base.gyp:ui_base', '../ui/gfx/gfx.gyp:gfx', '../ui/gfx/gfx.gyp:gfx_test_support', + '../ui/resources/ui_resources.gyp:ui_resources', + '../ui/strings/ui_strings.gyp:ui_strings', 'components_resources.gyp:components_resources', @@ -516,6 +515,25 @@ 'components.gyp:web_resource_test_support', '../base/base.gyp:base', ], + 'actions': [ + { + 'action_name': 'repack_components_pak', + 'variables': { + 'pak_inputs': [ + '<(SHARED_INTERMEDIATE_DIR)/components/components_resources.pak', + '<(SHARED_INTERMEDIATE_DIR)/components/strings/components_strings_en-US.pak', + '<(SHARED_INTERMEDIATE_DIR)/ui/resources/ui_resources_100_percent.pak', + '<(SHARED_INTERMEDIATE_DIR)/ui/strings/app_locale_settings_en-US.pak', + '<(SHARED_INTERMEDIATE_DIR)/ui/strings/ui_strings_en-US.pak', + ], + 'pak_output': '<(PRODUCT_DIR)/components_unittests_resources.pak', + }, + 'includes': [ '../build/repack_action.gypi' ], + }, + ], + 'mac_bundle_resources': [ + '<(PRODUCT_DIR)/components_unittests_resources.pak', + ], 'conditions': [ ['toolkit_views == 1', { 'sources': [ @@ -621,7 +639,6 @@ }], ], }, { # 'OS == "ios"' - 'includes': ['../chrome/chrome_ios_bundle_resources.gypi'], 'sources': [ 'webp_transcode/webp_decoder_unittest.mm', ], @@ -1063,7 +1080,7 @@ ], 'actions': [ { - 'action_name': 'repack_components_pack', + 'action_name': 'repack_components_pak', 'variables': { 'pak_inputs': [ '<(SHARED_INTERMEDIATE_DIR)/components/components_resources.pak', diff --git a/components/components_unittests.isolate b/components/components_unittests.isolate index da4e0e6..331cafb 100644 --- a/components/components_unittests.isolate +++ b/components/components_unittests.isolate @@ -7,7 +7,7 @@ 'variables': { 'files': [ 'test/data/', - '<(PRODUCT_DIR)/resources.pak', + '<(PRODUCT_DIR)/components_unittests_resources.pak', ], }, }], @@ -22,8 +22,6 @@ ['OS=="android" or OS=="linux" or OS=="win"', { 'variables': { 'files': [ - '<(PRODUCT_DIR)/chrome_100_percent.pak', - '<(PRODUCT_DIR)/locales/en-US.pak', ], }, }], diff --git a/components/test/run_all_unittests.cc b/components/test/run_all_unittests.cc index 533ac9d..00d8594a 100644 --- a/components/test/run_all_unittests.cc +++ b/components/test/run_all_unittests.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include "base/bind.h" +#include "base/files/file_path.h" #include "base/memory/scoped_ptr.h" #include "base/metrics/statistics_recorder.h" #include "base/path_service.h" @@ -15,10 +16,6 @@ #include "ui/base/ui_base_paths.h" #include "url/url_util.h" -#if defined(OS_MACOSX) -#include "base/mac/bundle_locations.h" -#endif - #if !defined(OS_IOS) #include "ui/gl/gl_surface.h" #endif @@ -56,41 +53,16 @@ class ComponentsTestSuite : public base::TestSuite { invalidation::android::RegisterInvalidationJni(env); #endif -#if defined(OS_MACOSX) && !defined(OS_IOS) - // Look in the framework bundle for resources. - base::FilePath path; - PathService::Get(base::DIR_EXE, &path); - - // TODO(tfarina): This is temporary. The right fix is to write a - // framework-Info.plist and integrate that into the build. - // Hardcode the framework name here to avoid having to depend on chrome's - // common target for chrome::kFrameworkName. -#if defined(GOOGLE_CHROME_BUILD) - path = path.AppendASCII("Google Chrome Framework.framework"); -#elif defined(CHROMIUM_BUILD) - path = path.AppendASCII("Chromium Framework.framework"); -#else -#error Unknown branding -#endif - - base::mac::SetOverrideFrameworkBundlePath(path); -#endif - ui::RegisterPathProvider(); - // TODO(tfarina): This should be changed to InitSharedInstanceWithPakFile() - // so we can load our pak file instead of chrome.pak. crbug.com/348563 - ui::ResourceBundle::InitSharedInstanceWithLocale( - "en-US", NULL, ui::ResourceBundle::LOAD_COMMON_RESOURCES); base::FilePath resources_pack_path; -#if !defined(OS_ANDROID) - PathService::Get(base::DIR_MODULE, &resources_pack_path); -#else +#if defined(OS_ANDROID) PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID, &resources_pack_path); +#else + PathService::Get(base::DIR_MODULE, &resources_pack_path); #endif - ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath( - resources_pack_path.AppendASCII("resources.pak"), - ui::SCALE_FACTOR_NONE); + ui::ResourceBundle::InitSharedInstanceWithPakPath( + resources_pack_path.AppendASCII("components_unittests_resources.pak")); // These schemes need to be added globally to pass tests of // autocomplete_input_unittest.cc and content_settings_pattern* @@ -107,10 +79,6 @@ class ComponentsTestSuite : public base::TestSuite { void Shutdown() override { ui::ResourceBundle::CleanupSharedInstance(); -#if defined(OS_MACOSX) && !defined(OS_IOS) - base::mac::SetOverrideFrameworkBundle(NULL); -#endif - base::TestSuite::Shutdown(); } |