OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <map> | 5 #include <map> |
6 | 6 |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "testing/gmock/include/gmock/gmock.h" | 9 #include "testing/gmock/include/gmock/gmock.h" |
10 #include "ui/base/clipboard/clipboard.h" | 10 #include "ui/base/clipboard/clipboard.h" |
(...skipping 2093 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2104 ASSERT_EQ(-1, child1->GetIndexOf(child2)); | 2104 ASSERT_EQ(-1, child1->GetIndexOf(child2)); |
2105 ASSERT_EQ(0, child1->GetIndexOf(foo1)); | 2105 ASSERT_EQ(0, child1->GetIndexOf(foo1)); |
2106 | 2106 |
2107 ASSERT_EQ(-1, child2->GetIndexOf(NULL)); | 2107 ASSERT_EQ(-1, child2->GetIndexOf(NULL)); |
2108 ASSERT_EQ(-1, child2->GetIndexOf(&root)); | 2108 ASSERT_EQ(-1, child2->GetIndexOf(&root)); |
2109 ASSERT_EQ(-1, child2->GetIndexOf(child2)); | 2109 ASSERT_EQ(-1, child2->GetIndexOf(child2)); |
2110 ASSERT_EQ(-1, child2->GetIndexOf(child1)); | 2110 ASSERT_EQ(-1, child2->GetIndexOf(child1)); |
2111 ASSERT_EQ(-1, child2->GetIndexOf(foo1)); | 2111 ASSERT_EQ(-1, child2->GetIndexOf(foo1)); |
2112 } | 2112 } |
2113 | 2113 |
2114 // Verifies that the child views can be reordered correctly. | |
2115 TEST_F(ViewTest, ReorderChildren) { | |
2116 View root; | |
2117 | |
2118 View* child = new View(); | |
2119 root.AddChildView(child); | |
2120 | |
2121 View* foo1 = new View(); | |
2122 child->AddChildView(foo1); | |
2123 View* foo2 = new View(); | |
2124 child->AddChildView(foo2); | |
2125 View* foo3 = new View(); | |
2126 child->AddChildView(foo3); | |
2127 foo1->set_focusable(true); | |
2128 foo2->set_focusable(true); | |
2129 foo3->set_focusable(true); | |
2130 | |
2131 ASSERT_EQ(0, child->GetIndexOf(foo1)); | |
2132 ASSERT_EQ(1, child->GetIndexOf(foo2)); | |
2133 ASSERT_EQ(2, child->GetIndexOf(foo3)); | |
2134 ASSERT_EQ(foo2, foo1->GetNextFocusableView()); | |
2135 ASSERT_EQ(foo3, foo2->GetNextFocusableView()); | |
2136 ASSERT_EQ(NULL, foo3->GetNextFocusableView()); | |
2137 | |
2138 // Move |foo2| at the end. | |
2139 child->ReorderChildView(foo2, -1); | |
2140 ASSERT_EQ(0, child->GetIndexOf(foo1)); | |
2141 ASSERT_EQ(1, child->GetIndexOf(foo3)); | |
2142 ASSERT_EQ(2, child->GetIndexOf(foo2)); | |
2143 ASSERT_EQ(foo3, foo1->GetNextFocusableView()); | |
2144 ASSERT_EQ(foo2, foo3->GetNextFocusableView()); | |
2145 ASSERT_EQ(NULL, foo2->GetNextFocusableView()); | |
2146 | |
2147 // Move |foo1| at the end. | |
tfarina
2011/06/16 15:59:42
Could you test adding it to another position besid
sadrul
2011/06/16 16:12:54
Done.
| |
2148 child->ReorderChildView(foo1, -1); | |
2149 ASSERT_EQ(0, child->GetIndexOf(foo3)); | |
2150 ASSERT_EQ(1, child->GetIndexOf(foo2)); | |
2151 ASSERT_EQ(2, child->GetIndexOf(foo1)); | |
2152 ASSERT_EQ(NULL, foo1->GetNextFocusableView()); | |
2153 ASSERT_EQ(foo2, foo3->GetNextFocusableView()); | |
2154 ASSERT_EQ(foo1, foo2->GetNextFocusableView()); | |
2155 } | |
tfarina
2011/06/16 15:59:42
Nice! Thanks for adding it. Looks good.
| |
2156 | |
2114 } // namespace views | 2157 } // namespace views |
OLD | NEW |