Chromium Code Reviews| 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..0fde2520490915144fda2dd8b0d2365f083bf78c 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,7 +226,7 @@ TEST_F(BrowserAccessibilityTest, TestChildrenChange) { |
| text_accessible.Release(); |
| // Notify the BrowserAccessibilityManager that the text child has changed. |
| - text.name = L"new text"; |
| + text.SetName("new text"); |
| AccessibilityHostMsg_NotificationParams param; |
| param.notification_type = AccessibilityNotificationChildrenChanged; |
| param.nodes.push_back(text); |
| @@ -314,12 +315,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 +350,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 +411,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 +448,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 +477,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"; |
|
aboxhall
2013/08/07 17:16:09
Should this and the below be used on lines 564 and
dmazzoni
2013/08/07 17:48:18
Done.
|
| + 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 +507,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 +541,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; |