| 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/default_header_painter.h" | 5 #include "ash/frame/default_header_painter.h" |
| 6 | 6 |
| 7 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h" | 7 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/test/ash_test_base.h" | 9 #include "ash/test/ash_test_base.h" |
| 10 #include "ash/wm/window_state.h" | 10 #include "ash/wm/window_state.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 painter.Init(w.get(), | 46 painter.Init(w.get(), |
| 47 w->non_client_view()->frame_view(), | 47 w->non_client_view()->frame_view(), |
| 48 &container); | 48 &container); |
| 49 painter.UpdateLeftHeaderView(&window_icon); | 49 painter.UpdateLeftHeaderView(&window_icon); |
| 50 painter.LayoutHeader(); | 50 painter.LayoutHeader(); |
| 51 gfx::Rect title_bounds = painter.GetTitleBounds(); | 51 gfx::Rect title_bounds = painter.GetTitleBounds(); |
| 52 EXPECT_EQ(window_icon.bounds().CenterPoint().y(), | 52 EXPECT_EQ(window_icon.bounds().CenterPoint().y(), |
| 53 title_bounds.CenterPoint().y()); | 53 title_bounds.CenterPoint().y()); |
| 54 } | 54 } |
| 55 | 55 |
| 56 // Ensure the light icons are used when appropriate. |
| 57 TEST_F(DefaultHeaderPainterTest, LightIcons) { |
| 58 scoped_ptr<Widget> w(CreateTestWidget()); |
| 59 ash::FrameCaptionButtonContainerView container(w.get()); |
| 60 views::StaticSizedView window_icon(gfx::Size(16, 16)); |
| 61 window_icon.SetBounds(0, 0, 16, 16); |
| 62 w->SetBounds(gfx::Rect(0, 0, 500, 500)); |
| 63 w->Show(); |
| 64 |
| 65 DefaultHeaderPainter painter; |
| 66 painter.Init(w.get(), w->non_client_view()->frame_view(), &container); |
| 67 |
| 68 // Check by default light icons are not used. |
| 69 painter.mode_ = HeaderPainter::MODE_ACTIVE; |
| 70 EXPECT_EQ(false, painter.ShouldUseLightImages()); |
| 71 painter.mode_ = HeaderPainter::MODE_INACTIVE; |
| 72 EXPECT_EQ(false, painter.ShouldUseLightImages()); |
| 73 |
| 74 // Check that setting dark colors should use light icons. |
| 75 painter.SetFrameColors(SkColorSetRGB(0, 0, 0), SkColorSetRGB(0, 0, 0)); |
| 76 painter.mode_ = HeaderPainter::MODE_ACTIVE; |
| 77 EXPECT_EQ(true, painter.ShouldUseLightImages()); |
| 78 painter.mode_ = HeaderPainter::MODE_INACTIVE; |
| 79 EXPECT_EQ(true, painter.ShouldUseLightImages()); |
| 80 |
| 81 // Check that inactive and active colors are used properly. |
| 82 painter.SetFrameColors(SkColorSetRGB(0, 0, 0), SkColorSetRGB(255, 255, 255)); |
| 83 painter.mode_ = HeaderPainter::MODE_ACTIVE; |
| 84 EXPECT_EQ(true, painter.ShouldUseLightImages()); |
| 85 painter.mode_ = HeaderPainter::MODE_INACTIVE; |
| 86 EXPECT_EQ(false, painter.ShouldUseLightImages()); |
| 87 |
| 88 // Check not so light or dark colors. |
| 89 painter.SetFrameColors(SkColorSetRGB(70, 70, 70), |
| 90 SkColorSetRGB(200, 200, 200)); |
| 91 painter.mode_ = HeaderPainter::MODE_ACTIVE; |
| 92 EXPECT_EQ(true, painter.ShouldUseLightImages()); |
| 93 painter.mode_ = HeaderPainter::MODE_INACTIVE; |
| 94 EXPECT_EQ(false, painter.ShouldUseLightImages()); |
| 95 } |
| 96 |
| 56 } // namespace ash | 97 } // namespace ash |
| OLD | NEW |