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

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: rebased 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
« no previous file with comments | « ui/views/touchui/touch_selection_controller_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 0eecd0344ce2d2b64721849b072902f1f09e5e11..505acd806eaaed89aca33bf7360bbcb7b6c5e913 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/strings/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,24 @@
#include "ui/aura/window.h"
#endif
+namespace {
+// Should match kSelectionHandlePadding in touch_selection_controller.
+const int kPadding = 10;
+
+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 +107,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 + kPadding, 0);
controller->SelectionHandleDragged(p);
// Do the work of OnMouseReleased().
@@ -149,8 +169,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 + kPadding, 0); \
+ sh2.Offset(GetHandleImageSize().width() / 2 + kPadding, 0); \
if (cursor_at_selection_handle_1) { \
EXPECT_EQ(sh1, selection_end); \
EXPECT_EQ(sh2, selection_start); \
@@ -164,7 +184,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 + kPadding, 0); \
EXPECT_EQ(ch_pos, cursor_pos); \
} \
}
@@ -429,6 +449,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 + kPadding, 0);
generator.GestureTapAt(cursor_pos);
generator.GestureTapAt(cursor_pos);
EXPECT_TRUE(textfield_->HasSelection());
« no previous file with comments | « ui/views/touchui/touch_selection_controller_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698