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

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

Issue 867473002: Revert of Eliminate components_unittests' dependence on chrome resources. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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"
7 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
8 #include "base/metrics/statistics_recorder.h" 7 #include "base/metrics/statistics_recorder.h"
9 #include "base/path_service.h" 8 #include "base/path_service.h"
10 #include "base/test/launcher/unit_test_launcher.h" 9 #include "base/test/launcher/unit_test_launcher.h"
11 #include "base/test/test_suite.h" 10 #include "base/test/test_suite.h"
12 #include "components/content_settings/core/common/content_settings_pattern.h" 11 #include "components/content_settings/core/common/content_settings_pattern.h"
13 #include "content/public/test/test_content_client_initializer.h" 12 #include "content/public/test/test_content_client_initializer.h"
14 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
15 #include "ui/base/resource/resource_bundle.h" 14 #include "ui/base/resource/resource_bundle.h"
16 #include "ui/base/ui_base_paths.h" 15 #include "ui/base/ui_base_paths.h"
17 #include "url/url_util.h" 16 #include "url/url_util.h"
18 17
18 #if defined(OS_MACOSX)
19 #include "base/mac/bundle_locations.h"
20 #endif
21
19 #if !defined(OS_IOS) 22 #if !defined(OS_IOS)
20 #include "ui/gl/gl_surface.h" 23 #include "ui/gl/gl_surface.h"
21 #endif 24 #endif
22 25
23 #if defined(OS_ANDROID) 26 #if defined(OS_ANDROID)
24 #include "base/android/jni_android.h" 27 #include "base/android/jni_android.h"
25 #include "components/invalidation/android/component_jni_registrar.h" 28 #include "components/invalidation/android/component_jni_registrar.h"
26 #include "ui/base/android/ui_base_jni_registrar.h" 29 #include "ui/base/android/ui_base_jni_registrar.h"
27 #include "ui/gfx/android/gfx_jni_registrar.h" 30 #include "ui/gfx/android/gfx_jni_registrar.h"
28 #endif 31 #endif
(...skipping 17 matching lines...) Expand all
46 gfx::GLSurface::InitializeOneOffForTests(); 49 gfx::GLSurface::InitializeOneOffForTests();
47 #endif 50 #endif
48 #if defined(OS_ANDROID) 51 #if defined(OS_ANDROID)
49 // Register JNI bindings for android. 52 // Register JNI bindings for android.
50 JNIEnv* env = base::android::AttachCurrentThread(); 53 JNIEnv* env = base::android::AttachCurrentThread();
51 gfx::android::RegisterJni(env); 54 gfx::android::RegisterJni(env);
52 ui::android::RegisterJni(env); 55 ui::android::RegisterJni(env);
53 invalidation::android::RegisterInvalidationJni(env); 56 invalidation::android::RegisterInvalidationJni(env);
54 #endif 57 #endif
55 58
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
56 ui::RegisterPathProvider(); 79 ui::RegisterPathProvider();
57 80
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);
58 base::FilePath resources_pack_path; 85 base::FilePath resources_pack_path;
59 #if defined(OS_ANDROID) 86 #if !defined(OS_ANDROID)
87 PathService::Get(base::DIR_MODULE, &resources_pack_path);
88 #else
60 PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID, &resources_pack_path); 89 PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID, &resources_pack_path);
61 #else
62 PathService::Get(base::DIR_MODULE, &resources_pack_path);
63 #endif 90 #endif
64 ui::ResourceBundle::InitSharedInstanceWithPakPath( 91 ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath(
65 resources_pack_path.AppendASCII("components_unittests_resources.pak")); 92 resources_pack_path.AppendASCII("resources.pak"),
93 ui::SCALE_FACTOR_NONE);
66 94
67 // These schemes need to be added globally to pass tests of 95 // These schemes need to be added globally to pass tests of
68 // autocomplete_input_unittest.cc and content_settings_pattern* 96 // autocomplete_input_unittest.cc and content_settings_pattern*
69 url::AddStandardScheme("chrome"); 97 url::AddStandardScheme("chrome");
70 url::AddStandardScheme("chrome-extension"); 98 url::AddStandardScheme("chrome-extension");
71 url::AddStandardScheme("chrome-devtools"); 99 url::AddStandardScheme("chrome-devtools");
72 url::AddStandardScheme("chrome-search"); 100 url::AddStandardScheme("chrome-search");
73 101
74 // Not using kExtensionScheme to avoid the dependency to extensions. 102 // Not using kExtensionScheme to avoid the dependency to extensions.
75 ContentSettingsPattern::SetNonWildcardDomainNonPortScheme( 103 ContentSettingsPattern::SetNonWildcardDomainNonPortScheme(
76 "chrome-extension"); 104 "chrome-extension");
77 } 105 }
78 106
79 void Shutdown() override { 107 void Shutdown() override {
80 ui::ResourceBundle::CleanupSharedInstance(); 108 ui::ResourceBundle::CleanupSharedInstance();
81 109
110 #if defined(OS_MACOSX) && !defined(OS_IOS)
111 base::mac::SetOverrideFrameworkBundle(NULL);
112 #endif
113
82 base::TestSuite::Shutdown(); 114 base::TestSuite::Shutdown();
83 } 115 }
84 116
85 DISALLOW_COPY_AND_ASSIGN(ComponentsTestSuite); 117 DISALLOW_COPY_AND_ASSIGN(ComponentsTestSuite);
86 }; 118 };
87 119
88 class ComponentsUnitTestEventListener : public testing::EmptyTestEventListener { 120 class ComponentsUnitTestEventListener : public testing::EmptyTestEventListener {
89 public: 121 public:
90 ComponentsUnitTestEventListener() {} 122 ComponentsUnitTestEventListener() {}
91 virtual ~ComponentsUnitTestEventListener() {} 123 virtual ~ComponentsUnitTestEventListener() {}
(...skipping 20 matching lines...) Expand all
112 // The listener will set up common test environment for all components unit 144 // The listener will set up common test environment for all components unit
113 // tests. 145 // tests.
114 testing::TestEventListeners& listeners = 146 testing::TestEventListeners& listeners =
115 testing::UnitTest::GetInstance()->listeners(); 147 testing::UnitTest::GetInstance()->listeners();
116 listeners.Append(new ComponentsUnitTestEventListener()); 148 listeners.Append(new ComponentsUnitTestEventListener());
117 149
118 return base::LaunchUnitTests( 150 return base::LaunchUnitTests(
119 argc, argv, base::Bind(&base::TestSuite::Run, 151 argc, argv, base::Bind(&base::TestSuite::Run,
120 base::Unretained(&test_suite))); 152 base::Unretained(&test_suite)));
121 } 153 }
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