| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ash/frame/caption_buttons/frame_size_button.h" | 5 #include "ash/frame/caption_buttons/frame_size_button.h" |
| 6 | 6 |
| 7 #include "ash/frame/caption_buttons/frame_caption_button.h" | 7 #include "ash/frame/caption_buttons/frame_caption_button.h" |
| 8 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h" | 8 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/test/ash_test_base.h" | 10 #include "ash/test/ash_test_base.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 namespace test { | 24 namespace test { |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 class TestWidgetDelegate : public views::WidgetDelegateView { | 28 class TestWidgetDelegate : public views::WidgetDelegateView { |
| 29 public: | 29 public: |
| 30 TestWidgetDelegate() {} | 30 TestWidgetDelegate() {} |
| 31 virtual ~TestWidgetDelegate() {} | 31 virtual ~TestWidgetDelegate() {} |
| 32 | 32 |
| 33 // Overridden from views::WidgetDelegate: | 33 // Overridden from views::WidgetDelegate: |
| 34 virtual views::View* GetContentsView() OVERRIDE { | 34 virtual views::View* GetContentsView() override { |
| 35 return this; | 35 return this; |
| 36 } | 36 } |
| 37 virtual bool CanResize() const OVERRIDE { | 37 virtual bool CanResize() const override { |
| 38 return true; | 38 return true; |
| 39 } | 39 } |
| 40 virtual bool CanMaximize() const OVERRIDE { | 40 virtual bool CanMaximize() const override { |
| 41 return true; | 41 return true; |
| 42 } | 42 } |
| 43 virtual bool CanMinimize() const OVERRIDE { | 43 virtual bool CanMinimize() const override { |
| 44 return true; | 44 return true; |
| 45 } | 45 } |
| 46 | 46 |
| 47 ash::FrameCaptionButtonContainerView* caption_button_container() { | 47 ash::FrameCaptionButtonContainerView* caption_button_container() { |
| 48 return caption_button_container_; | 48 return caption_button_container_; |
| 49 } | 49 } |
| 50 | 50 |
| 51 private: | 51 private: |
| 52 // Overridden from views::View: | 52 // Overridden from views::View: |
| 53 virtual void Layout() OVERRIDE { | 53 virtual void Layout() override { |
| 54 caption_button_container_->Layout(); | 54 caption_button_container_->Layout(); |
| 55 | 55 |
| 56 // Right align the caption button container. | 56 // Right align the caption button container. |
| 57 gfx::Size preferred_size = caption_button_container_->GetPreferredSize(); | 57 gfx::Size preferred_size = caption_button_container_->GetPreferredSize(); |
| 58 caption_button_container_->SetBounds(width() - preferred_size.width(), 0, | 58 caption_button_container_->SetBounds(width() - preferred_size.width(), 0, |
| 59 preferred_size.width(), preferred_size.height()); | 59 preferred_size.width(), preferred_size.height()); |
| 60 } | 60 } |
| 61 | 61 |
| 62 virtual void ViewHierarchyChanged( | 62 virtual void ViewHierarchyChanged( |
| 63 const ViewHierarchyChangedDetails& details) OVERRIDE { | 63 const ViewHierarchyChangedDetails& details) override { |
| 64 if (details.is_add && details.child == this) { | 64 if (details.is_add && details.child == this) { |
| 65 caption_button_container_ = new FrameCaptionButtonContainerView( | 65 caption_button_container_ = new FrameCaptionButtonContainerView( |
| 66 GetWidget(), FrameCaptionButtonContainerView::MINIMIZE_ALLOWED); | 66 GetWidget(), FrameCaptionButtonContainerView::MINIMIZE_ALLOWED); |
| 67 | 67 |
| 68 // Set arbitrary images for the container's buttons so that the buttons | 68 // Set arbitrary images for the container's buttons so that the buttons |
| 69 // have non-empty sizes. | 69 // have non-empty sizes. |
| 70 for (int icon = 0; icon < CAPTION_BUTTON_ICON_COUNT; ++icon) { | 70 for (int icon = 0; icon < CAPTION_BUTTON_ICON_COUNT; ++icon) { |
| 71 caption_button_container_->SetButtonImages( | 71 caption_button_container_->SetButtonImages( |
| 72 static_cast<CaptionButtonIcon>(icon), | 72 static_cast<CaptionButtonIcon>(icon), |
| 73 IDR_AURA_WINDOW_CONTROL_ICON_CLOSE, | 73 IDR_AURA_WINDOW_CONTROL_ICON_CLOSE, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 118 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
| 119 params.context = CurrentContext(); | 119 params.context = CurrentContext(); |
| 120 params.delegate = delegate; | 120 params.delegate = delegate; |
| 121 params.bounds = gfx::Rect(10, 10, 100, 100); | 121 params.bounds = gfx::Rect(10, 10, 100, 100); |
| 122 widget->Init(params); | 122 widget->Init(params); |
| 123 widget->Show(); | 123 widget->Show(); |
| 124 return widget; | 124 return widget; |
| 125 } | 125 } |
| 126 | 126 |
| 127 // AshTestBase overrides: | 127 // AshTestBase overrides: |
| 128 virtual void SetUp() OVERRIDE { | 128 virtual void SetUp() override { |
| 129 AshTestBase::SetUp(); | 129 AshTestBase::SetUp(); |
| 130 | 130 |
| 131 TestWidgetDelegate* delegate = new TestWidgetDelegate(); | 131 TestWidgetDelegate* delegate = new TestWidgetDelegate(); |
| 132 window_state_ = ash::wm::GetWindowState( | 132 window_state_ = ash::wm::GetWindowState( |
| 133 CreateWidget(delegate)->GetNativeWindow()); | 133 CreateWidget(delegate)->GetNativeWindow()); |
| 134 | 134 |
| 135 FrameCaptionButtonContainerView::TestApi test( | 135 FrameCaptionButtonContainerView::TestApi test( |
| 136 delegate->caption_button_container()); | 136 delegate->caption_button_container()); |
| 137 | 137 |
| 138 minimize_button_ = test.minimize_button(); | 138 minimize_button_ = test.minimize_button(); |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 EXPECT_EQ(views::Button::STATE_NORMAL, minimize_button()->state()); | 401 EXPECT_EQ(views::Button::STATE_NORMAL, minimize_button()->state()); |
| 402 EXPECT_EQ(views::Button::STATE_PRESSED, size_button()->state()); | 402 EXPECT_EQ(views::Button::STATE_PRESSED, size_button()->state()); |
| 403 EXPECT_EQ(views::Button::STATE_HOVERED, close_button()->state()); | 403 EXPECT_EQ(views::Button::STATE_HOVERED, close_button()->state()); |
| 404 } | 404 } |
| 405 | 405 |
| 406 class FrameSizeButtonTestRTL : public FrameSizeButtonTest { | 406 class FrameSizeButtonTestRTL : public FrameSizeButtonTest { |
| 407 public: | 407 public: |
| 408 FrameSizeButtonTestRTL() {} | 408 FrameSizeButtonTestRTL() {} |
| 409 virtual ~FrameSizeButtonTestRTL() {} | 409 virtual ~FrameSizeButtonTestRTL() {} |
| 410 | 410 |
| 411 virtual void SetUp() OVERRIDE { | 411 virtual void SetUp() override { |
| 412 original_locale_ = l10n_util::GetApplicationLocale(std::string()); | 412 original_locale_ = l10n_util::GetApplicationLocale(std::string()); |
| 413 base::i18n::SetICUDefaultLocale("he"); | 413 base::i18n::SetICUDefaultLocale("he"); |
| 414 | 414 |
| 415 FrameSizeButtonTest::SetUp(); | 415 FrameSizeButtonTest::SetUp(); |
| 416 } | 416 } |
| 417 | 417 |
| 418 virtual void TearDown() OVERRIDE { | 418 virtual void TearDown() override { |
| 419 FrameSizeButtonTest::TearDown(); | 419 FrameSizeButtonTest::TearDown(); |
| 420 base::i18n::SetICUDefaultLocale(original_locale_); | 420 base::i18n::SetICUDefaultLocale(original_locale_); |
| 421 } | 421 } |
| 422 | 422 |
| 423 private: | 423 private: |
| 424 std::string original_locale_; | 424 std::string original_locale_; |
| 425 | 425 |
| 426 DISALLOW_COPY_AND_ASSIGN(FrameSizeButtonTestRTL); | 426 DISALLOW_COPY_AND_ASSIGN(FrameSizeButtonTestRTL); |
| 427 }; | 427 }; |
| 428 | 428 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 | 466 |
| 467 // None of the buttons should stay pressed and the buttons should have their | 467 // None of the buttons should stay pressed and the buttons should have their |
| 468 // regular icons. | 468 // regular icons. |
| 469 EXPECT_TRUE(AllButtonsInNormalState()); | 469 EXPECT_TRUE(AllButtonsInNormalState()); |
| 470 EXPECT_EQ(CAPTION_BUTTON_ICON_MINIMIZE, minimize_button()->icon()); | 470 EXPECT_EQ(CAPTION_BUTTON_ICON_MINIMIZE, minimize_button()->icon()); |
| 471 EXPECT_EQ(CAPTION_BUTTON_ICON_CLOSE, close_button()->icon()); | 471 EXPECT_EQ(CAPTION_BUTTON_ICON_CLOSE, close_button()->icon()); |
| 472 } | 472 } |
| 473 | 473 |
| 474 } // namespace test | 474 } // namespace test |
| 475 } // namespace ash | 475 } // namespace ash |
| OLD | NEW |