Chromium Code Reviews| Index: content/browser/accessibility/accessibility_win_browsertest.cc |
| diff --git a/content/browser/accessibility/accessibility_win_browsertest.cc b/content/browser/accessibility/accessibility_win_browsertest.cc |
| index 058e033ae4e4fb959d92411fde0d05f5f6440969..90b861e693b2e23fbbe40a5c8aec6e8e0938206e 100644 |
| --- a/content/browser/accessibility/accessibility_win_browsertest.cc |
| +++ b/content/browser/accessibility/accessibility_win_browsertest.cc |
| @@ -31,11 +31,73 @@ namespace content { |
| namespace { |
| -// Helpers -------------------------------------------------------------------- |
| +class AccessibleChecker; |
| -base::win::ScopedComPtr<IAccessible> GetAccessibleFromResultVariant( |
| - IAccessible* parent, |
| - VARIANT* var) { |
| + |
| +// AccessibilityWinBrowserTest ------------------------------------------------ |
| + |
| +class AccessibilityWinBrowserTest : public ContentBrowserTest { |
| + public: |
| + AccessibilityWinBrowserTest(); |
| + virtual ~AccessibilityWinBrowserTest(); |
| + |
| + protected: |
| + void LoadInitialAccessibilityTreeFromHtml(const std::string& html); |
| + IAccessible* GetRendererAccessible(); |
| + void ExecuteScript(const std::wstring& script); |
| + |
| + static base::win::ScopedComPtr<IAccessible> |
| + AccessibilityWinBrowserTest::GetAccessibleFromVariant( |
| + IAccessible* parent, VARIANT* var); |
| + static HRESULT QueryIAccessible2(IAccessible* accessible, |
| + IAccessible2** accessible2); |
|
dmazzoni
2014/11/06 06:53:30
nit: check indentation
|
| + static void RecursiveFindNodeInAccessibilityTree(IAccessible* node, |
| + int32 expected_role, const std::wstring& expected_name, |
| + int32 depth, bool* found); |
| + static void CheckTextAtOffset(IAccessibleText* element, |
| + LONG offset, IA2TextBoundaryType boundary_type, |
| + LONG expected_start_offset, LONG expected_end_offset, |
| + const std::wstring& expected_text); |
| + static std::vector<base::win::ScopedVariant> GetAllAccessibleChildren( |
| + IAccessible* element); |
| + |
| + private: |
| + friend class AccessibleChecker; |
| + DISALLOW_COPY_AND_ASSIGN(AccessibilityWinBrowserTest); |
| +}; |
| + |
| +AccessibilityWinBrowserTest::AccessibilityWinBrowserTest() { |
| +} |
| + |
| +AccessibilityWinBrowserTest::~AccessibilityWinBrowserTest() { |
| +} |
| + |
| +void AccessibilityWinBrowserTest::LoadInitialAccessibilityTreeFromHtml( |
| + const std::string& html) { |
| + AccessibilityNotificationWaiter waiter( |
| + shell(), AccessibilityModeComplete, |
| + ui::AX_EVENT_LOAD_COMPLETE); |
| + GURL html_data_url("data:text/html," + html); |
| + NavigateToURL(shell(), html_data_url); |
| + waiter.WaitForNotification(); |
| +} |
| + |
| +// Retrieve the MSAA client accessibility object for the Render Widget Host View |
| +// of the selected tab. |
| +IAccessible* AccessibilityWinBrowserTest::GetRendererAccessible() { |
| + content::WebContents* web_contents = shell()->web_contents(); |
| + return web_contents->GetRenderWidgetHostView()->GetNativeViewAccessible(); |
| +} |
| + |
| +void AccessibilityWinBrowserTest::ExecuteScript(const std::wstring& script) { |
| + shell()->web_contents()->GetMainFrame()->ExecuteJavaScript(script); |
| +} |
| + |
| +// Static helpers ------------------------------------------------ |
| + |
| +base::win::ScopedComPtr<IAccessible> |
| + AccessibilityWinBrowserTest::GetAccessibleFromVariant( |
| + IAccessible* parent, VARIANT* var) { |
| base::win::ScopedComPtr<IAccessible> ptr; |
| switch (V_VT(var)) { |
| case VT_DISPATCH: { |
| @@ -57,9 +119,10 @@ base::win::ScopedComPtr<IAccessible> GetAccessibleFromResultVariant( |
| return ptr; |
| } |
| -HRESULT QueryIAccessible2(IAccessible* accessible, IAccessible2** accessible2) { |
| - // TODO(ctguil): For some reason querying the IAccessible2 interface from |
| - // IAccessible fails. |
| +HRESULT AccessibilityWinBrowserTest::QueryIAccessible2( |
| + IAccessible* accessible, IAccessible2** accessible2) { |
|
dmazzoni
2014/11/06 06:53:30
I like naming output parameters with an "out_" pre
|
| + // IA2 Spec dictates that IServiceProvider should be used instead of |
| + // QueryInterface when retrieving IAccessible2. |
| base::win::ScopedComPtr<IServiceProvider> service_provider; |
| HRESULT hr = accessible->QueryInterface(service_provider.Receive()); |
| return SUCCEEDED(hr) ? |
| @@ -69,11 +132,9 @@ HRESULT QueryIAccessible2(IAccessible* accessible, IAccessible2** accessible2) { |
| // Recursively search through all of the descendants reachable from an |
| // IAccessible node and return true if we find one with the given role |
| // and name. |
| -void RecursiveFindNodeInAccessibilityTree(IAccessible* node, |
| - int32 expected_role, |
| - const std::wstring& expected_name, |
| - int32 depth, |
| - bool* found) { |
| +void AccessibilityWinBrowserTest::RecursiveFindNodeInAccessibilityTree( |
| + IAccessible* node, int32 expected_role, const std::wstring& expected_name, |
| + int32 depth, bool* found) { |
| base::win::ScopedBstr name_bstr; |
| base::win::ScopedVariant childid_self(CHILDID_SELF); |
| node->get_accName(childid_self, name_bstr.Receive()); |
| @@ -95,20 +156,11 @@ void RecursiveFindNodeInAccessibilityTree(IAccessible* node, |
| return; |
| } |
| - LONG child_count = 0; |
| - HRESULT hr = node->get_accChildCount(&child_count); |
| - ASSERT_EQ(S_OK, hr); |
| - |
| - scoped_ptr<VARIANT[]> child_array(new VARIANT[child_count]); |
| - LONG obtained_count = 0; |
| - hr = AccessibleChildren( |
| - node, 0, child_count, child_array.get(), &obtained_count); |
| - ASSERT_EQ(S_OK, hr); |
| - ASSERT_EQ(child_count, obtained_count); |
| - |
| - for (int index = 0; index < obtained_count; index++) { |
| + std::vector<base::win::ScopedVariant> children = GetAllAccessibleChildren( |
| + node); |
| + for (size_t i = 0; i < children.size(); ++i) { |
| base::win::ScopedComPtr<IAccessible> child_accessible( |
| - GetAccessibleFromResultVariant(node, &child_array.get()[index])); |
| + GetAccessibleFromVariant(node, children[i].AsInput())); |
| if (child_accessible) { |
| RecursiveFindNodeInAccessibilityTree( |
| child_accessible.get(), expected_role, expected_name, depth + 1, |
| @@ -119,48 +171,51 @@ void RecursiveFindNodeInAccessibilityTree(IAccessible* node, |
| } |
| } |
| - |
| -// AccessibilityWinBrowserTest ------------------------------------------------ |
| - |
| -class AccessibilityWinBrowserTest : public ContentBrowserTest { |
| - public: |
| - AccessibilityWinBrowserTest(); |
| - virtual ~AccessibilityWinBrowserTest(); |
| - |
| - protected: |
| - void LoadInitialAccessibilityTreeFromHtml(const std::string& html); |
| - IAccessible* GetRendererAccessible(); |
| - void ExecuteScript(const std::wstring& script); |
| - |
| - private: |
| - DISALLOW_COPY_AND_ASSIGN(AccessibilityWinBrowserTest); |
| -}; |
| - |
| -AccessibilityWinBrowserTest::AccessibilityWinBrowserTest() { |
| -} |
| - |
| -AccessibilityWinBrowserTest::~AccessibilityWinBrowserTest() { |
| +// Ensures that the text and the start and end offsets retrieved using |
| +// get_textAtOffset match the expected values. |
| +void AccessibilityWinBrowserTest::CheckTextAtOffset(IAccessibleText* element, |
| + LONG offset, IA2TextBoundaryType boundary_type, |
| + LONG expected_start_offset, LONG expected_end_offset, |
| + const std::wstring& expected_text) { |
| + testing::Message message; |
| + message << "while checking for " << expected_text << " at " << |
| + expected_start_offset << '-' << expected_end_offset; |
| + SCOPED_TRACE(message); |
| + |
| + LONG start_offset = 0; |
| + LONG end_offset = 0; |
| + base::win::ScopedBstr text; |
| + HRESULT hr = element->get_textAtOffset( |
| + offset, boundary_type, |
| + &start_offset, &end_offset, text.Receive()); |
| + EXPECT_EQ(S_OK, hr); |
| + EXPECT_EQ(expected_start_offset, start_offset); |
| + EXPECT_EQ(expected_end_offset, end_offset); |
| + EXPECT_EQ(expected_text, std::wstring(text, text.Length())); |
| } |
| -void AccessibilityWinBrowserTest::LoadInitialAccessibilityTreeFromHtml( |
| - const std::string& html) { |
| - AccessibilityNotificationWaiter waiter( |
| - shell(), AccessibilityModeComplete, |
| - ui::AX_EVENT_LOAD_COMPLETE); |
| - GURL html_data_url("data:text/html," + html); |
| - NavigateToURL(shell(), html_data_url); |
| - waiter.WaitForNotification(); |
| -} |
| +std::vector<base::win::ScopedVariant> |
| + AccessibilityWinBrowserTest::GetAllAccessibleChildren( |
| + IAccessible* element) { |
| + LONG child_count = 0; |
| + HRESULT hr = element->get_accChildCount(&child_count); |
| + EXPECT_EQ(S_OK, hr); |
| + if (child_count <= 0) |
| + return std::vector<base::win::ScopedVariant>(); |
| -// Retrieve the MSAA client accessibility object for the Render Widget Host View |
| -// of the selected tab. |
| -IAccessible* AccessibilityWinBrowserTest::GetRendererAccessible() { |
| - content::WebContents* web_contents = shell()->web_contents(); |
| - return web_contents->GetRenderWidgetHostView()->GetNativeViewAccessible(); |
| -} |
| + scoped_ptr<VARIANT[]> children_array(new VARIANT[child_count]); |
| + LONG obtained_count = 0; |
| + hr = AccessibleChildren( |
| + element, 0, child_count, children_array.get(), &obtained_count); |
| + EXPECT_EQ(S_OK, hr); |
| + EXPECT_EQ(child_count, obtained_count); |
| -void AccessibilityWinBrowserTest::ExecuteScript(const std::wstring& script) { |
| - shell()->web_contents()->GetMainFrame()->ExecuteJavaScript(script); |
| + std::vector<base::win::ScopedVariant> children( |
| + static_cast<size_t>(child_count)); |
| + for (size_t i = 0; i < children.size(); i++) { |
| + children[i].Reset(children_array[i]); |
| + } |
| + return children; |
| } |
| @@ -311,7 +366,8 @@ void AccessibleChecker::CheckAccessibleRole(IAccessible* accessible) { |
| void AccessibleChecker::CheckIA2Role(IAccessible* accessible) { |
| base::win::ScopedComPtr<IAccessible2> accessible2; |
| - HRESULT hr = QueryIAccessible2(accessible, accessible2.Receive()); |
| + HRESULT hr = AccessibilityWinBrowserTest::QueryIAccessible2( |
| + accessible, accessible2.Receive()); |
| ASSERT_EQ(S_OK, hr); |
| long ia2_role = 0; |
| hr = accessible2->role(&ia2_role); |
| @@ -361,24 +417,21 @@ void AccessibleChecker::CheckAccessibleState(IAccessible* accessible) { |
| } |
| void AccessibleChecker::CheckAccessibleChildren(IAccessible* parent) { |
| - LONG child_count = 0; |
| - HRESULT hr = parent->get_accChildCount(&child_count); |
| - EXPECT_EQ(S_OK, hr); |
| + std::vector<base::win::ScopedVariant> obtained_children = |
| + AccessibilityWinBrowserTest::GetAllAccessibleChildren(parent); |
| + size_t child_count = obtained_children.size(); |
| ASSERT_EQ(child_count, children_.size()); |
| - scoped_ptr<VARIANT[]> child_array(new VARIANT[child_count]); |
| - LONG obtained_count = 0; |
| - hr = AccessibleChildren(parent, 0, child_count, |
| - child_array.get(), &obtained_count); |
| - ASSERT_EQ(S_OK, hr); |
| - ASSERT_EQ(child_count, obtained_count); |
| - |
| - VARIANT* child = child_array.get(); |
| - for (AccessibleCheckerVector::iterator child_checker = children_.begin(); |
| - child_checker != children_.end(); |
| + AccessibleCheckerVector::iterator child_checker; |
| + std::vector<base::win::ScopedVariant>::iterator child; |
| + for (child_checker = children_.begin(), |
| + child = obtained_children.begin(); |
|
dmazzoni
2014/11/06 06:53:30
I'd indent this 4 more spaces as a continuation of
|
| + child_checker != children_.end() |
| + && child != obtained_children.end(); |
|
dmazzoni
2014/11/06 06:53:30
same here - indent 4 more.
|
| ++child_checker, ++child) { |
| base::win::ScopedComPtr<IAccessible> child_accessible( |
| - GetAccessibleFromResultVariant(parent, child)); |
| + AccessibilityWinBrowserTest::GetAccessibleFromVariant(parent, |
|
dmazzoni
2014/11/06 06:53:30
It'd be more readable if you didn't need the Acces
|
| + child->AsInput())); |
|
dmazzoni
2014/11/06 06:53:30
indent 4 more
|
| ASSERT_TRUE(child_accessible.get()); |
| (*child_checker)->CheckAccessible(child_accessible); |
| } |
| @@ -753,4 +806,216 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, TestRoleGroup) { |
| document_checker.CheckAccessible(GetRendererAccessible()); |
| } |
| +IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, TestTextAtOffset) { |
|
dmazzoni
2014/11/06 06:53:30
Consider splitting this into several smaller tests
|
| + const std::wstring input_contents(L"Mozilla/5.0 (NT 6.x; WOW64) " |
| + L"WebKit (KHTML, like)."); |
| + const std::wstring textarea_contents(L"Mozilla/5.0 (NT 6.x; WOW64)\n" |
| + L"WebKit \n(KHTML, like)."); |
| + ASSERT_EQ(input_contents.size(), textarea_contents.size()); |
| + LONG contents_length = static_cast<LONG>(input_contents.size()); |
| + LoadInitialAccessibilityTreeFromHtml("<!DOCTYPE html>" |
| + "<html><body><form>" |
| + "<label for='name'>Browser name:</label>" |
| + "<input type='text' id='name' name='name' value='" |
| + "Mozilla/5.0 (NT 6.x; WOW64) WebKit " |
| + "(KHTML, like).'>" |
| + "</form><textarea rows='3' cols='60'>" |
| + "<b>Moz</b>illa/<i>5.0 (NT</i> 6.x; WOW64)<br>" |
| + "WebKit <u><br>(KHTML,</u> like)." |
| + "</textarea></body></html>"); |
| + |
| + // Retrieve the IAccessible interface for the web page. |
| + base::win::ScopedComPtr<IAccessible> document(GetRendererAccessible()); |
| + std::vector<base::win::ScopedVariant> document_children = |
| + GetAllAccessibleChildren(document); |
| + ASSERT_EQ(2, document_children.size()); |
| + |
| + base::win::ScopedComPtr<IAccessible2> form; |
| + HRESULT hr = QueryIAccessible2(GetAccessibleFromVariant( |
| + document, document_children[0].AsInput()), form.Receive()); |
| + ASSERT_EQ(S_OK, hr); |
| + std::vector<base::win::ScopedVariant> form_children = |
| + GetAllAccessibleChildren(form); |
| + ASSERT_EQ(2, form_children.size()); |
| + |
| + // Find the two edit fields (simple and text area). |
| + base::win::ScopedComPtr<IAccessible2> input; |
| + hr = QueryIAccessible2(GetAccessibleFromVariant( |
| + form, form_children[1].AsInput()), input.Receive()); |
| + ASSERT_EQ(S_OK, hr); |
| + base::win::ScopedVariant input_role; |
| + hr = input->get_accRole( |
| + base::win::ScopedVariant(CHILDID_SELF), input_role.Receive()); |
| + ASSERT_EQ(S_OK, hr); |
| + ASSERT_EQ(VT_I4, input_role.type()); |
| + |
| + base::win::ScopedComPtr<IAccessible2> textarea; |
| + hr = QueryIAccessible2(GetAccessibleFromVariant( |
| + document, document_children[1].AsInput()), textarea.Receive()); |
| + ASSERT_EQ(S_OK, hr); |
| + base::win::ScopedVariant textarea_role; |
| + hr = textarea->get_accRole( |
| + base::win::ScopedVariant(CHILDID_SELF), textarea_role.Receive()); |
| + ASSERT_EQ(S_OK, hr); |
| + ASSERT_EQ(VT_BSTR, textarea_role.type()); |
| + |
| + // Retrieve the IAccessibleText interface for both of the fields. |
| + base::win::ScopedComPtr<IAccessibleText> input_text; |
| + hr = input_text.QueryFrom(input); |
| + ASSERT_EQ(S_OK, hr); |
| + base::win::ScopedComPtr<IAccessibleText> textarea_text; |
| + hr = textarea_text.QueryFrom(textarea); |
| + ASSERT_EQ(S_OK, hr); |
| + // Set the caret on the last character. |
| + LONG caret_offset = 49; |
| + hr = input_text->setCaretOffset(49); |
| + ASSERT_EQ(S_OK, hr); |
| + hr = textarea_text->setCaretOffset(49); |
| + ASSERT_EQ(S_OK, hr); |
| + |
| + // Test invalid arguments. |
| + hr = input_text->get_textAtOffset( |
| + 0, IA2_TEXT_BOUNDARY_CHAR, NULL, NULL, NULL); |
| + EXPECT_EQ(E_INVALIDARG, hr); |
| + hr = textarea_text->get_textAtOffset( |
| + 0, IA2_TEXT_BOUNDARY_CHAR, NULL, NULL, NULL); |
| + EXPECT_EQ(E_INVALIDARG, hr); |
| + |
| + // Test invalid offset. |
| + LONG invalid_offset = -5; |
| + LONG start_offset = 0; |
| + LONG end_offset = 0; |
| + base::win::ScopedBstr text; |
| + hr = input_text->get_textAtOffset( |
| + invalid_offset, IA2_TEXT_BOUNDARY_WORD, |
| + &start_offset, &end_offset, text.Receive()); |
| + EXPECT_EQ(E_FAIL, hr); |
| + hr = textarea_text->get_textAtOffset( |
| + invalid_offset, IA2_TEXT_BOUNDARY_WORD, |
| + &start_offset, &end_offset, text.Receive()); |
| + EXPECT_EQ(E_FAIL, hr); |
| + invalid_offset = contents_length; |
| + hr = input_text->get_textAtOffset( |
| + invalid_offset, IA2_TEXT_BOUNDARY_WORD, |
| + &start_offset, &end_offset, text.Receive()); |
| + EXPECT_EQ(E_FAIL, hr); |
| + hr = textarea_text->get_textAtOffset( |
| + invalid_offset, IA2_TEXT_BOUNDARY_WORD, |
| + &start_offset, &end_offset, text.Receive()); |
| + EXPECT_EQ(E_FAIL, hr); |
| + |
| + // Test character navigation. |
| + for (LONG offset = 0; offset < contents_length; ++offset) { |
| + std::wstring expected_text(textarea_contents[offset], 1); |
| + LONG expected_start_offset = offset; |
| + LONG expected_end_offset = offset + 1; |
| + CheckTextAtOffset(input_text, offset, IA2_TEXT_BOUNDARY_CHAR, |
| + expected_start_offset, expected_end_offset, expected_text); |
| + } |
| + for (LONG offset = contents_length - 1; offset >= 0; --offset) { |
| + std::wstring expected_text(textarea_contents[offset], 1); |
| + LONG expected_start_offset = offset; |
| + LONG expected_end_offset = offset + 1; |
| + CheckTextAtOffset(textarea_text, offset, IA2_TEXT_BOUNDARY_CHAR, |
| + expected_start_offset, expected_end_offset, expected_text); |
| + } |
| + // Test special offsets. |
| + CheckTextAtOffset(input_text, IA2_TEXT_OFFSET_LENGTH, |
| + IA2_TEXT_BOUNDARY_CHAR, 49, contents_length, L"."); |
| + CheckTextAtOffset(input_text, IA2_TEXT_OFFSET_CARET, |
| + IA2_TEXT_BOUNDARY_CHAR, 49, contents_length, L"."); |
| + CheckTextAtOffset(textarea_text, IA2_TEXT_OFFSET_LENGTH, |
| + IA2_TEXT_BOUNDARY_CHAR, 49, contents_length, L"."); |
| + CheckTextAtOffset(textarea_text, IA2_TEXT_OFFSET_CARET, |
| + IA2_TEXT_BOUNDARY_CHAR, 49, contents_length, L"."); |
| + |
| + // Test word navigation. |
| + // (Imitate Firefox behavior.) |
| + // Trailing punctuation should be included as part of the previous word. |
| + CheckTextAtOffset(input_text, 0, IA2_TEXT_BOUNDARY_WORD, |
| + 0, 8, L"Mozilla/"); |
| + CheckTextAtOffset(textarea_text, 6, IA2_TEXT_BOUNDARY_WORD, |
| + 0, 8, L"Mozilla/"); |
| + // If the offset is at the punctuation, it should return |
|
dmazzoni
2014/11/06 06:53:30
Nit: no indentatino for this comment.
|
| + // the previous word. |
| + CheckTextAtOffset(textarea_text, 7, IA2_TEXT_BOUNDARY_WORD, |
| + 0, 8, L"Mozilla/"); |
| + // Numbers with a decimal point (U.S), should be treated as two words. |
| + CheckTextAtOffset(input_text, 8, IA2_TEXT_BOUNDARY_WORD, |
| + 8, 10, L"5."); |
| + CheckTextAtOffset(textarea_text, 9, IA2_TEXT_BOUNDARY_WORD, |
| + 8, 10, L"5."); |
| + // Also, trailing punctuation that occurs after empty space should not be |
| + // part of the word. ("0 " and not "0 (".) |
| + CheckTextAtOffset(input_text, 10, IA2_TEXT_BOUNDARY_WORD, |
| + 10, 12, L"0 "); |
| + CheckTextAtOffset(textarea_text, 11, IA2_TEXT_BOUNDARY_WORD, |
| + 10, 12, L"0 "); |
| + // Leading punctuation should be included with the word after it. |
| + CheckTextAtOffset(input_text, 12, IA2_TEXT_BOUNDARY_WORD, |
| + 12, 16, L"(NT "); |
| + CheckTextAtOffset(textarea_text, 15, IA2_TEXT_BOUNDARY_WORD, |
| + 12, 16, L"(NT "); |
| + // Numbers separated from letters with trailing punctuation should |
| + // behave like decimal numbers above. |
| + CheckTextAtOffset(input_text, 16, IA2_TEXT_BOUNDARY_WORD, |
| + 16, 18, L"6."); |
| + CheckTextAtOffset(textarea_text, 19, IA2_TEXT_BOUNDARY_WORD, |
| + 18, 21, L"x; "); |
| + // Words with numbers should be treated like ordinary words. |
| + CheckTextAtOffset(input_text, 24, IA2_TEXT_BOUNDARY_WORD, |
| + 21, 28, L"WOW64) "); |
| + CheckTextAtOffset(textarea_text, 26, IA2_TEXT_BOUNDARY_WORD, |
| + 21, 28, L"WOW64)\n"); |
| + // Multiple trailing empty spaces should be part of the word preceding it. |
| + CheckTextAtOffset(input_text, 30, IA2_TEXT_BOUNDARY_WORD, |
| + 28, 36, L"WebKit "); |
| + CheckTextAtOffset(textarea_text, 35, IA2_TEXT_BOUNDARY_WORD, |
| + 28, 36, L"WebKit \n"); |
| + // Test special offsets. |
| + CheckTextAtOffset(input_text, IA2_TEXT_OFFSET_LENGTH, |
| + IA2_TEXT_BOUNDARY_WORD, 44, contents_length, L"like)."); |
| + CheckTextAtOffset(input_text, IA2_TEXT_OFFSET_CARET, |
| + IA2_TEXT_BOUNDARY_WORD, 44, contents_length, L"like)."); |
| + CheckTextAtOffset(textarea_text, IA2_TEXT_OFFSET_LENGTH, |
| + IA2_TEXT_BOUNDARY_WORD, 44, contents_length, L"like)."); |
| + CheckTextAtOffset(textarea_text, IA2_TEXT_OFFSET_CARET, |
| + IA2_TEXT_BOUNDARY_WORD, 44, contents_length, L"like)."); |
| + |
| + // Test sentence navigation (not currently implemented). |
| + hr = input_text->get_textAtOffset( |
| + 5, IA2_TEXT_BOUNDARY_SENTENCE, |
| + &start_offset, &end_offset, text.Receive()); |
| + EXPECT_EQ(S_FALSE, hr); |
| + hr = textarea_text->get_textAtOffset( |
| + 25, IA2_TEXT_BOUNDARY_CHAR, |
| + &start_offset, &end_offset, text.Receive()); |
| + EXPECT_EQ(S_FALSE, hr); |
| + |
| + // Test line navigation. |
| + CheckTextAtOffset(textarea_text, 0, IA2_TEXT_BOUNDARY_LINE, |
| + 0, 28, L"Mozilla/5.0 (NT 6.x; WOW64)\n"); |
| + // If the offset is at the newline, return the line preceding it. |
| + CheckTextAtOffset(textarea_text, 35, IA2_TEXT_BOUNDARY_LINE, |
| + 28, 36, L"WebKit \n"); |
| + // Last line does not have a trailing newline. |
| + CheckTextAtOffset(textarea_text, 36, IA2_TEXT_BOUNDARY_LINE, |
| + 36, contents_length, L"(KHTML, like)."); |
| + // Test special offsets. |
| + CheckTextAtOffset(input_text, IA2_TEXT_OFFSET_LENGTH, |
| + IA2_TEXT_BOUNDARY_LINE, 36, contents_length, L"(KHTML, like)."); |
| + CheckTextAtOffset(input_text, IA2_TEXT_OFFSET_CARET, |
| + IA2_TEXT_BOUNDARY_LINE, 36, contents_length, L"(KHTML, like)."); |
| + CheckTextAtOffset(textarea_text, IA2_TEXT_OFFSET_LENGTH, |
| + IA2_TEXT_BOUNDARY_LINE, 36, contents_length, L"(KHTML, like)."); |
| + CheckTextAtOffset(textarea_text, IA2_TEXT_OFFSET_CARET, |
| + IA2_TEXT_BOUNDARY_LINE, 36, contents_length, L"(KHTML, like)."); |
| + |
| + // Return the whole of the text. |
| + CheckTextAtOffset(input_text, 0, IA2_TEXT_BOUNDARY_ALL, |
| + 0, contents_length, input_contents); |
| + CheckTextAtOffset(textarea_text, contents_length - 1, IA2_TEXT_BOUNDARY_ALL, |
| + 0, contents_length, textarea_contents); |
| +} |
| + |
| } // namespace content |