| 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 52872a44aaef0c86a0ae410e7064ae477422d335..3db6b36b3cd8426b07e71ee289715fe31bc9cd8c 100644
|
| --- a/content/browser/accessibility/browser_accessibility_win_unittest.cc
|
| +++ b/content/browser/accessibility/browser_accessibility_win_unittest.cc
|
| @@ -406,3 +406,169 @@ TEST_F(BrowserAccessibilityTest, TestScrollingLogic) {
|
| #undef SCROLL
|
| }
|
|
|
| +TEST_F(BrowserAccessibilityTest, TestSimpleHypertext) {
|
| + WebAccessibility text1;
|
| + text1.id = 11;
|
| + text1.role = WebAccessibility::ROLE_STATIC_TEXT;
|
| + text1.state = 0;
|
| + text1.name = L"One two three.";
|
| +
|
| + WebAccessibility text2;
|
| + text2.id = 12;
|
| + text2.role = WebAccessibility::ROLE_STATIC_TEXT;
|
| + text2.state = 0;
|
| + text2.name = L" Four five six.";
|
| +
|
| + WebAccessibility root;
|
| + root.id = 1;
|
| + root.role = WebAccessibility::ROLE_DOCUMENT;
|
| + root.state = 0;
|
| + root.children.push_back(text1);
|
| + root.children.push_back(text2);
|
| +
|
| + CountedBrowserAccessibility::global_obj_count_ = 0;
|
| + BrowserAccessibilityManager* manager = BrowserAccessibilityManager::Create(
|
| + GetDesktopWindow(), root, NULL,
|
| + new CountedBrowserAccessibilityFactory());
|
| + ASSERT_EQ(3, CountedBrowserAccessibility::global_obj_count_);
|
| +
|
| + BrowserAccessibilityWin* root_obj =
|
| + manager->GetRoot()->toBrowserAccessibilityWin();
|
| +
|
| + BSTR text;
|
| +
|
| + long text_len;
|
| + ASSERT_EQ(S_OK, root_obj->get_nCharacters(&text_len));
|
| +
|
| + ASSERT_EQ(S_OK, root_obj->get_text(0, text_len, &text));
|
| + EXPECT_EQ(text, text1.name + text2.name);
|
| + SysFreeString(text);
|
| +
|
| + long hyperlink_count;
|
| + ASSERT_EQ(S_OK, root_obj->get_nHyperlinks(&hyperlink_count));
|
| + EXPECT_EQ(0, hyperlink_count);
|
| +
|
| + base::win::ScopedComPtr<IAccessibleHyperlink> hyperlink;
|
| + EXPECT_EQ(E_INVALIDARG, root_obj->get_hyperlink(-1, hyperlink.Receive()));
|
| + EXPECT_EQ(E_INVALIDARG, root_obj->get_hyperlink(0, hyperlink.Receive()));
|
| + EXPECT_EQ(E_INVALIDARG, root_obj->get_hyperlink(28, hyperlink.Receive()));
|
| + EXPECT_EQ(E_INVALIDARG, root_obj->get_hyperlink(29, hyperlink.Receive()));
|
| +
|
| + long hyperlink_index;
|
| + EXPECT_EQ(E_FAIL, root_obj->get_hyperlinkIndex(0, &hyperlink_index));
|
| + EXPECT_EQ(-1, hyperlink_index);
|
| + EXPECT_EQ(E_FAIL, root_obj->get_hyperlinkIndex(28, &hyperlink_index));
|
| + EXPECT_EQ(-1, hyperlink_index);
|
| + EXPECT_EQ(E_INVALIDARG, root_obj->get_hyperlinkIndex(-1, &hyperlink_index));
|
| + EXPECT_EQ(-1, hyperlink_index);
|
| + EXPECT_EQ(E_INVALIDARG, root_obj->get_hyperlinkIndex(29, &hyperlink_index));
|
| + EXPECT_EQ(-1, hyperlink_index);
|
| +
|
| + // Delete the manager and test that all BrowserAccessibility instances are
|
| + // deleted.
|
| + delete manager;
|
| + ASSERT_EQ(0, CountedBrowserAccessibility::global_obj_count_);
|
| +}
|
| +
|
| +TEST_F(BrowserAccessibilityTest, TestComplexHypertext) {
|
| + WebAccessibility text1;
|
| + text1.id = 11;
|
| + text1.role = WebAccessibility::ROLE_STATIC_TEXT;
|
| + text1.state = 0;
|
| + text1.name = L"One two three.";
|
| +
|
| + WebAccessibility text2;
|
| + text2.id = 12;
|
| + text2.role = WebAccessibility::ROLE_STATIC_TEXT;
|
| + text2.state = 0;
|
| + text2.name = L" Four five six.";
|
| +
|
| + WebAccessibility button1, button1_text;
|
| + button1.id = 13;
|
| + button1_text.id = 15;
|
| + button1_text.name = L"red";
|
| + button1.role = WebAccessibility::ROLE_BUTTON;
|
| + button1_text.role = WebAccessibility::ROLE_STATIC_TEXT;
|
| + button1.state = 0;
|
| + button1.children.push_back(button1_text);
|
| +
|
| + WebAccessibility link1, link1_text;
|
| + link1.id = 14;
|
| + link1_text.id = 16;
|
| + link1_text.name = L"blue";
|
| + link1.role = WebAccessibility::ROLE_LINK;
|
| + link1_text.role = WebAccessibility::ROLE_STATIC_TEXT;
|
| + link1.state = 0;
|
| + link1.children.push_back(link1_text);
|
| +
|
| + WebAccessibility root;
|
| + root.id = 1;
|
| + root.role = WebAccessibility::ROLE_DOCUMENT;
|
| + root.state = 0;
|
| + root.children.push_back(text1);
|
| + root.children.push_back(button1);
|
| + root.children.push_back(text2);
|
| + root.children.push_back(link1);
|
| +
|
| + CountedBrowserAccessibility::global_obj_count_ = 0;
|
| + BrowserAccessibilityManager* manager = BrowserAccessibilityManager::Create(
|
| + GetDesktopWindow(), root, NULL,
|
| + new CountedBrowserAccessibilityFactory());
|
| + ASSERT_EQ(7, CountedBrowserAccessibility::global_obj_count_);
|
| +
|
| + BrowserAccessibilityWin* root_obj =
|
| + manager->GetRoot()->toBrowserAccessibilityWin();
|
| +
|
| + BSTR text;
|
| +
|
| + long text_len;
|
| + ASSERT_EQ(S_OK, root_obj->get_nCharacters(&text_len));
|
| +
|
| + ASSERT_EQ(S_OK, root_obj->get_text(0, text_len, &text));
|
| + const string16 embed = BrowserAccessibilityWin::kEmbeddedCharacter;
|
| + EXPECT_EQ(text, text1.name + embed + text2.name + embed);
|
| + SysFreeString(text);
|
| +
|
| + long hyperlink_count;
|
| + ASSERT_EQ(S_OK, root_obj->get_nHyperlinks(&hyperlink_count));
|
| + EXPECT_EQ(2, hyperlink_count);
|
| +
|
| + base::win::ScopedComPtr<IAccessibleHyperlink> hyperlink;
|
| + base::win::ScopedComPtr<IAccessibleText> hypertext;
|
| + EXPECT_EQ(E_INVALIDARG, root_obj->get_hyperlink(-1, hyperlink.Receive()));
|
| + EXPECT_EQ(E_INVALIDARG, root_obj->get_hyperlink(2, hyperlink.Receive()));
|
| + EXPECT_EQ(E_INVALIDARG, root_obj->get_hyperlink(28, hyperlink.Receive()));
|
| +
|
| + EXPECT_EQ(S_OK, root_obj->get_hyperlink(0, hyperlink.Receive()));
|
| + EXPECT_EQ(S_OK,
|
| + hyperlink.QueryInterface<IAccessibleText>(hypertext.Receive()));
|
| + EXPECT_EQ(S_OK, hypertext->get_text(0, 3, &text));
|
| + EXPECT_EQ(text, string16(L"red"));
|
| + SysFreeString(text);
|
| + hyperlink.Release();
|
| + hypertext.Release();
|
| +
|
| + EXPECT_EQ(S_OK, root_obj->get_hyperlink(1, hyperlink.Receive()));
|
| + EXPECT_EQ(S_OK,
|
| + hyperlink.QueryInterface<IAccessibleText>(hypertext.Receive()));
|
| + EXPECT_EQ(S_OK, hypertext->get_text(0, 4, &text));
|
| + EXPECT_EQ(text, string16(L"blue"));
|
| + SysFreeString(text);
|
| + hyperlink.Release();
|
| + hypertext.Release();
|
| +
|
| + long hyperlink_index;
|
| + EXPECT_EQ(E_FAIL, root_obj->get_hyperlinkIndex(0, &hyperlink_index));
|
| + EXPECT_EQ(-1, hyperlink_index);
|
| + EXPECT_EQ(E_FAIL, root_obj->get_hyperlinkIndex(28, &hyperlink_index));
|
| + EXPECT_EQ(-1, hyperlink_index);
|
| + EXPECT_EQ(S_OK, root_obj->get_hyperlinkIndex(14, &hyperlink_index));
|
| + EXPECT_EQ(0, hyperlink_index);
|
| + EXPECT_EQ(S_OK, root_obj->get_hyperlinkIndex(30, &hyperlink_index));
|
| + EXPECT_EQ(1, hyperlink_index);
|
| +
|
| + // Delete the manager and test that all BrowserAccessibility instances are
|
| + // deleted.
|
| + delete manager;
|
| + ASSERT_EQ(0, CountedBrowserAccessibility::global_obj_count_);
|
| +}
|
|
|