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

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

Issue 102593002: Convert string16 to base::string16 in content. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | Annotate | Revision Log
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 "base/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "base/win/scoped_bstr.h" 7 #include "base/win/scoped_bstr.h"
8 #include "base/win/scoped_comptr.h" 8 #include "base/win/scoped_comptr.h"
9 #include "base/win/scoped_variant.h" 9 #include "base/win/scoped_variant.h"
10 #include "content/browser/accessibility/browser_accessibility_manager.h" 10 #include "content/browser/accessibility/browser_accessibility_manager.h"
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 ASSERT_EQ(S_OK, hr); 212 ASSERT_EQ(S_OK, hr);
213 213
214 base::win::ScopedComPtr<IAccessible> text_accessible; 214 base::win::ScopedComPtr<IAccessible> text_accessible;
215 hr = text_dispatch.QueryInterface(text_accessible.Receive()); 215 hr = text_dispatch.QueryInterface(text_accessible.Receive());
216 ASSERT_EQ(S_OK, hr); 216 ASSERT_EQ(S_OK, hr);
217 217
218 base::win::ScopedVariant childid_self(CHILDID_SELF); 218 base::win::ScopedVariant childid_self(CHILDID_SELF);
219 base::win::ScopedBstr name; 219 base::win::ScopedBstr name;
220 hr = text_accessible->get_accName(childid_self, name.Receive()); 220 hr = text_accessible->get_accName(childid_self, name.Receive());
221 ASSERT_EQ(S_OK, hr); 221 ASSERT_EQ(S_OK, hr);
222 EXPECT_EQ(L"old text", string16(name)); 222 EXPECT_EQ(L"old text", base::string16(name));
223 name.Reset(); 223 name.Reset();
224 224
225 text_dispatch.Release(); 225 text_dispatch.Release();
226 text_accessible.Release(); 226 text_accessible.Release();
227 227
228 // Notify the BrowserAccessibilityManager that the text child has changed. 228 // Notify the BrowserAccessibilityManager that the text child has changed.
229 AccessibilityNodeData text2; 229 AccessibilityNodeData text2;
230 text2.id = 2; 230 text2.id = 2;
231 text2.role = blink::WebAXRoleStaticText; 231 text2.role = blink::WebAXRoleStaticText;
232 text2.SetName("new text"); 232 text2.SetName("new text");
(...skipping 10 matching lines...) Expand all
243 // as its value. 243 // as its value.
244 hr = manager->GetRoot()->ToBrowserAccessibilityWin()->get_accChild( 244 hr = manager->GetRoot()->ToBrowserAccessibilityWin()->get_accChild(
245 one, text_dispatch.Receive()); 245 one, text_dispatch.Receive());
246 ASSERT_EQ(S_OK, hr); 246 ASSERT_EQ(S_OK, hr);
247 247
248 hr = text_dispatch.QueryInterface(text_accessible.Receive()); 248 hr = text_dispatch.QueryInterface(text_accessible.Receive());
249 ASSERT_EQ(S_OK, hr); 249 ASSERT_EQ(S_OK, hr);
250 250
251 hr = text_accessible->get_accName(childid_self, name.Receive()); 251 hr = text_accessible->get_accName(childid_self, name.Receive());
252 ASSERT_EQ(S_OK, hr); 252 ASSERT_EQ(S_OK, hr);
253 EXPECT_EQ(L"new text", string16(name)); 253 EXPECT_EQ(L"new text", base::string16(name));
254 254
255 text_dispatch.Release(); 255 text_dispatch.Release();
256 text_accessible.Release(); 256 text_accessible.Release();
257 257
258 // Delete the manager and test that all BrowserAccessibility instances are 258 // Delete the manager and test that all BrowserAccessibility instances are
259 // deleted. 259 // deleted.
260 manager.reset(); 260 manager.reset();
261 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); 261 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances());
262 } 262 }
263 263
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 BrowserAccessibilityWin* root_obj = 347 BrowserAccessibilityWin* root_obj =
348 manager->GetRoot()->ToBrowserAccessibilityWin(); 348 manager->GetRoot()->ToBrowserAccessibilityWin();
349 BrowserAccessibilityWin* text1_obj = 349 BrowserAccessibilityWin* text1_obj =
350 root_obj->PlatformGetChild(0)->ToBrowserAccessibilityWin(); 350 root_obj->PlatformGetChild(0)->ToBrowserAccessibilityWin();
351 351
352 long text1_len; 352 long text1_len;
353 ASSERT_EQ(S_OK, text1_obj->get_nCharacters(&text1_len)); 353 ASSERT_EQ(S_OK, text1_obj->get_nCharacters(&text1_len));
354 354
355 base::win::ScopedBstr text; 355 base::win::ScopedBstr text;
356 ASSERT_EQ(S_OK, text1_obj->get_text(0, text1_len, text.Receive())); 356 ASSERT_EQ(S_OK, text1_obj->get_text(0, text1_len, text.Receive()));
357 ASSERT_EQ(text1_value, base::UTF16ToUTF8(string16(text))); 357 ASSERT_EQ(text1_value, base::UTF16ToUTF8(base::string16(text)));
358 text.Reset(); 358 text.Reset();
359 359
360 ASSERT_EQ(S_OK, text1_obj->get_text(0, 4, text.Receive())); 360 ASSERT_EQ(S_OK, text1_obj->get_text(0, 4, text.Receive()));
361 ASSERT_STREQ(L"One ", text); 361 ASSERT_STREQ(L"One ", text);
362 text.Reset(); 362 text.Reset();
363 363
364 long start; 364 long start;
365 long end; 365 long end;
366 ASSERT_EQ(S_OK, text1_obj->get_textAtOffset( 366 ASSERT_EQ(S_OK, text1_obj->get_textAtOffset(
367 1, IA2_TEXT_BOUNDARY_CHAR, &start, &end, text.Receive())); 367 1, IA2_TEXT_BOUNDARY_CHAR, &start, &end, text.Receive()));
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 ASSERT_EQ(3, CountedBrowserAccessibility::num_instances()); 445 ASSERT_EQ(3, CountedBrowserAccessibility::num_instances());
446 446
447 BrowserAccessibilityWin* root_obj = 447 BrowserAccessibilityWin* root_obj =
448 manager->GetRoot()->ToBrowserAccessibilityWin(); 448 manager->GetRoot()->ToBrowserAccessibilityWin();
449 449
450 long text_len; 450 long text_len;
451 ASSERT_EQ(S_OK, root_obj->get_nCharacters(&text_len)); 451 ASSERT_EQ(S_OK, root_obj->get_nCharacters(&text_len));
452 452
453 base::win::ScopedBstr text; 453 base::win::ScopedBstr text;
454 ASSERT_EQ(S_OK, root_obj->get_text(0, text_len, text.Receive())); 454 ASSERT_EQ(S_OK, root_obj->get_text(0, text_len, text.Receive()));
455 EXPECT_EQ(text1_name + text2_name, base::UTF16ToUTF8(string16(text))); 455 EXPECT_EQ(text1_name + text2_name, base::UTF16ToUTF8(base::string16(text)));
456 456
457 long hyperlink_count; 457 long hyperlink_count;
458 ASSERT_EQ(S_OK, root_obj->get_nHyperlinks(&hyperlink_count)); 458 ASSERT_EQ(S_OK, root_obj->get_nHyperlinks(&hyperlink_count));
459 EXPECT_EQ(0, hyperlink_count); 459 EXPECT_EQ(0, hyperlink_count);
460 460
461 base::win::ScopedComPtr<IAccessibleHyperlink> hyperlink; 461 base::win::ScopedComPtr<IAccessibleHyperlink> hyperlink;
462 EXPECT_EQ(E_INVALIDARG, root_obj->get_hyperlink(-1, hyperlink.Receive())); 462 EXPECT_EQ(E_INVALIDARG, root_obj->get_hyperlink(-1, hyperlink.Receive()));
463 EXPECT_EQ(E_INVALIDARG, root_obj->get_hyperlink(0, hyperlink.Receive())); 463 EXPECT_EQ(E_INVALIDARG, root_obj->get_hyperlink(0, hyperlink.Receive()));
464 EXPECT_EQ(E_INVALIDARG, root_obj->get_hyperlink(28, hyperlink.Receive())); 464 EXPECT_EQ(E_INVALIDARG, root_obj->get_hyperlink(28, hyperlink.Receive()));
465 EXPECT_EQ(E_INVALIDARG, root_obj->get_hyperlink(29, hyperlink.Receive())); 465 EXPECT_EQ(E_INVALIDARG, root_obj->get_hyperlink(29, hyperlink.Receive()));
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 manager->GetRoot()->ToBrowserAccessibilityWin(); 541 manager->GetRoot()->ToBrowserAccessibilityWin();
542 542
543 long text_len; 543 long text_len;
544 ASSERT_EQ(S_OK, root_obj->get_nCharacters(&text_len)); 544 ASSERT_EQ(S_OK, root_obj->get_nCharacters(&text_len));
545 545
546 base::win::ScopedBstr text; 546 base::win::ScopedBstr text;
547 ASSERT_EQ(S_OK, root_obj->get_text(0, text_len, text.Receive())); 547 ASSERT_EQ(S_OK, root_obj->get_text(0, text_len, text.Receive()));
548 const std::string embed = base::UTF16ToUTF8( 548 const std::string embed = base::UTF16ToUTF8(
549 BrowserAccessibilityWin::kEmbeddedCharacter); 549 BrowserAccessibilityWin::kEmbeddedCharacter);
550 EXPECT_EQ(text1_name + embed + text2_name + embed, 550 EXPECT_EQ(text1_name + embed + text2_name + embed,
551 UTF16ToUTF8(string16(text))); 551 UTF16ToUTF8(base::string16(text)));
552 text.Reset(); 552 text.Reset();
553 553
554 long hyperlink_count; 554 long hyperlink_count;
555 ASSERT_EQ(S_OK, root_obj->get_nHyperlinks(&hyperlink_count)); 555 ASSERT_EQ(S_OK, root_obj->get_nHyperlinks(&hyperlink_count));
556 EXPECT_EQ(2, hyperlink_count); 556 EXPECT_EQ(2, hyperlink_count);
557 557
558 base::win::ScopedComPtr<IAccessibleHyperlink> hyperlink; 558 base::win::ScopedComPtr<IAccessibleHyperlink> hyperlink;
559 base::win::ScopedComPtr<IAccessibleText> hypertext; 559 base::win::ScopedComPtr<IAccessibleText> hypertext;
560 EXPECT_EQ(E_INVALIDARG, root_obj->get_hyperlink(-1, hyperlink.Receive())); 560 EXPECT_EQ(E_INVALIDARG, root_obj->get_hyperlink(-1, hyperlink.Receive()));
561 EXPECT_EQ(E_INVALIDARG, root_obj->get_hyperlink(2, hyperlink.Receive())); 561 EXPECT_EQ(E_INVALIDARG, root_obj->get_hyperlink(2, hyperlink.Receive()));
562 EXPECT_EQ(E_INVALIDARG, root_obj->get_hyperlink(28, hyperlink.Receive())); 562 EXPECT_EQ(E_INVALIDARG, root_obj->get_hyperlink(28, hyperlink.Receive()));
563 563
564 EXPECT_EQ(S_OK, root_obj->get_hyperlink(0, hyperlink.Receive())); 564 EXPECT_EQ(S_OK, root_obj->get_hyperlink(0, hyperlink.Receive()));
565 EXPECT_EQ(S_OK, 565 EXPECT_EQ(S_OK,
566 hyperlink.QueryInterface<IAccessibleText>(hypertext.Receive())); 566 hyperlink.QueryInterface<IAccessibleText>(hypertext.Receive()));
567 EXPECT_EQ(S_OK, hypertext->get_text(0, 3, text.Receive())); 567 EXPECT_EQ(S_OK, hypertext->get_text(0, 3, text.Receive()));
568 EXPECT_STREQ(button1_text_name.c_str(), 568 EXPECT_STREQ(button1_text_name.c_str(),
569 base::UTF16ToUTF8(string16(text)).c_str()); 569 base::UTF16ToUTF8(base::string16(text)).c_str());
570 text.Reset(); 570 text.Reset();
571 hyperlink.Release(); 571 hyperlink.Release();
572 hypertext.Release(); 572 hypertext.Release();
573 573
574 EXPECT_EQ(S_OK, root_obj->get_hyperlink(1, hyperlink.Receive())); 574 EXPECT_EQ(S_OK, root_obj->get_hyperlink(1, hyperlink.Receive()));
575 EXPECT_EQ(S_OK, 575 EXPECT_EQ(S_OK,
576 hyperlink.QueryInterface<IAccessibleText>(hypertext.Receive())); 576 hyperlink.QueryInterface<IAccessibleText>(hypertext.Receive()));
577 EXPECT_EQ(S_OK, hypertext->get_text(0, 4, text.Receive())); 577 EXPECT_EQ(S_OK, hypertext->get_text(0, 4, text.Receive()));
578 EXPECT_STREQ(link1_text_name.c_str(), 578 EXPECT_STREQ(link1_text_name.c_str(),
579 base::UTF16ToUTF8(string16(text)).c_str()); 579 base::UTF16ToUTF8(base::string16(text)).c_str());
580 text.Reset(); 580 text.Reset();
581 hyperlink.Release(); 581 hyperlink.Release();
582 hypertext.Release(); 582 hypertext.Release();
583 583
584 long hyperlink_index; 584 long hyperlink_index;
585 EXPECT_EQ(E_FAIL, root_obj->get_hyperlinkIndex(0, &hyperlink_index)); 585 EXPECT_EQ(E_FAIL, root_obj->get_hyperlinkIndex(0, &hyperlink_index));
586 EXPECT_EQ(-1, hyperlink_index); 586 EXPECT_EQ(-1, hyperlink_index);
587 EXPECT_EQ(E_FAIL, root_obj->get_hyperlinkIndex(28, &hyperlink_index)); 587 EXPECT_EQ(E_FAIL, root_obj->get_hyperlinkIndex(28, &hyperlink_index));
588 EXPECT_EQ(-1, hyperlink_index); 588 EXPECT_EQ(-1, hyperlink_index);
589 EXPECT_EQ(S_OK, root_obj->get_hyperlinkIndex(14, &hyperlink_index)); 589 EXPECT_EQ(S_OK, root_obj->get_hyperlinkIndex(14, &hyperlink_index));
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 // And the new child exists. 674 // And the new child exists.
675 EXPECT_EQ(blink::WebAXRoleButton, acc2_2->role()); 675 EXPECT_EQ(blink::WebAXRoleButton, acc2_2->role());
676 EXPECT_EQ(3, acc2_2->renderer_id()); 676 EXPECT_EQ(3, acc2_2->renderer_id());
677 677
678 // Ensure we properly cleaned up. 678 // Ensure we properly cleaned up.
679 manager.reset(); 679 manager.reset();
680 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances()); 680 ASSERT_EQ(0, CountedBrowserAccessibility::num_instances());
681 } 681 }
682 682
683 } // namespace content 683 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698