blob: e1ad56b53b8de39b2279760fc07e3d13d02779fe (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cc/input/layer_selection_bound.h"
#include "cc/proto/layer_selection_bound.pb.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/geometry/point.h"
namespace cc {
namespace {
void VerifySerializeAndDeserializeProto(const LayerSelectionBound& bound1) {
proto::LayerSelectionBound proto;
bound1.ToProtobuf(&proto);
LayerSelectionBound bound2;
bound2.FromProtobuf(proto);
EXPECT_EQ(bound1, bound2);
}
void VerifySerializeAndDeserializeLayerSelectionProto(
const LayerSelection& selection1) {
proto::LayerSelection proto;
LayerSelectionToProtobuf(selection1, &proto);
LayerSelection selection2;
LayerSelectionFromProtobuf(&selection2, proto);
EXPECT_EQ(selection1, selection2);
}
TEST(LayerSelectionBoundTest, AllTypePermutations) {
LayerSelectionBound bound;
bound.type = SelectionBoundType::SELECTION_BOUND_LEFT;
bound.edge_top = gfx::Point(3, 14);
bound.edge_bottom = gfx::Point(6, 28);
bound.layer_id = 42;
VerifySerializeAndDeserializeProto(bound);
bound.type = SelectionBoundType::SELECTION_BOUND_RIGHT;
VerifySerializeAndDeserializeProto(bound);
bound.type = SelectionBoundType::SELECTION_BOUND_CENTER;
VerifySerializeAndDeserializeProto(bound);
bound.type = SelectionBoundType::SELECTION_BOUND_EMPTY;
VerifySerializeAndDeserializeProto(bound);
}
TEST(LayerSelectionTest, AllSelectionPermutations) {
LayerSelectionBound start;
start.type = SelectionBoundType::SELECTION_BOUND_LEFT;
start.edge_top = gfx::Point(3, 14);
start.edge_bottom = gfx::Point(6, 28);
start.layer_id = 42;
LayerSelectionBound end;
end.type = SelectionBoundType::SELECTION_BOUND_RIGHT;
end.edge_top = gfx::Point(14, 3);
end.edge_bottom = gfx::Point(28, 6);
end.layer_id = 24;
LayerSelection selection;
selection.start = start;
selection.end = end;
selection.is_editable = true;
selection.is_empty_text_form_control = true;
VerifySerializeAndDeserializeLayerSelectionProto(selection);
selection.is_empty_text_form_control = false;
VerifySerializeAndDeserializeLayerSelectionProto(selection);
selection.is_editable = false;
VerifySerializeAndDeserializeLayerSelectionProto(selection);
selection.is_empty_text_form_control = true;
VerifySerializeAndDeserializeLayerSelectionProto(selection);
}
} // namespace
} // namespace cc
|