| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/test/test_suite.h" | 5 #include "ui/test/test_suite.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "ui/base/resource/resource_bundle.h" | 10 #include "ui/base/resource/resource_bundle.h" |
| 11 #include "ui/base/resource/resource_handle.h" | |
| 12 #include "ui/base/ui_base_paths.h" | 11 #include "ui/base/ui_base_paths.h" |
| 13 #include "ui/gfx/gfx_paths.h" | 12 #include "ui/gfx/gfx_paths.h" |
| 14 | 13 |
| 15 #if defined(OS_ANDROID) | 14 #if defined(OS_ANDROID) |
| 16 #include "base/android/jni_android.h" | 15 #include "base/android/jni_android.h" |
| 17 #include "ui/base/android/ui_base_jni_registrar.h" | 16 #include "ui/base/android/ui_base_jni_registrar.h" |
| 18 #include "ui/gfx/android/gfx_jni_registrar.h" | 17 #include "ui/gfx/android/gfx_jni_registrar.h" |
| 19 #endif | 18 #endif |
| 20 | 19 |
| 21 #if defined(OS_MACOSX) && !defined(OS_IOS) | 20 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 47 base::FilePath path; | 46 base::FilePath path; |
| 48 PathService::Get(base::DIR_EXE, &path); | 47 PathService::Get(base::DIR_EXE, &path); |
| 49 #if defined(GOOGLE_CHROME_BUILD) | 48 #if defined(GOOGLE_CHROME_BUILD) |
| 50 path = path.AppendASCII("Google Chrome Framework.framework"); | 49 path = path.AppendASCII("Google Chrome Framework.framework"); |
| 51 #elif defined(CHROMIUM_BUILD) | 50 #elif defined(CHROMIUM_BUILD) |
| 52 path = path.AppendASCII("Chromium Framework.framework"); | 51 path = path.AppendASCII("Chromium Framework.framework"); |
| 53 #else | 52 #else |
| 54 #error Unknown branding | 53 #error Unknown branding |
| 55 #endif | 54 #endif |
| 56 base::mac::SetOverrideFrameworkBundlePath(path); | 55 base::mac::SetOverrideFrameworkBundlePath(path); |
| 57 #elif defined(OS_POSIX) | |
| 58 base::FilePath pak_dir; | |
| 59 #if defined(OS_ANDROID) | |
| 60 PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID, &pak_dir); | |
| 61 #else | |
| 62 PathService::Get(base::DIR_MODULE, &pak_dir); | |
| 63 pak_dir = pak_dir.AppendASCII("ui_unittests_strings"); | |
| 64 PathService::Override(ui::DIR_LOCALES, pak_dir); | |
| 65 #endif // defined(OS_ANDROID) | |
| 66 #endif // defined(OS_MACOSX) && !defined(OS_IOS) | 56 #endif // defined(OS_MACOSX) && !defined(OS_IOS) |
| 67 | 57 |
| 68 // Force unittests to run using en-US so if we test against string | 58 // TODO(tfarina): This loads chrome_100_percent.pak and thus introduces a |
| 69 // output, it'll pass regardless of the system language. | 59 // dependency on chrome/, we don't want that here, so change this to |
| 60 // InitSharedInstanceWithPakPath(). |
| 70 ui::ResourceBundle::InitSharedInstanceWithLocale("en-US", NULL); | 61 ui::ResourceBundle::InitSharedInstanceWithLocale("en-US", NULL); |
| 71 | |
| 72 #if !defined(OS_MACOSX) && defined(OS_POSIX) | |
| 73 ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath( | |
| 74 pak_dir.AppendASCII("chrome_100_percent.pak"), | |
| 75 ui::SCALE_FACTOR_100P); | |
| 76 #endif | |
| 77 } | 62 } |
| 78 | 63 |
| 79 void UITestSuite::Shutdown() { | 64 void UITestSuite::Shutdown() { |
| 80 ui::ResourceBundle::CleanupSharedInstance(); | 65 ui::ResourceBundle::CleanupSharedInstance(); |
| 81 | 66 |
| 82 #if defined(OS_MACOSX) && !defined(OS_IOS) | 67 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 83 base::mac::SetOverrideFrameworkBundle(NULL); | 68 base::mac::SetOverrideFrameworkBundle(NULL); |
| 84 #endif | 69 #endif |
| 85 base::TestSuite::Shutdown(); | 70 base::TestSuite::Shutdown(); |
| 86 } | 71 } |
| 87 | 72 |
| 88 } // namespace test | 73 } // namespace test |
| 89 } // namespace ui | 74 } // namespace ui |
| OLD | NEW |