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 "base/utf_string_conversions.h" | 5 #include "base/utf_string_conversions.h" |
6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 #include "views/controls/tabbed_pane/tabbed_pane.h" | 8 #include "views/controls/tabbed_pane/tabbed_pane.h" |
9 #include "views/widget/widget.h" | 9 #include "views/widget/widget.h" |
10 #include "views/widget/widget_delegate.h" | 10 #include "views/widget/widget_delegate.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
60 return tabbed_pane_->GetWidget(); | 60 return tabbed_pane_->GetWidget(); |
61 } | 61 } |
62 | 62 |
63 MessageLoopForUI message_loop_; | 63 MessageLoopForUI message_loop_; |
64 Widget* window_; | 64 Widget* window_; |
65 | 65 |
66 DISALLOW_COPY_AND_ASSIGN(TabbedPaneTest); | 66 DISALLOW_COPY_AND_ASSIGN(TabbedPaneTest); |
67 }; | 67 }; |
68 | 68 |
69 #if defined(OS_WIN) | 69 #if defined(OS_WIN) |
70 // This test is failing and crashes on Win7. See http://crbug.com/104067 | 70 // These test are failing and crash on Win7. See http://crbug.com/104067 |
71 #define MAYBE_SizeAndLayout DISABLED_SizeAndLayout | 71 #define MAYBE_SizeAndLayout DISABLED_SizeAndLayout |
72 #define MAYBE_AddRemove DISBLED_AddRemove | |
nsylvain
2011/11/13 19:30:12
DISBLED->DISABLED. already fixed.
| |
72 #else | 73 #else |
73 #define MAYBE_SizeAndLayout SizeAndLayout | 74 #define MAYBE_SizeAndLayout SizeAndLayout |
75 #define MAYBE_AddRemove AddRemove | |
74 #endif | 76 #endif |
75 | 77 |
76 // Tests that TabbedPane::GetPreferredSize() and TabbedPane::Layout(). | 78 // Tests that TabbedPane::GetPreferredSize() and TabbedPane::Layout(). |
77 TEST_F(TabbedPaneTest, MAYBE_SizeAndLayout) { | 79 TEST_F(TabbedPaneTest, MAYBE_SizeAndLayout) { |
78 View* child1 = new FixedSizeView(gfx::Size(20, 10)); | 80 View* child1 = new FixedSizeView(gfx::Size(20, 10)); |
79 tabbed_pane_->AddTab(ASCIIToUTF16("tab1"), child1); | 81 tabbed_pane_->AddTab(ASCIIToUTF16("tab1"), child1); |
80 View* child2 = new FixedSizeView(gfx::Size(5, 5)); | 82 View* child2 = new FixedSizeView(gfx::Size(5, 5)); |
81 tabbed_pane_->AddTab(ASCIIToUTF16("tab2"), child2); | 83 tabbed_pane_->AddTab(ASCIIToUTF16("tab2"), child2); |
82 tabbed_pane_->SelectTabAt(0); | 84 tabbed_pane_->SelectTabAt(0); |
83 | 85 |
84 // Check that the preferred size is larger than the largest child. | 86 // Check that the preferred size is larger than the largest child. |
85 gfx::Size pref(tabbed_pane_->GetPreferredSize()); | 87 gfx::Size pref(tabbed_pane_->GetPreferredSize()); |
86 EXPECT_GT(pref.width(), 20); | 88 EXPECT_GT(pref.width(), 20); |
87 EXPECT_GT(pref.height(), 10); | 89 EXPECT_GT(pref.height(), 10); |
88 | 90 |
89 // The bounds of our children should be smaller than the tabbed pane's bounds. | 91 // The bounds of our children should be smaller than the tabbed pane's bounds. |
90 tabbed_pane_->SetBounds(0, 0, 100, 200); | 92 tabbed_pane_->SetBounds(0, 0, 100, 200); |
91 RunAllPending(); | 93 RunAllPending(); |
92 gfx::Rect bounds(child1->bounds()); | 94 gfx::Rect bounds(child1->bounds()); |
93 EXPECT_GT(bounds.width(), 0); | 95 EXPECT_GT(bounds.width(), 0); |
94 EXPECT_LT(bounds.width(), 100); | 96 EXPECT_LT(bounds.width(), 100); |
95 EXPECT_GT(bounds.height(), 0); | 97 EXPECT_GT(bounds.height(), 0); |
96 EXPECT_LT(bounds.height(), 200); | 98 EXPECT_LT(bounds.height(), 200); |
97 | 99 |
98 // If we switch to the other tab, it should get assigned the same bounds. | 100 // If we switch to the other tab, it should get assigned the same bounds. |
99 tabbed_pane_->SelectTabAt(1); | 101 tabbed_pane_->SelectTabAt(1); |
100 EXPECT_EQ(bounds, child2->bounds()); | 102 EXPECT_EQ(bounds, child2->bounds()); |
101 } | 103 } |
102 | 104 |
103 TEST_F(TabbedPaneTest, AddRemove) { | 105 TEST_F(TabbedPaneTest, MAYBE_AddRemove) { |
104 View* tab0 = new View; | 106 View* tab0 = new View; |
105 tabbed_pane_->AddTab(ASCIIToUTF16("tab0"), tab0); | 107 tabbed_pane_->AddTab(ASCIIToUTF16("tab0"), tab0); |
106 EXPECT_EQ(tab0, tabbed_pane_->GetSelectedTab()); | 108 EXPECT_EQ(tab0, tabbed_pane_->GetSelectedTab()); |
107 EXPECT_EQ(0, tabbed_pane_->GetSelectedTabIndex()); | 109 EXPECT_EQ(0, tabbed_pane_->GetSelectedTabIndex()); |
108 | 110 |
109 // Add more 3 tabs. | 111 // Add more 3 tabs. |
110 tabbed_pane_->AddTab(ASCIIToUTF16("tab1"), new View); | 112 tabbed_pane_->AddTab(ASCIIToUTF16("tab1"), new View); |
111 tabbed_pane_->AddTab(ASCIIToUTF16("tab2"), new View); | 113 tabbed_pane_->AddTab(ASCIIToUTF16("tab2"), new View); |
112 tabbed_pane_->AddTab(ASCIIToUTF16("tab3"), new View); | 114 tabbed_pane_->AddTab(ASCIIToUTF16("tab3"), new View); |
113 EXPECT_EQ(4, tabbed_pane_->GetTabCount()); | 115 EXPECT_EQ(4, tabbed_pane_->GetTabCount()); |
(...skipping 22 matching lines...) Expand all Loading... | |
136 // Now change the selected tab. | 138 // Now change the selected tab. |
137 tabbed_pane_->SelectTabAt(1); | 139 tabbed_pane_->SelectTabAt(1); |
138 EXPECT_EQ(1, tabbed_pane_->GetSelectedTabIndex()); | 140 EXPECT_EQ(1, tabbed_pane_->GetSelectedTabIndex()); |
139 | 141 |
140 // Remove the first one. | 142 // Remove the first one. |
141 delete tabbed_pane_->RemoveTabAtIndex(0); | 143 delete tabbed_pane_->RemoveTabAtIndex(0); |
142 EXPECT_EQ(0, tabbed_pane_->GetSelectedTabIndex()); | 144 EXPECT_EQ(0, tabbed_pane_->GetSelectedTabIndex()); |
143 } | 145 } |
144 | 146 |
145 } // namespace views | 147 } // namespace views |
OLD | NEW |