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

Unified Diff: chrome/browser/cocoa/bookmark_bubble_controller_unittest.mm

Issue 2805099: Pulse new bookmarks (as triggered by bookmark bubble). If not possible, ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 5 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
« no previous file with comments | « chrome/browser/cocoa/bookmark_bubble_controller.mm ('k') | chrome/browser/cocoa/bookmark_button.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/cocoa/bookmark_bubble_controller_unittest.mm
===================================================================
--- chrome/browser/cocoa/bookmark_bubble_controller_unittest.mm (revision 53704)
+++ chrome/browser/cocoa/bookmark_bubble_controller_unittest.mm (working copy)
@@ -15,6 +15,41 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
+// Watch for bookmark pulse notifications so we can confirm they were sent.
+@interface BookmarkPulseObserver : NSObject {
+ int notifications_;
+}
+@property (assign, nonatomic) int notifications;
+@end
+
+
+@implementation BookmarkPulseObserver
+
+@synthesize notifications = notifications_;
+
+- (id)init {
+ if ((self = [super init])) {
+ [[NSNotificationCenter defaultCenter]
+ addObserver:self
+ selector:@selector(pulseBookmarkNotification:)
+ name:bookmark_button::kPulseBookmarkButtonNotification
+ object:nil];
+ }
+ return self;
+}
+
+- (void)pulseBookmarkNotification:(NSNotificationCenter *)notification {
+ notifications_++;
+}
+
+- (void)dealloc {
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
+ [super dealloc];
+}
+
+@end
+
+
namespace {
class BookmarkBubbleControllerTest : public CocoaTest {
@@ -187,6 +222,7 @@
}
// CallClose; bubble gets closed.
+// Also confirm pulse notifications get sent.
TEST_F(BookmarkBubbleControllerTest, TestClose) {
BookmarkModel* model = GetBookmarkModel();
const BookmarkNode* node = model->AddURL(model->GetBookmarkBarNode(),
@@ -195,12 +231,17 @@
GURL("http://www.google.com"));
EXPECT_EQ(edits_, 0);
+ scoped_nsobject<BookmarkPulseObserver> observer([[BookmarkPulseObserver alloc]
+ init]);
+ EXPECT_EQ([observer notifications], 0);
BookmarkBubbleController* controller = ControllerForNode(node);
EXPECT_TRUE(controller);
EXPECT_FALSE(IsWindowClosing());
+ EXPECT_EQ([observer notifications], 1);
[controller ok:controller];
EXPECT_EQ(edits_, 0);
EXPECT_TRUE(IsWindowClosing());
+ EXPECT_EQ([observer notifications], 2);
}
// User changes title and parent folder in the UI
« no previous file with comments | « chrome/browser/cocoa/bookmark_bubble_controller.mm ('k') | chrome/browser/cocoa/bookmark_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698