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

Unified Diff: mojo/services/window_manager/view_target_unittest.cc

Issue 724973003: Get event targetting working for mouse events. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Move on top of the recently committed local view property stuff. Created 6 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: mojo/services/window_manager/view_target_unittest.cc
diff --git a/mojo/services/window_manager/view_target_unittest.cc b/mojo/services/window_manager/view_target_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a8d1b86107bf5fed25086777015487e61fa3aa42
--- /dev/null
+++ b/mojo/services/window_manager/view_target_unittest.cc
@@ -0,0 +1,63 @@
+// Copyright 2014 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 "mojo/services/window_manager/view_target.h"
+
+#include <set>
+
+#include "mojo/services/public/cpp/view_manager/view.h"
+#include "mojo/services/window_manager/window_manager_test_util.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/gfx/geometry/rect.h"
+
+namespace mojo {
+
+using ViewTargetTest = testing::Test;
+
+// V1
+// +-- V2
+TEST_F(ViewTargetTest, ConvertPointToTarget_Simple) {
+ TestView v1(1, gfx::Rect(20, 20, 400, 400));
+ TestView v2(2, gfx::Rect(10, 10, 350, 350));
+ v1.AddChild(&v2);
+
+ ViewTarget* t1 = v1.target();
+ ViewTarget* t2 = v2.target();
+
+ gfx::Point point1_in_t2_coords(5, 5);
+ ViewTarget::ConvertPointToTarget(t2, t1, &point1_in_t2_coords);
+ gfx::Point point1_in_t1_coords(15, 15);
+ EXPECT_EQ(point1_in_t1_coords, point1_in_t2_coords);
+
+ gfx::Point point2_in_t1_coords(5, 5);
+ ViewTarget::ConvertPointToTarget(t1, t2, &point2_in_t1_coords);
+ gfx::Point point2_in_t2_coords(-5, -5);
+ EXPECT_EQ(point2_in_t2_coords, point2_in_t1_coords);
+}
+
+// V1
+// +-- V2
+// +-- V3
+TEST_F(ViewTargetTest, ConvertPointToTarget_Medium) {
+ TestView v1(1, gfx::Rect(20, 20, 400, 400));
+ TestView v2(2, gfx::Rect(10, 10, 350, 350));
+ TestView v3(3, gfx::Rect(10, 10, 100, 100));
+ v1.AddChild(&v2);
+ v2.AddChild(&v3);
+
+ ViewTarget* t1 = v1.target();
+ ViewTarget* t3 = v3.target();
+
+ gfx::Point point1_in_t3_coords(5, 5);
+ ViewTarget::ConvertPointToTarget(t3, t1, &point1_in_t3_coords);
+ gfx::Point point1_in_t1_coords(25, 25);
+ EXPECT_EQ(point1_in_t1_coords, point1_in_t3_coords);
+
+ gfx::Point point2_in_t1_coords(5, 5);
+ ViewTarget::ConvertPointToTarget(t1, t3, &point2_in_t1_coords);
+ gfx::Point point2_in_t3_coords(-15, -15);
+ EXPECT_EQ(point2_in_t3_coords, point2_in_t1_coords);
+}
+
+} // namespace mojo

Powered by Google App Engine
This is Rietveld 408576698