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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "base/path_service.h" |
7 #include "base/test/launcher/unit_test_launcher.h" | 8 #include "base/test/launcher/unit_test_launcher.h" |
8 #include "base/test/test_suite.h" | 9 #include "base/test/test_suite.h" |
| 10 #include "chrome/common/chrome_constants.h" |
| 11 #include "chrome/common/chrome_paths.h" |
9 #include "content/public/test/test_content_client_initializer.h" | 12 #include "content/public/test/test_content_client_initializer.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
11 #include "ui/base/resource/resource_bundle.h" | 14 #include "ui/base/resource/resource_bundle.h" |
12 | 15 |
| 16 #if defined(OS_MACOSX) |
| 17 #include "base/mac/bundle_locations.h" |
| 18 #endif |
| 19 |
13 #if defined(OS_ANDROID) | 20 #if defined(OS_ANDROID) |
14 #include "base/android/jni_android.h" | 21 #include "base/android/jni_android.h" |
15 #include "ui/base/android/ui_base_jni_registrar.h" | 22 #include "ui/base/android/ui_base_jni_registrar.h" |
16 #include "ui/gfx/android/gfx_jni_registrar.h" | 23 #include "ui/gfx/android/gfx_jni_registrar.h" |
17 #endif | 24 #endif |
18 | 25 |
| 26 #if defined(OS_CHROMEOS) |
| 27 #include "chromeos/chromeos_paths.h" |
| 28 #endif |
| 29 |
19 namespace { | 30 namespace { |
20 | 31 |
21 class ComponentsTestSuite : public base::TestSuite { | 32 class ComponentsTestSuite : public base::TestSuite { |
22 public: | 33 public: |
23 ComponentsTestSuite(int argc, char** argv) : base::TestSuite(argc, argv) {} | 34 ComponentsTestSuite(int argc, char** argv) : base::TestSuite(argc, argv) {} |
24 | 35 |
25 private: | 36 private: |
26 virtual void Initialize() OVERRIDE { | 37 virtual void Initialize() OVERRIDE { |
27 base::TestSuite::Initialize(); | 38 base::TestSuite::Initialize(); |
28 | 39 |
29 #if defined(OS_ANDROID) | 40 #if defined(OS_ANDROID) |
30 // Register JNI bindings for android. | 41 // Register JNI bindings for android. |
31 JNIEnv* env = base::android::AttachCurrentThread(); | 42 JNIEnv* env = base::android::AttachCurrentThread(); |
32 gfx::android::RegisterJni(env); | 43 gfx::android::RegisterJni(env); |
33 ui::android::RegisterJni(env); | 44 ui::android::RegisterJni(env); |
34 #endif | 45 #endif |
35 | 46 |
| 47 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 48 // Look in the framework bundle for resources. |
| 49 base::FilePath path; |
| 50 PathService::Get(base::DIR_EXE, &path); |
| 51 path = path.Append(chrome::kFrameworkName); |
| 52 base::mac::SetOverrideFrameworkBundlePath(path); |
| 53 #endif |
| 54 |
| 55 chrome::RegisterPathProvider(); |
| 56 #if defined(OS_CHROMEOS) |
| 57 chromeos::RegisterPathProvider(); |
| 58 #endif |
36 // TODO(tfarina): This should be changed to InitSharedInstanceWithPakFile() | 59 // TODO(tfarina): This should be changed to InitSharedInstanceWithPakFile() |
37 // so we can load our pak file instead of chrome.pak. | 60 // so we can load our pak file instead of chrome.pak. |
38 ui::ResourceBundle::InitSharedInstanceWithLocale("en-US", NULL); | 61 ui::ResourceBundle::InitSharedInstanceWithLocale("en-US", NULL); |
| 62 base::FilePath resources_pack_path; |
| 63 PathService::Get(base::DIR_MODULE, &resources_pack_path); |
| 64 resources_pack_path = |
| 65 resources_pack_path.Append(FILE_PATH_LITERAL("resources.pak")); |
| 66 ResourceBundle::GetSharedInstance().AddDataPackFromPath( |
| 67 resources_pack_path, ui::SCALE_FACTOR_NONE); |
39 } | 68 } |
40 | 69 |
41 virtual void Shutdown() OVERRIDE { | 70 virtual void Shutdown() OVERRIDE { |
42 ui::ResourceBundle::CleanupSharedInstance(); | 71 ui::ResourceBundle::CleanupSharedInstance(); |
43 base::TestSuite::Shutdown(); | 72 base::TestSuite::Shutdown(); |
44 } | 73 } |
45 | 74 |
46 DISALLOW_COPY_AND_ASSIGN(ComponentsTestSuite); | 75 DISALLOW_COPY_AND_ASSIGN(ComponentsTestSuite); |
47 }; | 76 }; |
48 | 77 |
(...skipping 24 matching lines...) Expand all Loading... |
73 // The listener will set up common test environment for all components unit | 102 // The listener will set up common test environment for all components unit |
74 // tests. | 103 // tests. |
75 testing::TestEventListeners& listeners = | 104 testing::TestEventListeners& listeners = |
76 testing::UnitTest::GetInstance()->listeners(); | 105 testing::UnitTest::GetInstance()->listeners(); |
77 listeners.Append(new ComponentsUnitTestEventListener()); | 106 listeners.Append(new ComponentsUnitTestEventListener()); |
78 | 107 |
79 return base::LaunchUnitTests( | 108 return base::LaunchUnitTests( |
80 argc, argv, base::Bind(&base::TestSuite::Run, | 109 argc, argv, base::Bind(&base::TestSuite::Run, |
81 base::Unretained(&test_suite))); | 110 base::Unretained(&test_suite))); |
82 } | 111 } |
OLD | NEW |