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/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/intents_messages.h" | 10 #include "content/common/intents_messages.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 using WebKit::WebFrame; | 52 using WebKit::WebFrame; |
53 using WebKit::WebInputEvent; | 53 using WebKit::WebInputEvent; |
54 using WebKit::WebMouseEvent; | 54 using WebKit::WebMouseEvent; |
55 using WebKit::WebString; | 55 using WebKit::WebString; |
56 using WebKit::WebTextDirection; | 56 using WebKit::WebTextDirection; |
57 using WebKit::WebURLError; | 57 using WebKit::WebURLError; |
58 | 58 |
59 namespace content { | 59 namespace content { |
60 | 60 |
61 namespace { | 61 namespace { |
| 62 |
62 #if defined(USE_AURA) && defined(USE_X11) | 63 #if defined(USE_AURA) && defined(USE_X11) |
63 // Converts MockKeyboard::Modifiers to ui::EventFlags. | 64 // Converts MockKeyboard::Modifiers to ui::EventFlags. |
64 int ConvertMockKeyboardModifier(MockKeyboard::Modifiers modifiers) { | 65 int ConvertMockKeyboardModifier(MockKeyboard::Modifiers modifiers) { |
65 static struct ModifierMap { | 66 static struct ModifierMap { |
66 MockKeyboard::Modifiers src; | 67 MockKeyboard::Modifiers src; |
67 int dst; | 68 int dst; |
68 } kModifierMap[] = { | 69 } kModifierMap[] = { |
69 { MockKeyboard::LEFT_SHIFT, ui::EF_SHIFT_DOWN }, | 70 { MockKeyboard::LEFT_SHIFT, ui::EF_SHIFT_DOWN }, |
70 { MockKeyboard::RIGHT_SHIFT, ui::EF_SHIFT_DOWN }, | 71 { MockKeyboard::RIGHT_SHIFT, ui::EF_SHIFT_DOWN }, |
71 { MockKeyboard::LEFT_CONTROL, ui::EF_CONTROL_DOWN }, | 72 { MockKeyboard::LEFT_CONTROL, ui::EF_CONTROL_DOWN }, |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 WebUITestBrowserClient() {} | 125 WebUITestBrowserClient() {} |
125 | 126 |
126 virtual WebUIControllerFactory* GetWebUIControllerFactory() OVERRIDE { | 127 virtual WebUIControllerFactory* GetWebUIControllerFactory() OVERRIDE { |
127 return &factory_; | 128 return &factory_; |
128 } | 129 } |
129 | 130 |
130 private: | 131 private: |
131 WebUITestWebUIControllerFactory factory_; | 132 WebUITestWebUIControllerFactory factory_; |
132 }; | 133 }; |
133 | 134 |
134 } | 135 } // namespace |
135 | 136 |
136 class RenderViewImplTest : public RenderViewTest { | 137 class RenderViewImplTest : public RenderViewTest { |
137 public: | 138 public: |
138 RenderViewImplTest() { | 139 RenderViewImplTest() { |
139 // Attach a pseudo keyboard device to this object. | 140 // Attach a pseudo keyboard device to this object. |
140 mock_keyboard_.reset(new MockKeyboard()); | 141 mock_keyboard_.reset(new MockKeyboard()); |
141 } | 142 } |
142 | 143 |
143 RenderViewImpl* view() { | 144 RenderViewImpl* view() { |
144 return static_cast<RenderViewImpl*>(view_); | 145 return static_cast<RenderViewImpl*>(view_); |
145 } | 146 } |
146 | 147 |
147 // Sends IPC messages that emulates a key-press event. | 148 // Sends IPC messages that emulates a key-press event. |
148 int SendKeyEvent(MockKeyboard::Layout layout, | 149 int SendKeyEvent(MockKeyboard::Layout layout, |
149 int key_code, | 150 int key_code, |
150 MockKeyboard::Modifiers modifiers, | 151 MockKeyboard::Modifiers modifiers, |
151 string16* output) { | 152 string16* output) { |
152 #if defined(OS_WIN) | 153 #if defined(OS_WIN) |
153 // Retrieve the Unicode character for the given tuple (keyboard-layout, | 154 // Retrieve the Unicode character for the given tuple (keyboard-layout, |
154 // key-code, and modifiers). | 155 // key-code, and modifiers). |
155 // Exit when a keyboard-layout driver cannot assign a Unicode character to | 156 // Exit when a keyboard-layout driver cannot assign a Unicode character to |
156 // the tuple to prevent sending an invalid key code to the RenderView object
. | 157 // the tuple to prevent sending an invalid key code to the RenderView |
| 158 // object. |
157 CHECK(mock_keyboard_.get()); | 159 CHECK(mock_keyboard_.get()); |
158 CHECK(output); | 160 CHECK(output); |
159 int length = mock_keyboard_->GetCharacters(layout, key_code, modifiers, | 161 int length = mock_keyboard_->GetCharacters(layout, key_code, modifiers, |
160 output); | 162 output); |
161 if (length != 1) | 163 if (length != 1) |
162 return -1; | 164 return -1; |
163 | 165 |
164 // Create IPC messages from Windows messages and send them to our | 166 // Create IPC messages from Windows messages and send them to our |
165 // back-end. | 167 // back-end. |
166 // A keyboard event of Windows consists of three Windows messages: | 168 // A keyboard event of Windows consists of three Windows messages: |
(...skipping 1646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1813 LoadHTML("<html>" | 1815 LoadHTML("<html>" |
1814 "<head>" | 1816 "<head>" |
1815 "</head>" | 1817 "</head>" |
1816 "<body>" | 1818 "<body>" |
1817 "<input id=\"test1\" value=\"some test text hello\"></input>" | 1819 "<input id=\"test1\" value=\"some test text hello\"></input>" |
1818 "</body>" | 1820 "</body>" |
1819 "</html>"); | 1821 "</html>"); |
1820 ExecuteJavaScript("document.getElementById('test1').focus();"); | 1822 ExecuteJavaScript("document.getElementById('test1').focus();"); |
1821 view()->OnSetEditableSelectionOffsets(4, 8); | 1823 view()->OnSetEditableSelectionOffsets(4, 8); |
1822 const std::vector<WebKit::WebCompositionUnderline> empty_underline; | 1824 const std::vector<WebKit::WebCompositionUnderline> empty_underline; |
1823 view()->OnSetCompositionFromExistingText(7,10, empty_underline); | 1825 view()->OnSetCompositionFromExistingText(7, 10, empty_underline); |
1824 WebKit::WebTextInputInfo info = view()->webview()->textInputInfo(); | 1826 WebKit::WebTextInputInfo info = view()->webview()->textInputInfo(); |
1825 EXPECT_EQ(4, info.selectionStart); | 1827 EXPECT_EQ(4, info.selectionStart); |
1826 EXPECT_EQ(8, info.selectionEnd); | 1828 EXPECT_EQ(8, info.selectionEnd); |
1827 EXPECT_EQ(7, info.compositionStart); | 1829 EXPECT_EQ(7, info.compositionStart); |
1828 EXPECT_EQ(10, info.compositionEnd); | 1830 EXPECT_EQ(10, info.compositionEnd); |
1829 view()->OnUnselect(); | 1831 view()->OnUnselect(); |
1830 info = view()->webview()->textInputInfo(); | 1832 info = view()->webview()->textInputInfo(); |
1831 EXPECT_EQ(0, info.selectionStart); | 1833 EXPECT_EQ(0, info.selectionStart); |
1832 EXPECT_EQ(0, info.selectionEnd); | 1834 EXPECT_EQ(0, info.selectionEnd); |
1833 } | 1835 } |
(...skipping 17 matching lines...) Expand all Loading... |
1851 EXPECT_EQ(7, info.selectionEnd); | 1853 EXPECT_EQ(7, info.selectionEnd); |
1852 view()->OnSetEditableSelectionOffsets(4, 8); | 1854 view()->OnSetEditableSelectionOffsets(4, 8); |
1853 view()->OnExtendSelectionAndDelete(2, 5); | 1855 view()->OnExtendSelectionAndDelete(2, 5); |
1854 info = view()->webview()->textInputInfo(); | 1856 info = view()->webview()->textInputInfo(); |
1855 EXPECT_EQ("abuvwxyz", info.value); | 1857 EXPECT_EQ("abuvwxyz", info.value); |
1856 EXPECT_EQ(2, info.selectionStart); | 1858 EXPECT_EQ(2, info.selectionStart); |
1857 EXPECT_EQ(2, info.selectionEnd); | 1859 EXPECT_EQ(2, info.selectionEnd); |
1858 } | 1860 } |
1859 | 1861 |
1860 } // namespace content | 1862 } // namespace content |
OLD | NEW |