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

Side by Side Diff: chrome/browser/ui/app_list/app_list_positioner_unittest.cc

Issue 93863002: Mac App Launcher is positioned on center of dock in certain cases. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Goddamn Reitveld. Created 7 years 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/app_list/app_list_positioner.h" 5 #include "chrome/browser/ui/app_list/app_list_positioner.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace { 10 namespace {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 gfx::Point DoGetAnchorPointForScreenCorner( 81 gfx::Point DoGetAnchorPointForScreenCorner(
82 AppListPositioner::ScreenCorner corner) const { 82 AppListPositioner::ScreenCorner corner) const {
83 return positioner_->GetAnchorPointForScreenCorner(corner); 83 return positioner_->GetAnchorPointForScreenCorner(corner);
84 } 84 }
85 85
86 gfx::Point DoGetAnchorPointForShelfCorner( 86 gfx::Point DoGetAnchorPointForShelfCorner(
87 AppListPositioner::ScreenEdge shelf_edge) const { 87 AppListPositioner::ScreenEdge shelf_edge) const {
88 return positioner_->GetAnchorPointForShelfCorner(shelf_edge); 88 return positioner_->GetAnchorPointForShelfCorner(shelf_edge);
89 } 89 }
90 90
91 gfx::Point DoGetAnchorPointForShelfCenter(
92 AppListPositioner::ScreenEdge shelf_edge) const {
93 return positioner_->GetAnchorPointForShelfCenter(shelf_edge);
94 }
95
91 gfx::Point DoGetAnchorPointForShelfCursor( 96 gfx::Point DoGetAnchorPointForShelfCursor(
92 AppListPositioner::ScreenEdge shelf_edge) const { 97 AppListPositioner::ScreenEdge shelf_edge) const {
93 return positioner_->GetAnchorPointForShelfCursor(shelf_edge, cursor_); 98 return positioner_->GetAnchorPointForShelfCursor(shelf_edge, cursor_);
94 } 99 }
95 100
96 AppListPositioner::ScreenEdge DoGetShelfEdge( 101 AppListPositioner::ScreenEdge DoGetShelfEdge(
97 const gfx::Rect& shelf_rect) const { 102 const gfx::Rect& shelf_rect) const {
98 return positioner_->GetShelfEdge(shelf_rect); 103 return positioner_->GetShelfEdge(shelf_rect);
99 } 104 }
100 105
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 168
164 // Shelf on bottom. Expect app list in bottom-left corner. 169 // Shelf on bottom. Expect app list in bottom-left corner.
165 PlaceShelf(AppListPositioner::SCREEN_EDGE_BOTTOM); 170 PlaceShelf(AppListPositioner::SCREEN_EDGE_BOTTOM);
166 EXPECT_EQ( 171 EXPECT_EQ(
167 gfx::Point(kWindowWidth / 2 + kMinDistanceFromEdge, 172 gfx::Point(kWindowWidth / 2 + kMinDistanceFromEdge,
168 kScreenHeight - kShelfSize - kWindowHeight / 2 - 173 kScreenHeight - kShelfSize - kWindowHeight / 2 -
169 kMinDistanceFromEdge), 174 kMinDistanceFromEdge),
170 DoGetAnchorPointForShelfCorner(AppListPositioner::SCREEN_EDGE_BOTTOM)); 175 DoGetAnchorPointForShelfCorner(AppListPositioner::SCREEN_EDGE_BOTTOM));
171 } 176 }
172 177
178 TEST_F(AppListPositionerUnitTest, ShelfCenter) {
179 // Position the app list on the shelf, aligned with the shelf center.
180 PlaceShelf(AppListPositioner::SCREEN_EDGE_LEFT);
181 // Shelf on left. Expect app list to be center-left.
182 EXPECT_EQ(
183 gfx::Point(83, kScreenHeight / 2),
184 DoGetAnchorPointForShelfCenter(AppListPositioner::SCREEN_EDGE_LEFT));
185
186 // Shelf on right. Expect app list to be center-right.
187 PlaceShelf(AppListPositioner::SCREEN_EDGE_RIGHT);
188 EXPECT_EQ(
189 gfx::Point(kScreenWidth - 83, kScreenHeight / 2),
190 DoGetAnchorPointForShelfCenter(AppListPositioner::SCREEN_EDGE_RIGHT));
191
192 // Shelf on top. Expect app list to be top-center.
193 PlaceShelf(AppListPositioner::SCREEN_EDGE_TOP);
194 EXPECT_EQ(
195 gfx::Point(kScreenWidth / 2, 133),
196 DoGetAnchorPointForShelfCenter(AppListPositioner::SCREEN_EDGE_TOP));
197
198 // Shelf on bottom. Expect app list to be bottom-center.
199 PlaceShelf(AppListPositioner::SCREEN_EDGE_BOTTOM);
200 EXPECT_EQ(
201 gfx::Point(kScreenWidth / 2, kScreenHeight - 133),
202 DoGetAnchorPointForShelfCenter(AppListPositioner::SCREEN_EDGE_BOTTOM));
203 }
204
173 TEST_F(AppListPositionerUnitTest, ShelfCursor) { 205 TEST_F(AppListPositionerUnitTest, ShelfCursor) {
174 // Position the app list on the shelf, aligned with the mouse cursor. 206 // Position the app list on the shelf, aligned with the mouse cursor.
175 207
176 // Shelf on left. Expect app list in top-left corner. 208 // Shelf on left. Expect app list in top-left corner.
177 PlaceShelf(AppListPositioner::SCREEN_EDGE_LEFT); 209 PlaceShelf(AppListPositioner::SCREEN_EDGE_LEFT);
178 PlaceCursor(kCursorIgnore, kWindowAwayFromEdge); 210 PlaceCursor(kCursorIgnore, kWindowAwayFromEdge);
179 EXPECT_EQ( 211 EXPECT_EQ(
180 gfx::Point(kShelfSize + kWindowWidth / 2 + kMinDistanceFromEdge, 212 gfx::Point(kShelfSize + kWindowWidth / 2 + kMinDistanceFromEdge,
181 kWindowAwayFromEdge), 213 kWindowAwayFromEdge),
182 DoGetAnchorPointForShelfCursor(AppListPositioner::SCREEN_EDGE_LEFT)); 214 DoGetAnchorPointForShelfCursor(AppListPositioner::SCREEN_EDGE_LEFT));
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 EXPECT_EQ( 313 EXPECT_EQ(
282 kWindowAwayFromEdge - kShelfSize, 314 kWindowAwayFromEdge - kShelfSize,
283 DoGetCursorDistanceFromShelf(AppListPositioner::SCREEN_EDGE_BOTTOM)); 315 DoGetCursorDistanceFromShelf(AppListPositioner::SCREEN_EDGE_BOTTOM));
284 316
285 // Shelf on bottom. Cursor inside shelf; expect 0. 317 // Shelf on bottom. Cursor inside shelf; expect 0.
286 PlaceShelf(AppListPositioner::SCREEN_EDGE_BOTTOM); 318 PlaceShelf(AppListPositioner::SCREEN_EDGE_BOTTOM);
287 PlaceCursor(kCursorIgnore, kScreenHeight - kCursorOnShelf); 319 PlaceCursor(kCursorIgnore, kScreenHeight - kCursorOnShelf);
288 EXPECT_EQ( 320 EXPECT_EQ(
289 0, DoGetCursorDistanceFromShelf(AppListPositioner::SCREEN_EDGE_BOTTOM)); 321 0, DoGetCursorDistanceFromShelf(AppListPositioner::SCREEN_EDGE_BOTTOM));
290 } 322 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698