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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/browser/accessibility/ax_platform_position.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/accessibility/accessibility_win_browsertest.cc
diff --git a/content/browser/accessibility/accessibility_win_browsertest.cc b/content/browser/accessibility/accessibility_win_browsertest.cc
index 94a5140ce98136c117b9eeec17a14877fa5da12b..d6d910912f20ab049b817e002677c62df3df42b6 100644
--- a/content/browser/accessibility/accessibility_win_browsertest.cc
+++ b/content/browser/accessibility/accessibility_win_browsertest.cc
@@ -1273,8 +1273,10 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, TestMultiLineSetSelection) {
IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
TestStaticTextSetSelection) {
+ base::win::ScopedComPtr<IAccessible2> paragraph;
base::win::ScopedComPtr<IAccessibleText> paragraph_text;
- SetUpSampleParagraph(&paragraph_text);
+ SetUpSampleParagraph(&paragraph);
+ paragraph.QueryInterface(paragraph_text.Receive());
LONG n_characters;
ASSERT_HRESULT_SUCCEEDED(paragraph_text->get_nCharacters(&n_characters));
@@ -1296,6 +1298,7 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
EXPECT_EQ(0, start_offset);
EXPECT_EQ(n_characters, end_offset);
+ // Try selecting backwards.
start_offset = n_characters - 1;
end_offset = 0;
EXPECT_HRESULT_SUCCEEDED(
@@ -1307,6 +1310,48 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
// Start and end offsets are always swapped to be in ascending order.
EXPECT_EQ(0, start_offset);
EXPECT_EQ(n_characters - 1, end_offset);
+
+ // Try selecting the whole paragraph via the document object.
+ base::win::ScopedComPtr<IDispatch> dispatch;
+ base::win::ScopedComPtr<IAccessibleText> document;
+ ASSERT_HRESULT_SUCCEEDED(paragraph->get_accParent(dispatch.Receive()));
+ dispatch.QueryInterface(document.Receive());
+ start_offset = 0;
+ end_offset = IA2_TEXT_OFFSET_LENGTH;
+ EXPECT_HRESULT_SUCCEEDED(document->setSelection(0, start_offset, end_offset));
+ waiter.WaitForNotification();
+
+ hr = paragraph_text->get_selection(0, &start_offset, &end_offset);
+ EXPECT_EQ(S_OK, hr);
+ EXPECT_EQ(0, start_offset);
+ EXPECT_EQ(n_characters, end_offset);
+
+ // Try selecting each of the children individually.
+ std::vector<base::win::ScopedVariant> children =
+ GetAllAccessibleChildren(paragraph.get());
+ ASSERT_EQ(6U, children.size());
+ // Last offset is for the end of the last child.
+ LONG child_start_offsets[] = {0, 11, 29, 30, 46, 0, 0};
+ for (size_t i = 0; i < children.size(); ++i) {
+ base::win::ScopedComPtr<IAccessible2> child;
+ base::win::ScopedComPtr<IAccessibleText> child_text;
+ ASSERT_HRESULT_SUCCEEDED(QueryIAccessible2(
+ GetAccessibleFromVariant(paragraph.get(), children[i].AsInput()).get(),
+ child.Receive()));
+ child.QueryInterface(child_text.Receive());
+ LOG(ERROR) << "Nektar: got child " << i;
+
+ start_offset = 0;
+ end_offset = IA2_TEXT_OFFSET_LENGTH;
+ EXPECT_HRESULT_SUCCEEDED(
+ child_text->setSelection(0, start_offset, end_offset));
+ waiter.WaitForNotification();
+
+ hr = paragraph_text->get_selection(0, &start_offset, &end_offset);
+ EXPECT_EQ(S_OK, hr);
+ EXPECT_EQ(child_start_offsets[i], start_offset);
+ EXPECT_EQ(child_start_offsets[i + 1], end_offset);
+ }
}
IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
« 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