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

Unified Diff: chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_hover_state_unittest.mm

Issue 8141003: [Mac] Restore the old bookmark menus now that the experiment is over. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_hover_state_unittest.mm
diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_hover_state_unittest.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_hover_state_unittest.mm
new file mode 100644
index 0000000000000000000000000000000000000000..5efd8798f61f76125727f0438aa558bcf7530650
--- /dev/null
+++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_hover_state_unittest.mm
@@ -0,0 +1,77 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import <Cocoa/Cocoa.h>
+
+#include "base/message_loop.h"
+#import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h"
+#import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_hover_state.h"
+#import "chrome/browser/ui/cocoa/cocoa_test_helper.h"
+
+namespace {
+
+class BookmarkBarFolderHoverStateTest : public CocoaTest {
+};
+
+// Hover state machine interface.
+// A strict call order is implied with these calls. It is ONLY valid to make
+// these specific state transitions.
+TEST_F(BookmarkBarFolderHoverStateTest, HoverState) {
+ MessageLoopForUI message_loop;
+ scoped_nsobject<BookmarkBarFolderHoverState> bbfhs;
+ bbfhs.reset([[BookmarkBarFolderHoverState alloc] init]);
+
+ // Initial state.
+ EXPECT_FALSE([bbfhs hoverButton]);
+ ASSERT_EQ(kHoverStateClosed, [bbfhs hoverState]);
+
+ scoped_nsobject<BookmarkButton> button;
+ button.reset([[BookmarkButton alloc] initWithFrame:NSMakeRect(0, 0, 20, 20)]);
+
+ // Test transition from closed to opening.
+ ASSERT_EQ(kHoverStateClosed, [bbfhs hoverState]);
+ [bbfhs scheduleOpenBookmarkFolderOnHoverButton:button];
+ ASSERT_EQ(kHoverStateOpening, [bbfhs hoverState]);
+
+ // Test transition from opening to closed (aka cancel open).
+ [bbfhs cancelPendingOpenBookmarkFolderOnHoverButton];
+ ASSERT_EQ(kHoverStateClosed, [bbfhs hoverState]);
+ ASSERT_EQ(nil, [bbfhs hoverButton]);
+
+ // Test transition from closed to opening.
+ ASSERT_EQ(kHoverStateClosed, [bbfhs hoverState]);
+ [bbfhs scheduleOpenBookmarkFolderOnHoverButton:button];
+ ASSERT_EQ(kHoverStateOpening, [bbfhs hoverState]);
+
+ // Test transition from opening to opened.
+ message_loop.PostDelayedTask(
+ FROM_HERE,
+ new MessageLoop::QuitTask,
+ bookmarks::kDragHoverOpenDelay * 1000.0 * 1.5);
+ message_loop.Run();
+ ASSERT_EQ(kHoverStateOpen, [bbfhs hoverState]);
+ ASSERT_EQ(button, [bbfhs hoverButton]);
+
+ // Test transition from opening to opened.
+ [bbfhs scheduleCloseBookmarkFolderOnHoverButton];
+ ASSERT_EQ(kHoverStateClosing, [bbfhs hoverState]);
+
+ // Test transition from closing to open (aka cancel close).
+ [bbfhs cancelPendingCloseBookmarkFolderOnHoverButton];
+ ASSERT_EQ(kHoverStateOpen, [bbfhs hoverState]);
+ ASSERT_EQ(button, [bbfhs hoverButton]);
+
+ // Test transition from closing to closed.
+ [bbfhs scheduleCloseBookmarkFolderOnHoverButton];
+ ASSERT_EQ(kHoverStateClosing, [bbfhs hoverState]);
+ message_loop.PostDelayedTask(
+ FROM_HERE,
+ new MessageLoop::QuitTask,
+ bookmarks::kDragHoverCloseDelay * 1000.0 * 1.5);
+ message_loop.Run();
+ ASSERT_EQ(kHoverStateClosed, [bbfhs hoverState]);
+ ASSERT_EQ(nil, [bbfhs hoverButton]);
+}
+
+} // namespace

Powered by Google App Engine
This is Rietveld 408576698