Skip to content

Commit

Permalink
ui: Make views_unittests not depend on chrome's packed_resources target.
Browse files Browse the repository at this point in the history
Depending on chrome's target is a layer violation, so we should break that dependency.

BUG=299841,176960,144345
TEST=views_unittests
R=tony@chromium.org

Review URL: https://codereview.chromium.org/45753004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@234537 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
tfarina@chromium.org committed Nov 12, 2013
1 parent 5f817bf commit 33bf302
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 9 deletions.
6 changes: 2 additions & 4 deletions ui/base/resource/resource_bundle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -289,17 +289,15 @@ std::string ResourceBundle::LoadLocaleResources(
void ResourceBundle::LoadTestResources(const base::FilePath& path,
const base::FilePath& locale_path) {
// Use the given resource pak for both common and localized resources.
scoped_ptr<DataPack> data_pack(
new DataPack(SCALE_FACTOR_100P));
scoped_ptr<DataPack> data_pack(new DataPack(SCALE_FACTOR_100P));
if (!path.empty() && data_pack->LoadFromPath(path))
AddDataPack(data_pack.release());

data_pack.reset(new DataPack(ui::SCALE_FACTOR_NONE));
if (!locale_path.empty() && data_pack->LoadFromPath(locale_path)) {
locale_resources_data_.reset(data_pack.release());
} else {
locale_resources_data_.reset(
new DataPack(ui::SCALE_FACTOR_NONE));
locale_resources_data_.reset(new DataPack(ui::SCALE_FACTOR_NONE));
}
}

Expand Down
34 changes: 34 additions & 0 deletions ui/ui_resources.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,39 @@
],
'includes': [ '../build/grit_target.gypi' ],
},
{
# We build a minimal set of resources so WebKit in content_shell has
# access to necessary resources.
'target_name': 'ui_test_pak',
'type': 'none',
'dependencies': [
'base/strings/ui_strings.gyp:ui_strings',
'ui_resources',
],
'variables': {
'repack_path': '../tools/grit/grit/format/repack.py',
},
'actions': [
{
'action_name': 'repack_ui_test_pack',
'variables': {
'pak_inputs': [
'<(SHARED_INTERMEDIATE_DIR)/ui/app_locale_settings/app_locale_settings_en-US.pak',
'<(SHARED_INTERMEDIATE_DIR)/ui/ui_resources/ui_resources_100_percent.pak',
'<(SHARED_INTERMEDIATE_DIR)/ui/ui_resources/webui_resources.pak',
'<(SHARED_INTERMEDIATE_DIR)/ui/ui_strings/ui_strings_en-US.pak',
],
},
'inputs': [
'<(repack_path)',
'<@(pak_inputs)',
],
'outputs': [
'<(PRODUCT_DIR)/ui_test.pak',
],
'action': ['python', '<(repack_path)', '<@(_outputs)', '<@(pak_inputs)'],
},
],
},
],
}
10 changes: 9 additions & 1 deletion ui/views/run_all_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "base/basictypes.h"
#include "base/bind.h"
#include "base/compiler_specific.h"
#include "base/path_service.h"
#include "base/test/launcher/unit_test_launcher.h"
#include "base/test/test_suite.h"
#include "ui/base/resource/resource_bundle.h"
Expand All @@ -19,7 +20,14 @@ class ViewTestSuite : public base::TestSuite {
virtual void Initialize() OVERRIDE {
base::TestSuite::Initialize();
ui::RegisterPathProvider();
ui::ResourceBundle::InitSharedInstanceWithLocale("en-US", NULL);

base::FilePath pak_dir;
PathService::Get(base::DIR_MODULE, &pak_dir);

base::FilePath pak_file;
pak_file = pak_dir.Append(FILE_PATH_LITERAL("ui_test.pak"));

ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_file);
}

private:
Expand Down
5 changes: 1 addition & 4 deletions ui/views/views.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -702,10 +702,6 @@
'../../base/base.gyp:base',
'../../base/base.gyp:base_i18n',
'../../base/base.gyp:test_support_base',
# TODO(jcivelli): ideally the resource needed by views would be
# factored out. (for some reason it pulls in a bunch
# unrelated things like v8, sqlite nss...).
'../../chrome/chrome_resources.gyp:packed_resources',
'../../skia/skia.gyp:skia',
'../../testing/gmock.gyp:gmock',
'../../testing/gtest.gyp:gtest',
Expand All @@ -719,6 +715,7 @@
'../gfx/gfx.gyp:gfx',
'../ui.gyp:ui',
'../ui.gyp:ui_resources',
'../ui.gyp:ui_test_pak',
'../ui_unittests.gyp:ui_test_support',
'views',
'views_test_support',
Expand Down

0 comments on commit 33bf302

Please sign in to comment.