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/file_path.h" | 7 #include "base/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" | 11 #include "ui/base/resource/resource_handle.h" |
12 #include "ui/base/ui_base_paths.h" | 12 #include "ui/base/ui_base_paths.h" |
13 #include "ui/gfx/gfx_paths.h" | 13 #include "ui/gfx/gfx_paths.h" |
14 | 14 |
15 #if defined(OS_MACOSX) | 15 #if defined(OS_MACOSX) && !defined(OS_IOS) |
16 #include "base/mac/bundle_locations.h" | 16 #include "base/mac/bundle_locations.h" |
17 #endif | 17 #endif |
18 | 18 |
19 namespace ui { | 19 namespace ui { |
20 namespace test { | 20 namespace test { |
21 | 21 |
22 UITestSuite::UITestSuite(int argc, char** argv) : base::TestSuite(argc, argv) {} | 22 UITestSuite::UITestSuite(int argc, char** argv) : base::TestSuite(argc, argv) {} |
23 | 23 |
24 void UITestSuite::Initialize() { | 24 void UITestSuite::Initialize() { |
25 base::TestSuite::Initialize(); | 25 base::TestSuite::Initialize(); |
26 | 26 |
27 ui::RegisterPathProvider(); | 27 ui::RegisterPathProvider(); |
28 gfx::RegisterPathProvider(); | 28 gfx::RegisterPathProvider(); |
29 | 29 |
30 #if defined(OS_MACOSX) | 30 #if defined(OS_MACOSX) && !defined(OS_IOS) |
31 // Look in the framework bundle for resources. | 31 // Look in the framework bundle for resources. |
32 // TODO(port): make a resource bundle for non-app exes. What's done here | 32 // TODO(port): make a resource bundle for non-app exes. What's done here |
33 // isn't really right because this code needs to depend on chrome_dll | 33 // isn't really right because this code needs to depend on chrome_dll |
34 // being built. This is inappropriate in app. | 34 // being built. This is inappropriate in app. |
35 FilePath path; | 35 FilePath path; |
36 PathService::Get(base::DIR_EXE, &path); | 36 PathService::Get(base::DIR_EXE, &path); |
37 #if defined(GOOGLE_CHROME_BUILD) | 37 #if defined(GOOGLE_CHROME_BUILD) |
38 path = path.AppendASCII("Google Chrome Framework.framework"); | 38 path = path.AppendASCII("Google Chrome Framework.framework"); |
39 #elif defined(CHROMIUM_BUILD) | 39 #elif defined(CHROMIUM_BUILD) |
40 path = path.AppendASCII("Chromium Framework.framework"); | 40 path = path.AppendASCII("Chromium Framework.framework"); |
41 #else | 41 #else |
42 #error Unknown branding | 42 #error Unknown branding |
43 #endif | 43 #endif |
44 base::mac::SetOverrideFrameworkBundlePath(path); | 44 base::mac::SetOverrideFrameworkBundlePath(path); |
45 #elif defined(OS_POSIX) | 45 #elif defined(OS_POSIX) |
46 FilePath pak_dir; | 46 FilePath pak_dir; |
47 #if defined(OS_ANDROID) | 47 #if defined(OS_ANDROID) |
48 PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID, &pak_dir); | 48 PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID, &pak_dir); |
49 #else | 49 #else |
50 PathService::Get(base::DIR_MODULE, &pak_dir); | 50 PathService::Get(base::DIR_MODULE, &pak_dir); |
51 pak_dir = pak_dir.AppendASCII("ui_unittests_strings"); | 51 pak_dir = pak_dir.AppendASCII("ui_unittests_strings"); |
52 PathService::Override(ui::DIR_LOCALES, pak_dir); | 52 PathService::Override(ui::DIR_LOCALES, pak_dir); |
53 #endif // defined(OS_ANDROID) | 53 #endif // defined(OS_ANDROID) |
54 #endif // defined(OS_MACOSX) | 54 #endif // defined(OS_MACOSX) && !defined(OS_IOS) |
55 | 55 |
56 // Force unittests to run using en-US so if we test against string | 56 // Force unittests to run using en-US so if we test against string |
57 // output, it'll pass regardless of the system language. | 57 // output, it'll pass regardless of the system language. |
58 ui::ResourceBundle::InitSharedInstanceWithLocale("en-US", NULL); | 58 ui::ResourceBundle::InitSharedInstanceWithLocale("en-US", NULL); |
59 | 59 |
60 #if !defined(OS_MACOSX) && defined(OS_POSIX) | 60 #if !defined(OS_MACOSX) && defined(OS_POSIX) |
61 ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath( | 61 ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath( |
62 pak_dir.AppendASCII("chrome_100_percent.pak"), | 62 pak_dir.AppendASCII("chrome_100_percent.pak"), |
63 ui::SCALE_FACTOR_100P); | 63 ui::SCALE_FACTOR_100P); |
64 #endif | 64 #endif |
65 } | 65 } |
66 | 66 |
67 void UITestSuite::Shutdown() { | 67 void UITestSuite::Shutdown() { |
68 ui::ResourceBundle::CleanupSharedInstance(); | 68 ui::ResourceBundle::CleanupSharedInstance(); |
69 | 69 |
70 #if defined(OS_MACOSX) | 70 #if defined(OS_MACOSX) && !defined(OS_IOS) |
71 base::mac::SetOverrideFrameworkBundle(NULL); | 71 base::mac::SetOverrideFrameworkBundle(NULL); |
72 #endif | 72 #endif |
73 base::TestSuite::Shutdown(); | 73 base::TestSuite::Shutdown(); |
74 } | 74 } |
75 | 75 |
76 } // namespace test | 76 } // namespace test |
77 } // namespace ui | 77 } // namespace ui |
OLD | NEW |