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 "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
6 #include "ui/gfx/geometry/r_tree.h" | 6 #include "ui/gfx/geometry/r_tree.h" |
7 #include "ui/gfx/geometry/rect.h" | 7 #include "ui/gfx/geometry/rect.h" |
8 | 8 |
9 namespace gfx { | 9 namespace gfx { |
10 | 10 |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 for (int i = 101; i <= 200; ++i) { | 244 for (int i = 101; i <= 200; ++i) { |
245 rt.Insert(Rect(0, 0, i, i), i); | 245 rt.Insert(Rect(0, 0, i, i), i); |
246 ValidateRTree(&rt); | 246 ValidateRTree(&rt); |
247 } | 247 } |
248 results.clear(); | 248 results.clear(); |
249 rt.Query(test_rect, &results); | 249 rt.Query(test_rect, &results); |
250 EXPECT_EQ(results.size(), 200U); | 250 EXPECT_EQ(results.size(), 200U); |
251 VerifyAllKeys(results); | 251 VerifyAllKeys(results); |
252 } | 252 } |
253 | 253 |
| 254 TEST_F(RTreeTest, InsertDupToRoot) { |
| 255 RTree rt(2, 5); |
| 256 rt.Insert(Rect(0, 0, 1, 2), 1); |
| 257 ValidateRTree(&rt); |
| 258 rt.Insert(Rect(0, 0, 2, 1), 1); |
| 259 ValidateRTree(&rt); |
| 260 } |
| 261 |
254 TEST_F(RTreeTest, InsertNegativeCoordsRect) { | 262 TEST_F(RTreeTest, InsertNegativeCoordsRect) { |
255 RTree rt(5, 11); | 263 RTree rt(5, 11); |
256 for (int i = 1; i <= 100; ++i) { | 264 for (int i = 1; i <= 100; ++i) { |
257 rt.Insert(Rect(-i, -i, i, i), (i * 2) - 1); | 265 rt.Insert(Rect(-i, -i, i, i), (i * 2) - 1); |
258 ValidateRTree(&rt); | 266 ValidateRTree(&rt); |
259 rt.Insert(Rect(0, 0, i, i), i * 2); | 267 rt.Insert(Rect(0, 0, i, i), i * 2); |
260 ValidateRTree(&rt); | 268 ValidateRTree(&rt); |
261 } | 269 } |
262 base::hash_set<intptr_t> results; | 270 base::hash_set<intptr_t> results; |
263 Rect test_rect(-1, -1, 2, 2); | 271 Rect test_rect(-1, -1, 2, 2); |
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
860 // d | 868 // d |
861 // | 869 // |
862 Rect test_rect_tie_breaker(3, 1, 1, 1); | 870 Rect test_rect_tie_breaker(3, 1, 1, 1); |
863 BuildExpandedRects(test_parent.get(), test_rect_tie_breaker, &expanded_rects); | 871 BuildExpandedRects(test_parent.get(), test_rect_tie_breaker, &expanded_rects); |
864 result = | 872 result = |
865 test_parent->LeastAreaEnlargement(test_rect_tie_breaker, expanded_rects); | 873 test_parent->LeastAreaEnlargement(test_rect_tie_breaker, expanded_rects); |
866 EXPECT_EQ(result->key(), 3); | 874 EXPECT_EQ(result->key(), 3); |
867 } | 875 } |
868 | 876 |
869 } // namespace gfx | 877 } // namespace gfx |
OLD | NEW |