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

Unified Diff: ui/aura/desktop_unittest.cc

Issue 8526020: aura: Track mouse button state. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 9 years, 1 month 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/desktop.cc ('k') | ui/aura/window_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/desktop_unittest.cc
diff --git a/ui/aura/desktop_unittest.cc b/ui/aura/desktop_unittest.cc
index 30e326016f0058e8e161c2807d90b1a033670e72..0556019064f68a16e1e167a89463e0ad850fd054 100644
--- a/ui/aura/desktop_unittest.cc
+++ b/ui/aura/desktop_unittest.cc
@@ -57,8 +57,7 @@ class NonClientDelegate : public TestWindowDelegate {
} // namespace
-class DesktopTest : public AuraTestBase {
-};
+typedef AuraTestBase DesktopTest;
TEST_F(DesktopTest, DispatchMouseEvent) {
// Create two non-overlapping windows so we don't have to worry about which
@@ -93,5 +92,55 @@ TEST_F(DesktopTest, DispatchMouseEvent) {
EXPECT_TRUE(delegate1->mouse_event_flags() & ui::EF_IS_NON_CLIENT);
}
+// Check that we correctly track the state of the mouse buttons in response to
+// button press and release events.
+TEST_F(DesktopTest, MouseButtonState) {
+ Desktop* desktop = Desktop::GetInstance();
+ EXPECT_FALSE(desktop->IsMouseButtonDown());
+
+ gfx::Point location;
+ scoped_ptr<MouseEvent> event;
+
+ // Press the left button.
+ event.reset(new MouseEvent(
+ ui::ET_MOUSE_PRESSED,
+ location,
+ ui::EF_LEFT_BUTTON_DOWN));
+ desktop->DispatchMouseEvent(event.get());
+ EXPECT_TRUE(desktop->IsMouseButtonDown());
+
+ // Additionally press the right.
+ event.reset(new MouseEvent(
+ ui::ET_MOUSE_PRESSED,
+ location,
+ ui::EF_LEFT_BUTTON_DOWN | ui::EF_RIGHT_BUTTON_DOWN));
+ desktop->DispatchMouseEvent(event.get());
+ EXPECT_TRUE(desktop->IsMouseButtonDown());
+
+ // Release the left button.
+ event.reset(new MouseEvent(
+ ui::ET_MOUSE_RELEASED,
+ location,
+ ui::EF_RIGHT_BUTTON_DOWN));
+ desktop->DispatchMouseEvent(event.get());
+ EXPECT_TRUE(desktop->IsMouseButtonDown());
+
+ // Release the right button. We should ignore the Shift-is-down flag.
+ event.reset(new MouseEvent(
+ ui::ET_MOUSE_RELEASED,
+ location,
+ ui::EF_SHIFT_DOWN));
+ desktop->DispatchMouseEvent(event.get());
+ EXPECT_FALSE(desktop->IsMouseButtonDown());
+
+ // Press the middle button.
+ event.reset(new MouseEvent(
+ ui::ET_MOUSE_PRESSED,
+ location,
+ ui::EF_MIDDLE_BUTTON_DOWN));
+ desktop->DispatchMouseEvent(event.get());
+ EXPECT_TRUE(desktop->IsMouseButtonDown());
+}
+
} // namespace test
} // namespace aura
« no previous file with comments | « ui/aura/desktop.cc ('k') | ui/aura/window_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698