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; | 55 #if defined(OS_MACOSX) && !defined(OS_IOS) |
56 PathService::Get(base::DIR_EXE, &exe_path); | 56 // Look in the framework bundle for resources. |
| 57 // TODO(port): make a resource bundle for non-app exes. What's done here |
| 58 // isn't really right because this code needs to depend on chrome_dll |
| 59 // being built. This is inappropriate in app. |
| 60 base::FilePath path; |
| 61 PathService::Get(base::DIR_EXE, &path); |
| 62 #if defined(GOOGLE_CHROME_BUILD) |
| 63 path = path.AppendASCII("Google Chrome Framework.framework"); |
| 64 #elif defined(CHROMIUM_BUILD) |
| 65 path = path.AppendASCII("Chromium Framework.framework"); |
| 66 #else |
| 67 #error Unknown branding |
| 68 #endif |
| 69 base::mac::SetOverrideFrameworkBundlePath(path); |
| 70 #endif // defined(OS_MACOSX) && !defined(OS_IOS) |
57 | 71 |
58 #if defined(OS_MACOSX) && !defined(OS_IOS) | 72 // TODO(tfarina): This loads chrome_100_percent.pak and thus introduces a |
59 // On Mac, a test Framework bundle is created that links locale.pak and | 73 // dependency on chrome/, we don't want that here, so change this to |
60 // chrome_100_percent.pak at the appropriate places to ui_test.pak. | 74 // InitSharedInstanceWithPakPath(). |
61 base::mac::SetOverrideFrameworkBundlePath( | |
62 exe_path.AppendASCII("ui_unittests Framework.framework")); | |
63 ui::ResourceBundle::InitSharedInstanceWithLocale("en-US", NULL); | 75 ui::ResourceBundle::InitSharedInstanceWithLocale("en-US", NULL); |
64 | |
65 #elif defined(OS_IOS) || defined(OS_ANDROID) | |
66 // On iOS, the ui_unittests binary is itself a mini bundle, with resources | |
67 // built in. On Android, ui_unittests_apk provides the necessary framework. | |
68 ui::ResourceBundle::InitSharedInstanceWithLocale("en-US", NULL); | |
69 | |
70 #else | |
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")); | |
82 #endif | |
83 } | 76 } |
84 | 77 |
85 void UIBaseTestSuite::Shutdown() { | 78 void UIBaseTestSuite::Shutdown() { |
86 ui::ResourceBundle::CleanupSharedInstance(); | 79 ui::ResourceBundle::CleanupSharedInstance(); |
87 | 80 |
88 #if defined(OS_MACOSX) && !defined(OS_IOS) | 81 #if defined(OS_MACOSX) && !defined(OS_IOS) |
89 base::mac::SetOverrideFrameworkBundle(NULL); | 82 base::mac::SetOverrideFrameworkBundle(NULL); |
90 #endif | 83 #endif |
91 base::TestSuite::Shutdown(); | 84 base::TestSuite::Shutdown(); |
92 } | 85 } |
93 | 86 |
94 } // namespace | 87 } // namespace |
95 | 88 |
96 int main(int argc, char** argv) { | 89 int main(int argc, char** argv) { |
97 UIBaseTestSuite test_suite(argc, argv); | 90 UIBaseTestSuite test_suite(argc, argv); |
98 | 91 |
99 return base::LaunchUnitTests(argc, | 92 return base::LaunchUnitTests(argc, |
100 argv, | 93 argv, |
101 base::Bind(&UIBaseTestSuite::Run, | 94 base::Bind(&UIBaseTestSuite::Run, |
102 base::Unretained(&test_suite))); | 95 base::Unretained(&test_suite))); |
103 } | 96 } |
OLD | NEW |