| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "cc/test/layer_tree_json_parser.h" | 5 #include "cc/test/layer_tree_json_parser.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "cc/layers/layer.h" | 9 #include "cc/layers/layer.h" |
| 10 #include "cc/test/fake_impl_task_runner_provider.h" | 10 #include "cc/test/fake_impl_task_runner_provider.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 bool LayerTreesMatch(LayerImpl* const layer_impl, | 21 bool LayerTreesMatch(LayerImpl* const layer_impl, |
| 22 Layer* const layer) { | 22 Layer* const layer) { |
| 23 #define RETURN_IF_EXPECTATION_FAILS(exp) \ | 23 #define RETURN_IF_EXPECTATION_FAILS(exp) \ |
| 24 do { \ | 24 do { \ |
| 25 exp; \ | 25 exp; \ |
| 26 if (testing::UnitTest::GetInstance()->current_test_info()-> \ | 26 if (testing::UnitTest::GetInstance()->current_test_info()-> \ |
| 27 result()->Failed()) \ | 27 result()->Failed()) \ |
| 28 return false; \ | 28 return false; \ |
| 29 } while (0) | 29 } while (0) |
| 30 | 30 |
| 31 RETURN_IF_EXPECTATION_FAILS(EXPECT_EQ(layer_impl->children().size(), | 31 RETURN_IF_EXPECTATION_FAILS( |
| 32 layer->children().size())); | 32 EXPECT_EQ(layer_impl->test_properties()->children.size(), |
| 33 layer->children().size())); |
| 33 RETURN_IF_EXPECTATION_FAILS(EXPECT_EQ(layer_impl->bounds(), layer->bounds())); | 34 RETURN_IF_EXPECTATION_FAILS(EXPECT_EQ(layer_impl->bounds(), layer->bounds())); |
| 34 RETURN_IF_EXPECTATION_FAILS( | 35 RETURN_IF_EXPECTATION_FAILS( |
| 35 EXPECT_EQ(layer_impl->position(), layer->position())); | 36 EXPECT_EQ(layer_impl->position(), layer->position())); |
| 36 RETURN_IF_EXPECTATION_FAILS(EXPECT_TRANSFORMATION_MATRIX_EQ( | 37 RETURN_IF_EXPECTATION_FAILS(EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 37 layer_impl->transform(), layer->transform())); | 38 layer_impl->transform(), layer->transform())); |
| 38 RETURN_IF_EXPECTATION_FAILS(EXPECT_EQ(layer_impl->contents_opaque(), | 39 RETURN_IF_EXPECTATION_FAILS(EXPECT_EQ(layer_impl->contents_opaque(), |
| 39 layer->contents_opaque())); | 40 layer->contents_opaque())); |
| 40 RETURN_IF_EXPECTATION_FAILS(EXPECT_EQ(layer_impl->scrollable(), | 41 RETURN_IF_EXPECTATION_FAILS(EXPECT_EQ(layer_impl->scrollable(), |
| 41 layer->scrollable())); | 42 layer->scrollable())); |
| 42 RETURN_IF_EXPECTATION_FAILS( | 43 RETURN_IF_EXPECTATION_FAILS( |
| 43 EXPECT_FLOAT_EQ(layer_impl->Opacity(), layer->opacity())); | 44 EXPECT_FLOAT_EQ(layer_impl->Opacity(), layer->opacity())); |
| 44 RETURN_IF_EXPECTATION_FAILS( | 45 RETURN_IF_EXPECTATION_FAILS( |
| 45 EXPECT_EQ(layer_impl->touch_event_handler_region(), | 46 EXPECT_EQ(layer_impl->touch_event_handler_region(), |
| 46 layer->touch_event_handler_region())); | 47 layer->touch_event_handler_region())); |
| 47 | 48 |
| 48 for (size_t i = 0; i < layer_impl->children().size(); ++i) { | 49 for (size_t i = 0; i < layer_impl->test_properties()->children.size(); ++i) { |
| 49 RETURN_IF_EXPECTATION_FAILS(EXPECT_TRUE(LayerTreesMatch( | 50 RETURN_IF_EXPECTATION_FAILS( |
| 50 layer_impl->children()[i], layer->children()[i].get()))); | 51 EXPECT_TRUE(LayerTreesMatch(layer_impl->test_properties()->children[i], |
| 52 layer->children()[i].get()))); |
| 51 } | 53 } |
| 52 | 54 |
| 53 return true; | 55 return true; |
| 54 #undef RETURN_IF_EXPECTATION_FAILS | 56 #undef RETURN_IF_EXPECTATION_FAILS |
| 55 } | 57 } |
| 56 | 58 |
| 57 } // namespace | 59 } // namespace |
| 58 | 60 |
| 59 class LayerTreeJsonParserSanityCheck : public testing::Test { | 61 class LayerTreeJsonParserSanityCheck : public testing::Test { |
| 60 }; | 62 }; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 root_impl->AddChild(std::move(touch_layer)); | 115 root_impl->AddChild(std::move(touch_layer)); |
| 114 tree->SetRootLayer(std::move(root_impl)); | 116 tree->SetRootLayer(std::move(root_impl)); |
| 115 | 117 |
| 116 std::string json = host_impl.LayerTreeAsJson(); | 118 std::string json = host_impl.LayerTreeAsJson(); |
| 117 scoped_refptr<Layer> root = ParseTreeFromJson(json, NULL); | 119 scoped_refptr<Layer> root = ParseTreeFromJson(json, NULL); |
| 118 ASSERT_TRUE(root.get()); | 120 ASSERT_TRUE(root.get()); |
| 119 EXPECT_TRUE(LayerTreesMatch(host_impl.RootLayer(), root.get())); | 121 EXPECT_TRUE(LayerTreesMatch(host_impl.RootLayer(), root.get())); |
| 120 } | 122 } |
| 121 | 123 |
| 122 } // namespace cc | 124 } // namespace cc |
| OLD | NEW |