| 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 |
| 11 class RTreeTest : public ::testing::Test { | 11 class RTreeTest : public ::testing::Test { |
| 12 protected: | 12 protected: |
| 13 // Given a pointer to an RTree, traverse it and verify its internal structure | 13 // Given a pointer to an RTree, traverse it and verify that its internal |
| 14 // is consistent with the RTree semantics. | 14 // structure is consistent with RTree semantics. |
| 15 void ValidateRTree(RTree* rt) { | 15 void ValidateRTree(RTree* rt) { |
| 16 // If RTree is empty it should have an empty rectangle. | 16 // If RTree is empty it should have an empty rectangle. |
| 17 if (!rt->root_->count()) { | 17 if (!rt->root_->count()) { |
| 18 EXPECT_TRUE(rt->root_->rect().IsEmpty()); | 18 EXPECT_TRUE(rt->root_->rect().IsEmpty()); |
| 19 EXPECT_EQ(rt->root_->level(), 0); | 19 EXPECT_EQ(rt->root_->level(), 0); |
| 20 return; | 20 return; |
| 21 } | 21 } |
| 22 // Root is allowed to have fewer than min_children_ but never more than | 22 // Root is allowed to have fewer than min_children_ but never more than |
| 23 // max_children_. | 23 // max_children_. |
| 24 EXPECT_LE(rt->root_->count(), rt->max_children_); | 24 EXPECT_LE(rt->root_->count(), rt->max_children_); |
| (...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 860 // d | 860 // d |
| 861 // | 861 // |
| 862 Rect test_rect_tie_breaker(3, 1, 1, 1); | 862 Rect test_rect_tie_breaker(3, 1, 1, 1); |
| 863 BuildExpandedRects(test_parent.get(), test_rect_tie_breaker, &expanded_rects); | 863 BuildExpandedRects(test_parent.get(), test_rect_tie_breaker, &expanded_rects); |
| 864 result = | 864 result = |
| 865 test_parent->LeastAreaEnlargement(test_rect_tie_breaker, expanded_rects); | 865 test_parent->LeastAreaEnlargement(test_rect_tie_breaker, expanded_rects); |
| 866 EXPECT_EQ(result->key(), 3); | 866 EXPECT_EQ(result->key(), 3); |
| 867 } | 867 } |
| 868 | 868 |
| 869 } // namespace gfx | 869 } // namespace gfx |
| OLD | NEW |