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

Side by Side Diff: ui/events/event_unittest.cc

Issue 398393003: Require a mouse button release event before counting a press event as a new click. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« ui/events/event.cc ('K') | « ui/events/event.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "testing/gtest/include/gtest/gtest.h" 6 #include "testing/gtest/include/gtest/gtest.h"
7 #include "ui/events/event.h" 7 #include "ui/events/event.h"
8 #include "ui/events/event_utils.h" 8 #include "ui/events/event_utils.h"
9 #include "ui/events/keycodes/dom4/keycode_converter.h" 9 #include "ui/events/keycodes/dom4/keycode_converter.h"
10 #include "ui/events/test/events_test_utils.h" 10 #include "ui/events/test/events_test_utils.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 EXPECT_FALSE(MouseEvent::IsRepeatedClickEvent(mouse_ev1, mouse_ev2)); 91 EXPECT_FALSE(MouseEvent::IsRepeatedClickEvent(mouse_ev1, mouse_ev2));
92 92
93 // Too long a time between clicks. 93 // Too long a time between clicks.
94 test_ev1.set_location(gfx::Point(0, 0)); 94 test_ev1.set_location(gfx::Point(0, 0));
95 test_ev2.set_location(gfx::Point(0, 0)); 95 test_ev2.set_location(gfx::Point(0, 0));
96 test_ev1.set_time_stamp(start); 96 test_ev1.set_time_stamp(start);
97 test_ev2.set_time_stamp(later); 97 test_ev2.set_time_stamp(later);
98 EXPECT_FALSE(MouseEvent::IsRepeatedClickEvent(mouse_ev1, mouse_ev2)); 98 EXPECT_FALSE(MouseEvent::IsRepeatedClickEvent(mouse_ev1, mouse_ev2));
99 } 99 }
100 100
101 // Tests that an event only increases the click count and gets marked as a
102 // double click if a release event was seen for the previous click. This
103 // prevents the same PRESSED event from being processed twice:
104 // http://crbug.com/389162
105 TEST(EventTest, DoubleClickRequiresRelease) {
106 const gfx::Point origin1(0, 0);
107 const gfx::Point origin2(100, 0);
108 scoped_ptr<MouseEvent> ev;
109
110 ev.reset(new MouseEvent(ET_MOUSE_PRESSED, origin1, origin1, 0, 0));
111 EXPECT_EQ(1, MouseEvent::GetRepeatCount(*ev));
112 ev.reset(new MouseEvent(ET_MOUSE_PRESSED, origin1, origin1, 0, 0));
113 EXPECT_EQ(1, MouseEvent::GetRepeatCount(*ev));
114
115 ev.reset(new MouseEvent(ET_MOUSE_PRESSED, origin2, origin2, 0, 0));
116 EXPECT_EQ(1, MouseEvent::GetRepeatCount(*ev));
117 ev.reset(new MouseEvent(ET_MOUSE_RELEASED, origin2, origin2, 0, 0));
118 EXPECT_EQ(1, MouseEvent::GetRepeatCount(*ev));
119 ev.reset(new MouseEvent(ET_MOUSE_PRESSED, origin2, origin2, 0, 0));
120 EXPECT_EQ(2, MouseEvent::GetRepeatCount(*ev));
121 }
122
101 TEST(EventTest, KeyEvent) { 123 TEST(EventTest, KeyEvent) {
102 static const struct { 124 static const struct {
103 KeyboardCode key_code; 125 KeyboardCode key_code;
104 int flags; 126 int flags;
105 uint16 character; 127 uint16 character;
106 } kTestData[] = { 128 } kTestData[] = {
107 { VKEY_A, 0, 'a' }, 129 { VKEY_A, 0, 'a' },
108 { VKEY_A, EF_SHIFT_DOWN, 'A' }, 130 { VKEY_A, EF_SHIFT_DOWN, 'A' },
109 { VKEY_A, EF_CAPS_LOCK_DOWN, 'A' }, 131 { VKEY_A, EF_CAPS_LOCK_DOWN, 'A' },
110 { VKEY_A, EF_SHIFT_DOWN | EF_CAPS_LOCK_DOWN, 'a' }, 132 { VKEY_A, EF_SHIFT_DOWN | EF_CAPS_LOCK_DOWN, 'a' },
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 EXPECT_FALSE(key_a4_pressed.IsRepeat()); 409 EXPECT_FALSE(key_a4_pressed.IsRepeat());
388 410
389 KeyEvent key_a4_pressed_nonstandard_state( 411 KeyEvent key_a4_pressed_nonstandard_state(
390 native_event_a_pressed_nonstandard_state, false); 412 native_event_a_pressed_nonstandard_state, false);
391 EXPECT_FALSE(key_a4_pressed_nonstandard_state.IsRepeat()); 413 EXPECT_FALSE(key_a4_pressed_nonstandard_state.IsRepeat());
392 #endif 414 #endif
393 } 415 }
394 #endif // USE_X11 || OS_WIN 416 #endif // USE_X11 || OS_WIN
395 417
396 } // namespace ui 418 } // namespace ui
OLDNEW
« ui/events/event.cc ('K') | « ui/events/event.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698