Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Unified Diff: ui/accessibility/platform/ax_fake_caret_win_interactive_uitest.cc

Issue 2852763002: Added a system caret used for accessibility on Windows. (Closed)
Patch Set: Added a fake caret for accessibility. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/accessibility/platform/ax_fake_caret_win.cc ('k') | ui/base/ime/input_method_observer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/accessibility/platform/ax_fake_caret_win_interactive_uitest.cc
diff --git a/ui/accessibility/platform/ax_fake_caret_win_interactive_uitest.cc b/ui/accessibility/platform/ax_fake_caret_win_interactive_uitest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8ecfe7ce621b4c745c56a5379c0d0b5d9f553cc0
--- /dev/null
+++ b/ui/accessibility/platform/ax_fake_caret_win_interactive_uitest.cc
@@ -0,0 +1,96 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <oleacc.h>
+
+#include "base/path_service.h"
+#include "base/strings/utf_string_conversions.h"
+#include "base/win/scoped_comptr.h"
+#include "base/win/scoped_variant.h"
+#include "ui/aura/window.h"
+#include "ui/aura/window_tree_host.h"
+#include "ui/base/ime/input_method.h"
+#include "ui/base/ime/text_edit_commands.h"
+#include "ui/base/resource/resource_bundle.h"
+#include "ui/base/ui_base_paths.h"
+#include "ui/gfx/geometry/rect.h"
+#include "ui/gfx/native_widget_types.h"
+#include "ui/gl/test/gl_surface_test_support.h"
+#include "ui/views/controls/textfield/textfield.h"
+#include "ui/views/controls/textfield/textfield_test_api.h"
+#include "ui/views/test/widget_test.h"
+#include "ui/views/widget/widget.h"
+
+namespace ui {
+
+namespace {
+
+class AXFakeCaretWinTest : public views::test::WidgetTest {
+ public:
+ AXFakeCaretWinTest() {}
+ ~AXFakeCaretWinTest() override {}
+
+ void SetUp() {
+ gl::GLSurfaceTestSupport::InitializeOneOff();
dmazzoni 2017/06/15 06:00:27 Why this line?
+ RegisterPathProvider();
+ base::FilePath ui_test_pak_path;
+ ASSERT_TRUE(PathService::Get(ui::UI_TEST_PAK, &ui_test_pak_path));
+ ResourceBundle::InitSharedInstanceWithPakPath(ui_test_pak_path);
dmazzoni 2017/06/15 06:00:27 Are these lines needed? Why?
+
+ views::test::WidgetTest::SetUp();
+ }
+};
+
+} // namespace
+
+#if defined(OS_WIN)
+TEST_F(AXFakeCaretWinTest, TestOnCaretBoundsChangeInTextField) {
+ test_views_delegate()->set_use_desktop_native_widgets(true);
+ views::Widget* widget = CreateNativeDesktopWidget();
+ widget->SetBounds(gfx::Rect(0, 0, 200, 200));
+ views::Textfield* textfield = new views::Textfield();
+ textfield->SetBounds(0, 0, 200, 20);
+ textfield->SetText(base::ASCIIToUTF16("Some text."));
+ views::TextfieldTestApi textfield_test_api(textfield);
+ widget->GetRootView()->AddChildView(textfield);
+ widget->Show();
+ textfield->RequestFocus();
+ ASSERT_TRUE(widget->IsActive());
+ ASSERT_TRUE(textfield->HasFocus());
+ ASSERT_EQ(ui::TEXT_INPUT_TYPE_TEXT,
+ widget->GetInputMethod()->GetTextInputType());
+
+ base::win::ScopedComPtr<IAccessible> caret_accessible;
+ base::win::ScopedVariant self(CHILDID_SELF);
+ gfx::NativeWindow native_window = widget->GetNativeWindow();
+ ASSERT_NE(nullptr, native_window);
+ HWND hwnd = native_window->GetHost()->GetAcceleratedWidget();
+ EXPECT_HRESULT_SUCCEEDED(AccessibleObjectFromWindow(
+ hwnd, static_cast<DWORD>(OBJID_CARET), IID_IAccessible,
+ reinterpret_cast<void**>(caret_accessible.GetAddressOf())));
+
+ textfield_test_api.ExecuteTextEditCommand(
+ TextEditCommand::MOVE_TO_BEGINNING_OF_DOCUMENT);
+ gfx::Point caret_position = textfield_test_api.GetCursorViewOrigin();
+ LONG x, y, width, height;
+ EXPECT_EQ(S_OK, caret_accessible->accLocation(&x, &y, &width, &height, self));
+ EXPECT_EQ(caret_position.x(), x);
+ EXPECT_EQ(caret_position.y(), y);
+ EXPECT_EQ(1, width);
+ EXPECT_EQ(1, height);
+
+ textfield_test_api.ExecuteTextEditCommand(
+ TextEditCommand::MOVE_TO_END_OF_DOCUMENT);
+ caret_position = textfield_test_api.GetCursorViewOrigin();
dmazzoni 2017/06/15 06:00:27 It might be nice to call this caret_position2 and
+ EXPECT_EQ(S_OK, caret_accessible->accLocation(&x, &y, &width, &height, self));
+ EXPECT_EQ(caret_position.x(), x);
+ EXPECT_EQ(caret_position.y(), y);
+ EXPECT_EQ(1, width);
+ EXPECT_EQ(1, height);
+
+ widget->CloseNow();
+}
+#endif // defined(OS_WIN)
+
+} // namespace ui
« no previous file with comments | « ui/accessibility/platform/ax_fake_caret_win.cc ('k') | ui/base/ime/input_method_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698