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

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

Issue 2745713002: WIP: Modified AXPosition to work with objects with both embedded object characters and text. (Closed)
Patch Set: Simplified and cleaned up selection code in Blink > Accessibility. Created 3 years, 6 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.cc » ('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 <objbase.h> 5 #include <objbase.h>
6 #include <stddef.h> 6 #include <stddef.h>
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <vector> 10 #include <vector>
(...skipping 1255 matching lines...) Expand 10 before | Expand all | Expand 10 after
1266 1266
1267 hr = textarea_text->get_selection(0, &start_offset, &end_offset); 1267 hr = textarea_text->get_selection(0, &start_offset, &end_offset);
1268 EXPECT_EQ(S_OK, hr); 1268 EXPECT_EQ(S_OK, hr);
1269 // Start and end offsets are always swapped to be in ascending order. 1269 // Start and end offsets are always swapped to be in ascending order.
1270 EXPECT_EQ(0, start_offset); 1270 EXPECT_EQ(0, start_offset);
1271 EXPECT_EQ(CONTENTS_LENGTH - 1, end_offset); 1271 EXPECT_EQ(CONTENTS_LENGTH - 1, end_offset);
1272 } 1272 }
1273 1273
1274 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, 1274 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
1275 TestStaticTextSetSelection) { 1275 TestStaticTextSetSelection) {
1276 base::win::ScopedComPtr<IAccessible2> paragraph;
1276 base::win::ScopedComPtr<IAccessibleText> paragraph_text; 1277 base::win::ScopedComPtr<IAccessibleText> paragraph_text;
1277 SetUpSampleParagraph(&paragraph_text); 1278 SetUpSampleParagraph(&paragraph);
1279 paragraph.QueryInterface(paragraph_text.Receive());
1278 1280
1279 LONG n_characters; 1281 LONG n_characters;
1280 ASSERT_HRESULT_SUCCEEDED(paragraph_text->get_nCharacters(&n_characters)); 1282 ASSERT_HRESULT_SUCCEEDED(paragraph_text->get_nCharacters(&n_characters));
1281 ASSERT_LT(0, n_characters); 1283 ASSERT_LT(0, n_characters);
1282 1284
1283 AccessibilityNotificationWaiter waiter( 1285 AccessibilityNotificationWaiter waiter(
1284 shell()->web_contents(), kAccessibilityModeComplete, 1286 shell()->web_contents(), kAccessibilityModeComplete,
1285 ui::AX_EVENT_DOCUMENT_SELECTION_CHANGED); 1287 ui::AX_EVENT_DOCUMENT_SELECTION_CHANGED);
1286 LONG start_offset = 0; 1288 LONG start_offset = 0;
1287 LONG end_offset = n_characters; 1289 LONG end_offset = n_characters;
1288 EXPECT_HRESULT_FAILED( 1290 EXPECT_HRESULT_FAILED(
1289 paragraph_text->setSelection(1, start_offset, end_offset)); 1291 paragraph_text->setSelection(1, start_offset, end_offset));
1290 EXPECT_HRESULT_SUCCEEDED( 1292 EXPECT_HRESULT_SUCCEEDED(
1291 paragraph_text->setSelection(0, start_offset, end_offset)); 1293 paragraph_text->setSelection(0, start_offset, end_offset));
1292 waiter.WaitForNotification(); 1294 waiter.WaitForNotification();
1293 1295
1294 HRESULT hr = paragraph_text->get_selection(0, &start_offset, &end_offset); 1296 HRESULT hr = paragraph_text->get_selection(0, &start_offset, &end_offset);
1295 EXPECT_EQ(S_OK, hr); 1297 EXPECT_EQ(S_OK, hr);
1296 EXPECT_EQ(0, start_offset); 1298 EXPECT_EQ(0, start_offset);
1297 EXPECT_EQ(n_characters, end_offset); 1299 EXPECT_EQ(n_characters, end_offset);
1298 1300
1301 // Try selecting backwards.
1299 start_offset = n_characters - 1; 1302 start_offset = n_characters - 1;
1300 end_offset = 0; 1303 end_offset = 0;
1301 EXPECT_HRESULT_SUCCEEDED( 1304 EXPECT_HRESULT_SUCCEEDED(
1302 paragraph_text->setSelection(0, start_offset, end_offset)); 1305 paragraph_text->setSelection(0, start_offset, end_offset));
1303 waiter.WaitForNotification(); 1306 waiter.WaitForNotification();
1304 1307
1305 hr = paragraph_text->get_selection(0, &start_offset, &end_offset); 1308 hr = paragraph_text->get_selection(0, &start_offset, &end_offset);
1306 EXPECT_EQ(S_OK, hr); 1309 EXPECT_EQ(S_OK, hr);
1307 // Start and end offsets are always swapped to be in ascending order. 1310 // Start and end offsets are always swapped to be in ascending order.
1308 EXPECT_EQ(0, start_offset); 1311 EXPECT_EQ(0, start_offset);
1309 EXPECT_EQ(n_characters - 1, end_offset); 1312 EXPECT_EQ(n_characters - 1, end_offset);
1313
1314 // Try selecting the whole paragraph via the document object.
1315 base::win::ScopedComPtr<IDispatch> dispatch;
1316 base::win::ScopedComPtr<IAccessibleText> document;
1317 ASSERT_HRESULT_SUCCEEDED(paragraph->get_accParent(dispatch.Receive()));
1318 dispatch.QueryInterface(document.Receive());
1319 start_offset = 0;
1320 end_offset = IA2_TEXT_OFFSET_LENGTH;
1321 EXPECT_HRESULT_SUCCEEDED(document->setSelection(0, start_offset, end_offset));
1322 waiter.WaitForNotification();
1323
1324 hr = paragraph_text->get_selection(0, &start_offset, &end_offset);
1325 EXPECT_EQ(S_OK, hr);
1326 EXPECT_EQ(0, start_offset);
1327 EXPECT_EQ(n_characters, end_offset);
1328
1329 // Try selecting each of the children individually.
1330 std::vector<base::win::ScopedVariant> children =
1331 GetAllAccessibleChildren(paragraph.get());
1332 ASSERT_EQ(6U, children.size());
1333 // Last offset is for the end of the last child.
1334 LONG child_start_offsets[] = {0, 11, 29, 30, 46, 0, 0};
1335 for (size_t i = 0; i < children.size(); ++i) {
1336 base::win::ScopedComPtr<IAccessible2> child;
1337 base::win::ScopedComPtr<IAccessibleText> child_text;
1338 ASSERT_HRESULT_SUCCEEDED(QueryIAccessible2(
1339 GetAccessibleFromVariant(paragraph.get(), children[i].AsInput()).get(),
1340 child.Receive()));
1341 child.QueryInterface(child_text.Receive());
1342 LOG(ERROR) << "Nektar: got child " << i;
1343
1344 start_offset = 0;
1345 end_offset = IA2_TEXT_OFFSET_LENGTH;
1346 EXPECT_HRESULT_SUCCEEDED(
1347 child_text->setSelection(0, start_offset, end_offset));
1348 waiter.WaitForNotification();
1349
1350 hr = paragraph_text->get_selection(0, &start_offset, &end_offset);
1351 EXPECT_EQ(S_OK, hr);
1352 EXPECT_EQ(child_start_offsets[i], start_offset);
1353 EXPECT_EQ(child_start_offsets[i + 1], end_offset);
1354 }
1310 } 1355 }
1311 1356
1312 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, 1357 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
1313 TestTextAtOffsetWithInvalidArguments) { 1358 TestTextAtOffsetWithInvalidArguments) {
1314 base::win::ScopedComPtr<IAccessibleText> input_text; 1359 base::win::ScopedComPtr<IAccessibleText> input_text;
1315 SetUpInputField(&input_text); 1360 SetUpInputField(&input_text);
1316 HRESULT hr = input_text->get_textAtOffset( 1361 HRESULT hr = input_text->get_textAtOffset(
1317 0, IA2_TEXT_BOUNDARY_CHAR, NULL, NULL, NULL); 1362 0, IA2_TEXT_BOUNDARY_CHAR, NULL, NULL, NULL);
1318 EXPECT_EQ(E_INVALIDARG, hr); 1363 EXPECT_EQ(E_INVALIDARG, hr);
1319 1364
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after
2037 EXPECT_HRESULT_SUCCEEDED(accessible_cell->get_rowIndex(&row_index)); 2082 EXPECT_HRESULT_SUCCEEDED(accessible_cell->get_rowIndex(&row_index));
2038 EXPECT_HRESULT_SUCCEEDED(accessible_cell->get_columnIndex(&column_index)); 2083 EXPECT_HRESULT_SUCCEEDED(accessible_cell->get_columnIndex(&column_index));
2039 EXPECT_EQ(1, row_index); 2084 EXPECT_EQ(1, row_index);
2040 EXPECT_EQ(1, column_index); 2085 EXPECT_EQ(1, column_index);
2041 variant.Reset(); 2086 variant.Reset();
2042 name.Reset(); 2087 name.Reset();
2043 accessible_cell.Reset(); 2088 accessible_cell.Reset();
2044 } 2089 }
2045 2090
2046 } // namespace content 2091 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/accessibility/ax_platform_position.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698