OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/message_loop.h" | 5 #include "base/message_loop.h" |
6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
7 #include "views/controls/tabbed_pane/tabbed_pane.h" | 7 #include "views/controls/tabbed_pane/tabbed_pane.h" |
8 #include "views/window/window.h" | 8 #include "views/window/window.h" |
9 #include "views/window/window_delegate.h" | 9 #include "views/window/window_delegate.h" |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 DISALLOW_COPY_AND_ASSIGN(FixedSizeView); | 26 DISALLOW_COPY_AND_ASSIGN(FixedSizeView); |
27 }; | 27 }; |
28 | 28 |
29 class TabbedPaneTest : public testing::Test, WindowDelegate { | 29 class TabbedPaneTest : public testing::Test, WindowDelegate { |
30 public: | 30 public: |
31 TabbedPaneTest() {} | 31 TabbedPaneTest() {} |
32 | 32 |
33 TabbedPane* tabbed_pane_; | 33 TabbedPane* tabbed_pane_; |
34 | 34 |
| 35 void RunAllPending() { |
| 36 message_loop_.RunAllPending(); |
| 37 } |
| 38 |
35 private: | 39 private: |
36 virtual void SetUp() { | 40 virtual void SetUp() { |
37 tabbed_pane_ = new TabbedPane(); | 41 tabbed_pane_ = new TabbedPane(); |
38 window_ = Window::CreateChromeWindow(NULL, gfx::Rect(0, 0, 100, 100), this); | 42 window_ = Window::CreateChromeWindow(NULL, gfx::Rect(0, 0, 100, 100), this); |
39 window_->Show(); | 43 window_->Show(); |
40 } | 44 } |
41 | 45 |
42 virtual void TearDown() { | 46 virtual void TearDown() { |
43 window_->Close(); | 47 window_->Close(); |
44 message_loop_.RunAllPending(); | 48 message_loop_.RunAllPending(); |
(...skipping 17 matching lines...) Expand all Loading... |
62 tabbed_pane_->AddTab(L"tab2", child2); | 66 tabbed_pane_->AddTab(L"tab2", child2); |
63 tabbed_pane_->SelectTabAt(0); | 67 tabbed_pane_->SelectTabAt(0); |
64 | 68 |
65 // Check that the preferred size is larger than the largest child. | 69 // Check that the preferred size is larger than the largest child. |
66 gfx::Size pref(tabbed_pane_->GetPreferredSize()); | 70 gfx::Size pref(tabbed_pane_->GetPreferredSize()); |
67 EXPECT_GT(pref.width(), 20); | 71 EXPECT_GT(pref.width(), 20); |
68 EXPECT_GT(pref.height(), 10); | 72 EXPECT_GT(pref.height(), 10); |
69 | 73 |
70 // The bounds of our children should be smaller than the tabbed pane's bounds. | 74 // The bounds of our children should be smaller than the tabbed pane's bounds. |
71 tabbed_pane_->SetBounds(0, 0, 100, 200); | 75 tabbed_pane_->SetBounds(0, 0, 100, 200); |
| 76 RunAllPending(); |
72 gfx::Rect bounds(child1->bounds()); | 77 gfx::Rect bounds(child1->bounds()); |
73 EXPECT_GT(bounds.width(), 0); | 78 EXPECT_GT(bounds.width(), 0); |
74 EXPECT_LT(bounds.width(), 100); | 79 EXPECT_LT(bounds.width(), 100); |
75 EXPECT_GT(bounds.height(), 0); | 80 EXPECT_GT(bounds.height(), 0); |
76 EXPECT_LT(bounds.height(), 200); | 81 EXPECT_LT(bounds.height(), 200); |
77 | 82 |
78 // If we switch to the other tab, it should get assigned the same bounds. | 83 // If we switch to the other tab, it should get assigned the same bounds. |
79 tabbed_pane_->SelectTabAt(1); | 84 tabbed_pane_->SelectTabAt(1); |
80 EXPECT_EQ(bounds, child2->bounds()); | 85 EXPECT_EQ(bounds, child2->bounds()); |
81 } | 86 } |
82 | 87 |
83 } // namespace views | 88 } // namespace views |
OLD | NEW |