OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "components/viz/hit_test/query/hit_test_query.h" | |
6 | |
7 #include "testing/gtest/include/gtest/gtest.h" | |
8 | |
9 namespace viz { | |
10 namespace hit_test { | |
11 namespace test { | |
12 | |
13 class HitTestQueryTest : public testing::Test { | |
14 public: | |
15 HitTestQueryTest() {} | |
16 ~HitTestQueryTest() override {} | |
17 | |
18 HitTestQuery hit_test_query_; | |
19 | |
20 private: | |
21 // testing::Test: | |
22 void SetUp() override {} | |
23 void TearDown() override {} | |
24 | |
25 DISALLOW_COPY_AND_ASSIGN(HitTestQueryTest); | |
26 }; | |
27 | |
28 // One embedder with a clipped child with a tab and transparent background. | |
29 // | |
30 // +e-------------+ | |
31 // | +c---------| Point maps to | |
32 // | 1 |+a--+ | ----- ------- | |
33 // | || 2 | 3 | 1 e | |
34 // | |+b--------| 2 a | |
35 // | || | 3 e ( transparent area in c ) | |
36 // | || 4 | 4 b | |
37 // +--------------+ | |
38 // | |
39 TEST_F(HitTestQueryTest, ClippedChildWithTabAndTransparentBackground) { | |
40 cc::FrameSinkId e_id = cc::FrameSinkId(1, 1); | |
41 cc::FrameSinkId c_id = cc::FrameSinkId(2, 2); | |
42 gfx::Rect e_bounds_in_e = gfx::Rect(0, 0, 600, 600); | |
43 gfx::Rect c_bounds_in_e = gfx::Rect(200, 100, 800, 800); | |
44 gfx::Rect a_bounds_in_c = gfx::Rect(0, 0, 200, 100); | |
45 gfx::Rect b_bounds_in_c = gfx::Rect(0, 100, 800, 600); | |
46 gfx::Transform transform_e_to_e, transform_a_to_c, transform_b_to_c; | |
47 gfx::Transform transform_c_to_e; | |
48 transform_c_to_e.Translate(200, 100); | |
49 std::vector<DisplayHitTestData> display_hit_test_data_list = { | |
50 {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
| |
51 {e_id, c_bounds_in_e, transform_c_to_e, 0 /* HIT_TEST_BOUND */, 2}, // c | |
52 {c_id, a_bounds_in_c, transform_a_to_c, 1 /* HIT_TEST_MINE */, 0}, // a | |
53 {c_id, b_bounds_in_c, transform_b_to_c, 1 /* HIT_TEST_MINE */, 0} // b | |
54 }; | |
55 hit_test_query_.set_display_hit_test_data_list(display_hit_test_data_list); | |
56 | |
57 // 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
| |
58 gfx::Point point1(1, 1); | |
59 gfx::Point point2(202, 102); | |
60 gfx::Point point3(403, 103); | |
61 gfx::Point point4(202, 202); | |
62 | |
63 Target target1 = hit_test_query_.FindTargetForLocation(point1); | |
64 EXPECT_EQ(e_id.ToString(), target1.id.ToString()); | |
65 EXPECT_EQ(point1.ToString(), target1.location_in_target.ToString()); | |
66 EXPECT_TRUE(target1.flags); | |
67 | |
68 Target target2 = hit_test_query_.FindTargetForLocation(point2); | |
69 EXPECT_EQ(c_id.ToString(), target2.id.ToString()); | |
70 EXPECT_EQ(gfx::Point(2, 2).ToString(), target2.location_in_target.ToString()); | |
71 EXPECT_TRUE(target2.flags); | |
72 | |
73 Target target3 = hit_test_query_.FindTargetForLocation(point3); | |
74 EXPECT_EQ(e_id.ToString(), target3.id.ToString()); | |
75 EXPECT_EQ(point3.ToString(), target3.location_in_target.ToString()); | |
76 EXPECT_TRUE(target3.flags); | |
77 | |
78 Target target4 = hit_test_query_.FindTargetForLocation(point4); | |
79 EXPECT_EQ(c_id.ToString(), target4.id.ToString()); | |
80 EXPECT_EQ(gfx::Point(2, 102).ToString(), | |
81 target4.location_in_target.ToString()); | |
82 EXPECT_TRUE(target4.flags); | |
83 } | |
84 | |
85 } // namespace test | |
86 } // namespace hit_test | |
87 } // namespace viz | |
OLD | NEW |