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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 | 6 |
7 #include "base/memory/shared_memory.h" | 7 #include "base/memory/shared_memory.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "base/win/windows_version.h" | 10 #include "base/win/windows_version.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 #endif | 62 #endif |
63 | 63 |
64 using blink::WebFrame; | 64 using blink::WebFrame; |
65 using blink::WebInputEvent; | 65 using blink::WebInputEvent; |
66 using blink::WebMouseEvent; | 66 using blink::WebMouseEvent; |
67 using blink::WebRuntimeFeatures; | 67 using blink::WebRuntimeFeatures; |
68 using blink::WebString; | 68 using blink::WebString; |
69 using blink::WebTextDirection; | 69 using blink::WebTextDirection; |
70 using blink::WebURLError; | 70 using blink::WebURLError; |
71 | 71 |
72 namespace content { | 72 namespace content { |
73 | 73 |
74 namespace { | 74 namespace { |
75 | 75 |
76 #if (defined(USE_AURA) && defined(USE_X11)) || defined(USE_OZONE) | 76 #if (defined(USE_AURA) && defined(USE_X11)) || defined(USE_OZONE) |
77 // Converts MockKeyboard::Modifiers to ui::EventFlags. | 77 // Converts MockKeyboard::Modifiers to ui::EventFlags. |
78 int ConvertMockKeyboardModifier(MockKeyboard::Modifiers modifiers) { | 78 int ConvertMockKeyboardModifier(MockKeyboard::Modifiers modifiers) { |
79 static struct ModifierMap { | 79 static struct ModifierMap { |
80 MockKeyboard::Modifiers src; | 80 MockKeyboard::Modifiers src; |
81 int dst; | 81 int dst; |
82 } kModifierMap[] = { | 82 } kModifierMap[] = { |
(...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1060 view()->OnSetInputMethodActive(ime_message->enable); | 1060 view()->OnSetInputMethodActive(ime_message->enable); |
1061 break; | 1061 break; |
1062 | 1062 |
1063 case IME_SETFOCUS: | 1063 case IME_SETFOCUS: |
1064 // Update the window focus. | 1064 // Update the window focus. |
1065 view()->OnSetFocus(ime_message->enable); | 1065 view()->OnSetFocus(ime_message->enable); |
1066 break; | 1066 break; |
1067 | 1067 |
1068 case IME_SETCOMPOSITION: | 1068 case IME_SETCOMPOSITION: |
1069 view()->OnImeSetComposition( | 1069 view()->OnImeSetComposition( |
1070 WideToUTF16Hack(ime_message->ime_string), | 1070 base::WideToUTF16Hack(ime_message->ime_string), |
1071 std::vector<blink::WebCompositionUnderline>(), | 1071 std::vector<blink::WebCompositionUnderline>(), |
1072 ime_message->selection_start, | 1072 ime_message->selection_start, |
1073 ime_message->selection_end); | 1073 ime_message->selection_end); |
1074 break; | 1074 break; |
1075 | 1075 |
1076 case IME_CONFIRMCOMPOSITION: | 1076 case IME_CONFIRMCOMPOSITION: |
1077 view()->OnImeConfirmComposition( | 1077 view()->OnImeConfirmComposition( |
1078 WideToUTF16Hack(ime_message->ime_string), | 1078 base::WideToUTF16Hack(ime_message->ime_string), |
1079 gfx::Range::InvalidRange(), | 1079 gfx::Range::InvalidRange(), |
1080 false); | 1080 false); |
1081 break; | 1081 break; |
1082 | 1082 |
1083 case IME_CANCELCOMPOSITION: | 1083 case IME_CANCELCOMPOSITION: |
1084 view()->OnImeSetComposition( | 1084 view()->OnImeSetComposition( |
1085 base::string16(), | 1085 base::string16(), |
1086 std::vector<blink::WebCompositionUnderline>(), | 1086 std::vector<blink::WebCompositionUnderline>(), |
1087 0, 0); | 1087 0, 0); |
1088 break; | 1088 break; |
1089 } | 1089 } |
1090 | 1090 |
1091 // Update the status of our IME back-end. | 1091 // Update the status of our IME back-end. |
1092 // TODO(hbono): we should verify messages to be sent from the back-end. | 1092 // TODO(hbono): we should verify messages to be sent from the back-end. |
1093 view()->UpdateTextInputType(); | 1093 view()->UpdateTextInputType(); |
1094 ProcessPendingMessages(); | 1094 ProcessPendingMessages(); |
1095 render_thread_->sink().ClearMessages(); | 1095 render_thread_->sink().ClearMessages(); |
1096 | 1096 |
1097 if (ime_message->result) { | 1097 if (ime_message->result) { |
1098 // Retrieve the content of this page and compare it with the expected | 1098 // Retrieve the content of this page and compare it with the expected |
1099 // result. | 1099 // result. |
1100 const int kMaxOutputCharacters = 128; | 1100 const int kMaxOutputCharacters = 128; |
1101 std::wstring output = UTF16ToWideHack( | 1101 std::wstring output = base::UTF16ToWideHack( |
1102 GetMainFrame()->contentAsText(kMaxOutputCharacters)); | 1102 GetMainFrame()->contentAsText(kMaxOutputCharacters)); |
1103 EXPECT_EQ(output, ime_message->result); | 1103 EXPECT_EQ(output, ime_message->result); |
1104 } | 1104 } |
1105 } | 1105 } |
1106 } | 1106 } |
1107 | 1107 |
1108 // Test that the RenderView::OnSetTextDirection() function can change the text | 1108 // Test that the RenderView::OnSetTextDirection() function can change the text |
1109 // direction of the selected input element. | 1109 // direction of the selected input element. |
1110 TEST_F(RenderViewImplTest, OnSetTextDirection) { | 1110 TEST_F(RenderViewImplTest, OnSetTextDirection) { |
1111 // Load an HTML page consisting of a <textarea> element and a <div> element. | 1111 // Load an HTML page consisting of a <textarea> element and a <div> element. |
(...skipping 28 matching lines...) Expand all Loading... |
1140 ExecuteJavaScript("var result = document.getElementById('result');" | 1140 ExecuteJavaScript("var result = document.getElementById('result');" |
1141 "var node = document.getElementById('test');" | 1141 "var node = document.getElementById('test');" |
1142 "var style = getComputedStyle(node, null);" | 1142 "var style = getComputedStyle(node, null);" |
1143 "result.innerText =" | 1143 "result.innerText =" |
1144 " node.getAttribute('dir') + ',' +" | 1144 " node.getAttribute('dir') + ',' +" |
1145 " style.getPropertyValue('direction');"); | 1145 " style.getPropertyValue('direction');"); |
1146 | 1146 |
1147 // Copy the document content to std::wstring and compare with the | 1147 // Copy the document content to std::wstring and compare with the |
1148 // expected result. | 1148 // expected result. |
1149 const int kMaxOutputCharacters = 16; | 1149 const int kMaxOutputCharacters = 16; |
1150 std::wstring output = UTF16ToWideHack( | 1150 std::wstring output = base::UTF16ToWideHack( |
1151 GetMainFrame()->contentAsText(kMaxOutputCharacters)); | 1151 GetMainFrame()->contentAsText(kMaxOutputCharacters)); |
1152 EXPECT_EQ(output, kTextDirection[i].expected_result); | 1152 EXPECT_EQ(output, kTextDirection[i].expected_result); |
1153 } | 1153 } |
1154 } | 1154 } |
1155 | 1155 |
1156 // see http://crbug.com/238750 | 1156 // see http://crbug.com/238750 |
1157 #if defined(OS_WIN) | 1157 #if defined(OS_WIN) |
1158 #define MAYBE_OnHandleKeyboardEvent DISABLED_OnHandleKeyboardEvent | 1158 #define MAYBE_OnHandleKeyboardEvent DISABLED_OnHandleKeyboardEvent |
1159 #else | 1159 #else |
1160 #define MAYBE_OnHandleKeyboardEvent OnHandleKeyboardEvent | 1160 #define MAYBE_OnHandleKeyboardEvent OnHandleKeyboardEvent |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1520 base::string16 char_code; | 1520 base::string16 char_code; |
1521 if (SendKeyEvent(layout, key_code, modifiers, &char_code) < 0) | 1521 if (SendKeyEvent(layout, key_code, modifiers, &char_code) < 0) |
1522 continue; | 1522 continue; |
1523 } | 1523 } |
1524 } | 1524 } |
1525 | 1525 |
1526 // Retrieve the text in the test page and compare it with the expected | 1526 // Retrieve the text in the test page and compare it with the expected |
1527 // text created from a virtual-key code, a character code, and the | 1527 // text created from a virtual-key code, a character code, and the |
1528 // modifier-key status. | 1528 // modifier-key status. |
1529 const int kMaxOutputCharacters = 4096; | 1529 const int kMaxOutputCharacters = 4096; |
1530 std::wstring output = UTF16ToWideHack( | 1530 std::wstring output = base::UTF16ToWideHack( |
1531 GetMainFrame()->contentAsText(kMaxOutputCharacters)); | 1531 GetMainFrame()->contentAsText(kMaxOutputCharacters)); |
1532 EXPECT_EQ(kLayouts[i].expected_result, output); | 1532 EXPECT_EQ(kLayouts[i].expected_result, output); |
1533 } | 1533 } |
1534 #else | 1534 #else |
1535 NOTIMPLEMENTED(); | 1535 NOTIMPLEMENTED(); |
1536 #endif | 1536 #endif |
1537 } | 1537 } |
1538 | 1538 |
1539 // Crashy, http://crbug.com/53247. | 1539 // Crashy, http://crbug.com/53247. |
1540 TEST_F(RenderViewImplTest, DISABLED_DidFailProvisionalLoadWithErrorForError) { | 1540 TEST_F(RenderViewImplTest, DISABLED_DidFailProvisionalLoadWithErrorForError) { |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1988 nav_params.current_history_list_offset = 0; | 1988 nav_params.current_history_list_offset = 0; |
1989 nav_params.pending_history_list_offset = 1; | 1989 nav_params.pending_history_list_offset = 1; |
1990 nav_params.page_id = -1; | 1990 nav_params.page_id = -1; |
1991 nav_params.frame_to_navigate = "frame"; | 1991 nav_params.frame_to_navigate = "frame"; |
1992 view()->OnNavigate(nav_params); | 1992 view()->OnNavigate(nav_params); |
1993 ProcessPendingMessages(); | 1993 ProcessPendingMessages(); |
1994 | 1994 |
1995 // Copy the document content to std::wstring and compare with the | 1995 // Copy the document content to std::wstring and compare with the |
1996 // expected result. | 1996 // expected result. |
1997 const int kMaxOutputCharacters = 256; | 1997 const int kMaxOutputCharacters = 256; |
1998 std::wstring output = UTF16ToWideHack( | 1998 std::wstring output = base::UTF16ToWideHack( |
1999 GetMainFrame()->contentAsText(kMaxOutputCharacters)); | 1999 GetMainFrame()->contentAsText(kMaxOutputCharacters)); |
2000 EXPECT_EQ(output, L"hello \n\nworld"); | 2000 EXPECT_EQ(output, L"hello \n\nworld"); |
2001 } | 2001 } |
2002 | 2002 |
2003 // This test ensures that a RenderFrame object is created for the top level | 2003 // This test ensures that a RenderFrame object is created for the top level |
2004 // frame in the RenderView. | 2004 // frame in the RenderView. |
2005 TEST_F(RenderViewImplTest, BasicRenderFrame) { | 2005 TEST_F(RenderViewImplTest, BasicRenderFrame) { |
2006 EXPECT_TRUE(view()->main_render_frame_.get()); | 2006 EXPECT_TRUE(view()->main_render_frame_.get()); |
2007 } | 2007 } |
2008 | 2008 |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2197 // made by some of Chrome's favicon handling. | 2197 // made by some of Chrome's favicon handling. |
2198 LoadHTML("<html>" | 2198 LoadHTML("<html>" |
2199 "<head>" | 2199 "<head>" |
2200 "</head>" | 2200 "</head>" |
2201 "</html>"); | 2201 "</html>"); |
2202 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching( | 2202 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching( |
2203 ViewHostMsg_UpdateFaviconURL::ID)); | 2203 ViewHostMsg_UpdateFaviconURL::ID)); |
2204 } | 2204 } |
2205 | 2205 |
2206 } // namespace content | 2206 } // namespace content |
OLD | NEW |