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 #ifndef CHROME_BROWSER_UI_WINDOW_SIZER_COMMON_UNITTEST_H_ | 5 #ifndef CHROME_BROWSER_UI_WINDOW_SIZER_COMMON_UNITTEST_H_ |
6 #define CHROME_BROWSER_UI_WINDOW_SIZER_COMMON_UNITTEST_H_ | 6 #define CHROME_BROWSER_UI_WINDOW_SIZER_COMMON_UNITTEST_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 // Some standard monitor sizes (no task bar). | 9 // Some standard monitor sizes (no task bar). |
10 static const gfx::Rect tentwentyfour(0, 0, 1024, 768); | 10 static const gfx::Rect tentwentyfour(0, 0, 1024, 768); |
(...skipping 29 matching lines...) Expand all Loading... |
40 // Testing implementation of WindowSizer::MonitorInfoProvider that we can use | 40 // Testing implementation of WindowSizer::MonitorInfoProvider that we can use |
41 // to fake various monitor layouts and sizes. | 41 // to fake various monitor layouts and sizes. |
42 class TestMonitorInfoProvider : public MonitorInfoProvider { | 42 class TestMonitorInfoProvider : public MonitorInfoProvider { |
43 public: | 43 public: |
44 TestMonitorInfoProvider(); | 44 TestMonitorInfoProvider(); |
45 virtual ~TestMonitorInfoProvider(); | 45 virtual ~TestMonitorInfoProvider(); |
46 | 46 |
47 void AddMonitor(const gfx::Rect& bounds, const gfx::Rect& work_area); | 47 void AddMonitor(const gfx::Rect& bounds, const gfx::Rect& work_area); |
48 | 48 |
49 // Overridden from WindowSizer::MonitorInfoProvider: | 49 // Overridden from WindowSizer::MonitorInfoProvider: |
50 virtual gfx::Rect GetPrimaryMonitorWorkArea() const OVERRIDE; | 50 virtual gfx::Rect GetPrimaryDisplayWorkArea() const OVERRIDE; |
51 | 51 |
52 virtual gfx::Rect GetPrimaryMonitorBounds() const OVERRIDE; | 52 virtual gfx::Rect GetPrimaryDisplayBounds() const OVERRIDE; |
53 | 53 |
54 virtual gfx::Rect GetMonitorWorkAreaMatching( | 54 virtual gfx::Rect GetMonitorWorkAreaMatching( |
55 const gfx::Rect& match_rect) const OVERRIDE; | 55 const gfx::Rect& match_rect) const OVERRIDE; |
56 | 56 |
57 private: | 57 private: |
58 size_t GetMonitorIndexMatchingBounds(const gfx::Rect& match_rect) const; | 58 size_t GetMonitorIndexMatchingBounds(const gfx::Rect& match_rect) const; |
59 | 59 |
60 std::vector<gfx::Rect> monitor_bounds_; | 60 std::vector<gfx::Rect> monitor_bounds_; |
61 std::vector<gfx::Rect> work_areas_; | 61 std::vector<gfx::Rect> work_areas_; |
62 | 62 |
63 DISALLOW_COPY_AND_ASSIGN(TestMonitorInfoProvider); | 63 DISALLOW_COPY_AND_ASSIGN(TestMonitorInfoProvider); |
64 }; | 64 }; |
65 | 65 |
66 TestMonitorInfoProvider::TestMonitorInfoProvider() {} | 66 TestMonitorInfoProvider::TestMonitorInfoProvider() {} |
67 TestMonitorInfoProvider::~TestMonitorInfoProvider() {} | 67 TestMonitorInfoProvider::~TestMonitorInfoProvider() {} |
68 | 68 |
69 void TestMonitorInfoProvider::AddMonitor(const gfx::Rect& bounds, | 69 void TestMonitorInfoProvider::AddMonitor(const gfx::Rect& bounds, |
70 const gfx::Rect& work_area) { | 70 const gfx::Rect& work_area) { |
71 DCHECK(bounds.Contains(work_area)); | 71 DCHECK(bounds.Contains(work_area)); |
72 monitor_bounds_.push_back(bounds); | 72 monitor_bounds_.push_back(bounds); |
73 work_areas_.push_back(work_area); | 73 work_areas_.push_back(work_area); |
74 } | 74 } |
75 | 75 |
76 // Overridden from WindowSizer::MonitorInfoProvider: | 76 // Overridden from WindowSizer::MonitorInfoProvider: |
77 gfx::Rect TestMonitorInfoProvider::GetPrimaryMonitorWorkArea() const { | 77 gfx::Rect TestMonitorInfoProvider::GetPrimaryDisplayWorkArea() const { |
78 return work_areas_[0]; | 78 return work_areas_[0]; |
79 } | 79 } |
80 | 80 |
81 gfx::Rect TestMonitorInfoProvider::GetPrimaryMonitorBounds() const { | 81 gfx::Rect TestMonitorInfoProvider::GetPrimaryDisplayBounds() const { |
82 return monitor_bounds_[0]; | 82 return monitor_bounds_[0]; |
83 } | 83 } |
84 | 84 |
85 gfx::Rect TestMonitorInfoProvider::GetMonitorWorkAreaMatching( | 85 gfx::Rect TestMonitorInfoProvider::GetMonitorWorkAreaMatching( |
86 const gfx::Rect& match_rect) const { | 86 const gfx::Rect& match_rect) const { |
87 return work_areas_[GetMonitorIndexMatchingBounds(match_rect)]; | 87 return work_areas_[GetMonitorIndexMatchingBounds(match_rect)]; |
88 } | 88 } |
89 | 89 |
90 size_t TestMonitorInfoProvider::GetMonitorIndexMatchingBounds( | 90 size_t TestMonitorInfoProvider::GetMonitorIndexMatchingBounds( |
91 const gfx::Rect& match_rect) const { | 91 const gfx::Rect& match_rect) const { |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 if (source == PERSISTED) | 186 if (source == PERSISTED) |
187 sp->SetPersistentState(state, work_area, true); | 187 sp->SetPersistentState(state, work_area, true); |
188 else if (source == LAST_ACTIVE) | 188 else if (source == LAST_ACTIVE) |
189 sp->SetLastActiveState(state, true); | 189 sp->SetLastActiveState(state, true); |
190 | 190 |
191 WindowSizer sizer(sp, mip, browser); | 191 WindowSizer sizer(sp, mip, browser); |
192 sizer.DetermineWindowBounds(passed_in, out_bounds); | 192 sizer.DetermineWindowBounds(passed_in, out_bounds); |
193 } | 193 } |
194 | 194 |
195 #endif // CHROME_BROWSER_UI_WINDOW_SIZER_COMMON_UNITTEST_H_ | 195 #endif // CHROME_BROWSER_UI_WINDOW_SIZER_COMMON_UNITTEST_H_ |
OLD | NEW |