| 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 98a5d404a437e799e3ddf6570ea015a54f88bcfb..c65c1f3e92be52581d2ccb9a6a1ef5566293d4be 100644
|
| --- a/content/browser/accessibility/browser_accessibility_win_unittest.cc
|
| +++ b/content/browser/accessibility/browser_accessibility_win_unittest.cc
|
| @@ -3,6 +3,7 @@
|
| // found in the LICENSE file.
|
|
|
| #include "base/memory/scoped_ptr.h"
|
| +#include "base/strings/utf_string_conversions.h"
|
| #include "base/win/scoped_bstr.h"
|
| #include "base/win/scoped_comptr.h"
|
| #include "base/win/scoped_variant.h"
|
| @@ -113,19 +114,19 @@ TEST_F(BrowserAccessibilityTest, TestNoLeaks) {
|
| // BrowserAccessibilityManager.
|
| AccessibilityNodeData button;
|
| button.id = 2;
|
| - button.name = L"Button";
|
| + button.SetName("Button");
|
| button.role = AccessibilityNodeData::ROLE_BUTTON;
|
| button.state = 0;
|
|
|
| AccessibilityNodeData checkbox;
|
| checkbox.id = 3;
|
| - checkbox.name = L"Checkbox";
|
| + checkbox.SetName("Checkbox");
|
| checkbox.role = AccessibilityNodeData::ROLE_CHECKBOX;
|
| checkbox.state = 0;
|
|
|
| AccessibilityNodeData root;
|
| root.id = 1;
|
| - root.name = L"Document";
|
| + root.SetName("Document");
|
| root.role = AccessibilityNodeData::ROLE_ROOT_WEB_AREA;
|
| root.state = 0;
|
| root.child_ids.push_back(2);
|
| @@ -183,12 +184,12 @@ TEST_F(BrowserAccessibilityTest, TestChildrenChange) {
|
| AccessibilityNodeData text;
|
| text.id = 2;
|
| text.role = AccessibilityNodeData::ROLE_STATIC_TEXT;
|
| - text.name = L"old text";
|
| + text.SetName("old text");
|
| text.state = 0;
|
|
|
| AccessibilityNodeData root;
|
| root.id = 1;
|
| - root.name = L"Document";
|
| + root.SetName("Document");
|
| root.role = AccessibilityNodeData::ROLE_ROOT_WEB_AREA;
|
| root.state = 0;
|
| root.child_ids.push_back(2);
|
| @@ -225,11 +226,15 @@ TEST_F(BrowserAccessibilityTest, TestChildrenChange) {
|
| text_accessible.Release();
|
|
|
| // Notify the BrowserAccessibilityManager that the text child has changed.
|
| - text.name = L"new text";
|
| + AccessibilityNodeData text2;
|
| + text2.id = 2;
|
| + text2.role = AccessibilityNodeData::ROLE_STATIC_TEXT;
|
| + text2.SetName("new text");
|
| + text2.SetName("old text");
|
| AccessibilityHostMsg_NotificationParams param;
|
| param.notification_type = AccessibilityNotificationChildrenChanged;
|
| - param.nodes.push_back(text);
|
| - param.id = text.id;
|
| + param.nodes.push_back(text2);
|
| + param.id = text2.id;
|
| std::vector<AccessibilityHostMsg_NotificationParams> notifications;
|
| notifications.push_back(param);
|
| manager->OnAccessibilityNotifications(notifications);
|
| @@ -314,12 +319,17 @@ TEST_F(BrowserAccessibilityTest, TestChildrenChangeNoLeaks) {
|
| }
|
|
|
| TEST_F(BrowserAccessibilityTest, TestTextBoundaries) {
|
| + std::string text1_value = "One two three.\nFour five six.";
|
| +
|
| AccessibilityNodeData text1;
|
| text1.id = 11;
|
| text1.role = AccessibilityNodeData::ROLE_TEXT_FIELD;
|
| text1.state = 0;
|
| - text1.value = L"One two three.\nFour five six.";
|
| - text1.line_breaks.push_back(15);
|
| + text1.AddStringAttribute(AccessibilityNodeData::ATTR_VALUE, text1_value);
|
| + std::vector<int32> line_breaks;
|
| + line_breaks.push_back(15);
|
| + text1.AddIntListAttribute(
|
| + AccessibilityNodeData::ATTR_LINE_BREAKS, line_breaks);
|
|
|
| AccessibilityNodeData root;
|
| root.id = 1;
|
| @@ -344,7 +354,7 @@ TEST_F(BrowserAccessibilityTest, TestTextBoundaries) {
|
|
|
| base::win::ScopedBstr text;
|
| ASSERT_EQ(S_OK, text1_obj->get_text(0, text1_len, text.Receive()));
|
| - ASSERT_EQ(text1.value, string16(text));
|
| + ASSERT_EQ(text1_value, base::UTF16ToUTF8(string16(text)));
|
| text.Reset();
|
|
|
| ASSERT_EQ(S_OK, text1_obj->get_text(0, 4, text.Receive()));
|
| @@ -405,17 +415,20 @@ TEST_F(BrowserAccessibilityTest, TestTextBoundaries) {
|
| }
|
|
|
| TEST_F(BrowserAccessibilityTest, TestSimpleHypertext) {
|
| + const std::string text1_name = "One two three.";
|
| + const std::string text2_name = " Four five six.";
|
| +
|
| AccessibilityNodeData text1;
|
| text1.id = 11;
|
| text1.role = AccessibilityNodeData::ROLE_STATIC_TEXT;
|
| text1.state = 1 << AccessibilityNodeData::STATE_READONLY;
|
| - text1.name = L"One two three.";
|
| + text1.SetName(text1_name);
|
|
|
| AccessibilityNodeData text2;
|
| text2.id = 12;
|
| text2.role = AccessibilityNodeData::ROLE_STATIC_TEXT;
|
| text2.state = 1 << AccessibilityNodeData::STATE_READONLY;
|
| - text2.name = L" Four five six.";
|
| + text2.SetName(text2_name);
|
|
|
| AccessibilityNodeData root;
|
| root.id = 1;
|
| @@ -439,7 +452,7 @@ TEST_F(BrowserAccessibilityTest, TestSimpleHypertext) {
|
|
|
| base::win::ScopedBstr text;
|
| ASSERT_EQ(S_OK, root_obj->get_text(0, text_len, text.Receive()));
|
| - EXPECT_EQ(text1.name + text2.name, string16(text));
|
| + EXPECT_EQ(text1_name + text2_name, base::UTF16ToUTF8(string16(text)));
|
|
|
| long hyperlink_count;
|
| ASSERT_EQ(S_OK, root_obj->get_nHyperlinks(&hyperlink_count));
|
| @@ -468,22 +481,27 @@ TEST_F(BrowserAccessibilityTest, TestSimpleHypertext) {
|
| }
|
|
|
| TEST_F(BrowserAccessibilityTest, TestComplexHypertext) {
|
| + const std::string text1_name = "One two three.";
|
| + const std::string text2_name = " Four five six.";
|
| + const std::string button1_text_name = "red";
|
| + const std::string link1_text_name = "blue";
|
| +
|
| AccessibilityNodeData text1;
|
| text1.id = 11;
|
| text1.role = AccessibilityNodeData::ROLE_STATIC_TEXT;
|
| text1.state = 1 << AccessibilityNodeData::STATE_READONLY;
|
| - text1.name = L"One two three.";
|
| + text1.SetName(text1_name);
|
|
|
| AccessibilityNodeData text2;
|
| text2.id = 12;
|
| text2.role = AccessibilityNodeData::ROLE_STATIC_TEXT;
|
| text2.state = 1 << AccessibilityNodeData::STATE_READONLY;
|
| - text2.name = L" Four five six.";
|
| + text2.SetName(text2_name);
|
|
|
| AccessibilityNodeData button1, button1_text;
|
| button1.id = 13;
|
| button1_text.id = 15;
|
| - button1_text.name = L"red";
|
| + button1_text.SetName(button1_text_name);
|
| button1.role = AccessibilityNodeData::ROLE_BUTTON;
|
| button1_text.role = AccessibilityNodeData::ROLE_STATIC_TEXT;
|
| button1.state = 1 << AccessibilityNodeData::STATE_READONLY;
|
| @@ -493,7 +511,7 @@ TEST_F(BrowserAccessibilityTest, TestComplexHypertext) {
|
| AccessibilityNodeData link1, link1_text;
|
| link1.id = 14;
|
| link1_text.id = 16;
|
| - link1_text.name = L"blue";
|
| + link1_text.SetName(link1_text_name);
|
| link1.role = AccessibilityNodeData::ROLE_LINK;
|
| link1_text.role = AccessibilityNodeData::ROLE_STATIC_TEXT;
|
| link1.state = 1 << AccessibilityNodeData::STATE_READONLY;
|
| @@ -527,8 +545,10 @@ TEST_F(BrowserAccessibilityTest, TestComplexHypertext) {
|
|
|
| base::win::ScopedBstr text;
|
| ASSERT_EQ(S_OK, root_obj->get_text(0, text_len, text.Receive()));
|
| - const string16 embed = BrowserAccessibilityWin::kEmbeddedCharacter;
|
| - EXPECT_EQ(text1.name + embed + text2.name + embed, string16(text));
|
| + const std::string embed = base::UTF16ToUTF8(
|
| + BrowserAccessibilityWin::kEmbeddedCharacter);
|
| + EXPECT_EQ(text1_name + embed + text2_name + embed,
|
| + UTF16ToUTF8(string16(text)));
|
| text.Reset();
|
|
|
| long hyperlink_count;
|
| @@ -545,7 +565,8 @@ TEST_F(BrowserAccessibilityTest, TestComplexHypertext) {
|
| EXPECT_EQ(S_OK,
|
| hyperlink.QueryInterface<IAccessibleText>(hypertext.Receive()));
|
| EXPECT_EQ(S_OK, hypertext->get_text(0, 3, text.Receive()));
|
| - EXPECT_STREQ(L"red", text);
|
| + EXPECT_STREQ(button1_text_name.c_str(),
|
| + base::UTF16ToUTF8(string16(text)).c_str());
|
| text.Reset();
|
| hyperlink.Release();
|
| hypertext.Release();
|
| @@ -554,7 +575,8 @@ TEST_F(BrowserAccessibilityTest, TestComplexHypertext) {
|
| EXPECT_EQ(S_OK,
|
| hyperlink.QueryInterface<IAccessibleText>(hypertext.Receive()));
|
| EXPECT_EQ(S_OK, hypertext->get_text(0, 4, text.Receive()));
|
| - EXPECT_STREQ(L"blue", text);
|
| + EXPECT_STREQ(link1_text_name.c_str(),
|
| + base::UTF16ToUTF8(string16(text)).c_str());
|
| text.Reset();
|
| hyperlink.Release();
|
| hypertext.Release();
|
|
|