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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/aura/root_window.cc ('k') | ui/aura/test/event_generator.cc » ('j') | 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/root_window.h" 5 #include "ui/aura/root_window.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 1713 matching lines...) Expand 10 before | Expand all | Expand 10 after
1724 const EventFilterRecorder::Events& events = filter->events(); 1724 const EventFilterRecorder::Events& events = filter->events();
1725 EXPECT_EQ("TOUCH_MOVED TOUCH_RELEASED GESTURE_SCROLL_END GESTURE_END", 1725 EXPECT_EQ("TOUCH_MOVED TOUCH_RELEASED GESTURE_SCROLL_END GESTURE_END",
1726 EventTypesToString(events)); 1726 EventTypesToString(events));
1727 ASSERT_EQ(2u, filter->touch_locations().size()); 1727 ASSERT_EQ(2u, filter->touch_locations().size());
1728 EXPECT_EQ(gfx::Point(-40, 10).ToString(), 1728 EXPECT_EQ(gfx::Point(-40, 10).ToString(),
1729 filter->touch_locations()[0].ToString()); 1729 filter->touch_locations()[0].ToString());
1730 EXPECT_EQ(gfx::Point(-40, 10).ToString(), 1730 EXPECT_EQ(gfx::Point(-40, 10).ToString(),
1731 filter->touch_locations()[1].ToString()); 1731 filter->touch_locations()[1].ToString());
1732 } 1732 }
1733 1733
1734 class SelfDestructDelegate : public test::TestWindowDelegate {
1735 public:
1736 SelfDestructDelegate() {}
1737 virtual ~SelfDestructDelegate() {}
1738
1739 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE {
1740 window_.reset();
1741 }
1742
1743 void set_window(scoped_ptr<aura::Window> window) {
1744 window_ = window.Pass();
1745 }
1746 bool has_window() const { return !!window_.get(); }
1747
1748 private:
1749 scoped_ptr<aura::Window> window_;
1750 DISALLOW_COPY_AND_ASSIGN(SelfDestructDelegate);
1751 };
1752
1753 TEST_F(RootWindowTest, SynthesizedLocatedEvent) {
1754 test::EventGenerator generator(root_window());
1755 generator.MoveMouseTo(10, 10);
1756 EXPECT_EQ("10,10",
1757 Env::GetInstance()->last_mouse_location().ToString());
1758
1759 // Synthesized event should not update the mouse location.
1760 ui::MouseEvent mouseev(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(),
1761 ui::EF_IS_SYNTHESIZED, 0);
1762 generator.Dispatch(&mouseev);
1763 EXPECT_EQ("10,10",
1764 Env::GetInstance()->last_mouse_location().ToString());
1765
1766 generator.MoveMouseTo(0, 0);
1767 EXPECT_EQ("0,0",
1768 Env::GetInstance()->last_mouse_location().ToString());
1769
1770 // Make sure the location gets updated when a syntheiszed enter
1771 // event destroyed the window.
1772 SelfDestructDelegate delegate;
1773 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
1774 &delegate, 1, gfx::Rect(50, 50, 100, 100), root_window()));
1775 delegate.set_window(window.Pass());
1776 EXPECT_TRUE(delegate.has_window());
1777
1778 generator.MoveMouseTo(100, 100);
1779 EXPECT_FALSE(delegate.has_window());
1780 EXPECT_EQ("100,100",
1781 Env::GetInstance()->last_mouse_location().ToString());
1782 }
1783
1734 } // namespace aura 1784 } // namespace aura
OLDNEW
« 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