Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(839)

Side by Side Diff: content/browser/accessibility/accessibility_win_browsertest.cc

Issue 2692173003: Implemented SetSelection for the Web content on Windows. (Closed)
Patch Set: Fixed another compilation error on Windows. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | content/browser/accessibility/ax_platform_position.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <memory> 8 #include <memory>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1155 caret_offset = 0; 1155 caret_offset = 0;
1156 hr = textarea_text->setCaretOffset(caret_offset); 1156 hr = textarea_text->setCaretOffset(caret_offset);
1157 EXPECT_EQ(S_OK, hr); 1157 EXPECT_EQ(S_OK, hr);
1158 waiter.WaitForNotification(); 1158 waiter.WaitForNotification();
1159 1159
1160 hr = textarea_text->get_caretOffset(&caret_offset); 1160 hr = textarea_text->get_caretOffset(&caret_offset);
1161 EXPECT_EQ(S_OK, hr); 1161 EXPECT_EQ(S_OK, hr);
1162 EXPECT_EQ(0, caret_offset); 1162 EXPECT_EQ(0, caret_offset);
1163 } 1163 }
1164 1164
1165 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, TestSetSelection) {
1166 base::win::ScopedComPtr<IAccessibleText> input_text;
1167 SetUpInputField(&input_text);
1168
1169 LONG start_offset, end_offset;
1170 EXPECT_HRESULT_FAILED(
1171 input_text->get_selection(1, &start_offset, &end_offset));
1172 HRESULT hr = input_text->get_selection(0, &start_offset, &end_offset);
1173 // There is no selection, just a caret.
1174 EXPECT_EQ(E_INVALIDARG, hr);
1175
1176 AccessibilityNotificationWaiter waiter(shell()->web_contents(),
1177 ACCESSIBILITY_MODE_COMPLETE,
1178 ui::AX_EVENT_TEXT_SELECTION_CHANGED);
1179 start_offset = 0;
1180 end_offset = CONTENTS_LENGTH;
1181 EXPECT_HRESULT_FAILED(input_text->setSelection(1, start_offset, end_offset));
1182 EXPECT_HRESULT_SUCCEEDED(
1183 input_text->setSelection(0, start_offset, end_offset));
1184 waiter.WaitForNotification();
1185
1186 hr = input_text->get_selection(0, &start_offset, &end_offset);
1187 EXPECT_EQ(S_OK, hr);
1188 EXPECT_EQ(0, start_offset);
1189 EXPECT_EQ(CONTENTS_LENGTH, end_offset);
1190
1191 start_offset = CONTENTS_LENGTH;
1192 end_offset = 1;
1193 EXPECT_HRESULT_SUCCEEDED(
1194 input_text->setSelection(0, start_offset, end_offset));
1195 waiter.WaitForNotification();
1196
1197 hr = input_text->get_selection(0, &start_offset, &end_offset);
1198 EXPECT_EQ(S_OK, hr);
1199 // Start and end offsets are always swapped to be in ascending order.
1200 EXPECT_EQ(1, start_offset);
1201 EXPECT_EQ(CONTENTS_LENGTH, end_offset);
1202 }
1203
1204 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, TestMultiLineSetSelection) {
1205 base::win::ScopedComPtr<IAccessibleText> textarea_text;
1206 SetUpTextareaField(&textarea_text);
1207
1208 LONG start_offset, end_offset;
1209 EXPECT_HRESULT_FAILED(
1210 textarea_text->get_selection(1, &start_offset, &end_offset));
1211 HRESULT hr = textarea_text->get_selection(0, &start_offset, &end_offset);
1212 // There is no selection, just a caret.
1213 EXPECT_EQ(E_INVALIDARG, hr);
1214
1215 AccessibilityNotificationWaiter waiter(shell()->web_contents(),
1216 ACCESSIBILITY_MODE_COMPLETE,
1217 ui::AX_EVENT_TEXT_SELECTION_CHANGED);
1218 start_offset = 0;
1219 end_offset = CONTENTS_LENGTH;
1220 EXPECT_HRESULT_FAILED(
1221 textarea_text->setSelection(1, start_offset, end_offset));
1222 EXPECT_HRESULT_SUCCEEDED(
1223 textarea_text->setSelection(0, start_offset, end_offset));
1224 waiter.WaitForNotification();
1225
1226 hr = textarea_text->get_selection(0, &start_offset, &end_offset);
1227 EXPECT_EQ(S_OK, hr);
1228 EXPECT_EQ(0, start_offset);
1229 EXPECT_EQ(CONTENTS_LENGTH, end_offset);
1230
1231 start_offset = CONTENTS_LENGTH - 1;
1232 end_offset = 0;
1233 EXPECT_HRESULT_SUCCEEDED(
1234 textarea_text->setSelection(0, start_offset, end_offset));
1235 waiter.WaitForNotification();
1236
1237 hr = textarea_text->get_selection(0, &start_offset, &end_offset);
1238 EXPECT_EQ(S_OK, hr);
1239 // Start and end offsets are always swapped to be in ascending order.
1240 EXPECT_EQ(0, start_offset);
1241 EXPECT_EQ(CONTENTS_LENGTH - 1, end_offset);
1242 }
1243
1244 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
1245 TestStaticTextSetSelection) {
1246 base::win::ScopedComPtr<IAccessibleText> paragraph_text;
1247 SetUpSampleParagraph(&paragraph_text);
1248
1249 LONG n_characters;
1250 ASSERT_HRESULT_SUCCEEDED(paragraph_text->get_nCharacters(&n_characters));
1251 ASSERT_LT(0, n_characters);
1252
1253 AccessibilityNotificationWaiter waiter(
1254 shell()->web_contents(), ACCESSIBILITY_MODE_COMPLETE,
1255 ui::AX_EVENT_DOCUMENT_SELECTION_CHANGED);
1256 LONG start_offset = 0;
1257 LONG end_offset = n_characters;
1258 EXPECT_HRESULT_FAILED(
1259 paragraph_text->setSelection(1, start_offset, end_offset));
1260 EXPECT_HRESULT_SUCCEEDED(
1261 paragraph_text->setSelection(0, start_offset, end_offset));
1262 waiter.WaitForNotification();
1263
1264 HRESULT hr = paragraph_text->get_selection(0, &start_offset, &end_offset);
1265 EXPECT_EQ(S_OK, hr);
1266 EXPECT_EQ(0, start_offset);
1267 EXPECT_EQ(n_characters, end_offset);
1268
1269 start_offset = n_characters - 1;
1270 end_offset = 0;
1271 EXPECT_HRESULT_SUCCEEDED(
1272 paragraph_text->setSelection(0, start_offset, end_offset));
1273 waiter.WaitForNotification();
1274
1275 hr = paragraph_text->get_selection(0, &start_offset, &end_offset);
1276 EXPECT_EQ(S_OK, hr);
1277 // Start and end offsets are always swapped to be in ascending order.
1278 EXPECT_EQ(0, start_offset);
1279 EXPECT_EQ(n_characters - 1, end_offset);
1280 }
1281
1165 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, 1282 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
1166 TestTextAtOffsetWithInvalidArguments) { 1283 TestTextAtOffsetWithInvalidArguments) {
1167 base::win::ScopedComPtr<IAccessibleText> input_text; 1284 base::win::ScopedComPtr<IAccessibleText> input_text;
1168 SetUpInputField(&input_text); 1285 SetUpInputField(&input_text);
1169 HRESULT hr = input_text->get_textAtOffset( 1286 HRESULT hr = input_text->get_textAtOffset(
1170 0, IA2_TEXT_BOUNDARY_CHAR, NULL, NULL, NULL); 1287 0, IA2_TEXT_BOUNDARY_CHAR, NULL, NULL, NULL);
1171 EXPECT_EQ(E_INVALIDARG, hr); 1288 EXPECT_EQ(E_INVALIDARG, hr);
1172 1289
1173 // Test invalid offset. 1290 // Test invalid offset.
1174 LONG start_offset = 0; 1291 LONG start_offset = 0;
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after
1788 ASSERT_EQ(nullptr, manager->GetParentHWND()); 1905 ASSERT_EQ(nullptr, manager->GetParentHWND());
1789 1906
1790 // Now add the RWHVA's window to the root window and ensure that we have 1907 // Now add the RWHVA's window to the root window and ensure that we have
1791 // an HWND for accessibility now. 1908 // an HWND for accessibility now.
1792 web_contents_view->GetNativeView()->AddChild( 1909 web_contents_view->GetNativeView()->AddChild(
1793 web_contents->GetRenderWidgetHostView()->GetNativeView()); 1910 web_contents->GetRenderWidgetHostView()->GetNativeView());
1794 ASSERT_NE(nullptr, manager->GetParentHWND()); 1911 ASSERT_NE(nullptr, manager->GetParentHWND());
1795 } 1912 }
1796 1913
1797 } // namespace content 1914 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/accessibility/ax_platform_position.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698