Chromium Code Reviews| 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) { | |
|
tfarina
2011/06/16 16:18:24
I'd add a comment like this (but it's OK to not to
sadrul
2011/06/16 16:25:01
I think the view hierarchy is pretty self-evident,
Ben Goodger (Google)
2011/06/16 16:25:06
I think you mean:
On 2011/06/16 16:18:24, tfarina
tfarina
2011/06/16 16:28:12
Sure, that why I said I'm OK to not have one. It's
| |
| 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. | |
| 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, foo1->GetPreviousFocusableView()); | |
| 2154 ASSERT_EQ(foo2, foo3->GetNextFocusableView()); | |
| 2155 ASSERT_EQ(foo1, foo2->GetNextFocusableView()); | |
| 2156 | |
| 2157 // Move |foo2| at the front. | |
|
tfarina
2011/06/16 16:18:24
nit: at -> to?
sadrul
2011/06/16 16:25:01
Done.
| |
| 2158 child->ReorderChildView(foo2, 0); | |
| 2159 ASSERT_EQ(0, child->GetIndexOf(foo2)); | |
| 2160 ASSERT_EQ(1, child->GetIndexOf(foo3)); | |
| 2161 ASSERT_EQ(2, child->GetIndexOf(foo1)); | |
| 2162 ASSERT_EQ(NULL, foo1->GetNextFocusableView()); | |
| 2163 ASSERT_EQ(foo3, foo1->GetPreviousFocusableView()); | |
| 2164 ASSERT_EQ(foo3, foo2->GetNextFocusableView()); | |
| 2165 ASSERT_EQ(foo1, foo3->GetNextFocusableView()); | |
| 2166 } | |
| 2167 | |
| 2114 } // namespace views | 2168 } // namespace views |
| OLD | NEW |