diff options
author | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-18 22:56:47 +0000 |
---|---|---|
committer | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-18 22:56:47 +0000 |
commit | e38baf689097b646f0200f9698d8b91f6e1daf92 (patch) | |
tree | 1b05d6647c4a20fd6fb6339a61b72f162174aae3 /chrome/browser/cocoa/bookmark_bar_controller_unittest.mm | |
parent | db343035f369d9da377762f784fc3a7ddabaecf6 (diff) | |
download | chromium_src-e38baf689097b646f0200f9698d8b91f6e1daf92.zip chromium_src-e38baf689097b646f0200f9698d8b91f6e1daf92.tar.gz chromium_src-e38baf689097b646f0200f9698d8b91f6e1daf92.tar.bz2 |
Mac: animate NTP detached bookmark bar <-> normal bookmark bar.
Also mostly fix the placement of the "For quick access, place your bookmarks here [...]" message (when there are no bookmarks). It's not quite right in the new animation (detached <-> normal).
BUG=25600, 27692, 27693
TEST=Go to NTP and press Cmd-Shift-B a few times while watching closely. The detached bar should "morph" smoothly to the normal bar and vice versa. Switch themes and repeat; please test at least the default theme and the Brushed theme.
Review URL: http://codereview.chromium.org/400020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32425 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/bookmark_bar_controller_unittest.mm')
-rw-r--r-- | chrome/browser/cocoa/bookmark_bar_controller_unittest.mm | 93 |
1 files changed, 77 insertions, 16 deletions
diff --git a/chrome/browser/cocoa/bookmark_bar_controller_unittest.mm b/chrome/browser/cocoa/bookmark_bar_controller_unittest.mm index c025b0e..0fc68e3 100644 --- a/chrome/browser/cocoa/bookmark_bar_controller_unittest.mm +++ b/chrome/browser/cocoa/bookmark_bar_controller_unittest.mm @@ -126,13 +126,6 @@ class BookmarkBarControllerTest : public PlatformTest { withAnimation:NO]; } - // Update the state of the bookmark bar. - void UpdateBookmarkBar() { - [bar_ updateAndShowNormalBar:[bar_ isShownAsToolbar] - showDetachedBar:[bar_ isShownAsDetachedBar] - withAnimation:NO]; - } - // Return a menu item that points to the right URL. NSMenuItem* ItemForBookmarkBarMenu(GURL& gurl) { node_.reset(new BookmarkNode(gurl)); @@ -161,9 +154,10 @@ TEST_F(BookmarkBarControllerTest, ShowWhenShowBookmarkBarTrue) { [bar_ updateAndShowNormalBar:YES showDetachedBar:NO withAnimation:NO]; - EXPECT_TRUE([bar_ isShownAsToolbar]); - EXPECT_FALSE([bar_ isShownAsDetachedBar]); + EXPECT_TRUE([bar_ isInState:bookmarks::kShowingState]); + EXPECT_FALSE([bar_ isInState:bookmarks::kDetachedState]); EXPECT_TRUE([bar_ isVisible]); + EXPECT_FALSE([bar_ isAnimationRunning]); EXPECT_FALSE([[bar_ view] isHidden]); EXPECT_GT([resizeDelegate_ height], 0); EXPECT_GT([[bar_ view] frame].size.height, 0); @@ -173,9 +167,10 @@ TEST_F(BookmarkBarControllerTest, HideWhenShowBookmarkBarFalse) { [bar_ updateAndShowNormalBar:NO showDetachedBar:NO withAnimation:NO]; - EXPECT_FALSE([bar_ isShownAsToolbar]); - EXPECT_FALSE([bar_ isShownAsDetachedBar]); + EXPECT_FALSE([bar_ isInState:bookmarks::kShowingState]); + EXPECT_FALSE([bar_ isInState:bookmarks::kDetachedState]); EXPECT_FALSE([bar_ isVisible]); + EXPECT_FALSE([bar_ isAnimationRunning]); EXPECT_TRUE([[bar_ view] isHidden]); EXPECT_EQ(0, [resizeDelegate_ height]); EXPECT_EQ(0, [[bar_ view] frame].size.height); @@ -186,9 +181,10 @@ TEST_F(BookmarkBarControllerTest, HideWhenShowBookmarkBarTrueButDisabled) { [bar_ updateAndShowNormalBar:YES showDetachedBar:NO withAnimation:NO]; - EXPECT_TRUE([bar_ isShownAsToolbar]); - EXPECT_FALSE([bar_ isShownAsDetachedBar]); + EXPECT_TRUE([bar_ isInState:bookmarks::kShowingState]); + EXPECT_FALSE([bar_ isInState:bookmarks::kDetachedState]); EXPECT_FALSE([bar_ isVisible]); + EXPECT_FALSE([bar_ isAnimationRunning]); EXPECT_TRUE([[bar_ view] isHidden]); EXPECT_EQ(0, [resizeDelegate_ height]); EXPECT_EQ(0, [[bar_ view] frame].size.height); @@ -198,11 +194,12 @@ TEST_F(BookmarkBarControllerTest, ShowOnNewTabPage) { [bar_ updateAndShowNormalBar:NO showDetachedBar:YES withAnimation:NO]; - EXPECT_FALSE([bar_ isShownAsToolbar]); - EXPECT_TRUE([bar_ isShownAsDetachedBar]); + EXPECT_FALSE([bar_ isInState:bookmarks::kShowingState]); + EXPECT_TRUE([bar_ isInState:bookmarks::kDetachedState]); EXPECT_TRUE([bar_ isVisible]); + EXPECT_FALSE([bar_ isAnimationRunning]); EXPECT_FALSE([[bar_ view] isHidden]); - ;EXPECT_GT([resizeDelegate_ height], 0); + EXPECT_GT([resizeDelegate_ height], 0); EXPECT_GT([[bar_ view] frame].size.height, 0); // Make sure no buttons fall off the bar, either now or when resized @@ -238,6 +235,68 @@ TEST_F(BookmarkBarControllerTest, ShowOnNewTabPage) { } } +// Test whether |-updateAndShowNormalBar:...| sets states as we expect. Make +// sure things don't crash. +TEST_F(BookmarkBarControllerTest, StateChanges) { + // First, go in one-at-a-time cycle. + [bar_ updateAndShowNormalBar:NO + showDetachedBar:NO + withAnimation:NO]; + EXPECT_EQ(bookmarks::kHiddenState, [bar_ visualState]); + EXPECT_FALSE([bar_ isVisible]); + EXPECT_FALSE([bar_ isAnimationRunning]); + [bar_ updateAndShowNormalBar:YES + showDetachedBar:NO + withAnimation:NO]; + EXPECT_EQ(bookmarks::kShowingState, [bar_ visualState]); + EXPECT_TRUE([bar_ isVisible]); + EXPECT_FALSE([bar_ isAnimationRunning]); + [bar_ updateAndShowNormalBar:YES + showDetachedBar:YES + withAnimation:NO]; + EXPECT_EQ(bookmarks::kShowingState, [bar_ visualState]); + EXPECT_TRUE([bar_ isVisible]); + EXPECT_FALSE([bar_ isAnimationRunning]); + [bar_ updateAndShowNormalBar:NO + showDetachedBar:YES + withAnimation:NO]; + EXPECT_EQ(bookmarks::kDetachedState, [bar_ visualState]); + EXPECT_TRUE([bar_ isVisible]); + EXPECT_FALSE([bar_ isAnimationRunning]); + + // Now try some "jumps". + for (int i = 0; i < 2; i++) { + [bar_ updateAndShowNormalBar:NO + showDetachedBar:NO + withAnimation:NO]; + EXPECT_EQ(bookmarks::kHiddenState, [bar_ visualState]); + EXPECT_FALSE([bar_ isVisible]); + EXPECT_FALSE([bar_ isAnimationRunning]); + [bar_ updateAndShowNormalBar:YES + showDetachedBar:YES + withAnimation:NO]; + EXPECT_EQ(bookmarks::kShowingState, [bar_ visualState]); + EXPECT_TRUE([bar_ isVisible]); + EXPECT_FALSE([bar_ isAnimationRunning]); + } + + // Now try some "jumps". + for (int i = 0; i < 2; i++) { + [bar_ updateAndShowNormalBar:YES + showDetachedBar:NO + withAnimation:NO]; + EXPECT_EQ(bookmarks::kShowingState, [bar_ visualState]); + EXPECT_TRUE([bar_ isVisible]); + EXPECT_FALSE([bar_ isAnimationRunning]); + [bar_ updateAndShowNormalBar:NO + showDetachedBar:YES + withAnimation:NO]; + EXPECT_EQ(bookmarks::kDetachedState, [bar_ visualState]); + EXPECT_TRUE([bar_ isVisible]); + EXPECT_FALSE([bar_ isAnimationRunning]); + } +} + // Make sure we're watching for frame change notifications. TEST_F(BookmarkBarControllerTest, FrameChangeNotification) { scoped_nsobject<BookmarkBarControllerTogglePong> bar; @@ -789,4 +848,6 @@ TEST_F(BookmarkBarControllerTest, TestDragButton) { EXPECT_TRUE([[[[bar_ buttons] objectAtIndex:2] title] isEqual:@"a"]); } +// TODO(viettrungluu): figure out how to test animations. + } // namespace |