| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "cc/input/layer_selection_bound.h" | |
| 6 | |
| 7 #include "cc/proto/layer_selection_bound.pb.h" | |
| 8 #include "testing/gtest/include/gtest/gtest.h" | |
| 9 #include "ui/gfx/geometry/point.h" | |
| 10 | |
| 11 namespace cc { | |
| 12 namespace { | |
| 13 | |
| 14 void VerifySerializeAndDeserializeProto(const LayerSelectionBound& bound1) { | |
| 15 proto::LayerSelectionBound proto; | |
| 16 bound1.ToProtobuf(&proto); | |
| 17 LayerSelectionBound bound2; | |
| 18 bound2.FromProtobuf(proto); | |
| 19 EXPECT_EQ(bound1, bound2); | |
| 20 } | |
| 21 | |
| 22 void VerifySerializeAndDeserializeLayerSelectionProto( | |
| 23 const LayerSelection& selection1) { | |
| 24 proto::LayerSelection proto; | |
| 25 LayerSelectionToProtobuf(selection1, &proto); | |
| 26 LayerSelection selection2; | |
| 27 LayerSelectionFromProtobuf(&selection2, proto); | |
| 28 EXPECT_EQ(selection1, selection2); | |
| 29 } | |
| 30 | |
| 31 TEST(LayerSelectionBoundTest, AllTypePermutations) { | |
| 32 LayerSelectionBound bound; | |
| 33 bound.type = gfx::SelectionBound::LEFT; | |
| 34 bound.edge_top = gfx::Point(3, 14); | |
| 35 bound.edge_bottom = gfx::Point(6, 28); | |
| 36 bound.layer_id = 42; | |
| 37 | |
| 38 VerifySerializeAndDeserializeProto(bound); | |
| 39 bound.type = gfx::SelectionBound::RIGHT; | |
| 40 VerifySerializeAndDeserializeProto(bound); | |
| 41 bound.type = gfx::SelectionBound::CENTER; | |
| 42 VerifySerializeAndDeserializeProto(bound); | |
| 43 bound.type = gfx::SelectionBound::EMPTY; | |
| 44 VerifySerializeAndDeserializeProto(bound); | |
| 45 } | |
| 46 | |
| 47 TEST(LayerSelectionTest, AllSelectionPermutations) { | |
| 48 LayerSelectionBound start; | |
| 49 start.type = gfx::SelectionBound::LEFT; | |
| 50 start.edge_top = gfx::Point(3, 14); | |
| 51 start.edge_bottom = gfx::Point(6, 28); | |
| 52 start.layer_id = 42; | |
| 53 | |
| 54 LayerSelectionBound end; | |
| 55 end.type = gfx::SelectionBound::RIGHT; | |
| 56 end.edge_top = gfx::Point(14, 3); | |
| 57 end.edge_bottom = gfx::Point(28, 6); | |
| 58 end.layer_id = 24; | |
| 59 | |
| 60 LayerSelection selection; | |
| 61 selection.start = start; | |
| 62 selection.end = end; | |
| 63 selection.is_editable = true; | |
| 64 selection.is_empty_text_form_control = true; | |
| 65 | |
| 66 VerifySerializeAndDeserializeLayerSelectionProto(selection); | |
| 67 selection.is_empty_text_form_control = false; | |
| 68 VerifySerializeAndDeserializeLayerSelectionProto(selection); | |
| 69 selection.is_editable = false; | |
| 70 VerifySerializeAndDeserializeLayerSelectionProto(selection); | |
| 71 selection.is_empty_text_form_control = true; | |
| 72 VerifySerializeAndDeserializeLayerSelectionProto(selection); | |
| 73 } | |
| 74 | |
| 75 } // namespace | |
| 76 } // namespace cc | |
| OLD | NEW |