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

Unified Diff: ui/views/touchui/touch_selection_controller_impl_unittest.cc

Issue 16580009: Change touch selection handles to images given by UX. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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
Index: ui/views/touchui/touch_selection_controller_impl_unittest.cc
diff --git a/ui/views/touchui/touch_selection_controller_impl_unittest.cc b/ui/views/touchui/touch_selection_controller_impl_unittest.cc
index 25fc0f19f520f328aa2f99d2d676a6e28a762cbf..f46e6b7b140b9fa8a89ca2c5c6a8d82f31d76e07 100644
--- a/ui/views/touchui/touch_selection_controller_impl_unittest.cc
+++ b/ui/views/touchui/touch_selection_controller_impl_unittest.cc
@@ -4,6 +4,8 @@
#include "base/command_line.h"
#include "base/utf_string_conversions.h"
+#include "grit/ui_resources.h"
+#include "ui/base/resource/resource_bundle.h"
#include "ui/base/touch/touch_editing_controller.h"
#include "ui/base/ui_base_switches.h"
#include "ui/gfx/point.h"
@@ -20,6 +22,21 @@
#include "ui/aura/window.h"
#endif
+namespace {
+gfx::Image* GetHandleImage() {
+ static gfx::Image* handle_image = NULL;
+ if (!handle_image) {
+ handle_image = &ui::ResourceBundle::GetSharedInstance().GetImageNamed(
+ IDR_TEXT_SELECTION_HANDLE);
+ }
+ return handle_image;
+}
+
+gfx::Size GetHandleImageSize() {
+ return GetHandleImage()->Size();
+}
+} // namespace
+
namespace views {
class TouchSelectionControllerImplTest : public ViewsTestBase {
@@ -87,7 +104,7 @@ class TouchSelectionControllerImplTest : public ViewsTestBase {
// Offset the drag position by the selection handle radius since it is
// supposed to be in the coordinate system of the handle.
- p.Offset(10, 0);
+ p.Offset(GetHandleImageSize().width() / 2, 0);
controller->SelectionHandleDragged(p);
// Do the work of OnMouseReleased().
@@ -149,8 +166,8 @@ class TouchSelectionControllerImplTest : public ViewsTestBase {
gfx::Point selection_end = GetCursorPosition(sel); \
gfx::Point sh1 = GetSelectionHandle1Position(); \
gfx::Point sh2 = GetSelectionHandle2Position(); \
- sh1.Offset(10, 0); \
- sh2.Offset(10, 0); \
+ sh1.Offset(GetHandleImageSize().width() / 2, 0); \
+ sh2.Offset(GetHandleImageSize().width() / 2, 0); \
if (cursor_at_selection_handle_1) { \
EXPECT_EQ(sh1, selection_end); \
EXPECT_EQ(sh2, selection_start); \
@@ -164,7 +181,7 @@ class TouchSelectionControllerImplTest : public ViewsTestBase {
EXPECT_TRUE(IsCursorHandleVisible()); \
gfx::Point cursor_pos = GetCursorPosition(sel); \
gfx::Point ch_pos = GetCursorHandlePosition(); \
- ch_pos.Offset(10, 0); \
+ ch_pos.Offset(GetHandleImageSize().width() / 2, 0); \
EXPECT_EQ(ch_pos, cursor_pos); \
} \
}
@@ -429,6 +446,7 @@ TEST_F(TouchSelectionControllerImplTest,
// handle is not eating the event and that the event is falling through to the
// textfield.
gfx::Point cursor_pos = GetCursorHandlePosition();
+ cursor_pos.Offset(GetHandleImageSize().width() / 2, 0);
generator.GestureTapAt(cursor_pos);
generator.GestureTapAt(cursor_pos);
EXPECT_TRUE(textfield_->HasSelection());

Powered by Google App Engine
This is Rietveld 408576698