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" |
9 #include "content/public/test/test_content_client_initializer.h" | 10 #include "content/public/test/test_content_client_initializer.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
11 #include "ui/base/resource/resource_bundle.h" | 12 #include "ui/base/resource/resource_bundle.h" |
13 #include "ui/base/ui_base_paths.h" | |
14 | |
15 #if defined(OS_MACOSX) | |
16 #include "base/mac/bundle_locations.h" | |
17 #include "chrome/common/chrome_constants.h" | |
18 #endif | |
12 | 19 |
13 #if !defined(OS_IOS) | 20 #if !defined(OS_IOS) |
14 #include "ui/gl/gl_surface.h" | 21 #include "ui/gl/gl_surface.h" |
15 #endif | 22 #endif |
16 | 23 |
17 #if defined(OS_ANDROID) | 24 #if defined(OS_ANDROID) |
18 #include "base/android/jni_android.h" | 25 #include "base/android/jni_android.h" |
19 #include "ui/base/android/ui_base_jni_registrar.h" | 26 #include "ui/base/android/ui_base_jni_registrar.h" |
20 #include "ui/gfx/android/gfx_jni_registrar.h" | 27 #include "ui/gfx/android/gfx_jni_registrar.h" |
21 #endif | 28 #endif |
(...skipping 10 matching lines...) Expand all Loading... | |
32 #if !defined(OS_IOS) | 39 #if !defined(OS_IOS) |
33 gfx::GLSurface::InitializeOneOffForTests(true); | 40 gfx::GLSurface::InitializeOneOffForTests(true); |
34 #endif | 41 #endif |
35 #if defined(OS_ANDROID) | 42 #if defined(OS_ANDROID) |
36 // Register JNI bindings for android. | 43 // Register JNI bindings for android. |
37 JNIEnv* env = base::android::AttachCurrentThread(); | 44 JNIEnv* env = base::android::AttachCurrentThread(); |
38 gfx::android::RegisterJni(env); | 45 gfx::android::RegisterJni(env); |
39 ui::android::RegisterJni(env); | 46 ui::android::RegisterJni(env); |
40 #endif | 47 #endif |
41 | 48 |
49 #if defined(OS_MACOSX) && !defined(OS_IOS) | |
50 // Look in the framework bundle for resources. | |
51 base::FilePath path; | |
52 PathService::Get(base::DIR_EXE, &path); | |
53 path = path.Append(chrome::kFrameworkName); | |
54 base::mac::SetOverrideFrameworkBundlePath(path); | |
55 #endif | |
56 | |
57 ui::RegisterPathProvider(); | |
58 | |
42 // TODO(tfarina): This should be changed to InitSharedInstanceWithPakFile() | 59 // TODO(tfarina): This should be changed to InitSharedInstanceWithPakFile() |
43 // so we can load our pak file instead of chrome.pak. | 60 // so we can load our pak file instead of chrome.pak. |
44 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")); | |
tfarina
2014/02/26 12:51:44
you can inline this in AddDataPackFromPath call as
blundell
2014/03/03 14:57:51
Done.
| |
66 ResourceBundle::GetSharedInstance().AddDataPackFromPath( | |
tfarina
2014/02/26 12:51:44
nit: ui::ResourceBundle
blundell
2014/03/03 14:57:51
Done.
| |
67 resources_pack_path, ui::SCALE_FACTOR_NONE); | |
45 } | 68 } |
46 | 69 |
47 virtual void Shutdown() OVERRIDE { | 70 virtual void Shutdown() OVERRIDE { |
48 ui::ResourceBundle::CleanupSharedInstance(); | 71 ui::ResourceBundle::CleanupSharedInstance(); |
49 base::TestSuite::Shutdown(); | 72 base::TestSuite::Shutdown(); |
50 } | 73 } |
51 | 74 |
52 DISALLOW_COPY_AND_ASSIGN(ComponentsTestSuite); | 75 DISALLOW_COPY_AND_ASSIGN(ComponentsTestSuite); |
53 }; | 76 }; |
54 | 77 |
(...skipping 24 matching lines...) Expand all Loading... | |
79 // 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 |
80 // tests. | 103 // tests. |
81 testing::TestEventListeners& listeners = | 104 testing::TestEventListeners& listeners = |
82 testing::UnitTest::GetInstance()->listeners(); | 105 testing::UnitTest::GetInstance()->listeners(); |
83 listeners.Append(new ComponentsUnitTestEventListener()); | 106 listeners.Append(new ComponentsUnitTestEventListener()); |
84 | 107 |
85 return base::LaunchUnitTests( | 108 return base::LaunchUnitTests( |
86 argc, argv, base::Bind(&base::TestSuite::Run, | 109 argc, argv, base::Bind(&base::TestSuite::Run, |
87 base::Unretained(&test_suite))); | 110 base::Unretained(&test_suite))); |
88 } | 111 } |
OLD | NEW |