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

Side by Side Diff: ui/aura/window_event_dispatcher_unittest.cc

Issue 387863003: aura: Do not synthesize a mouse-move event during a drag. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: test 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
« no previous file with comments | « ui/aura/window_event_dispatcher.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 "ui/aura/window_event_dispatcher.h" 5 #include "ui/aura/window_event_dispatcher.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 EXPECT_FALSE(recorder.events().empty()); 909 EXPECT_FALSE(recorder.events().empty());
910 recorder.Reset(); 910 recorder.Reset();
911 911
912 // Dispatch a synthetic mouse event when mouse events are disabled. 912 // Dispatch a synthetic mouse event when mouse events are disabled.
913 cursor_client.DisableMouseEvents(); 913 cursor_client.DisableMouseEvents();
914 DispatchEventUsingWindowDispatcher(&mouse2); 914 DispatchEventUsingWindowDispatcher(&mouse2);
915 EXPECT_TRUE(recorder.events().empty()); 915 EXPECT_TRUE(recorder.events().empty());
916 root_window()->RemovePreTargetHandler(&recorder); 916 root_window()->RemovePreTargetHandler(&recorder);
917 } 917 }
918 918
919 // Tests that a mouse-move event is not synthesized when a mouse-button is down.
920 TEST_F(WindowEventDispatcherTest, DoNotSynthesizeWhileButtonDown) {
921 EventFilterRecorder recorder;
922 test::TestWindowDelegate delegate;
923 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
924 &delegate, 1234, gfx::Rect(5, 5, 100, 100), root_window()));
925 window->Show();
926
927 window->AddPreTargetHandler(&recorder);
928 // Dispatch a non-synthetic mouse event when mouse events are enabled.
929 ui::MouseEvent mouse1(ui::ET_MOUSE_PRESSED, gfx::Point(10, 10),
930 gfx::Point(10, 10), ui::EF_LEFT_MOUSE_BUTTON,
931 ui::EF_LEFT_MOUSE_BUTTON);
932 DispatchEventUsingWindowDispatcher(&mouse1);
933 ASSERT_EQ(1u, recorder.events().size());
934 EXPECT_EQ(ui::ET_MOUSE_PRESSED, recorder.events()[0]);
935 window->RemovePreTargetHandler(&recorder);
936 recorder.Reset();
937
938 // Move |window| away from underneath the cursor.
939 root_window()->AddPreTargetHandler(&recorder);
940 window->SetBounds(gfx::Rect(30, 30, 100, 100));
941 EXPECT_TRUE(recorder.events().empty());
942 RunAllPendingInMessageLoop();
943 EXPECT_TRUE(recorder.events().empty());
944 root_window()->RemovePreTargetHandler(&recorder);
945 }
946
919 #if defined(OS_WIN) && defined(ARCH_CPU_X86) 947 #if defined(OS_WIN) && defined(ARCH_CPU_X86)
920 #define MAYBE(x) DISABLED_##x 948 #define MAYBE(x) DISABLED_##x
921 #else 949 #else
922 #define MAYBE(x) x 950 #define MAYBE(x) x
923 #endif 951 #endif
924 952
925 // Tests synthetic mouse events generated when window bounds changes such that 953 // Tests synthetic mouse events generated when window bounds changes such that
926 // the cursor previously outside the window becomes inside, or vice versa. 954 // the cursor previously outside the window becomes inside, or vice versa.
927 // Do not synthesize events if the window ignores events or is invisible. 955 // Do not synthesize events if the window ignores events or is invisible.
928 // Flaky on 32-bit Windows bots. http://crbug.com/388272 956 // Flaky on 32-bit Windows bots. http://crbug.com/388272
(...skipping 1268 matching lines...) Expand 10 before | Expand all | Expand 10 after
2197 delegate.GetMouseMotionCountsAndReset(); 2225 delegate.GetMouseMotionCountsAndReset();
2198 2226
2199 // Notify both hosts that the cursor is now hidden. This should send a single 2227 // Notify both hosts that the cursor is now hidden. This should send a single
2200 // mouse-exit event to |window|. 2228 // mouse-exit event to |window|.
2201 host()->OnCursorVisibilityChanged(false); 2229 host()->OnCursorVisibilityChanged(false);
2202 second_host->OnCursorVisibilityChanged(false); 2230 second_host->OnCursorVisibilityChanged(false);
2203 EXPECT_EQ("0 0 1", delegate.GetMouseMotionCountsAndReset()); 2231 EXPECT_EQ("0 0 1", delegate.GetMouseMotionCountsAndReset());
2204 } 2232 }
2205 2233
2206 } // namespace aura 2234 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/window_event_dispatcher.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698