Commit 99c99f88 authored by Kevin Babbitt's avatar Kevin Babbitt Committed by Commit Bot

Re-enable and fix AXSystemCaretWin tests

Enable these tests to catch regressions in the system caret
accessibility object. Two changes were needed to get them passing:

- When looking for the caret at a particular point on the screen, add
the window offset to the expected position.

- One test was checking that the caret position changed when the window
position changed, including when maximizing the window. The handling
for window maximize causes our internal caret object to be re-created
on Win7 but not on Win10. The fix is to adjust the test to accept
either behavior.

Bug: 1067743
Change-Id: Ic6c0f4b7248874abb6a72c1419927e3677a8b453
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2146085Reviewed-by: default avatarNektarios Paisios <nektar@chromium.org>
Commit-Queue: Kevin Babbitt <kbabbitt@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#758919}
parent b51d02d6
...@@ -196,7 +196,7 @@ WinAccessibilityCaretEventMonitor::WinEventHookThunk(HWINEVENTHOOK handle, ...@@ -196,7 +196,7 @@ WinAccessibilityCaretEventMonitor::WinEventHookThunk(HWINEVENTHOOK handle,
} }
} // namespace } // namespace
TEST_F(AXSystemCaretWinTest, DISABLED_TestOnCaretBoundsChangeInTextField) { TEST_F(AXSystemCaretWinTest, TestOnCaretBoundsChangeInTextField) {
TextfieldTestApi textfield_test_api(textfield_); TextfieldTestApi textfield_test_api(textfield_);
Microsoft::WRL::ComPtr<IAccessible> caret_accessible; Microsoft::WRL::ComPtr<IAccessible> caret_accessible;
gfx::NativeWindow native_window = widget_->GetNativeWindow(); gfx::NativeWindow native_window = widget_->GetNativeWindow();
...@@ -205,9 +205,12 @@ TEST_F(AXSystemCaretWinTest, DISABLED_TestOnCaretBoundsChangeInTextField) { ...@@ -205,9 +205,12 @@ TEST_F(AXSystemCaretWinTest, DISABLED_TestOnCaretBoundsChangeInTextField) {
EXPECT_HRESULT_SUCCEEDED(AccessibleObjectFromWindow( EXPECT_HRESULT_SUCCEEDED(AccessibleObjectFromWindow(
hwnd, static_cast<DWORD>(OBJID_CARET), IID_PPV_ARGS(&caret_accessible))); hwnd, static_cast<DWORD>(OBJID_CARET), IID_PPV_ARGS(&caret_accessible)));
gfx::Rect window_bounds = native_window->GetBoundsInScreen();
textfield_test_api.ExecuteTextEditCommand( textfield_test_api.ExecuteTextEditCommand(
ui::TextEditCommand::MOVE_TO_BEGINNING_OF_DOCUMENT); ui::TextEditCommand::MOVE_TO_BEGINNING_OF_DOCUMENT);
gfx::Point caret_position = textfield_test_api.GetCursorViewRect().origin(); gfx::Point caret_position = textfield_test_api.GetCursorViewRect().origin() +
window_bounds.OffsetFromOrigin();
LONG x, y, width, height; LONG x, y, width, height;
EXPECT_EQ(S_OK, EXPECT_EQ(S_OK,
caret_accessible->accLocation(&x, &y, &width, &height, self_)); caret_accessible->accLocation(&x, &y, &width, &height, self_));
...@@ -217,7 +220,8 @@ TEST_F(AXSystemCaretWinTest, DISABLED_TestOnCaretBoundsChangeInTextField) { ...@@ -217,7 +220,8 @@ TEST_F(AXSystemCaretWinTest, DISABLED_TestOnCaretBoundsChangeInTextField) {
textfield_test_api.ExecuteTextEditCommand( textfield_test_api.ExecuteTextEditCommand(
ui::TextEditCommand::MOVE_TO_END_OF_DOCUMENT); ui::TextEditCommand::MOVE_TO_END_OF_DOCUMENT);
gfx::Point caret_position2 = textfield_test_api.GetCursorViewRect().origin(); gfx::Point caret_position2 = textfield_test_api.GetCursorViewRect().origin() +
window_bounds.OffsetFromOrigin();
EXPECT_NE(caret_position, caret_position2); EXPECT_NE(caret_position, caret_position2);
EXPECT_EQ(S_OK, EXPECT_EQ(S_OK,
caret_accessible->accLocation(&x, &y, &width, &height, self_)); caret_accessible->accLocation(&x, &y, &width, &height, self_));
...@@ -226,7 +230,7 @@ TEST_F(AXSystemCaretWinTest, DISABLED_TestOnCaretBoundsChangeInTextField) { ...@@ -226,7 +230,7 @@ TEST_F(AXSystemCaretWinTest, DISABLED_TestOnCaretBoundsChangeInTextField) {
EXPECT_EQ(1, width); EXPECT_EQ(1, width);
} }
TEST_F(AXSystemCaretWinTest, DISABLED_TestOnInputTypeChangeInTextField) { TEST_F(AXSystemCaretWinTest, TestOnInputTypeChangeInTextField) {
Microsoft::WRL::ComPtr<IAccessible> caret_accessible; Microsoft::WRL::ComPtr<IAccessible> caret_accessible;
gfx::NativeWindow native_window = widget_->GetNativeWindow(); gfx::NativeWindow native_window = widget_->GetNativeWindow();
ASSERT_NE(nullptr, native_window); ASSERT_NE(nullptr, native_window);
...@@ -255,7 +259,7 @@ TEST_F(AXSystemCaretWinTest, DISABLED_TestOnInputTypeChangeInTextField) { ...@@ -255,7 +259,7 @@ TEST_F(AXSystemCaretWinTest, DISABLED_TestOnInputTypeChangeInTextField) {
EXPECT_EQ(height, height2); EXPECT_EQ(height, height2);
} }
TEST_F(AXSystemCaretWinTest, DISABLED_TestMovingWindow) { TEST_F(AXSystemCaretWinTest, TestMovingWindow) {
Microsoft::WRL::ComPtr<IAccessible> caret_accessible; Microsoft::WRL::ComPtr<IAccessible> caret_accessible;
gfx::NativeWindow native_window = widget_->GetNativeWindow(); gfx::NativeWindow native_window = widget_->GetNativeWindow();
ASSERT_NE(nullptr, native_window); ASSERT_NE(nullptr, native_window);
...@@ -268,9 +272,6 @@ TEST_F(AXSystemCaretWinTest, DISABLED_TestMovingWindow) { ...@@ -268,9 +272,6 @@ TEST_F(AXSystemCaretWinTest, DISABLED_TestMovingWindow) {
widget_->SetBounds(gfx::Rect(100, 100, 500, 500)); widget_->SetBounds(gfx::Rect(100, 100, 500, 500));
LONG x2, y2, width2, height2; LONG x2, y2, width2, height2;
caret_accessible.Reset();
EXPECT_HRESULT_SUCCEEDED(AccessibleObjectFromWindow(
hwnd, static_cast<DWORD>(OBJID_CARET), IID_PPV_ARGS(&caret_accessible)));
EXPECT_EQ(S_OK, EXPECT_EQ(S_OK,
caret_accessible->accLocation(&x2, &y2, &width2, &height2, self_)); caret_accessible->accLocation(&x2, &y2, &width2, &height2, self_));
EXPECT_NE(x, x2); EXPECT_NE(x, x2);
...@@ -281,13 +282,14 @@ TEST_F(AXSystemCaretWinTest, DISABLED_TestMovingWindow) { ...@@ -281,13 +282,14 @@ TEST_F(AXSystemCaretWinTest, DISABLED_TestMovingWindow) {
// Try maximizing the window. // Try maximizing the window.
SendMessage(hwnd, WM_SYSCOMMAND, SC_MAXIMIZE, 0); SendMessage(hwnd, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
LONG x3, y3, width3, height3;
EXPECT_HRESULT_FAILED(
caret_accessible->accLocation(&x3, &y3, &width3, &height3, self_));
caret_accessible.Reset();
// On Win7, maximizing the window causes our caret object to get destroyed and
// re-created, so re-acquire it.
caret_accessible.Reset();
EXPECT_HRESULT_SUCCEEDED(AccessibleObjectFromWindow( EXPECT_HRESULT_SUCCEEDED(AccessibleObjectFromWindow(
hwnd, static_cast<DWORD>(OBJID_CARET), IID_PPV_ARGS(&caret_accessible))); hwnd, static_cast<DWORD>(OBJID_CARET), IID_PPV_ARGS(&caret_accessible)));
LONG x3, y3, width3, height3;
EXPECT_EQ(S_OK, EXPECT_EQ(S_OK,
caret_accessible->accLocation(&x3, &y3, &width3, &height3, self_)); caret_accessible->accLocation(&x3, &y3, &width3, &height3, self_));
EXPECT_NE(x2, x3); EXPECT_NE(x2, x3);
...@@ -297,7 +299,7 @@ TEST_F(AXSystemCaretWinTest, DISABLED_TestMovingWindow) { ...@@ -297,7 +299,7 @@ TEST_F(AXSystemCaretWinTest, DISABLED_TestMovingWindow) {
EXPECT_EQ(height, height3); EXPECT_EQ(height, height3);
} }
TEST_F(AXSystemCaretWinTest, DISABLED_TestCaretMSAAEvents) { TEST_F(AXSystemCaretWinTest, TestCaretMSAAEvents) {
TextfieldTestApi textfield_test_api(textfield_); TextfieldTestApi textfield_test_api(textfield_);
Microsoft::WRL::ComPtr<IAccessible> caret_accessible; Microsoft::WRL::ComPtr<IAccessible> caret_accessible;
gfx::NativeWindow native_window = widget_->GetNativeWindow(); gfx::NativeWindow native_window = widget_->GetNativeWindow();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment