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

Side by Side Diff: chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller_unittest.mm

Issue 1775223002: Prepare chrome/ for compilation with OS X 10.7 deployment target. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Compile errors. Fix null-window error. Created 4 years, 9 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
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 <cmath>
6
5 #include "base/mac/scoped_nsobject.h" 7 #include "base/mac/scoped_nsobject.h"
6 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
7 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 9 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
8 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h" 10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h"
9 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" 11 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h"
10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_button_cell.h" 12 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_button_cell.h"
11 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.h" 13 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.h"
12 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_unittest_helper.h" 14 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_unittest_helper.h"
13 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" 15 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h"
14 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" 16 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h"
15 #import "chrome/browser/ui/cocoa/view_resizer_pong.h" 17 #import "chrome/browser/ui/cocoa/view_resizer_pong.h"
16 #include "chrome/test/base/testing_profile.h" 18 #include "chrome/test/base/testing_profile.h"
17 #include "components/bookmarks/browser/bookmark_model.h" 19 #include "components/bookmarks/browser/bookmark_model.h"
18 #include "components/bookmarks/test/bookmark_test_helpers.h" 20 #include "components/bookmarks/test/bookmark_test_helpers.h"
19 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
20 #import "testing/gtest_mac.h" 22 #import "testing/gtest_mac.h"
21 #include "testing/platform_test.h" 23 #include "testing/platform_test.h"
22 #include "ui/base/cocoa/animation_utils.h" 24 #include "ui/base/cocoa/animation_utils.h"
23 25 #include "ui/base/cocoa/cocoa_base_utils.h"
24 #include <cmath>
25 26
26 using base::ASCIIToUTF16; 27 using base::ASCIIToUTF16;
27 using bookmarks::BookmarkModel; 28 using bookmarks::BookmarkModel;
28 using bookmarks::BookmarkNode; 29 using bookmarks::BookmarkNode;
29 30
30 namespace { 31 namespace {
31 32
32 const int kLotsOfNodesCount = 150; 33 const int kLotsOfNodesCount = 150;
33 34
34 // Deletes the bookmark corresponding to |button|. 35 // Deletes the bookmark corresponding to |button|.
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 bbfc.reset([[BookmarkBarFolderController alloc] 263 bbfc.reset([[BookmarkBarFolderController alloc]
263 initWithParentButton:parentButton 264 initWithParentButton:parentButton
264 parentController:nil 265 parentController:nil
265 barController:bar_ 266 barController:bar_
266 profile:profile()]); 267 profile:profile()]);
267 [bbfc window]; 268 [bbfc window];
268 NSPoint pt = [bbfc windowTopLeftForWidth:0 height:100]; // screen coords 269 NSPoint pt = [bbfc windowTopLeftForWidth:0 height:100]; // screen coords
269 NSPoint buttonOriginInWindow = 270 NSPoint buttonOriginInWindow =
270 [parentButton convertRect:[parentButton bounds] 271 [parentButton convertRect:[parentButton bounds]
271 toView:nil].origin; 272 toView:nil].origin;
272 NSPoint buttonOriginInScreen = 273 NSPoint buttonOriginInScreen = ui::ConvertPointFromWindowToScreen(
273 [[parentButton window] convertBaseToScreen:buttonOriginInWindow]; 274 [parentButton window], buttonOriginInWindow);
274 // Within margin 275 // Within margin
275 EXPECT_LE(std::abs(pt.x - buttonOriginInScreen.x), 276 EXPECT_LE(std::abs(pt.x - buttonOriginInScreen.x),
276 bookmarks::kBookmarkMenuOverlap + 1); 277 bookmarks::kBookmarkMenuOverlap + 1);
277 EXPECT_LE(std::abs(pt.y - buttonOriginInScreen.y), 278 EXPECT_LE(std::abs(pt.y - buttonOriginInScreen.y),
278 bookmarks::kBookmarkMenuOverlap + 1); 279 bookmarks::kBookmarkMenuOverlap + 1);
279 280
280 // Make sure we see the window shift left if it spills off the screen 281 // Make sure we see the window shift left if it spills off the screen
281 pt = [bbfc windowTopLeftForWidth:0 height:100]; 282 pt = [bbfc windowTopLeftForWidth:0 height:100];
282 NSPoint shifted = [bbfc windowTopLeftForWidth:9999999 height:100]; 283 NSPoint shifted = [bbfc windowTopLeftForWidth:9999999 height:100];
283 EXPECT_LT(shifted.x, pt.x); 284 EXPECT_LT(shifted.x, pt.x);
(...skipping 1381 matching lines...) Expand 10 before | Expand all | Expand 10 after
1665 DeleteBookmark([folder parentButton], profile()); 1666 DeleteBookmark([folder parentButton], profile());
1666 EXPECT_FALSE([folder folderController]); 1667 EXPECT_FALSE([folder folderController]);
1667 } 1668 }
1668 1669
1669 // TODO(jrg): draggingEntered: and draggingExited: trigger timers so 1670 // TODO(jrg): draggingEntered: and draggingExited: trigger timers so
1670 // they are hard to test. Factor out "fire timers" into routines 1671 // they are hard to test. Factor out "fire timers" into routines
1671 // which can be overridden to fire immediately to make behavior 1672 // which can be overridden to fire immediately to make behavior
1672 // confirmable. 1673 // confirmable.
1673 // There is a similar problem with mouseEnteredButton: and 1674 // There is a similar problem with mouseEnteredButton: and
1674 // mouseExitedButton:. 1675 // mouseExitedButton:.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698