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

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: 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
Index: ui/aura/desktop_unittest.cc
diff --git a/ui/aura/desktop_unittest.cc b/ui/aura/desktop_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..cac63dbffa230a1580a9aaf9fcbf29010e0224a9
--- /dev/null
+++ b/ui/aura/desktop_unittest.cc
@@ -0,0 +1,68 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/aura/desktop.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/aura/event.h"
+#include "ui/aura/test/aura_test_base.h"
+#include "ui/aura/test/event_generator.h"
+
+namespace aura {
+namespace test {
+
+typedef AuraTestBase DesktopTest;
+
+// 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') | ui/aura/window_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698