Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.h" | 5 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" | 10 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" |
| 11 #include "chrome/browser/ui/views/tab_icon_view.h" | 11 #include "chrome/browser/ui/views/tab_icon_view.h" |
| 12 #include "chrome/browser/ui/views/tabs/tab.h" | 12 #include "chrome/browser/ui/views/tabs/tab.h" |
| 13 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
| 14 #include "chrome/test/base/testing_browser_process.h" | |
| 15 #include "chrome/test/base/testing_profile_manager.h" | |
| 14 #include "components/signin/core/common/profile_management_switches.h" | 16 #include "components/signin/core/common/profile_management_switches.h" |
| 15 #include "ui/gfx/image/image_skia.h" | 17 #include "ui/gfx/image/image_skia.h" |
| 16 #include "ui/gfx/image/image_skia_rep.h" | 18 #include "ui/gfx/image/image_skia_rep.h" |
| 17 #include "ui/gfx/text_constants.h" | 19 #include "ui/gfx/text_constants.h" |
| 18 #include "ui/views/controls/button/image_button.h" | 20 #include "ui/views/controls/button/image_button.h" |
| 19 #include "ui/views/controls/button/menu_button.h" | 21 #include "ui/views/controls/button/menu_button.h" |
| 20 #include "ui/views/controls/label.h" | 22 #include "ui/views/controls/label.h" |
| 21 #include "ui/views/test/views_test_base.h" | 23 #include "ui/views/test/views_test_base.h" |
| 22 | 24 |
| 23 #if defined(ENABLE_SUPERVISED_USERS) | 25 #if defined(ENABLE_SUPERVISED_USERS) |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 bool show_caption_buttons_; | 129 bool show_caption_buttons_; |
| 128 WindowState window_state_; | 130 WindowState window_state_; |
| 129 | 131 |
| 130 DISALLOW_COPY_AND_ASSIGN(TestLayoutDelegate); | 132 DISALLOW_COPY_AND_ASSIGN(TestLayoutDelegate); |
| 131 }; | 133 }; |
| 132 | 134 |
| 133 } // namespace | 135 } // namespace |
| 134 | 136 |
| 135 class OpaqueBrowserFrameViewLayoutTest : public views::ViewsTestBase { | 137 class OpaqueBrowserFrameViewLayoutTest : public views::ViewsTestBase { |
| 136 public: | 138 public: |
| 137 OpaqueBrowserFrameViewLayoutTest() {} | 139 OpaqueBrowserFrameViewLayoutTest() |
| 140 : profile_manager_(TestingBrowserProcess::GetGlobal()) {} | |
|
msw
2015/04/01 01:30:16
nit: can you inline this in SetUp and remove the c
yao
2015/04/10 00:43:32
Done.
| |
| 138 ~OpaqueBrowserFrameViewLayoutTest() override {} | 141 ~OpaqueBrowserFrameViewLayoutTest() override {} |
| 139 | 142 |
| 140 void SetUp() override { | 143 void SetUp() override { |
| 141 views::ViewsTestBase::SetUp(); | 144 views::ViewsTestBase::SetUp(); |
| 145 ASSERT_TRUE(profile_manager_.SetUp()); | |
|
msw
2015/04/01 01:30:16
Why is this necessary? Can you add a comment?
yao
2015/04/10 00:43:32
Done.
| |
| 142 | 146 |
| 143 delegate_.reset(new TestLayoutDelegate); | 147 delegate_.reset(new TestLayoutDelegate); |
| 144 layout_manager_ = new OpaqueBrowserFrameViewLayout(delegate_.get()); | 148 layout_manager_ = new OpaqueBrowserFrameViewLayout(delegate_.get()); |
| 145 layout_manager_->set_extra_caption_y(0); | 149 layout_manager_->set_extra_caption_y(0); |
| 146 layout_manager_->set_window_caption_spacing(0); | 150 layout_manager_->set_window_caption_spacing(0); |
| 147 widget_ = new Widget; | 151 widget_ = new Widget; |
| 148 widget_->Init(CreateParams(Widget::InitParams::TYPE_POPUP)); | 152 widget_->Init(CreateParams(Widget::InitParams::TYPE_POPUP)); |
| 149 root_view_ = widget_->GetRootView(); | 153 root_view_ = widget_->GetRootView(); |
| 150 root_view_->SetSize(gfx::Size(kWidth, kWidth)); | 154 root_view_->SetSize(gfx::Size(kWidth, kWidth)); |
| 151 root_view_->SetLayoutManager(layout_manager_); | 155 root_view_->SetLayoutManager(layout_manager_); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 253 | 257 |
| 254 TabIconView* tab_icon_view_; | 258 TabIconView* tab_icon_view_; |
| 255 views::Label* window_title_; | 259 views::Label* window_title_; |
| 256 | 260 |
| 257 #if defined(ENABLE_SUPERVISED_USERS) | 261 #if defined(ENABLE_SUPERVISED_USERS) |
| 258 SupervisedUserAvatarLabel* supervised_user_avatar_label_; | 262 SupervisedUserAvatarLabel* supervised_user_avatar_label_; |
| 259 #endif | 263 #endif |
| 260 AvatarMenuButton* menu_button_; | 264 AvatarMenuButton* menu_button_; |
| 261 views::MenuButton* new_avatar_button_; | 265 views::MenuButton* new_avatar_button_; |
| 262 | 266 |
| 267 TestingProfileManager profile_manager_; | |
| 268 | |
| 263 DISALLOW_COPY_AND_ASSIGN(OpaqueBrowserFrameViewLayoutTest); | 269 DISALLOW_COPY_AND_ASSIGN(OpaqueBrowserFrameViewLayoutTest); |
| 264 }; | 270 }; |
| 265 | 271 |
| 266 TEST_F(OpaqueBrowserFrameViewLayoutTest, BasicWindow) { | 272 TEST_F(OpaqueBrowserFrameViewLayoutTest, BasicWindow) { |
| 267 // Tests the layout of a default chrome window with no avatars, no window | 273 // Tests the layout of a default chrome window with no avatars, no window |
| 268 // titles, and a tabstrip. | 274 // titles, and a tabstrip. |
| 269 root_view_->Layout(); | 275 root_view_->Layout(); |
| 270 | 276 |
| 271 ExpectBasicWindowBounds(); | 277 ExpectBasicWindowBounds(); |
| 272 | 278 |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 544 // both are displayed on the left side. | 550 // both are displayed on the left side. |
| 545 // The label height and width depends on the font size and the text displayed. | 551 // The label height and width depends on the font size and the text displayed. |
| 546 // This may possibly change, so we don't test it here. | 552 // This may possibly change, so we don't test it here. |
| 547 EXPECT_EQ(menu_button_->bounds().x() - 2, | 553 EXPECT_EQ(menu_button_->bounds().x() - 2, |
| 548 supervised_user_avatar_label_->bounds().x()); | 554 supervised_user_avatar_label_->bounds().x()); |
| 549 EXPECT_EQ(menu_button_->bounds().bottom() - 3 - | 555 EXPECT_EQ(menu_button_->bounds().bottom() - 3 - |
| 550 supervised_user_avatar_label_->bounds().height(), | 556 supervised_user_avatar_label_->bounds().height(), |
| 551 supervised_user_avatar_label_->bounds().y()); | 557 supervised_user_avatar_label_->bounds().y()); |
| 552 } | 558 } |
| 553 #endif | 559 #endif |
| OLD | NEW |