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 "webkit/support/platform_support.h" | 5 #include "webkit/support/platform_support.h" |
6 | 6 |
7 #import <AppKit/AppKit.h> | 7 #import <AppKit/AppKit.h> |
8 #include <AvailabilityMacros.h> | 8 #include <AvailabilityMacros.h> |
9 #import <Foundation/Foundation.h> | 9 #import <Foundation/Foundation.h> |
10 #import <objc/objc-runtime.h> | 10 #import <objc/objc-runtime.h> |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 #else | 92 #else |
93 // Swizzle instance methods... | 93 // Swizzle instance methods... |
94 SwizzleAllMethods(imposterClass, originalClass); | 94 SwizzleAllMethods(imposterClass, originalClass); |
95 // and then class methods. | 95 // and then class methods. |
96 SwizzleAllMethods(object_getClass(imposterClass), | 96 SwizzleAllMethods(object_getClass(imposterClass), |
97 object_getClass(originalClass)); | 97 object_getClass(originalClass)); |
98 #endif | 98 #endif |
99 } | 99 } |
100 | 100 |
101 void AfterInitialize(bool unit_test_mode) { | 101 void AfterInitialize(bool unit_test_mode) { |
102 if (unit_test_mode) | |
103 return; // We don't have a resource pack when running the unit-tests. | |
104 | |
105 // Load a data pack. | 102 // Load a data pack. |
106 g_resource_data_pack = new ui::DataPack(ui::SCALE_FACTOR_100P); | 103 g_resource_data_pack = new ui::DataPack(ui::SCALE_FACTOR_100P); |
107 NSString* resource_path = | 104 FilePath resources_pak_path; |
108 [base::mac::FrameworkBundle() pathForResource:@"DumpRenderTree" | 105 if (unit_test_mode) { |
109 ofType:@"pak"]; | 106 PathService::Get(base::DIR_EXE, &resources_pak_path); |
110 FilePath resources_pak_path([resource_path fileSystemRepresentation]); | 107 resources_pak_path = resources_pak_path.Append("DumpRenderTree.app") |
| 108 .Append("Contents") |
| 109 .Append("Resources") |
| 110 .Append("DumpRenderTree.pak"); |
| 111 } else { |
| 112 NSString* resource_path = |
| 113 [base::mac::FrameworkBundle() pathForResource:@"DumpRenderTree" |
| 114 ofType:@"pak"]; |
| 115 resources_pak_path = FilePath([resource_path fileSystemRepresentation]); |
| 116 } |
111 if (!g_resource_data_pack->LoadFromPath(resources_pak_path)) { | 117 if (!g_resource_data_pack->LoadFromPath(resources_pak_path)) { |
112 LOG(FATAL) << "failed to load DumpRenderTree.pak"; | 118 LOG(FATAL) << "failed to load DumpRenderTree.pak"; |
113 } | 119 } |
114 | 120 |
| 121 if (unit_test_mode) |
| 122 return; |
| 123 |
115 // Load font files in the resource folder. | 124 // Load font files in the resource folder. |
116 static const char* const fontFileNames[] = { | 125 static const char* const fontFileNames[] = { |
117 "AHEM____.TTF", | 126 "AHEM____.TTF", |
118 // We don't register WebKitWeightWather fonts because of | 127 // We don't register WebKitWeightWather fonts because of |
119 // webkit.org/b/50709. | 128 // webkit.org/b/50709. |
120 }; | 129 }; |
121 | 130 |
122 NSMutableArray* font_urls = [NSMutableArray array]; | 131 NSMutableArray* font_urls = [NSMutableArray array]; |
123 NSURL* resources_directory = [[NSBundle mainBundle] resourceURL]; | 132 NSURL* resources_directory = [[NSBundle mainBundle] resourceURL]; |
124 for (unsigned i = 0; i < arraysize(fontFileNames); ++i) { | 133 for (unsigned i = 0; i < arraysize(fontFileNames); ++i) { |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 } | 238 } |
230 } | 239 } |
231 return resize_corner_data; | 240 return resize_corner_data; |
232 } | 241 } |
233 } | 242 } |
234 base::StringPiece res; | 243 base::StringPiece res; |
235 if (g_resource_data_pack) | 244 if (g_resource_data_pack) |
236 g_resource_data_pack->GetStringPiece(resource_id, &res); | 245 g_resource_data_pack->GetStringPiece(resource_id, &res); |
237 return res; | 246 return res; |
238 } | 247 } |
OLD | NEW |