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

Unified Diff: content/browser/accessibility/browser_accessibility_win_unittest.cc

Issue 1377733002: Fixes for contenteditable caret and selection handling in Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed some more corner cases, updated tests to make them more resilient and added comments to the c… Created 5 years, 3 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
Index: content/browser/accessibility/browser_accessibility_win_unittest.cc
diff --git a/content/browser/accessibility/browser_accessibility_win_unittest.cc b/content/browser/accessibility/browser_accessibility_win_unittest.cc
index 898e5dced782e214bfcf9203450cd1850477b74f..6ebf583a4ff889572a0557ede5796762b4b2482b 100644
--- a/content/browser/accessibility/browser_accessibility_win_unittest.cc
+++ b/content/browser/accessibility/browser_accessibility_win_unittest.cc
@@ -981,9 +981,15 @@ TEST_F(BrowserAccessibilityTest, TestCaretInContentEditables) {
// -2 is never a valid offset.
LONG caret_offset = -2;
+ LONG n_selections = -2;
+
+ // No selection should be present.
+ HRESULT hr = div_editable_accessible->get_nSelections(&n_selections);;
+ EXPECT_EQ(S_OK, hr);
+ EXPECT_EQ(0L, n_selections);
// The caret should be on the embedded object character.
- HRESULT hr = div_editable_accessible->get_caretOffset(&caret_offset);;
+ hr = div_editable_accessible->get_caretOffset(&caret_offset);;
EXPECT_EQ(S_OK, hr);
EXPECT_EQ(6L, caret_offset);
@@ -1006,10 +1012,20 @@ TEST_F(BrowserAccessibilityTest, TestCaretInContentEditables) {
ASSERT_NE(nullptr, link_text_accessible);
// The caret should not have moved.
+ hr = div_editable_accessible->get_nSelections(&n_selections);;
+ EXPECT_EQ(S_OK, hr);
+ EXPECT_EQ(0L, n_selections);
hr = div_editable_accessible->get_caretOffset(&caret_offset);;
EXPECT_EQ(S_OK, hr);
EXPECT_EQ(6L, caret_offset);
+ hr = link_accessible->get_nSelections(&n_selections);;
+ EXPECT_EQ(S_OK, hr);
+ EXPECT_EQ(0L, n_selections);
+ hr = link_text_accessible->get_nSelections(&n_selections);;
+ EXPECT_EQ(S_OK, hr);
+ EXPECT_EQ(0L, n_selections);
+
hr = link_accessible->get_caretOffset(&caret_offset);;
EXPECT_EQ(S_OK, hr);
EXPECT_EQ(1L, caret_offset);
@@ -1021,7 +1037,7 @@ TEST_F(BrowserAccessibilityTest, TestCaretInContentEditables) {
ASSERT_EQ(0, CountedBrowserAccessibility::num_instances());
}
-TEST_F(BrowserAccessibilityTest, DISABLED_TestSelectionInContentEditables) {
+TEST_F(BrowserAccessibilityTest, TestSelectionInContentEditables) {
ui::AXNodeData root;
root.id = 1;
root.role = ui::AX_ROLE_ROOT_WEB_AREA;
@@ -1151,13 +1167,14 @@ TEST_F(BrowserAccessibilityTest, DISABLED_TestSelectionInContentEditables) {
EXPECT_EQ(S_OK, hr);
EXPECT_EQ(1L, caret_offset);
- // The HRESULT should be S_FALSE if the caret is not in the given object.
+ // The caret offset should reflect the position of the selection's anchor in
+ // any given object.
hr = link_accessible->get_caretOffset(&caret_offset);;
- EXPECT_EQ(S_FALSE, hr);
- EXPECT_EQ(-1L, caret_offset);
+ EXPECT_EQ(S_OK, hr);
+ EXPECT_EQ(0L, caret_offset);
hr = link_text_accessible->get_caretOffset(&caret_offset);;
- EXPECT_EQ(S_FALSE, hr);
- EXPECT_EQ(-1L, caret_offset);
+ EXPECT_EQ(S_OK, hr);
+ EXPECT_EQ(0L, caret_offset);
hr = div_editable_accessible->get_selection(
0L /* selection_index */, &selection_start, &selection_end);;

Powered by Google App Engine
This is Rietveld 408576698