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

Unified Diff: ui/aura/root_window_unittest.cc

Issue 143303006: Do not set the last mouse location from synthesized event (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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/aura/root_window.cc ('k') | ui/aura/test/event_generator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/root_window_unittest.cc
diff --git a/ui/aura/root_window_unittest.cc b/ui/aura/root_window_unittest.cc
index a5a6283269af1f664d163dd7bf39e56deb298296..46bd3083cd3cbc6362e34e032a5a41c8356b7485 100644
--- a/ui/aura/root_window_unittest.cc
+++ b/ui/aura/root_window_unittest.cc
@@ -1731,4 +1731,54 @@ TEST_F(RootWindowTestInHighDPI, TouchMovesHeldOnScroll) {
filter->touch_locations()[1].ToString());
}
+class SelfDestructDelegate : public test::TestWindowDelegate {
+ public:
+ SelfDestructDelegate() {}
+ virtual ~SelfDestructDelegate() {}
+
+ virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE {
+ window_.reset();
+ }
+
+ void set_window(scoped_ptr<aura::Window> window) {
+ window_ = window.Pass();
+ }
+ bool has_window() const { return !!window_.get(); }
+
+ private:
+ scoped_ptr<aura::Window> window_;
+ DISALLOW_COPY_AND_ASSIGN(SelfDestructDelegate);
+};
+
+TEST_F(RootWindowTest, SynthesizedLocatedEvent) {
+ test::EventGenerator generator(root_window());
+ generator.MoveMouseTo(10, 10);
+ EXPECT_EQ("10,10",
+ Env::GetInstance()->last_mouse_location().ToString());
+
+ // Synthesized event should not update the moust location.
sadrul 2014/02/13 15:30:27 *mouse
oshima 2014/02/13 16:48:17 Done.
+ ui::MouseEvent mouseev(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(),
+ ui::EF_IS_SYNTHESIZED, 0);
+ generator.Dispatch(&mouseev);
+ EXPECT_EQ("10,10",
+ Env::GetInstance()->last_mouse_location().ToString());
+
+ generator.MoveMouseTo(0, 0);
+ EXPECT_EQ("0,0",
+ Env::GetInstance()->last_mouse_location().ToString());
+
+ // Make sure the location gets updated when a syntheiszed enter
+ // event destroyed the window.
+ SelfDestructDelegate delegate;
+ scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
+ &delegate, 1, gfx::Rect(50, 50, 100, 100), root_window()));
+ delegate.set_window(window.Pass());
+ EXPECT_TRUE(delegate.has_window());
+
+ generator.MoveMouseTo(100, 100);
+ EXPECT_FALSE(delegate.has_window());
+ EXPECT_EQ("100,100",
+ Env::GetInstance()->last_mouse_location().ToString());
+}
+
} // namespace aura
« no previous file with comments | « ui/aura/root_window.cc ('k') | ui/aura/test/event_generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698