OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/shell/renderer/test_runner/web_test_proxy.h" | 5 #include "content/shell/renderer/test_runner/web_test_proxy.h" |
6 | 6 |
7 #include <cctype> | 7 #include <cctype> |
8 | 8 |
9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/debug/trace_event.h" | 11 #include "base/debug/trace_event.h" |
12 #include "base/i18n/rtl.h" | |
12 #include "base/logging.h" | 13 #include "base/logging.h" |
13 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
15 #include "base/strings/utf_string_conversions.h" | |
14 #include "content/public/common/content_switches.h" | 16 #include "content/public/common/content_switches.h" |
15 #include "content/shell/renderer/test_runner/TestPlugin.h" | 17 #include "content/shell/renderer/test_runner/TestPlugin.h" |
16 #include "content/shell/renderer/test_runner/WebTestDelegate.h" | 18 #include "content/shell/renderer/test_runner/WebTestDelegate.h" |
17 #include "content/shell/renderer/test_runner/WebTestInterfaces.h" | 19 #include "content/shell/renderer/test_runner/WebTestInterfaces.h" |
18 #include "content/shell/renderer/test_runner/accessibility_controller.h" | 20 #include "content/shell/renderer/test_runner/accessibility_controller.h" |
19 #include "content/shell/renderer/test_runner/event_sender.h" | 21 #include "content/shell/renderer/test_runner/event_sender.h" |
20 #include "content/shell/renderer/test_runner/mock_color_chooser.h" | 22 #include "content/shell/renderer/test_runner/mock_color_chooser.h" |
21 #include "content/shell/renderer/test_runner/mock_screen_orientation_client.h" | 23 #include "content/shell/renderer/test_runner/mock_screen_orientation_client.h" |
22 #include "content/shell/renderer/test_runner/mock_web_push_client.h" | 24 #include "content/shell/renderer/test_runner/mock_web_push_client.h" |
23 #include "content/shell/renderer/test_runner/mock_web_speech_recognizer.h" | 25 #include "content/shell/renderer/test_runner/mock_web_speech_recognizer.h" |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
373 const blink::WebFileChooserParams& params, | 375 const blink::WebFileChooserParams& params, |
374 blink::WebFileChooserCompletion* completion) { | 376 blink::WebFileChooserCompletion* completion) { |
375 delegate_->printMessage("Mock: Opening a file chooser.\n"); | 377 delegate_->printMessage("Mock: Opening a file chooser.\n"); |
376 // FIXME: Add ability to set file names to a file upload control. | 378 // FIXME: Add ability to set file names to a file upload control. |
377 return false; | 379 return false; |
378 } | 380 } |
379 | 381 |
380 void WebTestProxyBase::ShowValidationMessage( | 382 void WebTestProxyBase::ShowValidationMessage( |
381 const blink::WebRect& anchor_in_root_view, | 383 const blink::WebRect& anchor_in_root_view, |
382 const blink::WebString& message, | 384 const blink::WebString& message, |
385 blink::WebTextDirection message_dir, | |
383 const blink::WebString& sub_message, | 386 const blink::WebString& sub_message, |
384 blink::WebTextDirection hint) { | 387 blink::WebTextDirection sub_message_dir) { |
388 base::string16 wrapped_main_text = message; | |
389 base::string16 wrapped_sub_text = sub_message; | |
390 | |
391 if (message_dir == blink::WebTextDirectionLeftToRight) { | |
jamesr
2014/08/29 17:21:50
this looks very repetitive. is there any way to sh
| |
392 wrapped_main_text = | |
393 base::i18n::GetDisplayStringInLTRDirectionality(wrapped_main_text); | |
394 } else if (message_dir == blink::WebTextDirectionRightToLeft) { | |
395 base::i18n::WrapStringWithRTLFormatting(&wrapped_main_text); | |
396 } | |
397 | |
398 if (!wrapped_sub_text.empty()) { | |
399 if (sub_message_dir == blink::WebTextDirectionLeftToRight) { | |
400 wrapped_sub_text = | |
401 base::i18n::GetDisplayStringInLTRDirectionality(wrapped_sub_text); | |
402 } else if (sub_message_dir == blink::WebTextDirectionRightToLeft) { | |
403 base::i18n::WrapStringWithRTLFormatting(&wrapped_sub_text); | |
404 } | |
405 } | |
385 delegate_->printMessage( | 406 delegate_->printMessage( |
386 std::string("ValidationMessageClient: main-message=") + | 407 "ValidationMessageClient: main-message=" + |
387 std::string(message.utf8()) + " sub-message=" + | 408 base::UTF16ToUTF8(wrapped_main_text) + |
388 std::string(sub_message.utf8()) + "\n"); | 409 " sub-message=" + |
410 base::UTF16ToUTF8(wrapped_sub_text) + "\n"); | |
389 } | 411 } |
390 | 412 |
391 std::string WebTestProxyBase::CaptureTree(bool debug_render_tree) { | 413 std::string WebTestProxyBase::CaptureTree(bool debug_render_tree) { |
392 bool should_dump_custom_text = | 414 bool should_dump_custom_text = |
393 test_interfaces_->GetTestRunner()->shouldDumpAsCustomText(); | 415 test_interfaces_->GetTestRunner()->shouldDumpAsCustomText(); |
394 bool should_dump_as_text = | 416 bool should_dump_as_text = |
395 test_interfaces_->GetTestRunner()->shouldDumpAsText(); | 417 test_interfaces_->GetTestRunner()->shouldDumpAsText(); |
396 bool should_dump_as_markup = | 418 bool should_dump_as_markup = |
397 test_interfaces_->GetTestRunner()->shouldDumpAsMarkup(); | 419 test_interfaces_->GetTestRunner()->shouldDumpAsMarkup(); |
398 bool should_dump_as_printed = test_interfaces_->GetTestRunner()->isPrinting(); | 420 bool should_dump_as_printed = test_interfaces_->GetTestRunner()->isPrinting(); |
(...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1260 if (!push_client_.get()) | 1282 if (!push_client_.get()) |
1261 push_client_.reset(new MockWebPushClient); | 1283 push_client_.reset(new MockWebPushClient); |
1262 return push_client_.get(); | 1284 return push_client_.get(); |
1263 } | 1285 } |
1264 | 1286 |
1265 blink::WebPushClient* WebTestProxyBase::GetWebPushClient() { | 1287 blink::WebPushClient* WebTestProxyBase::GetWebPushClient() { |
1266 return GetPushClientMock(); | 1288 return GetPushClientMock(); |
1267 } | 1289 } |
1268 | 1290 |
1269 } // namespace content | 1291 } // namespace content |
OLD | NEW |