Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(259)

Side by Side Diff: components/test/run_all_unittests.cc

Issue 856163002: Eliminate components_unittests' dependence on chrome resources. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixes Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/components_unittests.isolate ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/files/file_path.h"
6 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
7 #include "base/metrics/statistics_recorder.h" 8 #include "base/metrics/statistics_recorder.h"
8 #include "base/path_service.h" 9 #include "base/path_service.h"
9 #include "base/test/launcher/unit_test_launcher.h" 10 #include "base/test/launcher/unit_test_launcher.h"
10 #include "base/test/test_suite.h" 11 #include "base/test/test_suite.h"
11 #include "components/content_settings/core/common/content_settings_pattern.h" 12 #include "components/content_settings/core/common/content_settings_pattern.h"
12 #include "content/public/test/test_content_client_initializer.h" 13 #include "content/public/test/test_content_client_initializer.h"
13 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
14 #include "ui/base/resource/resource_bundle.h" 15 #include "ui/base/resource/resource_bundle.h"
15 #include "ui/base/ui_base_paths.h" 16 #include "ui/base/ui_base_paths.h"
16 #include "url/url_util.h" 17 #include "url/url_util.h"
17 18
18 #if defined(OS_MACOSX)
19 #include "base/mac/bundle_locations.h"
20 #endif
21
22 #if !defined(OS_IOS) 19 #if !defined(OS_IOS)
23 #include "ui/gl/gl_surface.h" 20 #include "ui/gl/gl_surface.h"
24 #endif 21 #endif
25 22
26 #if defined(OS_ANDROID) 23 #if defined(OS_ANDROID)
27 #include "base/android/jni_android.h" 24 #include "base/android/jni_android.h"
28 #include "components/invalidation/android/component_jni_registrar.h" 25 #include "components/invalidation/android/component_jni_registrar.h"
29 #include "ui/base/android/ui_base_jni_registrar.h" 26 #include "ui/base/android/ui_base_jni_registrar.h"
30 #include "ui/gfx/android/gfx_jni_registrar.h" 27 #include "ui/gfx/android/gfx_jni_registrar.h"
31 #endif 28 #endif
(...skipping 17 matching lines...) Expand all
49 gfx::GLSurface::InitializeOneOffForTests(); 46 gfx::GLSurface::InitializeOneOffForTests();
50 #endif 47 #endif
51 #if defined(OS_ANDROID) 48 #if defined(OS_ANDROID)
52 // Register JNI bindings for android. 49 // Register JNI bindings for android.
53 JNIEnv* env = base::android::AttachCurrentThread(); 50 JNIEnv* env = base::android::AttachCurrentThread();
54 gfx::android::RegisterJni(env); 51 gfx::android::RegisterJni(env);
55 ui::android::RegisterJni(env); 52 ui::android::RegisterJni(env);
56 invalidation::android::RegisterInvalidationJni(env); 53 invalidation::android::RegisterInvalidationJni(env);
57 #endif 54 #endif
58 55
59 #if defined(OS_MACOSX) && !defined(OS_IOS)
60 // Look in the framework bundle for resources.
61 base::FilePath path;
62 PathService::Get(base::DIR_EXE, &path);
63
64 // TODO(tfarina): This is temporary. The right fix is to write a
65 // framework-Info.plist and integrate that into the build.
66 // Hardcode the framework name here to avoid having to depend on chrome's
67 // common target for chrome::kFrameworkName.
68 #if defined(GOOGLE_CHROME_BUILD)
69 path = path.AppendASCII("Google Chrome Framework.framework");
70 #elif defined(CHROMIUM_BUILD)
71 path = path.AppendASCII("Chromium Framework.framework");
72 #else
73 #error Unknown branding
74 #endif
75
76 base::mac::SetOverrideFrameworkBundlePath(path);
77 #endif
78
79 ui::RegisterPathProvider(); 56 ui::RegisterPathProvider();
80 57
81 // TODO(tfarina): This should be changed to InitSharedInstanceWithPakFile()
82 // so we can load our pak file instead of chrome.pak. crbug.com/348563
83 ui::ResourceBundle::InitSharedInstanceWithLocale(
84 "en-US", NULL, ui::ResourceBundle::LOAD_COMMON_RESOURCES);
85 base::FilePath resources_pack_path; 58 base::FilePath resources_pack_path;
86 #if !defined(OS_ANDROID) 59 #if defined(OS_ANDROID)
60 PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID, &resources_pack_path);
61 #else
87 PathService::Get(base::DIR_MODULE, &resources_pack_path); 62 PathService::Get(base::DIR_MODULE, &resources_pack_path);
88 #else
89 PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID, &resources_pack_path);
90 #endif 63 #endif
91 ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath( 64 ui::ResourceBundle::InitSharedInstanceWithPakPath(
92 resources_pack_path.AppendASCII("resources.pak"), 65 resources_pack_path.AppendASCII("components_unittests_resources.pak"));
93 ui::SCALE_FACTOR_NONE);
94 66
95 // These schemes need to be added globally to pass tests of 67 // These schemes need to be added globally to pass tests of
96 // autocomplete_input_unittest.cc and content_settings_pattern* 68 // autocomplete_input_unittest.cc and content_settings_pattern*
97 url::AddStandardScheme("chrome"); 69 url::AddStandardScheme("chrome");
98 url::AddStandardScheme("chrome-extension"); 70 url::AddStandardScheme("chrome-extension");
99 url::AddStandardScheme("chrome-devtools"); 71 url::AddStandardScheme("chrome-devtools");
100 url::AddStandardScheme("chrome-search"); 72 url::AddStandardScheme("chrome-search");
101 73
102 // Not using kExtensionScheme to avoid the dependency to extensions. 74 // Not using kExtensionScheme to avoid the dependency to extensions.
103 ContentSettingsPattern::SetNonWildcardDomainNonPortScheme( 75 ContentSettingsPattern::SetNonWildcardDomainNonPortScheme(
104 "chrome-extension"); 76 "chrome-extension");
105 } 77 }
106 78
107 void Shutdown() override { 79 void Shutdown() override {
108 ui::ResourceBundle::CleanupSharedInstance(); 80 ui::ResourceBundle::CleanupSharedInstance();
109 81
110 #if defined(OS_MACOSX) && !defined(OS_IOS)
111 base::mac::SetOverrideFrameworkBundle(NULL);
112 #endif
113
114 base::TestSuite::Shutdown(); 82 base::TestSuite::Shutdown();
115 } 83 }
116 84
117 DISALLOW_COPY_AND_ASSIGN(ComponentsTestSuite); 85 DISALLOW_COPY_AND_ASSIGN(ComponentsTestSuite);
118 }; 86 };
119 87
120 class ComponentsUnitTestEventListener : public testing::EmptyTestEventListener { 88 class ComponentsUnitTestEventListener : public testing::EmptyTestEventListener {
121 public: 89 public:
122 ComponentsUnitTestEventListener() {} 90 ComponentsUnitTestEventListener() {}
123 virtual ~ComponentsUnitTestEventListener() {} 91 virtual ~ComponentsUnitTestEventListener() {}
(...skipping 20 matching lines...) Expand all
144 // The listener will set up common test environment for all components unit 112 // The listener will set up common test environment for all components unit
145 // tests. 113 // tests.
146 testing::TestEventListeners& listeners = 114 testing::TestEventListeners& listeners =
147 testing::UnitTest::GetInstance()->listeners(); 115 testing::UnitTest::GetInstance()->listeners();
148 listeners.Append(new ComponentsUnitTestEventListener()); 116 listeners.Append(new ComponentsUnitTestEventListener());
149 117
150 return base::LaunchUnitTests( 118 return base::LaunchUnitTests(
151 argc, argv, base::Bind(&base::TestSuite::Run, 119 argc, argv, base::Bind(&base::TestSuite::Run,
152 base::Unretained(&test_suite))); 120 base::Unretained(&test_suite)));
153 } 121 }
OLDNEW
« no previous file with comments | « components/components_unittests.isolate ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698