OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/wm/frame_painter.h" | 5 #include "ash/wm/frame_painter.h" |
6 | 6 |
7 #include "ash/ash_constants.h" | 7 #include "ash/ash_constants.h" |
8 #include "ash/root_window_settings.h" | 8 #include "ash/root_window_settings.h" |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 | 112 |
113 DISALLOW_COPY_AND_ASSIGN(ScopedOpacityConstantModifier); | 113 DISALLOW_COPY_AND_ASSIGN(ScopedOpacityConstantModifier); |
114 }; | 114 }; |
115 | 115 |
116 // Creates a new FramePainter with empty buttons. Caller owns the memory. | 116 // Creates a new FramePainter with empty buttons. Caller owns the memory. |
117 FramePainter* CreateTestPainter(Widget* widget) { | 117 FramePainter* CreateTestPainter(Widget* widget) { |
118 FramePainter* painter = new FramePainter(); | 118 FramePainter* painter = new FramePainter(); |
119 NonClientFrameView* frame_view = widget->non_client_view()->frame_view(); | 119 NonClientFrameView* frame_view = widget->non_client_view()->frame_view(); |
120 ash::FrameCaptionButtonContainerView* container = | 120 ash::FrameCaptionButtonContainerView* container = |
121 new ash::FrameCaptionButtonContainerView( | 121 new ash::FrameCaptionButtonContainerView( |
122 frame_view, | |
123 widget, | 122 widget, |
124 ash::FrameCaptionButtonContainerView::MINIMIZE_ALLOWED); | 123 ash::FrameCaptionButtonContainerView::MINIMIZE_ALLOWED); |
125 // Add the container to the widget's non-client frame view so that it will be | 124 // Add the container to the widget's non-client frame view so that it will be |
126 // deleted when the widget is destroyed. | 125 // deleted when the widget is destroyed. |
127 frame_view->AddChildView(container); | 126 frame_view->AddChildView(container); |
128 painter->Init(widget, NULL, container); | 127 painter->Init(widget, NULL, container); |
129 return painter; | 128 return painter; |
130 } | 129 } |
131 | 130 |
132 // Self-owned manager of the frame painter which deletes the painter and itself | 131 // Self-owned manager of the frame painter which deletes the painter and itself |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 | 568 |
570 wm::GetWindowSettings(w->GetNativeWindow())->SetTrackedByWorkspace(false); | 569 wm::GetWindowSettings(w->GetNativeWindow())->SetTrackedByWorkspace(false); |
571 EXPECT_FALSE(p->ShouldUseMinimalHeaderStyle(FramePainter::THEMED_NO)); | 570 EXPECT_FALSE(p->ShouldUseMinimalHeaderStyle(FramePainter::THEMED_NO)); |
572 wm::GetWindowSettings(w->GetNativeWindow())->SetTrackedByWorkspace(true); | 571 wm::GetWindowSettings(w->GetNativeWindow())->SetTrackedByWorkspace(true); |
573 } | 572 } |
574 | 573 |
575 // Ensure the title text is vertically aligned with the window icon. | 574 // Ensure the title text is vertically aligned with the window icon. |
576 TEST_F(FramePainterTest, TitleIconAlignment) { | 575 TEST_F(FramePainterTest, TitleIconAlignment) { |
577 scoped_ptr<Widget> w(CreateTestWidget()); | 576 scoped_ptr<Widget> w(CreateTestWidget()); |
578 FramePainter p; | 577 FramePainter p; |
579 ash::FrameCaptionButtonContainerView container(NULL, w.get(), | 578 ash::FrameCaptionButtonContainerView container(w.get(), |
580 ash::FrameCaptionButtonContainerView::MINIMIZE_ALLOWED); | 579 ash::FrameCaptionButtonContainerView::MINIMIZE_ALLOWED); |
581 views::View window_icon; | 580 views::View window_icon; |
582 window_icon.SetBounds(0, 0, 16, 16); | 581 window_icon.SetBounds(0, 0, 16, 16); |
583 p.Init(w.get(), &window_icon, &container); | 582 p.Init(w.get(), &window_icon, &container); |
584 w->SetBounds(gfx::Rect(0, 0, 500, 500)); | 583 w->SetBounds(gfx::Rect(0, 0, 500, 500)); |
585 w->Show(); | 584 w->Show(); |
586 | 585 |
587 // Title and icon are aligned when shorter_header is false. | 586 // Title and icon are aligned when shorter_header is false. |
588 p.LayoutHeader(w->non_client_view()->frame_view(), false); | 587 p.LayoutHeader(w->non_client_view()->frame_view(), false); |
589 gfx::Font default_font; | 588 gfx::Font default_font; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 FramePainterOwner* o2 = new FramePainterOwner(w2); | 653 FramePainterOwner* o2 = new FramePainterOwner(w2); |
655 FramePainter* p2 = o2->frame_painter(); | 654 FramePainter* p2 = o2->frame_painter(); |
656 w2->Show(); | 655 w2->Show(); |
657 EXPECT_FALSE(p1->UseSoloWindowHeader()); | 656 EXPECT_FALSE(p1->UseSoloWindowHeader()); |
658 EXPECT_FALSE(p2->UseSoloWindowHeader()); | 657 EXPECT_FALSE(p2->UseSoloWindowHeader()); |
659 | 658 |
660 // Exit with no resource release. They'll be released at shutdown. | 659 // Exit with no resource release. They'll be released at shutdown. |
661 } | 660 } |
662 | 661 |
663 } // namespace ash | 662 } // namespace ash |
OLD | NEW |