Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(313)

Side by Side Diff: views/controls/tabbed_pane/tabbed_pane_unittest.cc

Issue 2883022: Re-land r51526 (Closed)
Patch Set: Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « views/controls/tabbed_pane/tabbed_pane.cc ('k') | views/controls/table/table_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/message_loop.h"
6 #include "testing/gtest/include/gtest/gtest.h"
7 #include "views/controls/tabbed_pane/tabbed_pane.h"
8 #include "views/window/window.h"
9 #include "views/window/window_delegate.h"
10
11 namespace views {
12
13 // A view for testing that takes a fixed preferred size upon construction.
14 class FixedSizeView : public View {
15 public:
16 FixedSizeView(const gfx::Size& size)
17 : size_(size) {}
18
19 virtual gfx::Size GetPreferredSize() {
20 return size_;
21 }
22
23 private:
24 const gfx::Size size_;
25
26 DISALLOW_COPY_AND_ASSIGN(FixedSizeView);
27 };
28
29 class TabbedPaneTest : public testing::Test, WindowDelegate {
30 public:
31 TabbedPaneTest() {}
32
33 TabbedPane* tabbed_pane_;
34
35 private:
36 virtual void SetUp() {
37 tabbed_pane_ = new TabbedPane();
38 window_ = Window::CreateChromeWindow(NULL, gfx::Rect(0, 0, 100, 100), this);
39 window_->Show();
40 }
41
42 virtual void TearDown() {
43 window_->Close();
44 message_loop_.RunAllPending();
Mattias Nissler (ping if slow) 2010/07/05 07:54:27 this line is new.
45 }
46
47 virtual views::View* GetContentsView() {
48 return tabbed_pane_;
49 }
50
51 MessageLoopForUI message_loop_;
52 Window* window_;
53
54 DISALLOW_COPY_AND_ASSIGN(TabbedPaneTest);
55 };
56
57 // Tests that TabbedPane::GetPreferredSize() and TabbedPane::Layout().
58 TEST_F(TabbedPaneTest, SizeAndLayout) {
59 View* child1 = new FixedSizeView(gfx::Size(20, 10));
60 tabbed_pane_->AddTab(L"tab1", child1);
61 View* child2 = new FixedSizeView(gfx::Size(5, 5));
62 tabbed_pane_->AddTab(L"tab2", child2);
63 tabbed_pane_->SelectTabAt(0);
64
65 // Check that the preferred size is larger than the largest child.
66 gfx::Size pref(tabbed_pane_->GetPreferredSize());
67 EXPECT_GT(pref.width(), 20);
68 EXPECT_GT(pref.height(), 10);
69
70 // The bounds of our children should be smaller than the tabbed pane's bounds.
71 tabbed_pane_->SetBounds(0, 0, 100, 200);
72 gfx::Rect bounds(child1->bounds());
73 EXPECT_GT(bounds.width(), 0);
74 EXPECT_LT(bounds.width(), 100);
75 EXPECT_GT(bounds.height(), 0);
76 EXPECT_LT(bounds.height(), 200);
77
78 // If we switch to the other tab, it should get assigned the same bounds.
79 tabbed_pane_->SelectTabAt(1);
80 EXPECT_EQ(bounds, child2->bounds());
81 }
82
83 } // namespace views
OLDNEW
« no previous file with comments | « views/controls/tabbed_pane/tabbed_pane.cc ('k') | views/controls/table/table_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698