OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include "cc/output/compositor_frame.h" | 7 #include "cc/output/compositor_frame.h" |
8 #include "cc/surfaces/surface.h" | 8 #include "cc/surfaces/surface.h" |
9 #include "cc/surfaces/surface_factory.h" | 9 #include "cc/surfaces/surface_factory.h" |
10 #include "cc/surfaces/surface_factory_client.h" | 10 #include "cc/surfaces/surface_factory_client.h" |
11 #include "cc/surfaces/surface_hittest.h" | 11 #include "cc/surfaces/surface_hittest.h" |
12 #include "cc/surfaces/surface_id_allocator.h" | 12 #include "cc/surfaces/surface_id_allocator.h" |
13 #include "cc/surfaces/surface_manager.h" | 13 #include "cc/surfaces/surface_manager.h" |
14 #include "cc/test/surface_hittest_test_helpers.h" | 14 #include "cc/test/surface_hittest_test_helpers.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 #include "third_party/skia/include/core/SkColor.h" | 16 #include "third_party/skia/include/core/SkColor.h" |
17 #include "ui/gfx/geometry/size.h" | 17 #include "ui/gfx/geometry/size.h" |
18 | 18 |
19 namespace cc { | 19 namespace cc { |
20 | 20 |
21 namespace { | 21 namespace { |
22 | 22 |
23 struct TestCase { | 23 struct TestCase { |
24 SurfaceId input_surface_id; | 24 SurfaceId input_surface_id; |
25 gfx::Point input_point; | 25 gfx::Point input_point; |
26 SurfaceId expected_output_surface_id; | 26 SurfaceId expected_compositor_frame_sink_id; |
27 gfx::Point expected_output_point; | 27 gfx::Point expected_output_point; |
28 }; | 28 }; |
29 | 29 |
30 void RunTests(SurfaceHittestDelegate* delegate, | 30 void RunTests(SurfaceHittestDelegate* delegate, |
31 SurfaceManager* manager, | 31 SurfaceManager* manager, |
32 TestCase* tests, | 32 TestCase* tests, |
33 size_t test_count) { | 33 size_t test_count) { |
34 SurfaceHittest hittest(delegate, manager); | 34 SurfaceHittest hittest(delegate, manager); |
35 for (size_t i = 0; i < test_count; ++i) { | 35 for (size_t i = 0; i < test_count; ++i) { |
36 const TestCase& test = tests[i]; | 36 const TestCase& test = tests[i]; |
37 gfx::Point point(test.input_point); | 37 gfx::Point point(test.input_point); |
38 gfx::Transform transform; | 38 gfx::Transform transform; |
39 EXPECT_EQ(test.expected_output_surface_id, | 39 EXPECT_EQ(test.expected_compositor_frame_sink_id, |
40 hittest.GetTargetSurfaceAtPoint(test.input_surface_id, point, | 40 hittest.GetTargetSurfaceAtPoint(test.input_surface_id, point, |
41 &transform)); | 41 &transform)); |
42 transform.TransformPoint(&point); | 42 transform.TransformPoint(&point); |
43 EXPECT_EQ(test.expected_output_point, point); | 43 EXPECT_EQ(test.expected_output_point, point); |
44 | 44 |
45 // Verify that GetTransformToTargetSurface returns true and returns the same | 45 // Verify that GetTransformToTargetSurface returns true and returns the same |
46 // transform as returned by GetTargetSurfaceAtPoint. | 46 // transform as returned by GetTargetSurfaceAtPoint. |
47 gfx::Transform target_transform; | 47 gfx::Transform target_transform; |
48 EXPECT_TRUE(hittest.GetTransformToTargetSurface( | 48 EXPECT_TRUE(hittest.GetTransformToTargetSurface( |
49 test.input_surface_id, test.expected_output_surface_id, | 49 test.input_surface_id, test.expected_compositor_frame_sink_id, |
50 &target_transform)); | 50 &target_transform)); |
51 EXPECT_EQ(transform, target_transform); | 51 EXPECT_EQ(transform, target_transform); |
52 } | 52 } |
53 } | 53 } |
54 | 54 |
55 } // namespace | 55 } // namespace |
56 | 56 |
57 using namespace test; | 57 using namespace test; |
58 | 58 |
59 // This test verifies that hit testing on a surface that does not exist does | 59 // This test verifies that hit testing on a surface that does not exist does |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
581 arraysize(test_expectations_with_accept_insets)); | 581 arraysize(test_expectations_with_accept_insets)); |
582 | 582 |
583 // Verify that insets have affected hit targeting. | 583 // Verify that insets have affected hit targeting. |
584 EXPECT_EQ(0, accept_delegate.reject_target_overrides()); | 584 EXPECT_EQ(0, accept_delegate.reject_target_overrides()); |
585 EXPECT_EQ(2, accept_delegate.accept_target_overrides()); | 585 EXPECT_EQ(2, accept_delegate.accept_target_overrides()); |
586 | 586 |
587 factory.Destroy(root_surface_id); | 587 factory.Destroy(root_surface_id); |
588 } | 588 } |
589 | 589 |
590 } // namespace cc | 590 } // namespace cc |
OLD | NEW |