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

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

Issue 2692173003: Implemented SetSelection for the Web content on Windows. (Closed)
Patch Set: 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
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 EXPECT_EQ(S_OK, hr);
1174 EXPECT_EQ(CONTENTS_LENGTH - 1, start_offset);
1175 EXPECT_EQ(CONTENTS_LENGTH - 1, end_offset);
1176
1177 AccessibilityNotificationWaiter waiter(shell()->web_contents(),
1178 ACCESSIBILITY_MODE_COMPLETE,
1179 ui::AX_EVENT_TEXT_SELECTION_CHANGED);
1180 start_offset = 0;
1181 end_offset = CONTENTS_LENGTH;
1182 EXPECT_HRESULT_FAILED(input_text->setSelection(1, start_offset, end_offset));
1183 EXPECT_HRESULT_SUCCEEDED(
1184 input_text->setSelection(0, start_offset, end_offset));
1185 waiter.WaitForNotification();
1186
1187 hr = input_text->get_selection(0, &start_offset, &end_offset);
1188 EXPECT_EQ(S_OK, hr);
1189 EXPECT_EQ(0, start_offset);
1190 EXPECT_EQ(CONTENTS_LENGTH, end_offset);
1191
1192 start_offset = CONTENTS_LENGTH;
1193 end_offset = 1;
1194 EXPECT_HRESULT_SUCCEEDED(
1195 input_text->setSelection(0, start_offset, end_offset));
1196 waiter.WaitForNotification();
1197
1198 hr = input_text->get_selection(0, &start_offset, &end_offset);
1199 EXPECT_EQ(S_OK, hr);
1200 EXPECT_EQ(CONTENTS_LENGTH, start_offset);
1201 EXPECT_EQ(1, 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 EXPECT_EQ(S_OK, hr);
1213 EXPECT_EQ(CONTENTS_LENGTH - 1, start_offset);
1214 EXPECT_EQ(CONTENTS_LENGTH - 1, end_offset);
1215
1216 AccessibilityNotificationWaiter waiter(shell()->web_contents(),
1217 ACCESSIBILITY_MODE_COMPLETE,
1218 ui::AX_EVENT_TEXT_SELECTION_CHANGED);
1219 start_offset = 0;
1220 end_offset = CONTENTS_LENGTH;
1221 EXPECT_HRESULT_FAILED(
1222 textarea_text->setSelection(1, start_offset, end_offset));
1223 EXPECT_HRESULT_SUCCEEDED(
1224 textarea_text->setSelection(0, start_offset, end_offset));
1225 waiter.WaitForNotification();
1226
1227 hr = textarea_text->get_selection(0, &start_offset, &end_offset);
1228 EXPECT_EQ(S_OK, hr);
1229 EXPECT_EQ(0, start_offset);
1230 EXPECT_EQ(CONTENTS_LENGTH, end_offset);
1231
1232 start_offset = CONTENTS_LENGTH - 1;
1233 end_offset = 0;
1234 EXPECT_HRESULT_SUCCEEDED(
1235 textarea_text->setSelection(0, start_offset, end_offset));
1236 waiter.WaitForNotification();
1237
1238 hr = textarea_text->get_selection(0, &start_offset, &end_offset);
1239 EXPECT_EQ(S_OK, hr);
1240 EXPECT_EQ(CONTENTS_LENGTH - 1, start_offset);
1241 EXPECT_EQ(0, 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_GT(0, n_characters);
1252
1253 AccessibilityNotificationWaiter waiter(shell()->web_contents(),
1254 ACCESSIBILITY_MODE_COMPLETE,
1255 ui::AX_EVENT_TEXT_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 EXPECT_EQ(n_characters - 1, start_offset);
1278 EXPECT_EQ(0, end_offset);
1279 }
1280
1165 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, 1281 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
1166 TestTextAtOffsetWithInvalidArguments) { 1282 TestTextAtOffsetWithInvalidArguments) {
1167 base::win::ScopedComPtr<IAccessibleText> input_text; 1283 base::win::ScopedComPtr<IAccessibleText> input_text;
1168 SetUpInputField(&input_text); 1284 SetUpInputField(&input_text);
1169 HRESULT hr = input_text->get_textAtOffset( 1285 HRESULT hr = input_text->get_textAtOffset(
1170 0, IA2_TEXT_BOUNDARY_CHAR, NULL, NULL, NULL); 1286 0, IA2_TEXT_BOUNDARY_CHAR, NULL, NULL, NULL);
1171 EXPECT_EQ(E_INVALIDARG, hr); 1287 EXPECT_EQ(E_INVALIDARG, hr);
1172 1288
1173 // Test invalid offset. 1289 // Test invalid offset.
1174 LONG start_offset = 0; 1290 LONG start_offset = 0;
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after
1788 ASSERT_EQ(nullptr, manager->GetParentHWND()); 1904 ASSERT_EQ(nullptr, manager->GetParentHWND());
1789 1905
1790 // Now add the RWHVA's window to the root window and ensure that we have 1906 // Now add the RWHVA's window to the root window and ensure that we have
1791 // an HWND for accessibility now. 1907 // an HWND for accessibility now.
1792 web_contents_view->GetNativeView()->AddChild( 1908 web_contents_view->GetNativeView()->AddChild(
1793 web_contents->GetRenderWidgetHostView()->GetNativeView()); 1909 web_contents->GetRenderWidgetHostView()->GetNativeView());
1794 ASSERT_NE(nullptr, manager->GetParentHWND()); 1910 ASSERT_NE(nullptr, manager->GetParentHWND());
1795 } 1911 }
1796 1912
1797 } // namespace content 1913 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698