| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/scoped_nsobject.h" | 8 #include "base/scoped_nsobject.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/bookmarks/bookmark_model.h" | 10 #include "chrome/browser/bookmarks/bookmark_model.h" |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 EXPECT_CGFLOAT_EQ(0.0, [window frame].origin.y); | 463 EXPECT_CGFLOAT_EQ(0.0, [window frame].origin.y); |
| 464 | 464 |
| 465 // Initially, should show scroll-up but not scroll-down. | 465 // Initially, should show scroll-up but not scroll-down. |
| 466 EXPECT_TRUE([bbfc canScrollUp]); | 466 EXPECT_TRUE([bbfc canScrollUp]); |
| 467 EXPECT_FALSE([bbfc canScrollDown]); | 467 EXPECT_FALSE([bbfc canScrollDown]); |
| 468 | 468 |
| 469 // Scroll up a bit. Make sure the window has gotten bigger each time. | 469 // Scroll up a bit. Make sure the window has gotten bigger each time. |
| 470 // Also, for each scroll, make sure our hit test finds a new button | 470 // Also, for each scroll, make sure our hit test finds a new button |
| 471 // (to confirm the content area changed). | 471 // (to confirm the content area changed). |
| 472 NSView* savedHit = nil; | 472 NSView* savedHit = nil; |
| 473 NSView* scrollView = [bbfc scrollView]; | 473 NSScrollView* scrollView = [bbfc scrollView]; |
| 474 | 474 |
| 475 // Find the next-to-last button showing at the bottom of the window and | 475 // Find the next-to-last button showing at the bottom of the window and |
| 476 // us its center for hit testing. | 476 // us its center for hit testing. |
| 477 BookmarkButton* targetButton = nil; | 477 BookmarkButton* targetButton = nil; |
| 478 NSPoint scrollPoint = [[bbfc scrollView] documentVisibleRect].origin; | 478 NSPoint scrollPoint = [scrollView documentVisibleRect].origin; |
| 479 for (BookmarkButton* button in [bbfc buttons]) { | 479 for (BookmarkButton* button in [bbfc buttons]) { |
| 480 NSRect buttonFrame = [button frame]; | 480 NSRect buttonFrame = [button frame]; |
| 481 buttonFrame.origin.y -= scrollPoint.y; | 481 buttonFrame.origin.y -= scrollPoint.y; |
| 482 if (buttonFrame.origin.y < 0.0) | 482 if (buttonFrame.origin.y < 0.0) |
| 483 break; | 483 break; |
| 484 targetButton = button; | 484 targetButton = button; |
| 485 } | 485 } |
| 486 NSPoint hitPoint = [targetButton frame].origin; | 486 NSPoint hitPoint = [targetButton frame].origin; |
| 487 hitPoint.x += 50.0; | 487 hitPoint.x += 50.0; |
| 488 hitPoint.y += (bookmarks::kBookmarkButtonHeight / 2.0) - scrollPoint.y; | 488 hitPoint.y += (bookmarks::kBookmarkButtonHeight / 2.0) - scrollPoint.y; |
| (...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1192 // Now add a real bookmark and reopen. | 1192 // Now add a real bookmark and reopen. |
| 1193 model.AddURL(folder, folder->GetChildCount(), ASCIIToUTF16("a"), | 1193 model.AddURL(folder, folder->GetChildCount(), ASCIIToUTF16("a"), |
| 1194 GURL("http://a.com/")); | 1194 GURL("http://a.com/")); |
| 1195 folderController = [bar_ folderController]; | 1195 folderController = [bar_ folderController]; |
| 1196 EXPECT_TRUE(folderController); | 1196 EXPECT_TRUE(folderController); |
| 1197 NSView* folderView = [folderController folderView]; | 1197 NSView* folderView = [folderController folderView]; |
| 1198 EXPECT_TRUE(folderView); | 1198 EXPECT_TRUE(folderView); |
| 1199 NSRect menuFrame = [folderView frame]; | 1199 NSRect menuFrame = [folderView frame]; |
| 1200 NSView* visibleView = [folderController visibleView]; | 1200 NSView* visibleView = [folderController visibleView]; |
| 1201 NSRect visibleFrame = [visibleView frame]; | 1201 NSRect visibleFrame = [visibleView frame]; |
| 1202 NSView* scrollView = [folderController scrollView]; | 1202 NSScrollView* scrollView = [folderController scrollView]; |
| 1203 NSRect scrollFrame = [scrollView frame]; | 1203 NSRect scrollFrame = [scrollView frame]; |
| 1204 | 1204 |
| 1205 // Determine the margins between the scroll frame and the visible frame. | 1205 // Determine the margins between the scroll frame and the visible frame. |
| 1206 CGFloat widthDelta = NSWidth(visibleFrame) - NSWidth(scrollFrame); | 1206 CGFloat widthDelta = NSWidth(visibleFrame) - NSWidth(scrollFrame); |
| 1207 | 1207 |
| 1208 CGFloat menuHeight = NSHeight(menuFrame); | 1208 CGFloat menuHeight = NSHeight(menuFrame); |
| 1209 EXPECT_CGFLOAT_EQ(expectedHeight, menuHeight); | 1209 EXPECT_CGFLOAT_EQ(expectedHeight, menuHeight); |
| 1210 CGFloat scrollerWidth = NSWidth(scrollFrame); | 1210 CGFloat scrollerWidth = NSWidth(scrollFrame); |
| 1211 button = [folderController buttonWithTitleEqualTo:@"a"]; | 1211 button = [folderController buttonWithTitleEqualTo:@"a"]; |
| 1212 CGFloat buttonWidth = NSWidth([button frame]); | 1212 CGFloat buttonWidth = NSWidth([button frame]); |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1553 [folder deleteBookmark:folder]; | 1553 [folder deleteBookmark:folder]; |
| 1554 EXPECT_FALSE([folder folderController]); | 1554 EXPECT_FALSE([folder folderController]); |
| 1555 } | 1555 } |
| 1556 | 1556 |
| 1557 // TODO(jrg): draggingEntered: and draggingExited: trigger timers so | 1557 // TODO(jrg): draggingEntered: and draggingExited: trigger timers so |
| 1558 // they are hard to test. Factor out "fire timers" into routines | 1558 // they are hard to test. Factor out "fire timers" into routines |
| 1559 // which can be overridden to fire immediately to make behavior | 1559 // which can be overridden to fire immediately to make behavior |
| 1560 // confirmable. | 1560 // confirmable. |
| 1561 // There is a similar problem with mouseEnteredButton: and | 1561 // There is a similar problem with mouseEnteredButton: and |
| 1562 // mouseExitedButton:. | 1562 // mouseExitedButton:. |
| OLD | NEW |