Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / chrome / browser / ui / window_sizer / window_sizer_common_unittest.h
blob4ab6d25bd35548bf7fb18b3282bafa0343c767d5
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_WINDOW_SIZER_WINDOW_SIZER_COMMON_UNITTEST_H_
6 #define CHROME_BROWSER_UI_WINDOW_SIZER_WINDOW_SIZER_COMMON_UNITTEST_H_
8 #include <vector>
10 #include "base/logging.h"
11 #include "chrome/browser/ui/window_sizer/window_sizer.h"
12 #include "chrome/test/base/test_browser_window.h"
13 #include "ui/gfx/geometry/rect.h"
15 // Some standard primary monitor sizes (no task bar).
16 static const gfx::Rect p1024x768(0, 0, 1024, 768);
17 static const gfx::Rect p1280x1024(0, 0, 1280, 1024);
18 static const gfx::Rect p1600x1200(0, 0, 1600, 1200);
19 static const gfx::Rect p1680x1050(0, 0, 1680, 1050);
20 static const gfx::Rect p1920x1200(0, 0, 1920, 1200);
22 // Represents a 1024x768 monitor that is the secondary monitor, arranged to
23 // the immediate left of the primary 1024x768 monitor.
24 static const gfx::Rect left_s1024x768(-1024, 0, 1024, 768);
26 // Represents a 1024x768 monitor that is the secondary monitor, arranged to
27 // the immediate right of the primary 1024x768 monitor.
28 static const gfx::Rect right_s1024x768(1024, 0, 1024, 768);
30 // Represents a 1024x768 monitor that is the secondary monitor, arranged to
31 // the immediate top of the primary 1024x768 monitor.
32 static const gfx::Rect top_s1024x768(0, -768, 1024, 768);
34 // Represents a 1024x768 monitor that is the secondary monitor, arranged to
35 // the immediate bottom of the primary 1024x768 monitor.
36 static const gfx::Rect bottom_s1024x768(0, 768, 1024, 768);
38 // Represents a 1600x1200 monitor that is the secondary monitor, arranged to
39 // the immediate bottom of the primary 1600x1200 monitor.
40 static const gfx::Rect bottom_s1600x1200(0, 1200, 1600, 1200);
42 // The work area for 1024x768 monitors with different taskbar orientations.
43 static const gfx::Rect taskbar_bottom_work_area(0, 0, 1024, 734);
44 static const gfx::Rect taskbar_top_work_area(0, 34, 1024, 734);
45 static const gfx::Rect taskbar_left_work_area(107, 0, 917, 768);
46 static const gfx::Rect taskbar_right_work_area(0, 0, 917, 768);
48 extern int kWindowTilePixels;
50 // Testing implementation of WindowSizer::StateProvider that we use to fake
51 // persistent storage and existing windows.
52 class TestStateProvider : public WindowSizer::StateProvider {
53 public:
54 TestStateProvider();
55 ~TestStateProvider() override {}
57 void SetPersistentState(const gfx::Rect& bounds,
58 const gfx::Rect& work_area,
59 ui::WindowShowState show_state,
60 bool has_persistent_data);
61 void SetLastActiveState(const gfx::Rect& bounds,
62 ui::WindowShowState show_state,
63 bool has_last_active_data);
65 // Overridden from WindowSizer::StateProvider:
66 bool GetPersistentState(gfx::Rect* bounds,
67 gfx::Rect* saved_work_area,
68 ui::WindowShowState* show_state) const override;
69 bool GetLastActiveWindowState(gfx::Rect* bounds,
70 ui::WindowShowState* show_state) const override;
72 private:
73 gfx::Rect persistent_bounds_;
74 gfx::Rect persistent_work_area_;
75 bool has_persistent_data_;
76 ui::WindowShowState persistent_show_state_;
78 gfx::Rect last_active_bounds_;
79 bool has_last_active_data_;
80 ui::WindowShowState last_active_show_state_;
82 DISALLOW_COPY_AND_ASSIGN(TestStateProvider);
85 // Several convenience functions which allow to set up a state for
86 // window sizer test operations with a single call.
88 enum Source { DEFAULT, LAST_ACTIVE, PERSISTED, BOTH };
90 // Sets up the window bounds, monitor bounds, show states and more to get the
91 // resulting |out_bounds| and |out_show_state| from the WindowSizer.
92 // |source| specifies which type of data gets set for the test: Either the
93 // last active window, the persisted value which was stored earlier, both or
94 // none. For all these states the |bounds| and |work_area| get used, for the
95 // show states either |show_state_persisted| or |show_state_last| will be used.
96 void GetWindowBoundsAndShowState(const gfx::Rect& monitor1_bounds,
97 const gfx::Rect& monitor1_work_area,
98 const gfx::Rect& monitor2_bounds,
99 const gfx::Rect& bounds,
100 const gfx::Rect& work_area,
101 ui::WindowShowState show_state_persisted,
102 ui::WindowShowState show_state_last,
103 Source source,
104 const Browser* browser,
105 const gfx::Rect& passed_in,
106 gfx::Rect* out_bounds,
107 ui::WindowShowState* out_show_state);
109 // Sets up the window bounds, monitor bounds, and work area to get the
110 // resulting |out_bounds| from the WindowSizer.
111 // |source| specifies which type of data gets set for the test: Either the
112 // last active window, the persisted value which was stored earlier, both or
113 // none. For all these states the |bounds| and |work_area| get used, for the
114 // show states either |show_state_persisted| or |show_state_last| will be used.
115 void GetWindowBounds(const gfx::Rect& monitor1_bounds,
116 const gfx::Rect& monitor1_work_area,
117 const gfx::Rect& monitor2_bounds,
118 const gfx::Rect& bounds,
119 const gfx::Rect& work_area,
120 Source source,
121 const Browser* browser,
122 const gfx::Rect& passed_in,
123 gfx::Rect* out_bounds);
125 // Sets up the window |bounds| and various system states which have an influence
126 // on the WindowSizer and then determines the resulting show state from it.
127 // |bounds| specifies the |browser| last or persistent bounds depending on
128 // |source|. The |display_config| is the primary display configuration used.
129 ui::WindowShowState GetWindowShowState(
130 ui::WindowShowState show_state_persisted,
131 ui::WindowShowState show_state_last,
132 Source source,
133 const Browser* browser,
134 const gfx::Rect& bounds,
135 const gfx::Rect& display_config);
137 #endif // CHROME_BROWSER_UI_WINDOW_SIZER_WINDOW_SIZER_COMMON_UNITTEST_H_