OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "base/message_loop/message_loop.h" | 5 #include "base/message_loop/message_loop.h" |
6 #include "cc/input/selection.h" | 6 #include "cc/input/selection.h" |
7 #include "cc/ipc/traits_test_service.mojom.h" | 7 #include "cc/ipc/traits_test_service.mojom.h" |
8 #include "cc/quads/render_pass_id.h" | 8 #include "cc/quads/render_pass_id.h" |
9 #include "mojo/public/cpp/bindings/binding_set.h" | 9 #include "mojo/public/cpp/bindings/binding_set.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 return traits_test_bindings_.CreateInterfacePtrAndBind(this); | 22 return traits_test_bindings_.CreateInterfacePtrAndBind(this); |
23 } | 23 } |
24 | 24 |
25 private: | 25 private: |
26 // TraitsTestService: | 26 // TraitsTestService: |
27 void EchoBeginFrameArgs(const BeginFrameArgs& b, | 27 void EchoBeginFrameArgs(const BeginFrameArgs& b, |
28 const EchoBeginFrameArgsCallback& callback) override { | 28 const EchoBeginFrameArgsCallback& callback) override { |
29 callback.Run(b); | 29 callback.Run(b); |
30 } | 30 } |
31 | 31 |
| 32 void EchoCompositorFrameMetadata( |
| 33 const CompositorFrameMetadata& c, |
| 34 const EchoCompositorFrameMetadataCallback& callback) override { |
| 35 callback.Run(c); |
| 36 } |
| 37 |
32 void EchoRenderPassId(const RenderPassId& r, | 38 void EchoRenderPassId(const RenderPassId& r, |
33 const EchoRenderPassIdCallback& callback) override { | 39 const EchoRenderPassIdCallback& callback) override { |
34 callback.Run(r); | 40 callback.Run(r); |
35 } | 41 } |
36 | 42 |
37 void EchoReturnedResource( | 43 void EchoReturnedResource( |
38 const ReturnedResource& r, | 44 const ReturnedResource& r, |
39 const EchoReturnedResourceCallback& callback) override { | 45 const EchoReturnedResourceCallback& callback) override { |
40 callback.Run(r); | 46 callback.Run(r); |
41 } | 47 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); | 89 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); |
84 BeginFrameArgs output; | 90 BeginFrameArgs output; |
85 proxy->EchoBeginFrameArgs(input, &output); | 91 proxy->EchoBeginFrameArgs(input, &output); |
86 EXPECT_EQ(frame_time, output.frame_time); | 92 EXPECT_EQ(frame_time, output.frame_time); |
87 EXPECT_EQ(deadline, output.deadline); | 93 EXPECT_EQ(deadline, output.deadline); |
88 EXPECT_EQ(interval, output.interval); | 94 EXPECT_EQ(interval, output.interval); |
89 EXPECT_EQ(type, output.type); | 95 EXPECT_EQ(type, output.type); |
90 EXPECT_EQ(on_critical_path, output.on_critical_path); | 96 EXPECT_EQ(on_critical_path, output.on_critical_path); |
91 } | 97 } |
92 | 98 |
| 99 TEST_F(StructTraitsTest, CompositorFrameMetadata) { |
| 100 const float device_scale_factor = 2.6f; |
| 101 const gfx::Vector2dF root_scroll_offset(1234.5f, 6789.1f); |
| 102 const float page_scale_factor = 1337.5f; |
| 103 const gfx::SizeF scrollable_viewport_size(1337.7f, 1234.5f); |
| 104 const gfx::SizeF root_layer_size(1234.5f, 5432.1f); |
| 105 const float min_page_scale_factor = 3.5f; |
| 106 const float max_page_scale_factor = 4.6f; |
| 107 const bool root_overflow_x_hidden = true; |
| 108 const bool root_overflow_y_hidden = true; |
| 109 const gfx::Vector2dF location_bar_offset(1234.5f, 5432.1f); |
| 110 const gfx::Vector2dF location_bar_content_translation(1234.5f, 5432.1f); |
| 111 const uint32_t root_background_color = 1337; |
| 112 Selection<gfx::SelectionBound> selection; |
| 113 selection.start.SetEdge(gfx::PointF(1234.5f, 67891.f), |
| 114 gfx::PointF(5432.1f, 1987.6f)); |
| 115 selection.start.set_visible(true); |
| 116 selection.start.set_type(gfx::SelectionBound::CENTER); |
| 117 selection.end.SetEdge(gfx::PointF(1337.5f, 52124.f), |
| 118 gfx::PointF(1234.3f, 8765.6f)); |
| 119 selection.end.set_visible(false); |
| 120 selection.end.set_type(gfx::SelectionBound::RIGHT); |
| 121 selection.is_editable = true; |
| 122 selection.is_empty_text_form_control = true; |
| 123 ui::LatencyInfo latency_info; |
| 124 latency_info.AddLatencyNumber( |
| 125 ui::LATENCY_BEGIN_SCROLL_LISTENER_UPDATE_MAIN_COMPONENT, 1337, 7331); |
| 126 std::vector<ui::LatencyInfo> latency_infos = {latency_info}; |
| 127 std::vector<uint32_t> satisfies_sequences = {1234, 1337}; |
| 128 std::vector<SurfaceId> referenced_surfaces; |
| 129 SurfaceId id(1234, 5678, 9101112); |
| 130 referenced_surfaces.push_back(id); |
| 131 |
| 132 CompositorFrameMetadata input; |
| 133 input.device_scale_factor = device_scale_factor; |
| 134 input.root_scroll_offset = root_scroll_offset; |
| 135 input.page_scale_factor = page_scale_factor; |
| 136 input.scrollable_viewport_size = scrollable_viewport_size; |
| 137 input.root_layer_size = root_layer_size; |
| 138 input.min_page_scale_factor = min_page_scale_factor; |
| 139 input.max_page_scale_factor = max_page_scale_factor; |
| 140 input.root_overflow_x_hidden = root_overflow_x_hidden; |
| 141 input.root_overflow_y_hidden = root_overflow_y_hidden; |
| 142 input.location_bar_offset = location_bar_offset; |
| 143 input.location_bar_content_translation = location_bar_content_translation; |
| 144 input.root_background_color = root_background_color; |
| 145 input.selection = selection; |
| 146 input.latency_info = latency_infos; |
| 147 input.satisfies_sequences = satisfies_sequences; |
| 148 input.referenced_surfaces = referenced_surfaces; |
| 149 |
| 150 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); |
| 151 CompositorFrameMetadata output; |
| 152 proxy->EchoCompositorFrameMetadata(input, &output); |
| 153 EXPECT_EQ(device_scale_factor, output.device_scale_factor); |
| 154 EXPECT_EQ(root_scroll_offset, output.root_scroll_offset); |
| 155 EXPECT_EQ(page_scale_factor, output.page_scale_factor); |
| 156 EXPECT_EQ(scrollable_viewport_size, output.scrollable_viewport_size); |
| 157 EXPECT_EQ(root_layer_size, output.root_layer_size); |
| 158 EXPECT_EQ(min_page_scale_factor, output.min_page_scale_factor); |
| 159 EXPECT_EQ(max_page_scale_factor, output.max_page_scale_factor); |
| 160 EXPECT_EQ(root_overflow_x_hidden, output.root_overflow_x_hidden); |
| 161 EXPECT_EQ(root_overflow_y_hidden, output.root_overflow_y_hidden); |
| 162 EXPECT_EQ(location_bar_offset, output.location_bar_offset); |
| 163 EXPECT_EQ(location_bar_content_translation, |
| 164 output.location_bar_content_translation); |
| 165 EXPECT_EQ(root_background_color, output.root_background_color); |
| 166 EXPECT_EQ(selection, output.selection); |
| 167 EXPECT_EQ(latency_infos.size(), output.latency_info.size()); |
| 168 ui::LatencyInfo::LatencyComponent component; |
| 169 EXPECT_TRUE(output.latency_info[0].FindLatency( |
| 170 ui::LATENCY_BEGIN_SCROLL_LISTENER_UPDATE_MAIN_COMPONENT, 1337, |
| 171 &component)); |
| 172 EXPECT_EQ(7331, component.sequence_number); |
| 173 EXPECT_EQ(satisfies_sequences.size(), output.satisfies_sequences.size()); |
| 174 for (uint32_t i = 0; i < satisfies_sequences.size(); ++i) |
| 175 EXPECT_EQ(satisfies_sequences[i], output.satisfies_sequences[i]); |
| 176 EXPECT_EQ(referenced_surfaces.size(), output.referenced_surfaces.size()); |
| 177 for (uint32_t i = 0; i < referenced_surfaces.size(); ++i) |
| 178 EXPECT_EQ(referenced_surfaces[i], output.referenced_surfaces[i]); |
| 179 } |
| 180 |
93 TEST_F(StructTraitsTest, RenderPassId) { | 181 TEST_F(StructTraitsTest, RenderPassId) { |
94 const int layer_id = 1337; | 182 const int layer_id = 1337; |
95 const uint32_t index = 0xdeadbeef; | 183 const uint32_t index = 0xdeadbeef; |
96 RenderPassId input(layer_id, index); | 184 RenderPassId input(layer_id, index); |
97 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); | 185 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); |
98 RenderPassId output; | 186 RenderPassId output; |
99 proxy->EchoRenderPassId(input, &output); | 187 proxy->EchoRenderPassId(input, &output); |
100 EXPECT_EQ(layer_id, output.layer_id); | 188 EXPECT_EQ(layer_id, output.layer_id); |
101 EXPECT_EQ(index, output.index); | 189 EXPECT_EQ(index, output.index); |
102 } | 190 } |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 EXPECT_EQ(mailbox_holder.sync_token, output.mailbox_holder.sync_token); | 328 EXPECT_EQ(mailbox_holder.sync_token, output.mailbox_holder.sync_token); |
241 EXPECT_EQ(mailbox_holder.texture_target, | 329 EXPECT_EQ(mailbox_holder.texture_target, |
242 output.mailbox_holder.texture_target); | 330 output.mailbox_holder.texture_target); |
243 EXPECT_EQ(read_lock_fences_enabled, output.read_lock_fences_enabled); | 331 EXPECT_EQ(read_lock_fences_enabled, output.read_lock_fences_enabled); |
244 EXPECT_EQ(is_software, output.is_software); | 332 EXPECT_EQ(is_software, output.is_software); |
245 EXPECT_EQ(gpu_memory_buffer_id, output.gpu_memory_buffer_id.id); | 333 EXPECT_EQ(gpu_memory_buffer_id, output.gpu_memory_buffer_id.id); |
246 EXPECT_EQ(is_overlay_candidate, output.is_overlay_candidate); | 334 EXPECT_EQ(is_overlay_candidate, output.is_overlay_candidate); |
247 } | 335 } |
248 | 336 |
249 } // namespace cc | 337 } // namespace cc |
OLD | NEW |