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

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

Issue 1308293002: [Mac] Refactor bookmark pulsing into BookmarkBubbleObserverCocoa. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bookmarkeditor
Patch Set: Address comments. Update unit_tests. Created 5 years, 4 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 #import <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/mac/mac_util.h" 9 #include "base/mac/mac_util.h"
10 #include "base/mac/scoped_nsobject.h" 10 #include "base/mac/scoped_nsobject.h"
(...skipping 2068 matching lines...) Expand 10 before | Expand all | Expand 10 after
2079 2079
2080 TEST_F(BookmarkBarControllerDragDropTest, PulseButton) { 2080 TEST_F(BookmarkBarControllerDragDropTest, PulseButton) {
2081 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); 2081 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile());
2082 const BookmarkNode* root = model->bookmark_bar_node(); 2082 const BookmarkNode* root = model->bookmark_bar_node();
2083 GURL gurl("http://www.google.com"); 2083 GURL gurl("http://www.google.com");
2084 const BookmarkNode* node = model->AddURL(root, root->child_count(), 2084 const BookmarkNode* node = model->AddURL(root, root->child_count(),
2085 ASCIIToUTF16("title"), gurl); 2085 ASCIIToUTF16("title"), gurl);
2086 2086
2087 BookmarkButton* button = [[bar_ buttons] objectAtIndex:0]; 2087 BookmarkButton* button = [[bar_ buttons] objectAtIndex:0];
2088 EXPECT_FALSE([button isContinuousPulsing]); 2088 EXPECT_FALSE([button isContinuousPulsing]);
2089 [bar_ startPulsingBookmarkNode:node];
2090 EXPECT_TRUE([button isContinuousPulsing]);
2091 [bar_ stopPulsingBookmarkNode];
2092 EXPECT_FALSE([button isContinuousPulsing]);
2089 2093
2090 NSValue *value = [NSValue valueWithPointer:node]; 2094 // Pulsing a node within a folder should pulse the folder button.
2091 NSDictionary *dict = [NSDictionary 2095 const BookmarkNode* folder =
2092 dictionaryWithObjectsAndKeys:value, 2096 model->AddFolder(root, root->child_count(), ASCIIToUTF16("folder"));
2093 bookmark_button::kBookmarkKey, 2097 const BookmarkNode* inner =
2094 [NSNumber numberWithBool:YES], 2098 model->AddURL(folder, folder->child_count(), ASCIIToUTF16("inner"), gurl);
2095 bookmark_button::kBookmarkPulseFlagKey,
2096 nil];
2097 [[NSNotificationCenter defaultCenter]
2098 postNotificationName:bookmark_button::kPulseBookmarkButtonNotification
2099 object:nil
2100 userInfo:dict];
2101 EXPECT_TRUE([button isContinuousPulsing]);
2102 2099
2103 dict = [NSDictionary dictionaryWithObjectsAndKeys:value, 2100 BookmarkButton* folder_button = [[bar_ buttons] objectAtIndex:1];
2104 bookmark_button::kBookmarkKey, 2101 EXPECT_FALSE([folder_button isContinuousPulsing]);
2105 [NSNumber numberWithBool:NO], 2102 [bar_ startPulsingBookmarkNode:inner];
2106 bookmark_button::kBookmarkPulseFlagKey, 2103 EXPECT_TRUE([folder_button isContinuousPulsing]);
2107 nil]; 2104 [bar_ stopPulsingBookmarkNode];
2108 [[NSNotificationCenter defaultCenter] 2105 EXPECT_FALSE([folder_button isContinuousPulsing]);
2109 postNotificationName:bookmark_button::kPulseBookmarkButtonNotification 2106
2110 object:nil 2107 // Stop pulsing if the node moved.
2111 userInfo:dict]; 2108 [bar_ startPulsingBookmarkNode:inner];
2112 EXPECT_FALSE([button isContinuousPulsing]); 2109 EXPECT_TRUE([folder_button isContinuousPulsing]);
2110 const BookmarkNode* folder2 =
2111 model->AddFolder(root, root->child_count(), ASCIIToUTF16("folder2"));
2112 model->Move(inner, folder2, 0);
2113 EXPECT_FALSE([folder_button isContinuousPulsing]);
2114
2115 // Removing a pulsing folder is allowed.
2116 [bar_ startPulsingBookmarkNode:inner];
2117 BookmarkButton* folder2_button = [[bar_ buttons] objectAtIndex:2];
2118 EXPECT_TRUE([folder2_button isContinuousPulsing]);
2119 model->Remove(folder2);
2120 EXPECT_FALSE([folder2_button isContinuousPulsing]);
2121 [bar_ stopPulsingBookmarkNode]; // Should not crash.
2113 } 2122 }
2114 2123
2115 TEST_F(BookmarkBarControllerDragDropTest, DragBookmarkDataToTrash) { 2124 TEST_F(BookmarkBarControllerDragDropTest, DragBookmarkDataToTrash) {
2116 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); 2125 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile());
2117 const BookmarkNode* root = model->bookmark_bar_node(); 2126 const BookmarkNode* root = model->bookmark_bar_node();
2118 const std::string model_string("1b 2f:[ 2f1b 2f2f:[ 2f2f1b 2f2f2b 2f2f3b ] " 2127 const std::string model_string("1b 2f:[ 2f1b 2f2f:[ 2f2f1b 2f2f2b 2f2f3b ] "
2119 "2f3b ] 3b 4b "); 2128 "2f3b ] 3b 4b ");
2120 bookmarks::test::AddNodesFromModelString(model, root, model_string); 2129 bookmarks::test::AddNodesFromModelString(model, root, model_string);
2121 2130
2122 // Validate initial model. 2131 // Validate initial model.
(...skipping 16 matching lines...) Expand all
2139 "2f3b ] 4b "); 2148 "2f3b ] 4b ");
2140 actual = bookmarks::test::ModelStringFromNode(root); 2149 actual = bookmarks::test::ModelStringFromNode(root);
2141 EXPECT_EQ(expected, actual); 2150 EXPECT_EQ(expected, actual);
2142 2151
2143 // Verify that the other bookmark folder can't be deleted. 2152 // Verify that the other bookmark folder can't be deleted.
2144 BookmarkButton *otherButton = [bar_ otherBookmarksButton]; 2153 BookmarkButton *otherButton = [bar_ otherBookmarksButton];
2145 EXPECT_FALSE([bar_ canDragBookmarkButtonToTrash:otherButton]); 2154 EXPECT_FALSE([bar_ canDragBookmarkButtonToTrash:otherButton]);
2146 } 2155 }
2147 2156
2148 } // namespace 2157 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698