OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/ui/panels/auto_hiding_desktop_bar_win.h" |
| 6 |
| 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 |
| 10 |
| 11 class AutoHidingDesktopBarWinTest : public testing::Test, |
| 12 public AutoHidingDesktopBar::Observer { |
| 13 protected: |
| 14 // Overridden from AutoHidingDesktopBar::Observer: |
| 15 virtual void OnAutoHidingDesktopBarThicknessChanged() OVERRIDE { |
| 16 } |
| 17 |
| 18 virtual void OnAutoHidingDesktopBarVisibilityChanged( |
| 19 AutoHidingDesktopBar::Alignment alignment, |
| 20 AutoHidingDesktopBar::Visibility visibility) OVERRIDE { |
| 21 } |
| 22 |
| 23 void TestGetVisibilityFromBounds() { |
| 24 scoped_refptr<AutoHidingDesktopBarWin> bar = |
| 25 new AutoHidingDesktopBarWin(this); |
| 26 bar->set_work_area(gfx::Rect(0, 0, 800, 600)); |
| 27 |
| 28 AutoHidingDesktopBar::Visibility visibility; |
| 29 |
| 30 // Tests for bottom bar. |
| 31 visibility = bar->GetVisibilityFromBounds( |
| 32 AutoHidingDesktopBar::ALIGN_BOTTOM, gfx::Rect(0, 560, 800, 40)); |
| 33 EXPECT_EQ(AutoHidingDesktopBar::VISIBLE, visibility); |
| 34 visibility = bar->GetVisibilityFromBounds( |
| 35 AutoHidingDesktopBar::ALIGN_BOTTOM, gfx::Rect(0, 598, 800, 40)); |
| 36 EXPECT_EQ(AutoHidingDesktopBar::HIDDEN, visibility); |
| 37 visibility = bar->GetVisibilityFromBounds( |
| 38 AutoHidingDesktopBar::ALIGN_BOTTOM, gfx::Rect(0, 580, 800, 40)); |
| 39 EXPECT_EQ(AutoHidingDesktopBar::ANIMATING, visibility); |
| 40 |
| 41 // Tests for right bar. |
| 42 visibility = bar->GetVisibilityFromBounds( |
| 43 AutoHidingDesktopBar::ALIGN_RIGHT, gfx::Rect(760, 0, 40, 600)); |
| 44 EXPECT_EQ(AutoHidingDesktopBar::VISIBLE, visibility); |
| 45 visibility = bar->GetVisibilityFromBounds( |
| 46 AutoHidingDesktopBar::ALIGN_RIGHT, gfx::Rect(798, 0, 40, 600)); |
| 47 EXPECT_EQ(AutoHidingDesktopBar::HIDDEN, visibility); |
| 48 visibility = bar->GetVisibilityFromBounds( |
| 49 AutoHidingDesktopBar::ALIGN_RIGHT, gfx::Rect(780, 0, 40, 600)); |
| 50 EXPECT_EQ(AutoHidingDesktopBar::ANIMATING, visibility); |
| 51 |
| 52 // Tests for left bar. |
| 53 visibility = bar->GetVisibilityFromBounds( |
| 54 AutoHidingDesktopBar::ALIGN_LEFT, gfx::Rect(0, 0, 40, 600)); |
| 55 EXPECT_EQ(AutoHidingDesktopBar::VISIBLE, visibility); |
| 56 visibility = bar->GetVisibilityFromBounds( |
| 57 AutoHidingDesktopBar::ALIGN_LEFT, gfx::Rect(-38, 0, 40, 600)); |
| 58 EXPECT_EQ(AutoHidingDesktopBar::HIDDEN, visibility); |
| 59 visibility = bar->GetVisibilityFromBounds( |
| 60 AutoHidingDesktopBar::ALIGN_LEFT, gfx::Rect(-15, 0, 40, 600)); |
| 61 EXPECT_EQ(AutoHidingDesktopBar::ANIMATING, visibility); |
| 62 } |
| 63 }; |
| 64 |
| 65 TEST_F(AutoHidingDesktopBarWinTest, GetVisibilityFromBounds) { |
| 66 TestGetVisibilityFromBounds(); |
| 67 } |
OLD | NEW |