| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/test/test_blink_web_unit_test_support.h" | 5 #include "content/test/test_blink_web_unit_test_support.h" |
| 6 | 6 |
| 7 #include "base/feature_list.h" | 7 #include "base/feature_list.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 #ifdef V8_USE_EXTERNAL_STARTUP_DATA | 48 #ifdef V8_USE_EXTERNAL_STARTUP_DATA |
| 49 #include "gin/v8_initializer.h" // nogncheck | 49 #include "gin/v8_initializer.h" // nogncheck |
| 50 #endif | 50 #endif |
| 51 | 51 |
| 52 #if BUILDFLAG(ENABLE_WEBRTC) | 52 #if BUILDFLAG(ENABLE_WEBRTC) |
| 53 #include "content/renderer/media/rtc_certificate.h" | 53 #include "content/renderer/media/rtc_certificate.h" |
| 54 #include "third_party/WebKit/public/platform/WebRTCCertificateGenerator.h" | 54 #include "third_party/WebKit/public/platform/WebRTCCertificateGenerator.h" |
| 55 #include "third_party/webrtc/base/rtccertificate.h" // nogncheck | 55 #include "third_party/webrtc/base/rtccertificate.h" // nogncheck |
| 56 #endif | 56 #endif |
| 57 | 57 |
| 58 using blink::WebString; |
| 59 |
| 58 namespace { | 60 namespace { |
| 59 | 61 |
| 60 class DummyTaskRunner : public base::SingleThreadTaskRunner { | 62 class DummyTaskRunner : public base::SingleThreadTaskRunner { |
| 61 public: | 63 public: |
| 62 DummyTaskRunner() : thread_id_(base::PlatformThread::CurrentId()) {} | 64 DummyTaskRunner() : thread_id_(base::PlatformThread::CurrentId()) {} |
| 63 | 65 |
| 64 bool PostDelayedTask(const tracked_objects::Location& from_here, | 66 bool PostDelayedTask(const tracked_objects::Location& from_here, |
| 65 const base::Closure& task, | 67 const base::Closure& task, |
| 66 base::TimeDelta delay) override { | 68 base::TimeDelta delay) override { |
| 67 // Drop the delayed task. | 69 // Drop the delayed task. |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 const blink::WebSize& size) { | 210 const blink::WebSize& size) { |
| 209 return shared_bitmap_manager_ | 211 return shared_bitmap_manager_ |
| 210 ->AllocateSharedBitmap(gfx::Size(size.width, size.height)); | 212 ->AllocateSharedBitmap(gfx::Size(size.width, size.height)); |
| 211 } | 213 } |
| 212 | 214 |
| 213 blink::WebString TestBlinkWebUnitTestSupport::queryLocalizedString( | 215 blink::WebString TestBlinkWebUnitTestSupport::queryLocalizedString( |
| 214 blink::WebLocalizedString::Name name) { | 216 blink::WebLocalizedString::Name name) { |
| 215 // Returns placeholder strings to check if they are correctly localized. | 217 // Returns placeholder strings to check if they are correctly localized. |
| 216 switch (name) { | 218 switch (name) { |
| 217 case blink::WebLocalizedString::OtherDateLabel: | 219 case blink::WebLocalizedString::OtherDateLabel: |
| 218 return base::ASCIIToUTF16("<<OtherDateLabel>>"); | 220 return WebString::fromASCII("<<OtherDateLabel>>"); |
| 219 case blink::WebLocalizedString::OtherMonthLabel: | 221 case blink::WebLocalizedString::OtherMonthLabel: |
| 220 return base::ASCIIToUTF16("<<OtherMonthLabel>>"); | 222 return WebString::fromASCII("<<OtherMonthLabel>>"); |
| 221 case blink::WebLocalizedString::OtherTimeLabel: | 223 case blink::WebLocalizedString::OtherTimeLabel: |
| 222 return base::ASCIIToUTF16("<<OtherTimeLabel>>"); | 224 return WebString::fromASCII("<<OtherTimeLabel>>"); |
| 223 case blink::WebLocalizedString::OtherWeekLabel: | 225 case blink::WebLocalizedString::OtherWeekLabel: |
| 224 return base::ASCIIToUTF16("<<OtherWeekLabel>>"); | 226 return WebString::fromASCII("<<OtherWeekLabel>>"); |
| 225 case blink::WebLocalizedString::CalendarClear: | 227 case blink::WebLocalizedString::CalendarClear: |
| 226 return base::ASCIIToUTF16("<<CalendarClear>>"); | 228 return WebString::fromASCII("<<CalendarClear>>"); |
| 227 case blink::WebLocalizedString::CalendarToday: | 229 case blink::WebLocalizedString::CalendarToday: |
| 228 return base::ASCIIToUTF16("<<CalendarToday>>"); | 230 return WebString::fromASCII("<<CalendarToday>>"); |
| 229 case blink::WebLocalizedString::ThisMonthButtonLabel: | 231 case blink::WebLocalizedString::ThisMonthButtonLabel: |
| 230 return base::ASCIIToUTF16("<<ThisMonthLabel>>"); | 232 return WebString::fromASCII("<<ThisMonthLabel>>"); |
| 231 case blink::WebLocalizedString::ThisWeekButtonLabel: | 233 case blink::WebLocalizedString::ThisWeekButtonLabel: |
| 232 return base::ASCIIToUTF16("<<ThisWeekLabel>>"); | 234 return WebString::fromASCII("<<ThisWeekLabel>>"); |
| 233 case blink::WebLocalizedString::ValidationValueMissing: | 235 case blink::WebLocalizedString::ValidationValueMissing: |
| 234 return base::ASCIIToUTF16("<<ValidationValueMissing>>"); | 236 return WebString::fromASCII("<<ValidationValueMissing>>"); |
| 235 case blink::WebLocalizedString::ValidationValueMissingForSelect: | 237 case blink::WebLocalizedString::ValidationValueMissingForSelect: |
| 236 return base::ASCIIToUTF16("<<ValidationValueMissingForSelect>>"); | 238 return WebString::fromASCII("<<ValidationValueMissingForSelect>>"); |
| 237 case blink::WebLocalizedString::WeekFormatTemplate: | 239 case blink::WebLocalizedString::WeekFormatTemplate: |
| 238 return base::ASCIIToUTF16("Week $2, $1"); | 240 return WebString::fromASCII("Week $2, $1"); |
| 239 default: | 241 default: |
| 240 return blink::WebString(); | 242 return blink::WebString(); |
| 241 } | 243 } |
| 242 } | 244 } |
| 243 | 245 |
| 244 blink::WebString TestBlinkWebUnitTestSupport::queryLocalizedString( | 246 blink::WebString TestBlinkWebUnitTestSupport::queryLocalizedString( |
| 245 blink::WebLocalizedString::Name name, | 247 blink::WebLocalizedString::Name name, |
| 246 const blink::WebString& value) { | 248 const blink::WebString& value) { |
| 247 if (name == blink::WebLocalizedString::ValidationRangeUnderflow) | 249 if (name == blink::WebLocalizedString::ValidationRangeUnderflow) |
| 248 return base::ASCIIToUTF16("range underflow"); | 250 return blink::WebString::fromASCII("range underflow"); |
| 249 if (name == blink::WebLocalizedString::ValidationRangeOverflow) | 251 if (name == blink::WebLocalizedString::ValidationRangeOverflow) |
| 250 return base::ASCIIToUTF16("range overflow"); | 252 return blink::WebString::fromASCII("range overflow"); |
| 251 if (name == blink::WebLocalizedString::SelectMenuListText) | 253 if (name == blink::WebLocalizedString::SelectMenuListText) |
| 252 return base::ASCIIToUTF16("$1 selected"); | 254 return blink::WebString::fromASCII("$1 selected"); |
| 253 return BlinkPlatformImpl::queryLocalizedString(name, value); | 255 return BlinkPlatformImpl::queryLocalizedString(name, value); |
| 254 } | 256 } |
| 255 | 257 |
| 256 blink::WebString TestBlinkWebUnitTestSupport::queryLocalizedString( | 258 blink::WebString TestBlinkWebUnitTestSupport::queryLocalizedString( |
| 257 blink::WebLocalizedString::Name name, | 259 blink::WebLocalizedString::Name name, |
| 258 const blink::WebString& value1, | 260 const blink::WebString& value1, |
| 259 const blink::WebString& value2) { | 261 const blink::WebString& value2) { |
| 260 if (name == blink::WebLocalizedString::ValidationTooLong) | 262 if (name == blink::WebLocalizedString::ValidationTooLong) |
| 261 return base::ASCIIToUTF16("too long"); | 263 return blink::WebString::fromASCII("too long"); |
| 262 if (name == blink::WebLocalizedString::ValidationStepMismatch) | 264 if (name == blink::WebLocalizedString::ValidationStepMismatch) |
| 263 return base::ASCIIToUTF16("step mismatch"); | 265 return blink::WebString::fromASCII("step mismatch"); |
| 264 return BlinkPlatformImpl::queryLocalizedString(name, value1, value2); | 266 return BlinkPlatformImpl::queryLocalizedString(name, value1, value2); |
| 265 } | 267 } |
| 266 | 268 |
| 267 blink::WebString TestBlinkWebUnitTestSupport::defaultLocale() { | 269 blink::WebString TestBlinkWebUnitTestSupport::defaultLocale() { |
| 268 return base::ASCIIToUTF16("en-US"); | 270 return blink::WebString::fromASCII("en-US"); |
| 269 } | 271 } |
| 270 | 272 |
| 271 #if defined(OS_WIN) || defined(OS_MACOSX) | 273 #if defined(OS_WIN) || defined(OS_MACOSX) |
| 272 void TestBlinkWebUnitTestSupport::SetThemeEngine( | 274 void TestBlinkWebUnitTestSupport::SetThemeEngine( |
| 273 blink::WebThemeEngine* engine) { | 275 blink::WebThemeEngine* engine) { |
| 274 active_theme_engine_ = engine ? engine : BlinkPlatformImpl::themeEngine(); | 276 active_theme_engine_ = engine ? engine : BlinkPlatformImpl::themeEngine(); |
| 275 } | 277 } |
| 276 | 278 |
| 277 blink::WebThemeEngine* TestBlinkWebUnitTestSupport::themeEngine() { | 279 blink::WebThemeEngine* TestBlinkWebUnitTestSupport::themeEngine() { |
| 278 return active_theme_engine_; | 280 return active_theme_engine_; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 blink::WebRTCCertificateGenerator* | 349 blink::WebRTCCertificateGenerator* |
| 348 TestBlinkWebUnitTestSupport::createRTCCertificateGenerator() { | 350 TestBlinkWebUnitTestSupport::createRTCCertificateGenerator() { |
| 349 #if BUILDFLAG(ENABLE_WEBRTC) | 351 #if BUILDFLAG(ENABLE_WEBRTC) |
| 350 return new TestWebRTCCertificateGenerator(); | 352 return new TestWebRTCCertificateGenerator(); |
| 351 #else | 353 #else |
| 352 return nullptr; | 354 return nullptr; |
| 353 #endif | 355 #endif |
| 354 } | 356 } |
| 355 | 357 |
| 356 } // namespace content | 358 } // namespace content |
| OLD | NEW |