Commit 4f133fc9 authored by Wez's avatar Wez Committed by Commit Bot

CHECK that DataPack can be loaded in ResourceBundle::LoadTestResources.

Failure to load the DataPack, if a pak path is specified, should be
surfaced more visibly.

Bug: 1078365
Change-Id: I63b331b3bc58cd51843df6c8be5f16efb0647c6f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1018165Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Wez <wez@chromium.org>
Auto-Submit: Wez <wez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#790010}
parent 1d2cc073
...@@ -456,18 +456,28 @@ void ResourceBundle::LoadTestResources(const base::FilePath& path, ...@@ -456,18 +456,28 @@ void ResourceBundle::LoadTestResources(const base::FilePath& path,
const base::FilePath& locale_path) { const base::FilePath& locale_path) {
is_test_resources_ = true; is_test_resources_ = true;
DCHECK(!ui::GetSupportedScaleFactors().empty()); DCHECK(!ui::GetSupportedScaleFactors().empty());
const ScaleFactor scale_factor(ui::GetSupportedScaleFactors()[0]);
// Use the given resource pak for both common and localized resources. // Use the given resource pak for both common and localized resources.
std::unique_ptr<DataPack> data_pack(new DataPack(scale_factor));
if (!path.empty() && data_pack->LoadFromPath(path)) if (!path.empty()) {
const ScaleFactor scale_factor(ui::GetSupportedScaleFactors()[0]);
auto data_pack = std::make_unique<DataPack>(scale_factor);
#if defined(OS_ANDROID)
// TODO(https://crbug.com/1078365): Fix Android and remove this conditional.
if (data_pack->LoadFromPath(path))
AddDataPack(std::move(data_pack));
#else // !defined(OS_ANDROID)
CHECK(data_pack->LoadFromPath(path));
AddDataPack(std::move(data_pack)); AddDataPack(std::move(data_pack));
#endif // !define(OS_ANDROID)
}
data_pack = std::make_unique<DataPack>(ui::SCALE_FACTOR_NONE); auto data_pack = std::make_unique<DataPack>(ui::SCALE_FACTOR_NONE);
if (!locale_path.empty() && data_pack->LoadFromPath(locale_path)) { if (!locale_path.empty() && data_pack->LoadFromPath(locale_path)) {
locale_resources_data_ = std::move(data_pack); locale_resources_data_ = std::move(data_pack);
} else { } else {
locale_resources_data_ = std::make_unique<DataPack>(ui::SCALE_FACTOR_NONE); locale_resources_data_ = std::make_unique<DataPack>(ui::SCALE_FACTOR_NONE);
} }
// This is necessary to initialize ICU since we won't be calling // This is necessary to initialize ICU since we won't be calling
// LoadLocaleResources in this case. // LoadLocaleResources in this case.
l10n_util::GetApplicationLocale(std::string()); l10n_util::GetApplicationLocale(std::string());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment