| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/views/focus/focus_manager.h" | 5 #include "ui/views/focus/focus_manager.h" |
| 6 | 6 |
| 7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "ui/base/models/combobox_model.h" | 10 #include "ui/base/models/combobox_model.h" |
| (...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 788 }; | 788 }; |
| 789 | 789 |
| 790 void FocusTraversalNonFocusableTest::InitContentView() { | 790 void FocusTraversalNonFocusableTest::InitContentView() { |
| 791 // Create a complex nested view hierarchy with no focusable views. This is a | 791 // Create a complex nested view hierarchy with no focusable views. This is a |
| 792 // regression test for http://crbug.com/453699. There was previously a bug | 792 // regression test for http://crbug.com/453699. There was previously a bug |
| 793 // where advancing focus backwards through this tree resulted in an | 793 // where advancing focus backwards through this tree resulted in an |
| 794 // exponential number of nodes being searched. (Each time it traverses one of | 794 // exponential number of nodes being searched. (Each time it traverses one of |
| 795 // the x1-x3-x2 triangles, it will traverse the left sibling of x1, (x+1)0, | 795 // the x1-x3-x2 triangles, it will traverse the left sibling of x1, (x+1)0, |
| 796 // twice, which means it will visit O(2^n) nodes.) | 796 // twice, which means it will visit O(2^n) nodes.) |
| 797 // | 797 // |
| 798 // 0 | 798 // | 0 | |
| 799 // / \ | 799 // | / \ | |
| 800 // / \ | 800 // | / \ | |
| 801 // 10 1 | 801 // | 10 1 | |
| 802 // / \ / \ | 802 // | / \ / \ | |
| 803 // / \ / \ | 803 // | / \ / \ | |
| 804 // 20 11 2 3 | 804 // | 20 11 2 3 | |
| 805 // / \ / \ | 805 // | / \ / \ | |
| 806 // / \ / \ | 806 // | / \ / \ | |
| 807 // ... 21 12 13 | 807 // | ... 21 12 13 | |
| 808 // / \ | 808 // | / \ | |
| 809 // / \ | 809 // | / \ | |
| 810 // 22 23 | 810 // | 22 23 | |
| 811 | 811 |
| 812 View* v = GetContentsView(); | 812 View* v = GetContentsView(); |
| 813 // Create 30 groups of 4 nodes. |v| is the top of each group. | 813 // Create 30 groups of 4 nodes. |v| is the top of each group. |
| 814 for (int i = 0; i < 300; i += 10) { | 814 for (int i = 0; i < 300; i += 10) { |
| 815 // |v|'s left child is the top of the next group. If |v| is 20, this is 30. | 815 // |v|'s left child is the top of the next group. If |v| is 20, this is 30. |
| 816 View* v10 = new View; | 816 View* v10 = new View; |
| 817 v10->set_id(i + 10); | 817 v10->set_id(i + 10); |
| 818 v->AddChildView(v10); | 818 v->AddChildView(v10); |
| 819 | 819 |
| 820 // |v|'s right child. If |v| is 20, this is 21. | 820 // |v|'s right child. If |v| is 20, this is 21. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 843 GetFocusManager()->AdvanceFocus(false); | 843 GetFocusManager()->AdvanceFocus(false); |
| 844 EXPECT_FALSE(GetFocusManager()->GetFocusedView()); | 844 EXPECT_FALSE(GetFocusManager()->GetFocusedView()); |
| 845 | 845 |
| 846 // Advance backwards from the root node. | 846 // Advance backwards from the root node. |
| 847 GetFocusManager()->ClearFocus(); | 847 GetFocusManager()->ClearFocus(); |
| 848 GetFocusManager()->AdvanceFocus(true); | 848 GetFocusManager()->AdvanceFocus(true); |
| 849 EXPECT_FALSE(GetFocusManager()->GetFocusedView()); | 849 EXPECT_FALSE(GetFocusManager()->GetFocusedView()); |
| 850 } | 850 } |
| 851 | 851 |
| 852 } // namespace views | 852 } // namespace views |
| OLD | NEW |