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" |
11 #include "ash/test/ash_test_base.h" | 11 #include "ash/test/ash_test_base.h" |
12 #include "ash/wm/caption_buttons/frame_caption_button_container_view.h" | 12 #include "ash/wm/caption_buttons/frame_caption_button_container_view.h" |
13 #include "ash/wm/window_settings.h" | 13 #include "ash/wm/window_state.h" |
14 #include "ash/wm/window_util.h" | 14 #include "ash/wm/window_util.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
17 #include "grit/ash_resources.h" | 17 #include "grit/ash_resources.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
19 #include "ui/aura/client/aura_constants.h" | 19 #include "ui/aura/client/aura_constants.h" |
20 #include "ui/aura/root_window.h" | 20 #include "ui/aura/root_window.h" |
21 #include "ui/aura/window_observer.h" | 21 #include "ui/aura/window_observer.h" |
22 #include "ui/base/hit_test.h" | 22 #include "ui/base/hit_test.h" |
23 #include "ui/gfx/font.h" | 23 #include "ui/gfx/font.h" |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 | 474 |
475 // Moves the w3 to the secondary display too. Now w1 should be solo again. | 475 // Moves the w3 to the secondary display too. Now w1 should be solo again. |
476 w3->SetBounds(gfx::Rect(1200, 0, 100, 100)); | 476 w3->SetBounds(gfx::Rect(1200, 0, 100, 100)); |
477 EXPECT_TRUE(p1->UseSoloWindowHeader()); | 477 EXPECT_TRUE(p1->UseSoloWindowHeader()); |
478 EXPECT_FALSE(p2->UseSoloWindowHeader()); | 478 EXPECT_FALSE(p2->UseSoloWindowHeader()); |
479 EXPECT_FALSE(p3->UseSoloWindowHeader()); | 479 EXPECT_FALSE(p3->UseSoloWindowHeader()); |
480 EXPECT_FALSE(p4->UseSoloWindowHeader()); | 480 EXPECT_FALSE(p4->UseSoloWindowHeader()); |
481 EXPECT_TRUE(checker1.IsPaintScheduledAndReset()); | 481 EXPECT_TRUE(checker1.IsPaintScheduledAndReset()); |
482 | 482 |
483 // Change the w3 state to maximize. Doesn't affect to w1. | 483 // Change the w3 state to maximize. Doesn't affect to w1. |
484 wm::MaximizeWindow(w3->GetNativeWindow()); | 484 wm::GetWindowState(w3->GetNativeWindow())->Maximize(); |
485 EXPECT_TRUE(p1->UseSoloWindowHeader()); | 485 EXPECT_TRUE(p1->UseSoloWindowHeader()); |
486 EXPECT_FALSE(p2->UseSoloWindowHeader()); | 486 EXPECT_FALSE(p2->UseSoloWindowHeader()); |
487 EXPECT_FALSE(p3->UseSoloWindowHeader()); | 487 EXPECT_FALSE(p3->UseSoloWindowHeader()); |
488 EXPECT_FALSE(p4->UseSoloWindowHeader()); | 488 EXPECT_FALSE(p4->UseSoloWindowHeader()); |
489 | 489 |
490 // Close the w3 and w4. | 490 // Close the w3 and w4. |
491 w3.reset(); | 491 w3.reset(); |
492 w4.reset(); | 492 w4.reset(); |
493 EXPECT_TRUE(p1->UseSoloWindowHeader()); | 493 EXPECT_TRUE(p1->UseSoloWindowHeader()); |
494 EXPECT_TRUE(p2->UseSoloWindowHeader()); | 494 EXPECT_TRUE(p2->UseSoloWindowHeader()); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 IDR_AURA_WINDOW_HEADER_BASE_ACTIVE, | 534 IDR_AURA_WINDOW_HEADER_BASE_ACTIVE, |
535 0)); | 535 0)); |
536 | 536 |
537 // Inactive window has inactive window opacity. | 537 // Inactive window has inactive window opacity. |
538 EXPECT_EQ(FramePainter::kInactiveWindowOpacity, | 538 EXPECT_EQ(FramePainter::kInactiveWindowOpacity, |
539 p2->GetHeaderOpacity(FramePainter::INACTIVE, | 539 p2->GetHeaderOpacity(FramePainter::INACTIVE, |
540 IDR_AURA_WINDOW_HEADER_BASE_INACTIVE, | 540 IDR_AURA_WINDOW_HEADER_BASE_INACTIVE, |
541 0)); | 541 0)); |
542 | 542 |
543 // Regular maximized windows are fully opaque. | 543 // Regular maximized windows are fully opaque. |
544 ash::wm::MaximizeWindow(w1->GetNativeWindow()); | 544 wm::GetWindowState(w1->GetNativeWindow())->Maximize(); |
545 EXPECT_EQ(255, | 545 EXPECT_EQ(255, |
546 p1->GetHeaderOpacity(FramePainter::ACTIVE, | 546 p1->GetHeaderOpacity(FramePainter::ACTIVE, |
547 IDR_AURA_WINDOW_HEADER_BASE_ACTIVE, | 547 IDR_AURA_WINDOW_HEADER_BASE_ACTIVE, |
548 0)); | 548 0)); |
549 } | 549 } |
550 | 550 |
551 // Test that the minimal header style is used in the proper situations. | 551 // Test that the minimal header style is used in the proper situations. |
552 TEST_F(FramePainterTest, MinimalHeaderStyle) { | 552 TEST_F(FramePainterTest, MinimalHeaderStyle) { |
553 // Create a widget and a painter for it. | 553 // Create a widget and a painter for it. |
554 scoped_ptr<Widget> w(CreateTestWidget()); | 554 scoped_ptr<Widget> w(CreateTestWidget()); |
555 scoped_ptr<FramePainter> p(CreateTestPainter(w.get())); | 555 scoped_ptr<FramePainter> p(CreateTestPainter(w.get())); |
556 w->Show(); | 556 w->Show(); |
557 | 557 |
558 // Regular non-maximized windows should not use the minimal header style. | 558 // Regular non-maximized windows should not use the minimal header style. |
559 EXPECT_FALSE(p->ShouldUseMinimalHeaderStyle(FramePainter::THEMED_NO)); | 559 EXPECT_FALSE(p->ShouldUseMinimalHeaderStyle(FramePainter::THEMED_NO)); |
560 | 560 |
561 // Regular maximized windows should use the minimal header style. | 561 // Regular maximized windows should use the minimal header style. |
562 w->Maximize(); | 562 w->Maximize(); |
563 EXPECT_TRUE(p->ShouldUseMinimalHeaderStyle(FramePainter::THEMED_NO)); | 563 EXPECT_TRUE(p->ShouldUseMinimalHeaderStyle(FramePainter::THEMED_NO)); |
564 | 564 |
565 // Test cases where the maximized window should not use the minimal header | 565 // Test cases where the maximized window should not use the minimal header |
566 // style. | 566 // style. |
567 EXPECT_FALSE(p->ShouldUseMinimalHeaderStyle(FramePainter::THEMED_YES)); | 567 EXPECT_FALSE(p->ShouldUseMinimalHeaderStyle(FramePainter::THEMED_YES)); |
568 | 568 |
569 wm::GetWindowSettings(w->GetNativeWindow())->SetTrackedByWorkspace(false); | 569 wm::GetWindowState(w->GetNativeWindow())->SetTrackedByWorkspace(false); |
570 EXPECT_FALSE(p->ShouldUseMinimalHeaderStyle(FramePainter::THEMED_NO)); | 570 EXPECT_FALSE(p->ShouldUseMinimalHeaderStyle(FramePainter::THEMED_NO)); |
571 wm::GetWindowSettings(w->GetNativeWindow())->SetTrackedByWorkspace(true); | 571 wm::GetWindowState(w->GetNativeWindow())->SetTrackedByWorkspace(true); |
572 } | 572 } |
573 | 573 |
574 // Ensure the title text is vertically aligned with the window icon. | 574 // Ensure the title text is vertically aligned with the window icon. |
575 TEST_F(FramePainterTest, TitleIconAlignment) { | 575 TEST_F(FramePainterTest, TitleIconAlignment) { |
576 scoped_ptr<Widget> w(CreateTestWidget()); | 576 scoped_ptr<Widget> w(CreateTestWidget()); |
577 FramePainter p; | 577 FramePainter p; |
578 ash::FrameCaptionButtonContainerView container(w.get(), | 578 ash::FrameCaptionButtonContainerView container(w.get(), |
579 ash::FrameCaptionButtonContainerView::MINIMIZE_ALLOWED); | 579 ash::FrameCaptionButtonContainerView::MINIMIZE_ALLOWED); |
580 views::View window_icon; | 580 views::View window_icon; |
581 window_icon.SetBounds(0, 0, 16, 16); | 581 window_icon.SetBounds(0, 0, 16, 16); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 FramePainterOwner* o2 = new FramePainterOwner(w2); | 653 FramePainterOwner* o2 = new FramePainterOwner(w2); |
654 FramePainter* p2 = o2->frame_painter(); | 654 FramePainter* p2 = o2->frame_painter(); |
655 w2->Show(); | 655 w2->Show(); |
656 EXPECT_FALSE(p1->UseSoloWindowHeader()); | 656 EXPECT_FALSE(p1->UseSoloWindowHeader()); |
657 EXPECT_FALSE(p2->UseSoloWindowHeader()); | 657 EXPECT_FALSE(p2->UseSoloWindowHeader()); |
658 | 658 |
659 // Exit with no resource release. They'll be released at shutdown. | 659 // Exit with no resource release. They'll be released at shutdown. |
660 } | 660 } |
661 | 661 |
662 } // namespace ash | 662 } // namespace ash |
OLD | NEW |