Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: ash/wm/custom_frame_view_ash_unittest.cc

Issue 10795013: Rename bounds accessors to be intuitive and consistent (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/wm/base_layout_manager_unittest.cc ('k') | ash/wm/frame_painter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "ash/wm/custom_frame_view_ash.h" 5 #include "ash/wm/custom_frame_view_ash.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/test/ash_test_base.h" 8 #include "ash/test/ash_test_base.h"
9 #include "ash/wm/window_util.h" 9 #include "ash/wm/window_util.h"
10 #include "ash/wm/workspace/snap_sizer.h" 10 #include "ash/wm/workspace/snap_sizer.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 }; 105 };
106 106
107 // Tests that clicking on the resize-button toggles between maximize and normal 107 // Tests that clicking on the resize-button toggles between maximize and normal
108 // state. 108 // state.
109 TEST_F(CustomFrameViewAshTest, ResizeButtonToggleMaximize) { 109 TEST_F(CustomFrameViewAshTest, ResizeButtonToggleMaximize) {
110 views::Widget* widget = CreateWidget(); 110 views::Widget* widget = CreateWidget();
111 aura::Window* window = widget->GetNativeWindow(); 111 aura::Window* window = widget->GetNativeWindow();
112 CustomFrameViewAsh* frame = custom_frame_view_ash(widget); 112 CustomFrameViewAsh* frame = custom_frame_view_ash(widget);
113 CustomFrameViewAsh::TestApi test(frame); 113 CustomFrameViewAsh::TestApi test(frame);
114 views::View* view = test.maximize_button(); 114 views::View* view = test.maximize_button();
115 gfx::Point center = view->GetScreenBounds().CenterPoint(); 115 gfx::Point center = view->GetBoundsInScreen().CenterPoint();
116 116
117 aura::test::EventGenerator generator(window->GetRootWindow(), center); 117 aura::test::EventGenerator generator(window->GetRootWindow(), center);
118 118
119 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); 119 EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
120 120
121 generator.ClickLeftButton(); 121 generator.ClickLeftButton();
122 RunAllPendingInMessageLoop(); 122 RunAllPendingInMessageLoop();
123 EXPECT_TRUE(ash::wm::IsWindowMaximized(window)); 123 EXPECT_TRUE(ash::wm::IsWindowMaximized(window));
124 124
125 center = view->GetScreenBounds().CenterPoint(); 125 center = view->GetBoundsInScreen().CenterPoint();
126 generator.MoveMouseTo(center); 126 generator.MoveMouseTo(center);
127 generator.ClickLeftButton(); 127 generator.ClickLeftButton();
128 RunAllPendingInMessageLoop(); 128 RunAllPendingInMessageLoop();
129 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); 129 EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
130 130
131 generator.GestureTapAt(view->GetScreenBounds().CenterPoint()); 131 generator.GestureTapAt(view->GetBoundsInScreen().CenterPoint());
132 EXPECT_TRUE(ash::wm::IsWindowMaximized(window)); 132 EXPECT_TRUE(ash::wm::IsWindowMaximized(window));
133 133
134 generator.GestureTapAt(view->GetScreenBounds().CenterPoint()); 134 generator.GestureTapAt(view->GetBoundsInScreen().CenterPoint());
135 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); 135 EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
136 136
137 generator.GestureTapDownAndUp(view->GetScreenBounds().CenterPoint()); 137 generator.GestureTapDownAndUp(view->GetBoundsInScreen().CenterPoint());
138 EXPECT_TRUE(ash::wm::IsWindowMaximized(window)); 138 EXPECT_TRUE(ash::wm::IsWindowMaximized(window));
139 139
140 generator.GestureTapDownAndUp(view->GetScreenBounds().CenterPoint()); 140 generator.GestureTapDownAndUp(view->GetBoundsInScreen().CenterPoint());
141 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); 141 EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
142 142
143 widget->Close(); 143 widget->Close();
144 } 144 }
145 145
146 // Tests that click+dragging on the resize-button tiles or minimizes the window. 146 // Tests that click+dragging on the resize-button tiles or minimizes the window.
147 TEST_F(CustomFrameViewAshTest, ResizeButtonDrag) { 147 TEST_F(CustomFrameViewAshTest, ResizeButtonDrag) {
148 views::Widget* widget = CreateWidget(); 148 views::Widget* widget = CreateWidget();
149 aura::Window* window = widget->GetNativeWindow(); 149 aura::Window* window = widget->GetNativeWindow();
150 CustomFrameViewAsh* frame = custom_frame_view_ash(widget); 150 CustomFrameViewAsh* frame = custom_frame_view_ash(widget);
151 CustomFrameViewAsh::TestApi test(frame); 151 CustomFrameViewAsh::TestApi test(frame);
152 views::View* view = test.maximize_button(); 152 views::View* view = test.maximize_button();
153 gfx::Point center = view->GetScreenBounds().CenterPoint(); 153 gfx::Point center = view->GetBoundsInScreen().CenterPoint();
154 const int kGridSize = ash::Shell::GetInstance()->GetGridSize(); 154 const int kGridSize = ash::Shell::GetInstance()->GetGridSize();
155 155
156 aura::test::EventGenerator generator(window->GetRootWindow(), center); 156 aura::test::EventGenerator generator(window->GetRootWindow(), center);
157 157
158 EXPECT_TRUE(ash::wm::IsWindowNormal(window)); 158 EXPECT_TRUE(ash::wm::IsWindowNormal(window));
159 159
160 // Snap right. 160 // Snap right.
161 { 161 {
162 generator.PressLeftButton(); 162 generator.PressLeftButton();
163 generator.MoveMouseBy(10, 0); 163 generator.MoveMouseBy(10, 0);
164 generator.ReleaseLeftButton(); 164 generator.ReleaseLeftButton();
165 RunAllPendingInMessageLoop(); 165 RunAllPendingInMessageLoop();
166 166
167 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); 167 EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
168 EXPECT_FALSE(ash::wm::IsWindowMinimized(window)); 168 EXPECT_FALSE(ash::wm::IsWindowMinimized(window));
169 internal::SnapSizer sizer(window, center, 169 internal::SnapSizer sizer(window, center,
170 internal::SnapSizer::RIGHT_EDGE, kGridSize); 170 internal::SnapSizer::RIGHT_EDGE, kGridSize);
171 EXPECT_EQ(sizer.target_bounds().ToString(), window->bounds().ToString()); 171 EXPECT_EQ(sizer.target_bounds().ToString(), window->bounds().ToString());
172 } 172 }
173 173
174 // Snap left. 174 // Snap left.
175 { 175 {
176 center = view->GetScreenBounds().CenterPoint(); 176 center = view->GetBoundsInScreen().CenterPoint();
177 generator.MoveMouseTo(center); 177 generator.MoveMouseTo(center);
178 generator.PressLeftButton(); 178 generator.PressLeftButton();
179 generator.MoveMouseBy(-10, 0); 179 generator.MoveMouseBy(-10, 0);
180 generator.ReleaseLeftButton(); 180 generator.ReleaseLeftButton();
181 RunAllPendingInMessageLoop(); 181 RunAllPendingInMessageLoop();
182 182
183 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); 183 EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
184 EXPECT_FALSE(ash::wm::IsWindowMinimized(window)); 184 EXPECT_FALSE(ash::wm::IsWindowMinimized(window));
185 internal::SnapSizer sizer(window, center, 185 internal::SnapSizer sizer(window, center,
186 internal::SnapSizer::LEFT_EDGE, kGridSize); 186 internal::SnapSizer::LEFT_EDGE, kGridSize);
187 EXPECT_EQ(sizer.target_bounds().ToString(), window->bounds().ToString()); 187 EXPECT_EQ(sizer.target_bounds().ToString(), window->bounds().ToString());
188 } 188 }
189 189
190 // Minimize. 190 // Minimize.
191 { 191 {
192 center = view->GetScreenBounds().CenterPoint(); 192 center = view->GetBoundsInScreen().CenterPoint();
193 generator.MoveMouseTo(center); 193 generator.MoveMouseTo(center);
194 generator.PressLeftButton(); 194 generator.PressLeftButton();
195 generator.MoveMouseBy(0, 10); 195 generator.MoveMouseBy(0, 10);
196 generator.ReleaseLeftButton(); 196 generator.ReleaseLeftButton();
197 RunAllPendingInMessageLoop(); 197 RunAllPendingInMessageLoop();
198 198
199 EXPECT_TRUE(ash::wm::IsWindowMinimized(window)); 199 EXPECT_TRUE(ash::wm::IsWindowMinimized(window));
200 } 200 }
201 201
202 ash::wm::RestoreWindow(window); 202 ash::wm::RestoreWindow(window);
203 203
204 // Now test the same behaviour for gesture events. 204 // Now test the same behaviour for gesture events.
205 205
206 // Snap right. 206 // Snap right.
207 { 207 {
208 center = view->GetScreenBounds().CenterPoint(); 208 center = view->GetBoundsInScreen().CenterPoint();
209 gfx::Point end = center; 209 gfx::Point end = center;
210 end.Offset(40, 0); 210 end.Offset(40, 0);
211 generator.GestureScrollSequence(center, end, 211 generator.GestureScrollSequence(center, end,
212 base::TimeDelta::FromMilliseconds(100), 212 base::TimeDelta::FromMilliseconds(100),
213 3); 213 3);
214 RunAllPendingInMessageLoop(); 214 RunAllPendingInMessageLoop();
215 215
216 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); 216 EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
217 EXPECT_FALSE(ash::wm::IsWindowMinimized(window)); 217 EXPECT_FALSE(ash::wm::IsWindowMinimized(window));
218 internal::SnapSizer sizer(window, center, 218 internal::SnapSizer sizer(window, center,
219 internal::SnapSizer::RIGHT_EDGE, kGridSize); 219 internal::SnapSizer::RIGHT_EDGE, kGridSize);
220 EXPECT_EQ(sizer.target_bounds().ToString(), window->bounds().ToString()); 220 EXPECT_EQ(sizer.target_bounds().ToString(), window->bounds().ToString());
221 } 221 }
222 222
223 // Snap left. 223 // Snap left.
224 { 224 {
225 center = view->GetScreenBounds().CenterPoint(); 225 center = view->GetBoundsInScreen().CenterPoint();
226 gfx::Point end = center; 226 gfx::Point end = center;
227 end.Offset(-40, 0); 227 end.Offset(-40, 0);
228 generator.GestureScrollSequence(center, end, 228 generator.GestureScrollSequence(center, end,
229 base::TimeDelta::FromMilliseconds(100), 229 base::TimeDelta::FromMilliseconds(100),
230 3); 230 3);
231 RunAllPendingInMessageLoop(); 231 RunAllPendingInMessageLoop();
232 232
233 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); 233 EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
234 EXPECT_FALSE(ash::wm::IsWindowMinimized(window)); 234 EXPECT_FALSE(ash::wm::IsWindowMinimized(window));
235 internal::SnapSizer sizer(window, center, 235 internal::SnapSizer sizer(window, center,
236 internal::SnapSizer::LEFT_EDGE, kGridSize); 236 internal::SnapSizer::LEFT_EDGE, kGridSize);
237 EXPECT_EQ(sizer.target_bounds().ToString(), window->bounds().ToString()); 237 EXPECT_EQ(sizer.target_bounds().ToString(), window->bounds().ToString());
238 } 238 }
239 239
240 // Minimize. 240 // Minimize.
241 { 241 {
242 center = view->GetScreenBounds().CenterPoint(); 242 center = view->GetBoundsInScreen().CenterPoint();
243 gfx::Point end = center; 243 gfx::Point end = center;
244 end.Offset(0, 40); 244 end.Offset(0, 40);
245 generator.GestureScrollSequence(center, end, 245 generator.GestureScrollSequence(center, end,
246 base::TimeDelta::FromMilliseconds(100), 246 base::TimeDelta::FromMilliseconds(100),
247 3); 247 3);
248 RunAllPendingInMessageLoop(); 248 RunAllPendingInMessageLoop();
249 249
250 EXPECT_TRUE(ash::wm::IsWindowMinimized(window)); 250 EXPECT_TRUE(ash::wm::IsWindowMinimized(window));
251 } 251 }
252 252
253 // Test with gesture events. 253 // Test with gesture events.
254 254
255 widget->Close(); 255 widget->Close();
256 } 256 }
257 257
258 } // namespace internal 258 } // namespace internal
259 } // namespace ash 259 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/base_layout_manager_unittest.cc ('k') | ash/wm/frame_painter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698