| 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/debug_border_draw_quad.h" |
| 9 #include "cc/quads/render_pass.h" |
| 8 #include "cc/quads/render_pass_id.h" | 10 #include "cc/quads/render_pass_id.h" |
| 11 #include "cc/quads/solid_color_draw_quad.h" |
| 9 #include "mojo/public/cpp/bindings/binding_set.h" | 12 #include "mojo/public/cpp/bindings/binding_set.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "third_party/skia/include/core/SkString.h" | 14 #include "third_party/skia/include/core/SkString.h" |
| 12 #include "third_party/skia/include/effects/SkDropShadowImageFilter.h" | 15 #include "third_party/skia/include/effects/SkDropShadowImageFilter.h" |
| 13 | 16 |
| 14 namespace cc { | 17 namespace cc { |
| 15 | 18 |
| 16 namespace { | 19 namespace { |
| 17 | 20 |
| 18 class StructTraitsTest : public testing::Test, public mojom::TraitsTestService { | 21 class StructTraitsTest : public testing::Test, public mojom::TraitsTestService { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 42 const EchoFilterOperationCallback& callback) override { | 45 const EchoFilterOperationCallback& callback) override { |
| 43 callback.Run(f); | 46 callback.Run(f); |
| 44 } | 47 } |
| 45 | 48 |
| 46 void EchoFilterOperations( | 49 void EchoFilterOperations( |
| 47 const FilterOperations& f, | 50 const FilterOperations& f, |
| 48 const EchoFilterOperationsCallback& callback) override { | 51 const EchoFilterOperationsCallback& callback) override { |
| 49 callback.Run(f); | 52 callback.Run(f); |
| 50 } | 53 } |
| 51 | 54 |
| 55 void EchoQuadList(const QuadList& q, |
| 56 const EchoQuadListCallback& callback) override { |
| 57 callback.Run(q); |
| 58 } |
| 59 |
| 52 void EchoRenderPassId(const RenderPassId& r, | 60 void EchoRenderPassId(const RenderPassId& r, |
| 53 const EchoRenderPassIdCallback& callback) override { | 61 const EchoRenderPassIdCallback& callback) override { |
| 54 callback.Run(r); | 62 callback.Run(r); |
| 55 } | 63 } |
| 56 | 64 |
| 57 void EchoReturnedResource( | 65 void EchoReturnedResource( |
| 58 const ReturnedResource& r, | 66 const ReturnedResource& r, |
| 59 const EchoReturnedResourceCallback& callback) override { | 67 const EchoReturnedResourceCallback& callback) override { |
| 60 callback.Run(r); | 68 callback.Run(r); |
| 61 } | 69 } |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 input.Append(FilterOperation::CreateZoomFilter(2.0f, 1)); | 268 input.Append(FilterOperation::CreateZoomFilter(2.0f, 1)); |
| 261 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); | 269 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); |
| 262 FilterOperations output; | 270 FilterOperations output; |
| 263 proxy->EchoFilterOperations(input, &output); | 271 proxy->EchoFilterOperations(input, &output); |
| 264 EXPECT_EQ(input.size(), output.size()); | 272 EXPECT_EQ(input.size(), output.size()); |
| 265 for (size_t i = 0; i < input.size(); ++i) { | 273 for (size_t i = 0; i < input.size(); ++i) { |
| 266 EXPECT_EQ(input.at(i), output.at(i)); | 274 EXPECT_EQ(input.at(i), output.at(i)); |
| 267 } | 275 } |
| 268 } | 276 } |
| 269 | 277 |
| 278 TEST_F(StructTraitsTest, QuadList) { |
| 279 const DrawQuad::Material material1 = DrawQuad::DEBUG_BORDER; |
| 280 const DrawQuad::Material material2 = DrawQuad::SOLID_COLOR; |
| 281 const gfx::Rect rect1(1234, 4321, 1357, 7531); |
| 282 const gfx::Rect rect2(2468, 8642, 4321, 1234); |
| 283 const int32_t width1 = 1337; |
| 284 const uint32_t color2 = 0xffffffff; |
| 285 |
| 286 QuadList input; |
| 287 DebugBorderDrawQuad* debug_quad = |
| 288 input.AllocateAndConstruct<DebugBorderDrawQuad>(); |
| 289 debug_quad->material = material1; |
| 290 debug_quad->rect = rect1; |
| 291 debug_quad->width = width1; |
| 292 |
| 293 SolidColorDrawQuad* solid_quad = |
| 294 input.AllocateAndConstruct<SolidColorDrawQuad>(); |
| 295 solid_quad->material = material2; |
| 296 solid_quad->rect = rect2; |
| 297 solid_quad->color = color2; |
| 298 |
| 299 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); |
| 300 QuadList output; |
| 301 proxy->EchoQuadList(input, &output); |
| 302 |
| 303 ASSERT_EQ(input.size(), output.size()); |
| 304 |
| 305 ASSERT_EQ(material1, output.ElementAt(0)->material); |
| 306 EXPECT_EQ(rect1, output.ElementAt(0)->rect); |
| 307 EXPECT_EQ(width1, |
| 308 static_cast<DebugBorderDrawQuad*>(output.ElementAt(0))->width); |
| 309 |
| 310 ASSERT_EQ(material2, output.ElementAt(1)->material); |
| 311 EXPECT_EQ(rect2, output.ElementAt(1)->rect); |
| 312 EXPECT_EQ(color2, |
| 313 static_cast<SolidColorDrawQuad*>(output.ElementAt(1))->color); |
| 314 } |
| 315 |
| 270 TEST_F(StructTraitsTest, RenderPassId) { | 316 TEST_F(StructTraitsTest, RenderPassId) { |
| 271 const int layer_id = 1337; | 317 const int layer_id = 1337; |
| 272 const uint32_t index = 0xdeadbeef; | 318 const uint32_t index = 0xdeadbeef; |
| 273 RenderPassId input(layer_id, index); | 319 RenderPassId input(layer_id, index); |
| 274 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); | 320 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); |
| 275 RenderPassId output; | 321 RenderPassId output; |
| 276 proxy->EchoRenderPassId(input, &output); | 322 proxy->EchoRenderPassId(input, &output); |
| 277 EXPECT_EQ(layer_id, output.layer_id); | 323 EXPECT_EQ(layer_id, output.layer_id); |
| 278 EXPECT_EQ(index, output.index); | 324 EXPECT_EQ(index, output.index); |
| 279 } | 325 } |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 EXPECT_EQ(mailbox_holder.sync_token, output.mailbox_holder.sync_token); | 474 EXPECT_EQ(mailbox_holder.sync_token, output.mailbox_holder.sync_token); |
| 429 EXPECT_EQ(mailbox_holder.texture_target, | 475 EXPECT_EQ(mailbox_holder.texture_target, |
| 430 output.mailbox_holder.texture_target); | 476 output.mailbox_holder.texture_target); |
| 431 EXPECT_EQ(read_lock_fences_enabled, output.read_lock_fences_enabled); | 477 EXPECT_EQ(read_lock_fences_enabled, output.read_lock_fences_enabled); |
| 432 EXPECT_EQ(is_software, output.is_software); | 478 EXPECT_EQ(is_software, output.is_software); |
| 433 EXPECT_EQ(gpu_memory_buffer_id, output.gpu_memory_buffer_id.id); | 479 EXPECT_EQ(gpu_memory_buffer_id, output.gpu_memory_buffer_id.id); |
| 434 EXPECT_EQ(is_overlay_candidate, output.is_overlay_candidate); | 480 EXPECT_EQ(is_overlay_candidate, output.is_overlay_candidate); |
| 435 } | 481 } |
| 436 | 482 |
| 437 } // namespace cc | 483 } // namespace cc |
| OLD | NEW |