| OLD | NEW |
| 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 Loading... |
| 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 draggingSession:nil | 157 NSDragOperation operation = [button draggingSourceOperationMaskForLocal:NO]; |
| 158 sourceOperationMaskForDraggingContext: | |
| 159 NSDraggingContextOutsideApplication]; | |
| 160 EXPECT_EQ(0u, operation & NSDragOperationDelete); | 158 EXPECT_EQ(0u, operation & NSDragOperationDelete); |
| 161 operation = [button draggingSession:nil | 159 operation = [button draggingSourceOperationMaskForLocal:YES]; |
| 162 sourceOperationMaskForDraggingContext:NSDraggingContextWithinApplication]; | |
| 163 EXPECT_EQ(0u, operation & NSDragOperationDelete); | 160 EXPECT_EQ(0u, operation & NSDragOperationDelete); |
| 164 | 161 |
| 165 // Verify that if canDragBookmarkButtonToTrash is YES then the button can | 162 // Verify that if canDragBookmarkButtonToTrash is YES then the button can |
| 166 // be dragged to the trash. | 163 // be dragged to the trash. |
| 167 delegate.get()->canDragToTrash_ = YES; | 164 delegate.get()->canDragToTrash_ = YES; |
| 168 operation = [button draggingSession:nil | 165 operation = [button draggingSourceOperationMaskForLocal:NO]; |
| 169 sourceOperationMaskForDraggingContext: | |
| 170 NSDraggingContextOutsideApplication]; | |
| 171 EXPECT_EQ(NSDragOperationDelete, operation & NSDragOperationDelete); | 166 EXPECT_EQ(NSDragOperationDelete, operation & NSDragOperationDelete); |
| 172 operation = [button draggingSession:nil | 167 operation = [button draggingSourceOperationMaskForLocal:YES]; |
| 173 sourceOperationMaskForDraggingContext:NSDraggingContextWithinApplication]; | |
| 174 EXPECT_EQ(NSDragOperationDelete, operation & NSDragOperationDelete); | 168 EXPECT_EQ(NSDragOperationDelete, operation & NSDragOperationDelete); |
| 175 | 169 |
| 176 // Verify that canDragBookmarkButtonToTrash is called when expected. | 170 // Verify that canDragBookmarkButtonToTrash is called when expected. |
| 177 delegate.get()->canDragToTrash_ = YES; | 171 delegate.get()->canDragToTrash_ = YES; |
| 178 EXPECT_EQ(0, delegate.get()->didDragToTrashCount_); | 172 EXPECT_EQ(0, delegate.get()->didDragToTrashCount_); |
| 179 [button draggingSession:nil | 173 [button draggedImage:nil endedAt:NSZeroPoint operation:NSDragOperationCopy]; |
| 180 endedAtPoint:NSZeroPoint | |
| 181 operation:NSDragOperationCopy]; | |
| 182 EXPECT_EQ(0, delegate.get()->didDragToTrashCount_); | 174 EXPECT_EQ(0, delegate.get()->didDragToTrashCount_); |
| 183 [button draggingSession:nil | 175 [button draggedImage:nil endedAt:NSZeroPoint operation:NSDragOperationMove]; |
| 184 endedAtPoint:NSZeroPoint | |
| 185 operation:NSDragOperationMove]; | |
| 186 EXPECT_EQ(0, delegate.get()->didDragToTrashCount_); | 176 EXPECT_EQ(0, delegate.get()->didDragToTrashCount_); |
| 187 [button draggingSession:nil | 177 [button draggedImage:nil endedAt:NSZeroPoint operation:NSDragOperationDelete]; |
| 188 endedAtPoint:NSZeroPoint | |
| 189 operation:NSDragOperationDelete]; | |
| 190 EXPECT_EQ(1, delegate.get()->didDragToTrashCount_); | 178 EXPECT_EQ(1, delegate.get()->didDragToTrashCount_); |
| 191 } | 179 } |
| 192 | 180 |
| 193 } | 181 } |
| OLD | NEW |