OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/basictypes.h" | 5 #include "base/basictypes.h" |
6 | 6 |
7 #include "base/shared_memory.h" | 7 #include "base/shared_memory.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "content/common/view_messages.h" | 10 #include "content/common/view_messages.h" |
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 | 514 |
515 // Copy the document content to std::wstring and compare with the | 515 // Copy the document content to std::wstring and compare with the |
516 // expected result. | 516 // expected result. |
517 const int kMaxOutputCharacters = 16; | 517 const int kMaxOutputCharacters = 16; |
518 std::wstring output = UTF16ToWideHack( | 518 std::wstring output = UTF16ToWideHack( |
519 GetMainFrame()->contentAsText(kMaxOutputCharacters)); | 519 GetMainFrame()->contentAsText(kMaxOutputCharacters)); |
520 EXPECT_EQ(output, kTextDirection[i].expected_result); | 520 EXPECT_EQ(output, kTextDirection[i].expected_result); |
521 } | 521 } |
522 } | 522 } |
523 | 523 |
524 #if defined(USE_AURA) | |
525 // crbug.com/103499. | |
526 #define MAYBE_OnHandleKeyboardEvent DISABLED_OnHandleKeyboardEvent | |
527 #else | |
528 #define MAYBE_OnHandleKeyboardEvent OnHandleKeyboardEvent | |
529 #endif | |
530 | |
531 // Test that we can receive correct DOM events when we send input events | 524 // Test that we can receive correct DOM events when we send input events |
532 // through the RenderWidget::OnHandleInputEvent() function. | 525 // through the RenderWidget::OnHandleInputEvent() function. |
533 TEST_F(RenderViewImplTest, MAYBE_OnHandleKeyboardEvent) { | 526 TEST_F(RenderViewImplTest, OnHandleKeyboardEvent) { |
534 #if !defined(OS_MACOSX) | 527 #if !defined(OS_MACOSX) |
535 // Load an HTML page consisting of one <input> element and three | 528 // Load an HTML page consisting of one <input> element and three |
536 // contentediable <div> elements. | 529 // contentediable <div> elements. |
537 // The <input> element is used for sending keyboard events, and the <div> | 530 // The <input> element is used for sending keyboard events, and the <div> |
538 // elements are used for writing DOM events in the following format: | 531 // elements are used for writing DOM events in the following format: |
539 // "<keyCode>,<shiftKey>,<controlKey>,<altKey>". | 532 // "<keyCode>,<shiftKey>,<controlKey>,<altKey>". |
540 // TODO(hbono): <http://crbug.com/2215> Our WebKit port set |ev.metaKey| to | 533 // TODO(hbono): <http://crbug.com/2215> Our WebKit port set |ev.metaKey| to |
541 // true when pressing an alt key, i.e. the |ev.metaKey| value is not | 534 // true when pressing an alt key, i.e. the |ev.metaKey| value is not |
542 // trustworthy. We will check the |ev.metaKey| value when this issue is fixed. | 535 // trustworthy. We will check the |ev.metaKey| value when this issue is fixed. |
543 view()->set_send_content_state_immediately(true); | 536 view()->set_send_content_state_immediately(true); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 #endif | 624 #endif |
632 }; | 625 }; |
633 | 626 |
634 MockKeyboard::Modifiers modifiers = kModifierData[j].modifiers; | 627 MockKeyboard::Modifiers modifiers = kModifierData[j].modifiers; |
635 for (size_t k = 0; k < ARRAYSIZE_UNSAFE(kKeyCodes); ++k) { | 628 for (size_t k = 0; k < ARRAYSIZE_UNSAFE(kKeyCodes); ++k) { |
636 // Send a keyboard event to the RenderView object. | 629 // Send a keyboard event to the RenderView object. |
637 // We should test a keyboard event only when the given keyboard-layout | 630 // We should test a keyboard event only when the given keyboard-layout |
638 // driver is installed in a PC and the driver can assign a Unicode | 631 // driver is installed in a PC and the driver can assign a Unicode |
639 // charcter for the given tuple (key-code and modifiers). | 632 // charcter for the given tuple (key-code and modifiers). |
640 int key_code = kKeyCodes[k]; | 633 int key_code = kKeyCodes[k]; |
641 std::wstring char_code; | 634 string16 char_code; |
642 if (SendKeyEvent(layout, key_code, modifiers, &char_code) < 0) | 635 if (SendKeyEvent(layout, key_code, modifiers, &char_code) < 0) |
643 continue; | 636 continue; |
644 | 637 |
645 // Create an expected result from the virtual-key code, the character | 638 // Create an expected result from the virtual-key code, the character |
646 // code, and the modifier-key status. | 639 // code, and the modifier-key status. |
647 // We format a string that emulates a DOM-event string produced hy | 640 // We format a string that emulates a DOM-event string produced hy |
648 // our JavaScript function. (See the above comment for the format.) | 641 // our JavaScript function. (See the above comment for the format.) |
649 static char expected_result[1024]; | 642 static char expected_result[1024]; |
650 expected_result[0] = 0; | 643 expected_result[0] = 0; |
651 base::snprintf(&expected_result[0], | 644 base::snprintf(&expected_result[0], |
(...skipping 15 matching lines...) Expand all Loading... |
667 GetMainFrame()->contentAsText(kMaxOutputCharacters)); | 660 GetMainFrame()->contentAsText(kMaxOutputCharacters)); |
668 EXPECT_EQ(expected_result, output); | 661 EXPECT_EQ(expected_result, output); |
669 } | 662 } |
670 } | 663 } |
671 } | 664 } |
672 #else | 665 #else |
673 NOTIMPLEMENTED(); | 666 NOTIMPLEMENTED(); |
674 #endif | 667 #endif |
675 } | 668 } |
676 | 669 |
677 #if defined(USE_AURA) | |
678 // crbug.com/103499. | |
679 #define MAYBE_InsertCharacters DISABLED_InsertCharacters | |
680 #else | |
681 #define MAYBE_InsertCharacters InsertCharacters | |
682 #endif | |
683 | |
684 // Test that our EditorClientImpl class can insert characters when we send | 670 // Test that our EditorClientImpl class can insert characters when we send |
685 // keyboard events through the RenderWidget::OnHandleInputEvent() function. | 671 // keyboard events through the RenderWidget::OnHandleInputEvent() function. |
686 // This test is for preventing regressions caused only when we use non-US | 672 // This test is for preventing regressions caused only when we use non-US |
687 // keyboards, such as Issue 10846. | 673 // keyboards, such as Issue 10846. |
688 TEST_F(RenderViewImplTest, MAYBE_InsertCharacters) { | 674 TEST_F(RenderViewImplTest, InsertCharacters) { |
689 #if !defined(OS_MACOSX) | 675 #if !defined(OS_MACOSX) |
690 static const struct { | 676 static const struct { |
691 MockKeyboard::Layout layout; | 677 MockKeyboard::Layout layout; |
692 const wchar_t* expected_result; | 678 const wchar_t* expected_result; |
693 } kLayouts[] = { | 679 } kLayouts[] = { |
694 #if 0 | 680 #if 0 |
695 // Disabled these keyboard layouts because buildbots do not have their | 681 // Disabled these keyboard layouts because buildbots do not have their |
696 // keyboard-layout drivers installed. | 682 // keyboard-layout drivers installed. |
697 {MockKeyboard::LAYOUT_ARABIC, | 683 {MockKeyboard::LAYOUT_ARABIC, |
698 L"\x0030\x0031\x0032\x0033\x0034\x0035\x0036\x0037" | 684 L"\x0030\x0031\x0032\x0033\x0034\x0035\x0036\x0037" |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
879 #endif | 865 #endif |
880 }; | 866 }; |
881 | 867 |
882 MockKeyboard::Modifiers modifiers = kModifiers[j]; | 868 MockKeyboard::Modifiers modifiers = kModifiers[j]; |
883 for (size_t k = 0; k < ARRAYSIZE_UNSAFE(kKeyCodes); ++k) { | 869 for (size_t k = 0; k < ARRAYSIZE_UNSAFE(kKeyCodes); ++k) { |
884 // Send a keyboard event to the RenderView object. | 870 // Send a keyboard event to the RenderView object. |
885 // We should test a keyboard event only when the given keyboard-layout | 871 // We should test a keyboard event only when the given keyboard-layout |
886 // driver is installed in a PC and the driver can assign a Unicode | 872 // driver is installed in a PC and the driver can assign a Unicode |
887 // charcter for the given tuple (layout, key-code, and modifiers). | 873 // charcter for the given tuple (layout, key-code, and modifiers). |
888 int key_code = kKeyCodes[k]; | 874 int key_code = kKeyCodes[k]; |
889 std::wstring char_code; | 875 string16 char_code; |
890 if (SendKeyEvent(layout, key_code, modifiers, &char_code) < 0) | 876 if (SendKeyEvent(layout, key_code, modifiers, &char_code) < 0) |
891 continue; | 877 continue; |
892 } | 878 } |
893 } | 879 } |
894 | 880 |
895 // Retrieve the text in the test page and compare it with the expected | 881 // Retrieve the text in the test page and compare it with the expected |
896 // text created from a virtual-key code, a character code, and the | 882 // text created from a virtual-key code, a character code, and the |
897 // modifier-key status. | 883 // modifier-key status. |
898 const int kMaxOutputCharacters = 4096; | 884 const int kMaxOutputCharacters = 4096; |
899 std::wstring output = UTF16ToWideHack( | 885 std::wstring output = UTF16ToWideHack( |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1091 expected_page_id_2 = view()->page_id_; | 1077 expected_page_id_2 = view()->page_id_; |
1092 EXPECT_GT(expected_page_id_2, expected_page_id); | 1078 EXPECT_GT(expected_page_id_2, expected_page_id); |
1093 view()->OnSetHistoryLengthAndPrune(2, -1); | 1079 view()->OnSetHistoryLengthAndPrune(2, -1); |
1094 EXPECT_EQ(4, view()->history_list_length_); | 1080 EXPECT_EQ(4, view()->history_list_length_); |
1095 EXPECT_EQ(3, view()->history_list_offset_); | 1081 EXPECT_EQ(3, view()->history_list_offset_); |
1096 EXPECT_EQ(-1, view()->history_page_ids_[0]); | 1082 EXPECT_EQ(-1, view()->history_page_ids_[0]); |
1097 EXPECT_EQ(-1, view()->history_page_ids_[1]); | 1083 EXPECT_EQ(-1, view()->history_page_ids_[1]); |
1098 EXPECT_EQ(expected_page_id, view()->history_page_ids_[2]); | 1084 EXPECT_EQ(expected_page_id, view()->history_page_ids_[2]); |
1099 EXPECT_EQ(expected_page_id_2, view()->history_page_ids_[3]); | 1085 EXPECT_EQ(expected_page_id_2, view()->history_page_ids_[3]); |
1100 } | 1086 } |
OLD | NEW |