Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Unified Diff: ui/base/test/run_all_unittests.cc

Issue 152543005: Introduce a mock ui_unittests Framework for loading resources. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix iOS with an explainer Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/base/test/run_all_unittests.cc
diff --git a/ui/base/test/run_all_unittests.cc b/ui/base/test/run_all_unittests.cc
index 0f94dacdeaf72ba90ac4f7d6ec7fb7c4f0a7d2b6..3998220629f289f5b7d3b1961f567d52e12a7aab 100644
--- a/ui/base/test/run_all_unittests.cc
+++ b/ui/base/test/run_all_unittests.cc
@@ -52,27 +52,34 @@ void UIBaseTestSuite::Initialize() {
ui::RegisterPathProvider();
gfx::RegisterPathProvider();
-#if defined(OS_MACOSX) && !defined(OS_IOS)
- // Look in the framework bundle for resources.
- // TODO(port): make a resource bundle for non-app exes. What's done here
- // isn't really right because this code needs to depend on chrome_dll
- // being built. This is inappropriate in app.
- base::FilePath path;
- PathService::Get(base::DIR_EXE, &path);
-#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 // defined(OS_MACOSX) && !defined(OS_IOS)
+ base::FilePath exe_path;
+ PathService::Get(base::DIR_EXE, &exe_path);
+
+#if defined(OS_MACOSX)
+
+# if !defined(OS_IOS)
+ // On Mac, a test Framework bundle is created that links locale.pak and
+ // chrome_100_percent.pak at the appropriate places to ui_test.pak. On iOS,
+ // the ui_unittests binary is itself a mini bundle, with resources built in.
+ base::mac::SetOverrideFrameworkBundlePath(
+ exe_path.AppendASCII("ui_unittests Framework.framework"));
+# endif // !defined(OS_IOS)
- // TODO(tfarina): This loads chrome_100_percent.pak and thus introduces a
- // dependency on chrome/, we don't want that here, so change this to
- // InitSharedInstanceWithPakPath().
ui::ResourceBundle::InitSharedInstanceWithLocale("en-US", NULL);
+
+#else // !defined(OS_MACOSX)
+ // On other platforms, the (hardcoded) paths for chrome_100_percent.pak and
+ // locale.pak get populated by later build steps. To avoid clobbering them,
+ // load the test .pak files directly.
+ ui::ResourceBundle::InitSharedInstanceWithPakPath(
+ exe_path.Append(FILE_PATH_LITERAL("ui_test.pak")));
+
+ // ui_unittests can't depend on the locales folder which Chrome will make
+ // later, so use the path created by ui_unittest_strings.
+ PathService::Override(
+ ui::DIR_LOCALES,
+ exe_path.Append(FILE_PATH_LITERAL("ui_unittests_strings")));
+#endif // defined(OS_MACOSX)
}
void UIBaseTestSuite::Shutdown() {

Powered by Google App Engine
This is Rietveld 408576698