| 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" |
| 11 #include "cc/test/fake_layer_tree_host.h" | 11 #include "cc/test/fake_layer_tree_host.h" |
| 12 #include "cc/test/fake_layer_tree_host_impl.h" | 12 #include "cc/test/fake_layer_tree_host_impl.h" |
| 13 #include "cc/test/geometry_test_utils.h" | 13 #include "cc/test/geometry_test_utils.h" |
| 14 #include "cc/test/layer_test_common.h" |
| 14 #include "cc/test/test_task_graph_runner.h" | 15 #include "cc/test/test_task_graph_runner.h" |
| 16 #include "cc/trees/effect_node.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 18 |
| 17 namespace cc { | 19 namespace cc { |
| 18 | 20 |
| 19 namespace { | 21 namespace { |
| 20 | 22 |
| 21 bool LayerTreesMatch(LayerImpl* const layer_impl, | 23 bool LayerTreesMatch(LayerImpl* const layer_impl, |
| 22 Layer* const layer) { | 24 Layer* const layer) { |
| 23 #define RETURN_IF_EXPECTATION_FAILS(exp) \ | 25 #define RETURN_IF_EXPECTATION_FAILS(exp) \ |
| 24 do { \ | 26 do { \ |
| 25 exp; \ | 27 exp; \ |
| 26 if (testing::UnitTest::GetInstance()->current_test_info()-> \ | 28 if (testing::UnitTest::GetInstance()->current_test_info()-> \ |
| 27 result()->Failed()) \ | 29 result()->Failed()) \ |
| 28 return false; \ | 30 return false; \ |
| 29 } while (0) | 31 } while (0) |
| 30 | 32 |
| 31 RETURN_IF_EXPECTATION_FAILS( | 33 RETURN_IF_EXPECTATION_FAILS( |
| 32 EXPECT_EQ(layer_impl->test_properties()->children.size(), | 34 EXPECT_EQ(layer_impl->test_properties()->children.size(), |
| 33 layer->children().size())); | 35 layer->children().size())); |
| 34 RETURN_IF_EXPECTATION_FAILS(EXPECT_EQ(layer_impl->bounds(), layer->bounds())); | 36 RETURN_IF_EXPECTATION_FAILS(EXPECT_EQ(layer_impl->bounds(), layer->bounds())); |
| 35 RETURN_IF_EXPECTATION_FAILS( | 37 RETURN_IF_EXPECTATION_FAILS( |
| 36 EXPECT_EQ(layer_impl->position(), layer->position())); | 38 EXPECT_EQ(layer_impl->position(), layer->position())); |
| 37 RETURN_IF_EXPECTATION_FAILS(EXPECT_TRANSFORMATION_MATRIX_EQ( | 39 RETURN_IF_EXPECTATION_FAILS(EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 38 layer_impl->test_properties()->transform, layer->transform())); | 40 layer_impl->test_properties()->transform, layer->transform())); |
| 39 RETURN_IF_EXPECTATION_FAILS(EXPECT_EQ(layer_impl->contents_opaque(), | 41 RETURN_IF_EXPECTATION_FAILS(EXPECT_EQ(layer_impl->contents_opaque(), |
| 40 layer->contents_opaque())); | 42 layer->contents_opaque())); |
| 41 RETURN_IF_EXPECTATION_FAILS(EXPECT_EQ(layer_impl->scrollable(), | 43 RETURN_IF_EXPECTATION_FAILS(EXPECT_EQ(layer_impl->scrollable(), |
| 42 layer->scrollable())); | 44 layer->scrollable())); |
| 45 |
| 43 RETURN_IF_EXPECTATION_FAILS( | 46 RETURN_IF_EXPECTATION_FAILS( |
| 44 EXPECT_FLOAT_EQ(layer_impl->Opacity(), layer->opacity())); | 47 EXPECT_FLOAT_EQ(OpacityForLayer(layer_impl), layer->opacity())); |
| 45 RETURN_IF_EXPECTATION_FAILS( | 48 RETURN_IF_EXPECTATION_FAILS( |
| 46 EXPECT_EQ(layer_impl->touch_event_handler_region(), | 49 EXPECT_EQ(layer_impl->touch_event_handler_region(), |
| 47 layer->touch_event_handler_region())); | 50 layer->touch_event_handler_region())); |
| 48 | 51 |
| 49 for (size_t i = 0; i < layer_impl->test_properties()->children.size(); ++i) { | 52 for (size_t i = 0; i < layer_impl->test_properties()->children.size(); ++i) { |
| 50 RETURN_IF_EXPECTATION_FAILS( | 53 RETURN_IF_EXPECTATION_FAILS( |
| 51 EXPECT_TRUE(LayerTreesMatch(layer_impl->test_properties()->children[i], | 54 EXPECT_TRUE(LayerTreesMatch(layer_impl->test_properties()->children[i], |
| 52 layer->children()[i].get()))); | 55 layer->children()[i].get()))); |
| 53 } | 56 } |
| 54 | 57 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 tree->BuildPropertyTreesForTesting(); | 118 tree->BuildPropertyTreesForTesting(); |
| 116 | 119 |
| 117 std::string json = host_impl.LayerTreeAsJson(); | 120 std::string json = host_impl.LayerTreeAsJson(); |
| 118 scoped_refptr<Layer> root = ParseTreeFromJson(json, NULL); | 121 scoped_refptr<Layer> root = ParseTreeFromJson(json, NULL); |
| 119 ASSERT_TRUE(root.get()); | 122 ASSERT_TRUE(root.get()); |
| 120 EXPECT_TRUE(LayerTreesMatch(host_impl.active_tree()->root_layer_for_testing(), | 123 EXPECT_TRUE(LayerTreesMatch(host_impl.active_tree()->root_layer_for_testing(), |
| 121 root.get())); | 124 root.get())); |
| 122 } | 125 } |
| 123 | 126 |
| 124 } // namespace cc | 127 } // namespace cc |
| OLD | NEW |