OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <utility> | 5 #include <utility> |
6 | 6 |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "mojo/public/interfaces/bindings/tests/test_structs.mojom.h" | 8 #include "mojo/public/interfaces/bindings/tests/test_structs.mojom.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 EXPECT_FALSE(n1.Equals(n2)); | 77 EXPECT_FALSE(n1.Equals(n2)); |
78 | 78 |
79 n2->rects->resize(1); | 79 n2->rects->resize(1); |
80 (*n2->rects)[0]->width = 0; | 80 (*n2->rects)[0]->width = 0; |
81 EXPECT_FALSE(n1.Equals(n2)); | 81 EXPECT_FALSE(n1.Equals(n2)); |
82 | 82 |
83 (*n2->rects)[0] = CreateRect(); | 83 (*n2->rects)[0] = CreateRect(); |
84 EXPECT_TRUE(n1.Equals(n2)); | 84 EXPECT_TRUE(n1.Equals(n2)); |
85 } | 85 } |
86 | 86 |
87 TEST_F(EqualsTest, Map) { | |
88 auto n1(NamedRegion::New()); | |
89 n1->name.emplace("foo"); | |
90 n1->rects.emplace(); | |
91 n1->rects->push_back(CreateRect()); | |
92 | |
93 Map<std::string, NamedRegionPtr> m1; | |
94 m1.insert("foo", std::move(n1)); | |
95 | |
96 decltype(m1) m2; | |
97 EXPECT_FALSE(m1.Equals(m2)); | |
98 | |
99 m2.insert("bar", m1.at("foo").Clone()); | |
100 EXPECT_FALSE(m1.Equals(m2)); | |
101 | |
102 m2 = m1.Clone(); | |
103 m2.at("foo")->name.emplace("monkey"); | |
104 EXPECT_FALSE(m1.Equals(m2)); | |
105 | |
106 m2 = m1.Clone(); | |
107 m2.at("foo")->rects->push_back(Rect::New()); | |
108 EXPECT_FALSE(m1.Equals(m2)); | |
109 | |
110 m2.at("foo")->rects->resize(1); | |
111 (*m2.at("foo")->rects)[0]->width = 1; | |
112 EXPECT_FALSE(m1.Equals(m2)); | |
113 | |
114 m2 = m1.Clone(); | |
115 EXPECT_TRUE(m1.Equals(m2)); | |
116 } | |
117 | |
118 TEST_F(EqualsTest, InterfacePtr) { | 87 TEST_F(EqualsTest, InterfacePtr) { |
119 base::MessageLoop message_loop; | 88 base::MessageLoop message_loop; |
120 | 89 |
121 SomeInterfacePtr inf1; | 90 SomeInterfacePtr inf1; |
122 SomeInterfacePtr inf2; | 91 SomeInterfacePtr inf2; |
123 | 92 |
124 EXPECT_TRUE(inf1.Equals(inf1)); | 93 EXPECT_TRUE(inf1.Equals(inf1)); |
125 EXPECT_TRUE(inf1.Equals(inf2)); | 94 EXPECT_TRUE(inf1.Equals(inf2)); |
126 | 95 |
127 auto inf1_request = MakeRequest(&inf1); | 96 auto inf1_request = MakeRequest(&inf1); |
(...skipping 24 matching lines...) Expand all Loading... |
152 EXPECT_FALSE(req1.Equals(req2)); | 121 EXPECT_FALSE(req1.Equals(req2)); |
153 | 122 |
154 SomeInterfacePtr inf2; | 123 SomeInterfacePtr inf2; |
155 req2 = MakeRequest(&inf2); | 124 req2 = MakeRequest(&inf2); |
156 | 125 |
157 EXPECT_FALSE(req1.Equals(req2)); | 126 EXPECT_FALSE(req1.Equals(req2)); |
158 } | 127 } |
159 | 128 |
160 } // test | 129 } // test |
161 } // mojo | 130 } // mojo |
OLD | NEW |