summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-24 20:59:43 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-24 20:59:43 +0000
commitc54570e98375aaf60b87822f359bfd2b7e7ed027 (patch)
tree39547d8dbf80231352bf84f814d8b51bcc41c469 /ash
parentc54b41cb226d9f394b8a5eec80aff813ea51d71c (diff)
downloadchromium_src-c54570e98375aaf60b87822f359bfd2b7e7ed027.zip
chromium_src-c54570e98375aaf60b87822f359bfd2b7e7ed027.tar.gz
chromium_src-c54570e98375aaf60b87822f359bfd2b7e7ed027.tar.bz2
ash: Make gesture handling in the maximize button less crashy.
BUG=144003 Review URL: https://chromiumcodereview.appspot.com/10883021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@153279 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/wm/custom_frame_view_ash_unittest.cc29
-rw-r--r--ash/wm/workspace/frame_maximize_button.cc7
2 files changed, 36 insertions, 0 deletions
diff --git a/ash/wm/custom_frame_view_ash_unittest.cc b/ash/wm/custom_frame_view_ash_unittest.cc
index 3dec675..f7af09a 100644
--- a/ash/wm/custom_frame_view_ash_unittest.cc
+++ b/ash/wm/custom_frame_view_ash_unittest.cc
@@ -14,7 +14,9 @@
#include "ui/aura/aura_switches.h"
#include "ui/aura/focus_manager.h"
#include "ui/aura/test/event_generator.h"
+#include "ui/aura/root_window.h"
#include "ui/aura/window.h"
+#include "ui/base/gestures/gesture_configuration.h"
#include "ui/views/controls/button/image_button.h"
#include "ui/views/test/test_views_delegate.h"
#include "ui/views/widget/widget.h"
@@ -397,6 +399,33 @@ TEST_F(CustomFrameViewAshTest, MaximizeKeepFocus) {
EXPECT_EQ(active, window->GetFocusManager()->GetFocusedWindow());
}
+TEST_F(CustomFrameViewAshTest, MaximizeTap) {
+ views::Widget* widget = CreateWidget();
+ aura::Window* window = widget->GetNativeWindow();
+ aura::RootWindow* root_window = window->GetRootWindow();
+ CustomFrameViewAsh* frame = custom_frame_view_ash(widget);
+ CustomFrameViewAsh::TestApi test(frame);
+ ash::FrameMaximizeButton* maximize_button = test.maximize_button();
+ gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint();
+
+ const int touch_default_radius =
+ ui::GestureConfiguration::default_radius();
+ ui::GestureConfiguration::set_default_radius(0);
+
+ const int kTouchId = 2;
+ ui::TouchEvent press(ui::ET_TOUCH_PRESSED, button_pos, kTouchId,
+ base::Time::NowFromSystemTime() - base::Time());
+ root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&press);
+
+ button_pos.Offset(9, 8);
+ ui::TouchEvent release(
+ ui::ET_TOUCH_RELEASED, button_pos, kTouchId,
+ press.time_stamp() + base::TimeDelta::FromMilliseconds(50));
+ root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&release);
+
+ ui::GestureConfiguration::set_default_radius(touch_default_radius);
+}
+
// Test that only the left button will activate the maximize button.
TEST_F(CustomFrameViewAshTest, OnlyLeftButtonMaximizes) {
views::Widget* widget = CreateWidget();
diff --git a/ash/wm/workspace/frame_maximize_button.cc b/ash/wm/workspace/frame_maximize_button.cc
index 32064d2..8f8f7e8 100644
--- a/ash/wm/workspace/frame_maximize_button.cc
+++ b/ash/wm/workspace/frame_maximize_button.cc
@@ -267,6 +267,10 @@ ui::GestureStatus FrameMaximizeButton::OnGestureEvent(
if (event.type() == ui::ET_GESTURE_TAP ||
event.type() == ui::ET_GESTURE_SCROLL_END) {
+ // The position of the event may have changed from the previous event (both
+ // for TAP and SCROLL_END). So it is necessary to update the snap-state for
+ // the current event.
+ ProcessUpdateEvent(event);
if (event.type() == ui::ET_GESTURE_TAP)
snap_type_ = SnapTypeForLocation(event.location());
ProcessEndEvent(event);
@@ -276,6 +280,9 @@ ui::GestureStatus FrameMaximizeButton::OnGestureEvent(
if (is_snap_enabled_) {
if (event.type() == ui::ET_GESTURE_END &&
event.details().touch_points() == 1) {
+ // The position of the event may have changed from the previous event. So
+ // it is necessary to update the snap-state for the current event.
+ ProcessUpdateEvent(event);
snap_type_ = SnapTypeForLocation(event.location());
ProcessEndEvent(event);
return ui::GESTURE_STATUS_CONSUMED;