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

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

Issue 1815053002: Update BookmarkBarController to use non-deprecated dragging APIs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@temp20_107_bluetooth
Patch Set: Comments from avi. Created 4 years, 9 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 #include "base/mac/scoped_nsobject.h" 5 #include "base/mac/scoped_nsobject.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 7 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
8 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h" 8 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h"
9 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.h" 9 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.h"
10 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" 10 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); 147 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile());
148 const BookmarkNode* barNode = model->bookmark_bar_node(); 148 const BookmarkNode* barNode = model->bookmark_bar_node();
149 const BookmarkNode* node = model->AddURL(barNode, 0, 149 const BookmarkNode* node = model->AddURL(barNode, 0,
150 base::ASCIIToUTF16("hi mom"), 150 base::ASCIIToUTF16("hi mom"),
151 GURL("http://www.google.com")); 151 GURL("http://www.google.com"));
152 [cell setBookmarkNode:node]; 152 [cell setBookmarkNode:node];
153 153
154 // Verify that if canDragBookmarkButtonToTrash is NO then the button can't 154 // Verify that if canDragBookmarkButtonToTrash is NO then the button can't
155 // be dragged to the trash. 155 // be dragged to the trash.
156 delegate.get()->canDragToTrash_ = NO; 156 delegate.get()->canDragToTrash_ = NO;
157 NSDragOperation operation = [button draggingSourceOperationMaskForLocal:NO]; 157 NSDragOperation operation = [button draggingSession:nil
158 sourceOperationMaskForDraggingContext:
159 NSDraggingContextOutsideApplication];
158 EXPECT_EQ(0u, operation & NSDragOperationDelete); 160 EXPECT_EQ(0u, operation & NSDragOperationDelete);
159 operation = [button draggingSourceOperationMaskForLocal:YES]; 161 operation = [button draggingSession:nil
162 sourceOperationMaskForDraggingContext:NSDraggingContextWithinApplication];
160 EXPECT_EQ(0u, operation & NSDragOperationDelete); 163 EXPECT_EQ(0u, operation & NSDragOperationDelete);
161 164
162 // Verify that if canDragBookmarkButtonToTrash is YES then the button can 165 // Verify that if canDragBookmarkButtonToTrash is YES then the button can
163 // be dragged to the trash. 166 // be dragged to the trash.
164 delegate.get()->canDragToTrash_ = YES; 167 delegate.get()->canDragToTrash_ = YES;
165 operation = [button draggingSourceOperationMaskForLocal:NO]; 168 operation = [button draggingSession:nil
169 sourceOperationMaskForDraggingContext:
170 NSDraggingContextOutsideApplication];
166 EXPECT_EQ(NSDragOperationDelete, operation & NSDragOperationDelete); 171 EXPECT_EQ(NSDragOperationDelete, operation & NSDragOperationDelete);
167 operation = [button draggingSourceOperationMaskForLocal:YES]; 172 operation = [button draggingSession:nil
173 sourceOperationMaskForDraggingContext:NSDraggingContextWithinApplication];
168 EXPECT_EQ(NSDragOperationDelete, operation & NSDragOperationDelete); 174 EXPECT_EQ(NSDragOperationDelete, operation & NSDragOperationDelete);
169 175
170 // Verify that canDragBookmarkButtonToTrash is called when expected. 176 // Verify that canDragBookmarkButtonToTrash is called when expected.
171 delegate.get()->canDragToTrash_ = YES; 177 delegate.get()->canDragToTrash_ = YES;
172 EXPECT_EQ(0, delegate.get()->didDragToTrashCount_); 178 EXPECT_EQ(0, delegate.get()->didDragToTrashCount_);
173 [button draggedImage:nil endedAt:NSZeroPoint operation:NSDragOperationCopy]; 179 [button draggingSession:nil
180 endedAtPoint:NSZeroPoint
181 operation:NSDragOperationCopy];
174 EXPECT_EQ(0, delegate.get()->didDragToTrashCount_); 182 EXPECT_EQ(0, delegate.get()->didDragToTrashCount_);
175 [button draggedImage:nil endedAt:NSZeroPoint operation:NSDragOperationMove]; 183 [button draggingSession:nil
184 endedAtPoint:NSZeroPoint
185 operation:NSDragOperationMove];
176 EXPECT_EQ(0, delegate.get()->didDragToTrashCount_); 186 EXPECT_EQ(0, delegate.get()->didDragToTrashCount_);
177 [button draggedImage:nil endedAt:NSZeroPoint operation:NSDragOperationDelete]; 187 [button draggingSession:nil
188 endedAtPoint:NSZeroPoint
189 operation:NSDragOperationDelete];
178 EXPECT_EQ(1, delegate.get()->didDragToTrashCount_); 190 EXPECT_EQ(1, delegate.get()->didDragToTrashCount_);
179 } 191 }
180 192
181 } 193 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/bookmarks/bookmark_button.mm ('k') | chrome/browser/ui/cocoa/bookmarks/bookmark_folder_target.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698