| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
| 7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "base/test/launcher/unit_test_launcher.h" | 8 #include "base/test/launcher/unit_test_launcher.h" |
| 9 #include "base/test/test_suite.h" | 9 #include "base/test/test_suite.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 | 45 |
| 46 #if defined(OS_ANDROID) | 46 #if defined(OS_ANDROID) |
| 47 // Register JNI bindings for android. | 47 // Register JNI bindings for android. |
| 48 gfx::android::RegisterJni(base::android::AttachCurrentThread()); | 48 gfx::android::RegisterJni(base::android::AttachCurrentThread()); |
| 49 ui::android::RegisterJni(base::android::AttachCurrentThread()); | 49 ui::android::RegisterJni(base::android::AttachCurrentThread()); |
| 50 #endif | 50 #endif |
| 51 | 51 |
| 52 ui::RegisterPathProvider(); | 52 ui::RegisterPathProvider(); |
| 53 gfx::RegisterPathProvider(); | 53 gfx::RegisterPathProvider(); |
| 54 | 54 |
| 55 base::FilePath exe_path; |
| 56 PathService::Get(base::DIR_EXE, &exe_path); |
| 57 |
| 55 #if defined(OS_MACOSX) && !defined(OS_IOS) | 58 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 56 // Look in the framework bundle for resources. | 59 // On Mac, a test Framework bundle is created that links locale.pak and |
| 57 // TODO(port): make a resource bundle for non-app exes. What's done here | 60 // chrome_100_percent.pak at the appropriate places to ui_test.pak. |
| 58 // isn't really right because this code needs to depend on chrome_dll | 61 base::mac::SetOverrideFrameworkBundlePath( |
| 59 // being built. This is inappropriate in app. | 62 exe_path.AppendASCII("ui_unittests Framework.framework")); |
| 60 base::FilePath path; | 63 ui::ResourceBundle::InitSharedInstanceWithLocale("en-US", NULL); |
| 61 PathService::Get(base::DIR_EXE, &path); | 64 |
| 62 #if defined(GOOGLE_CHROME_BUILD) | 65 #elif defined(OS_IOS) || defined(OS_ANDROID) |
| 63 path = path.AppendASCII("Google Chrome Framework.framework"); | 66 // On iOS, the ui_unittests binary is itself a mini bundle, with resources |
| 64 #elif defined(CHROMIUM_BUILD) | 67 // built in. On Android, ui_unittests_apk provides the necessary framework. |
| 65 path = path.AppendASCII("Chromium Framework.framework"); | 68 ui::ResourceBundle::InitSharedInstanceWithLocale("en-US", NULL); |
| 69 |
| 66 #else | 70 #else |
| 67 #error Unknown branding | 71 // On other platforms, the (hardcoded) paths for chrome_100_percent.pak and |
| 72 // locale.pak get populated by later build steps. To avoid clobbering them, |
| 73 // load the test .pak files directly. |
| 74 ui::ResourceBundle::InitSharedInstanceWithPakPath( |
| 75 exe_path.AppendASCII("ui_test.pak")); |
| 76 |
| 77 // ui_unittests can't depend on the locales folder which Chrome will make |
| 78 // later, so use the path created by ui_unittest_strings. |
| 79 PathService::Override( |
| 80 ui::DIR_LOCALES, |
| 81 exe_path.AppendASCII("ui_unittests_strings")); |
| 68 #endif | 82 #endif |
| 69 base::mac::SetOverrideFrameworkBundlePath(path); | |
| 70 #endif // defined(OS_MACOSX) && !defined(OS_IOS) | |
| 71 | |
| 72 // TODO(tfarina): This loads chrome_100_percent.pak and thus introduces a | |
| 73 // dependency on chrome/, we don't want that here, so change this to | |
| 74 // InitSharedInstanceWithPakPath(). | |
| 75 ui::ResourceBundle::InitSharedInstanceWithLocale("en-US", NULL); | |
| 76 } | 83 } |
| 77 | 84 |
| 78 void UIBaseTestSuite::Shutdown() { | 85 void UIBaseTestSuite::Shutdown() { |
| 79 ui::ResourceBundle::CleanupSharedInstance(); | 86 ui::ResourceBundle::CleanupSharedInstance(); |
| 80 | 87 |
| 81 #if defined(OS_MACOSX) && !defined(OS_IOS) | 88 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 82 base::mac::SetOverrideFrameworkBundle(NULL); | 89 base::mac::SetOverrideFrameworkBundle(NULL); |
| 83 #endif | 90 #endif |
| 84 base::TestSuite::Shutdown(); | 91 base::TestSuite::Shutdown(); |
| 85 } | 92 } |
| 86 | 93 |
| 87 } // namespace | 94 } // namespace |
| 88 | 95 |
| 89 int main(int argc, char** argv) { | 96 int main(int argc, char** argv) { |
| 90 UIBaseTestSuite test_suite(argc, argv); | 97 UIBaseTestSuite test_suite(argc, argv); |
| 91 | 98 |
| 92 return base::LaunchUnitTests(argc, | 99 return base::LaunchUnitTests(argc, |
| 93 argv, | 100 argv, |
| 94 base::Bind(&UIBaseTestSuite::Run, | 101 base::Bind(&UIBaseTestSuite::Run, |
| 95 base::Unretained(&test_suite))); | 102 base::Unretained(&test_suite))); |
| 96 } | 103 } |
| OLD | NEW |