| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/browser/ui/window_sizer.h" | 5 #include "chrome/browser/ui/window_sizer.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "chrome/browser/ui/monitor_info_provider.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 13 |
| 13 // Some standard monitor sizes (no task bar). | 14 // Some standard monitor sizes (no task bar). |
| 14 static const gfx::Rect tentwentyfour(0, 0, 1024, 768); | 15 static const gfx::Rect tentwentyfour(0, 0, 1024, 768); |
| 15 static const gfx::Rect twelveeighty(0, 0, 1280, 1024); | 16 static const gfx::Rect twelveeighty(0, 0, 1280, 1024); |
| 16 static const gfx::Rect sixteenhundred(0, 0, 1600, 1200); | 17 static const gfx::Rect sixteenhundred(0, 0, 1600, 1200); |
| 17 static const gfx::Rect sixteeneighty(0, 0, 1680, 1050); | 18 static const gfx::Rect sixteeneighty(0, 0, 1680, 1050); |
| 18 static const gfx::Rect nineteentwenty(0, 0, 1920, 1200); | 19 static const gfx::Rect nineteentwenty(0, 0, 1920, 1200); |
| 19 | 20 |
| 20 // Represents a 1024x768 monitor that is not the primary monitor, arranged to | 21 // Represents a 1024x768 monitor that is not the primary monitor, arranged to |
| (...skipping 15 matching lines...) Expand all Loading... |
| 36 // The work area for 1024x768 monitors with different taskbar orientations. | 37 // The work area for 1024x768 monitors with different taskbar orientations. |
| 37 static const gfx::Rect taskbar_bottom_work_area(0, 0, 1024, 734); | 38 static const gfx::Rect taskbar_bottom_work_area(0, 0, 1024, 734); |
| 38 static const gfx::Rect taskbar_top_work_area(0, 34, 1024, 734); | 39 static const gfx::Rect taskbar_top_work_area(0, 34, 1024, 734); |
| 39 static const gfx::Rect taskbar_left_work_area(107, 0, 917, 768); | 40 static const gfx::Rect taskbar_left_work_area(107, 0, 917, 768); |
| 40 static const gfx::Rect taskbar_right_work_area(0, 0, 917, 768); | 41 static const gfx::Rect taskbar_right_work_area(0, 0, 917, 768); |
| 41 | 42 |
| 42 static int kWindowTilePixels = WindowSizer::kWindowTilePixels; | 43 static int kWindowTilePixels = WindowSizer::kWindowTilePixels; |
| 43 | 44 |
| 44 // Testing implementation of WindowSizer::MonitorInfoProvider that we can use | 45 // Testing implementation of WindowSizer::MonitorInfoProvider that we can use |
| 45 // to fake various monitor layouts and sizes. | 46 // to fake various monitor layouts and sizes. |
| 46 class TestMonitorInfoProvider : public WindowSizer::MonitorInfoProvider { | 47 class TestMonitorInfoProvider : public MonitorInfoProvider { |
| 47 public: | 48 public: |
| 48 TestMonitorInfoProvider() {} | 49 TestMonitorInfoProvider() {} |
| 49 virtual ~TestMonitorInfoProvider() {} | 50 virtual ~TestMonitorInfoProvider() {} |
| 50 | 51 |
| 51 void AddMonitor(const gfx::Rect& bounds, const gfx::Rect& work_area) { | 52 void AddMonitor(const gfx::Rect& bounds, const gfx::Rect& work_area) { |
| 52 DCHECK(bounds.Contains(work_area)); | 53 DCHECK(bounds.Contains(work_area)); |
| 53 monitor_bounds_.push_back(bounds); | 54 monitor_bounds_.push_back(bounds); |
| 54 work_areas_.push_back(work_area); | 55 work_areas_.push_back(work_area); |
| 55 } | 56 } |
| 56 | 57 |
| 57 // Overridden from WindowSizer::MonitorInfoProvider: | 58 // Overridden from MonitorInfoProvider: |
| 58 virtual gfx::Rect GetPrimaryMonitorWorkArea() const OVERRIDE { | 59 virtual gfx::Rect GetPrimaryMonitorWorkArea() const OVERRIDE { |
| 59 return work_areas_[0]; | 60 return work_areas_[0]; |
| 60 } | 61 } |
| 61 | 62 |
| 62 virtual gfx::Rect GetPrimaryMonitorBounds() const OVERRIDE { | 63 virtual gfx::Rect GetPrimaryMonitorBounds() const OVERRIDE { |
| 63 return monitor_bounds_[0]; | 64 return monitor_bounds_[0]; |
| 64 } | 65 } |
| 65 | 66 |
| 66 virtual gfx::Rect GetMonitorWorkAreaMatching( | 67 virtual gfx::Rect GetMonitorWorkAreaMatching( |
| 67 const gfx::Rect& match_rect) const OVERRIDE { | 68 const gfx::Rect& match_rect) const OVERRIDE { |
| (...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 829 | 830 |
| 830 { // entirely off bottom (monitor was detached since last run) | 831 { // entirely off bottom (monitor was detached since last run) |
| 831 gfx::Rect window_bounds; | 832 gfx::Rect window_bounds; |
| 832 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 833 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 833 gfx::Rect(50, 800, 500, 400), bottom_nonprimary, | 834 gfx::Rect(50, 800, 500, 400), bottom_nonprimary, |
| 834 PERSISTED, &window_bounds); | 835 PERSISTED, &window_bounds); |
| 835 EXPECT_EQ(gfx::Rect(50, 368, 500, 400), window_bounds); | 836 EXPECT_EQ(gfx::Rect(50, 368, 500, 400), window_bounds); |
| 836 } | 837 } |
| 837 } | 838 } |
| 838 #endif //defined(OS_MACOSX) | 839 #endif //defined(OS_MACOSX) |
| OLD | NEW |