Splits ash_test_resources_100_percent into two pak files
One depends upon content, the other doesn't. This way ash_unittests
doesn't depend upon anything in content.
BUG=641026
TEST=test only changes
[email protected]
Review-Url: https://codereview.chromium.org/2316803002
Cr-Commit-Position: refs/heads/master@{#416808}
diff --git a/ash/BUILD.gn b/ash/BUILD.gn
index e9d5994..d00bfb7 100644
--- a/ash/BUILD.gn
+++ b/ash/BUILD.gn
@@ -152,6 +152,9 @@
"wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_ozone.h",
]
}
+
+ # Usage of content should be in ash_content_unittests.
+ assert_no_deps = [ "//content/*" ]
}
component("ash_with_content") {
@@ -407,7 +410,7 @@
data_deps = [
"//ash/common/strings:ash_test_strings",
- "//ash/resources:ash_test_resources_100_percent",
+ "//ash/resources:ash_test_resources_with_content_100_percent",
"//ash/resources:ash_test_resources_200_percent",
]
@@ -537,6 +540,9 @@
if (!use_x11 || !is_chromeos) {
sources -= [ "touch/touch_transformer_controller_unittest.cc" ]
}
+
+ # Usage of content should be in ash_with_content.
+ assert_no_deps = [ "//content/*" ]
}
executable("ash_shell_with_content") {
@@ -557,7 +563,7 @@
data_deps = [
"//ash/common/strings:ash_test_strings",
- "//ash/resources:ash_test_resources_100_percent",
+ "//ash/resources:ash_test_resources_with_content_100_percent",
"//ash/resources:ash_test_resources_200_percent",
]
diff --git a/ash/resources/BUILD.gn b/ash/resources/BUILD.gn
index 8fa121fb..1454da5 100644
--- a/ash/resources/BUILD.gn
+++ b/ash/resources/BUILD.gn
@@ -23,7 +23,7 @@
percent = invoker.percent
repack("ash_test_resources_${target_name}") {
- output = "$root_build_dir/ash_test_resources_${percent}_percent.pak"
+ output = "$root_build_dir/${target_name}.pak"
sources = [
"$root_gen_dir/ash/resources/ash_resources_${percent}_percent.pak",
@@ -31,18 +31,22 @@
]
if (percent == "100") {
- sources += [
- "$root_gen_dir/content/content_resources.pak",
- "$root_gen_dir/ui/resources/webui_resources.pak",
- ]
+ sources += [ "$root_gen_dir/ui/resources/webui_resources.pak" ]
+ }
+
+ if (defined(invoker.sources)) {
+ sources += invoker.sources
}
deps = [
"//ash/resources",
- "//content:resources",
"//ui/resources",
]
+ if (defined(invoker.deps)) {
+ deps += invoker.deps
+ }
+
if (toolkit_views) {
deps += [
"//ui/app_list/resources",
@@ -75,3 +79,15 @@
ash_test_resources("200_percent") {
percent = "200"
}
+
+# There is no with_content_200_percent as content resources are only available
+# at 100%.
+ash_test_resources("with_content_100_percent") {
+ percent = "100"
+ sources = [
+ "$root_gen_dir/content/content_resources.pak",
+ ]
+ deps = [
+ "//content:resources",
+ ]
+}
diff --git a/ash/shell/content/client/shell_main_delegate.cc b/ash/shell/content/client/shell_main_delegate.cc
index e984b98..c052bcc 100644
--- a/ash/shell/content/client/shell_main_delegate.cc
+++ b/ash/shell/content/client/shell_main_delegate.cc
@@ -46,17 +46,19 @@
PathService::Get(base::DIR_MODULE, &path);
base::FilePath ash_test_strings =
path.Append(FILE_PATH_LITERAL("ash_test_strings.pak"));
- base::FilePath ash_test_resources_100 =
- path.Append(FILE_PATH_LITERAL("ash_test_resources_100_percent.pak"));
- base::FilePath ash_test_resources_200 =
- path.Append(FILE_PATH_LITERAL("ash_test_resources_200_percent.pak"));
ui::ResourceBundle::InitSharedInstanceWithPakPath(ash_test_strings);
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
- if (ui::ResourceBundle::IsScaleFactorSupported(ui::SCALE_FACTOR_100P))
+ if (ui::ResourceBundle::IsScaleFactorSupported(ui::SCALE_FACTOR_100P)) {
+ base::FilePath ash_test_resources_100 = path.Append(
+ FILE_PATH_LITERAL("ash_test_resources_with_content_100_percent.pak"));
rb.AddDataPackFromPath(ash_test_resources_100, ui::SCALE_FACTOR_100P);
- if (ui::ResourceBundle::IsScaleFactorSupported(ui::SCALE_FACTOR_200P))
+ }
+ if (ui::ResourceBundle::IsScaleFactorSupported(ui::SCALE_FACTOR_200P)) {
+ base::FilePath ash_test_resources_200 =
+ path.Append(FILE_PATH_LITERAL("ash_test_resources_200_percent.pak"));
rb.AddDataPackFromPath(ash_test_resources_200, ui::SCALE_FACTOR_200P);
+ }
}
} // namespace shell
diff --git a/ash/test/ash_test_environment.h b/ash/test/ash_test_environment.h
index a763936..c533120f 100644
--- a/ash/test/ash_test_environment.h
+++ b/ash/test/ash_test_environment.h
@@ -6,6 +6,7 @@
#define ASH_TEST_ASH_TEST_ENVIRONMENT_H_
#include <memory>
+#include <string>
namespace base {
class SequencedWorkerPool;
@@ -34,6 +35,9 @@
// Creates the object appropriate to the current environment.
static std::unique_ptr<AshTestEnvironment> Create();
+ // Returns the ASCII file name of where the 100% resources are stored.
+ static std::string Get100PercentResourceFileName();
+
// Called from AshTestHelper::SetUp()/TearDown().
virtual void SetUp() {}
virtual void TearDown() {}
diff --git a/ash/test/ash_test_environment_content.cc b/ash/test/ash_test_environment_content.cc
index 0e51237..e0d228c 100644
--- a/ash/test/ash_test_environment_content.cc
+++ b/ash/test/ash_test_environment_content.cc
@@ -39,6 +39,11 @@
return base::MakeUnique<AshTestEnvironmentContent>();
}
+// static
+std::string AshTestEnvironment::Get100PercentResourceFileName() {
+ return "ash_test_resources_with_content_100_percent.pak";
+}
+
AshTestEnvironmentContent::AshTestEnvironmentContent()
: thread_bundle_(base::MakeUnique<content::TestBrowserThreadBundle>()) {}
diff --git a/ash/test/ash_test_environment_default.cc b/ash/test/ash_test_environment_default.cc
index f1d9d328..b070ce60 100644
--- a/ash/test/ash_test_environment_default.cc
+++ b/ash/test/ash_test_environment_default.cc
@@ -53,5 +53,10 @@
return base::MakeUnique<AshTestEnvironmentDefault>();
}
+// static
+std::string AshTestEnvironment::Get100PercentResourceFileName() {
+ return "ash_test_resources_100_percent.pak";
+}
+
} // namespace test
} // namespace ash
diff --git a/ash/test/test_suite.cc b/ash/test/test_suite.cc
index eb28d27..33dedc1 100644
--- a/ash/test/test_suite.cc
+++ b/ash/test/test_suite.cc
@@ -5,6 +5,7 @@
#include "ash/test/test_suite.h"
#include "ash/common/ash_switches.h"
+#include "ash/test/ash_test_environment.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/i18n/rtl.h"
@@ -58,17 +59,20 @@
PathService::Get(base::DIR_MODULE, &path);
base::FilePath ash_test_strings =
path.Append(FILE_PATH_LITERAL("ash_test_strings.pak"));
- base::FilePath ash_test_resources_100 =
- path.Append(FILE_PATH_LITERAL("ash_test_resources_100_percent.pak"));
- base::FilePath ash_test_resources_200 =
- path.Append(FILE_PATH_LITERAL("ash_test_resources_200_percent.pak"));
-
ui::ResourceBundle::InitSharedInstanceWithPakPath(ash_test_strings);
- ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
- if (ui::ResourceBundle::IsScaleFactorSupported(ui::SCALE_FACTOR_100P))
- rb.AddDataPackFromPath(ash_test_resources_100, ui::SCALE_FACTOR_100P);
- if (ui::ResourceBundle::IsScaleFactorSupported(ui::SCALE_FACTOR_200P))
- rb.AddDataPackFromPath(ash_test_resources_200, ui::SCALE_FACTOR_200P);
+
+ if (ui::ResourceBundle::IsScaleFactorSupported(ui::SCALE_FACTOR_100P)) {
+ base::FilePath ash_test_resources_100 =
+ path.AppendASCII(AshTestEnvironment::Get100PercentResourceFileName());
+ ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath(
+ ash_test_resources_100, ui::SCALE_FACTOR_100P);
+ }
+ if (ui::ResourceBundle::IsScaleFactorSupported(ui::SCALE_FACTOR_200P)) {
+ base::FilePath ash_test_resources_200 =
+ path.Append(FILE_PATH_LITERAL("ash_test_resources_200_percent.pak"));
+ ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath(
+ ash_test_resources_200, ui::SCALE_FACTOR_200P);
+ }
base::DiscardableMemoryAllocator::SetInstance(&discardable_memory_allocator_);
env_ = aura::Env::CreateInstance();