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

Unified Diff: components/viz/hit_test/query/hit_test_query_unittest.cc

Issue 2933493003: Add viz-host HitTestQuery. (Closed)
Patch Set: Created 3 years, 6 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
Index: components/viz/hit_test/query/hit_test_query_unittest.cc
diff --git a/components/viz/hit_test/query/hit_test_query_unittest.cc b/components/viz/hit_test/query/hit_test_query_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..27870c6cd0927a46d764ac74c56b2950187cd0d1
--- /dev/null
+++ b/components/viz/hit_test/query/hit_test_query_unittest.cc
@@ -0,0 +1,87 @@
+// Copyright 2017 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 "components/viz/hit_test/query/hit_test_query.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace viz {
+namespace hit_test {
+namespace test {
+
+class HitTestQueryTest : public testing::Test {
+ public:
+ HitTestQueryTest() {}
+ ~HitTestQueryTest() override {}
+
+ HitTestQuery hit_test_query_;
+
+ private:
+ // testing::Test:
+ void SetUp() override {}
+ void TearDown() override {}
+
+ DISALLOW_COPY_AND_ASSIGN(HitTestQueryTest);
+};
+
+// One embedder with a clipped child with a tab and transparent background.
+//
+// +e-------------+
+// | +c---------| Point maps to
+// | 1 |+a--+ | ----- -------
+// | || 2 | 3 | 1 e
+// | |+b--------| 2 a
+// | || | 3 e ( transparent area in c )
+// | || 4 | 4 b
+// +--------------+
+//
+TEST_F(HitTestQueryTest, ClippedChildWithTabAndTransparentBackground) {
+ cc::FrameSinkId e_id = cc::FrameSinkId(1, 1);
+ cc::FrameSinkId c_id = cc::FrameSinkId(2, 2);
+ gfx::Rect e_bounds_in_e = gfx::Rect(0, 0, 600, 600);
+ gfx::Rect c_bounds_in_e = gfx::Rect(200, 100, 800, 800);
+ gfx::Rect a_bounds_in_c = gfx::Rect(0, 0, 200, 100);
+ gfx::Rect b_bounds_in_c = gfx::Rect(0, 100, 800, 600);
+ gfx::Transform transform_e_to_e, transform_a_to_c, transform_b_to_c;
+ gfx::Transform transform_c_to_e;
+ transform_c_to_e.Translate(200, 100);
+ std::vector<DisplayHitTestData> display_hit_test_data_list = {
+ {e_id, e_bounds_in_e, transform_e_to_e, 1 /* HIT_TEST_MINE */, 3}, // e
rjkroege 2017/06/12 17:17:24 realistic transforms?
riajiang 2017/06/13 18:42:30 In this case, bounds of e and c are in the coordin
+ {e_id, c_bounds_in_e, transform_c_to_e, 0 /* HIT_TEST_BOUND */, 2}, // c
+ {c_id, a_bounds_in_c, transform_a_to_c, 1 /* HIT_TEST_MINE */, 0}, // a
+ {c_id, b_bounds_in_c, transform_b_to_c, 1 /* HIT_TEST_MINE */, 0} // b
+ };
+ hit_test_query_.set_display_hit_test_data_list(display_hit_test_data_list);
+
+ // All points are in display coordinate systems.
rjkroege 2017/06/12 17:17:24 need to be in their respective coordinate systes.
riajiang 2017/06/13 18:42:30 I thought that when the point first comes in, they
+ gfx::Point point1(1, 1);
+ gfx::Point point2(202, 102);
+ gfx::Point point3(403, 103);
+ gfx::Point point4(202, 202);
+
+ Target target1 = hit_test_query_.FindTargetForLocation(point1);
+ EXPECT_EQ(e_id.ToString(), target1.id.ToString());
+ EXPECT_EQ(point1.ToString(), target1.location_in_target.ToString());
+ EXPECT_TRUE(target1.flags);
+
+ Target target2 = hit_test_query_.FindTargetForLocation(point2);
+ EXPECT_EQ(c_id.ToString(), target2.id.ToString());
+ EXPECT_EQ(gfx::Point(2, 2).ToString(), target2.location_in_target.ToString());
+ EXPECT_TRUE(target2.flags);
+
+ Target target3 = hit_test_query_.FindTargetForLocation(point3);
+ EXPECT_EQ(e_id.ToString(), target3.id.ToString());
+ EXPECT_EQ(point3.ToString(), target3.location_in_target.ToString());
+ EXPECT_TRUE(target3.flags);
+
+ Target target4 = hit_test_query_.FindTargetForLocation(point4);
+ EXPECT_EQ(c_id.ToString(), target4.id.ToString());
+ EXPECT_EQ(gfx::Point(2, 102).ToString(),
+ target4.location_in_target.ToString());
+ EXPECT_TRUE(target4.flags);
+}
+
+} // namespace test
+} // namespace hit_test
+} // namespace viz

Powered by Google App Engine
This is Rietveld 408576698