Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ui/views/cocoa/drag_drop_client_mac.h" | 5 #import "ui/views/cocoa/drag_drop_client_mac.h" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 | 8 |
| 9 #import "base/mac/scoped_objc_class_swizzler.h" | 9 #import "base/mac/scoped_objc_class_swizzler.h" |
| 10 #include "base/mac/sdk_forward_declarations.h" | 10 #include "base/mac/sdk_forward_declarations.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "base/threading/thread_task_runner_handle.h" | 12 #include "base/threading/thread_task_runner_handle.h" |
| 13 #include "ui/base/clipboard/clipboard_util_mac.h" | |
|
tapted
2016/11/29 23:00:37
nit: import?
erikchen
2016/11/29 23:08:38
Done.
| |
| 13 #import "ui/views/cocoa/bridged_native_widget.h" | 14 #import "ui/views/cocoa/bridged_native_widget.h" |
| 14 #include "ui/views/test/widget_test.h" | 15 #include "ui/views/test/widget_test.h" |
| 15 #include "ui/views/view.h" | 16 #include "ui/views/view.h" |
| 16 #include "ui/views/widget/native_widget_mac.h" | 17 #include "ui/views/widget/native_widget_mac.h" |
| 17 #include "ui/views/widget/widget.h" | 18 #include "ui/views/widget/widget.h" |
| 18 | 19 |
| 19 using base::ASCIIToUTF16; | 20 using base::ASCIIToUTF16; |
| 20 | 21 |
| 21 @interface NSView (DragSessionTestingDonor) | 22 @interface NSView (DragSessionTestingDonor) |
| 22 @end | 23 @end |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 272 // operation. | 273 // operation. |
| 273 EXPECT_EQ(DragUpdate(nil), NSDragOperationNone); | 274 EXPECT_EQ(DragUpdate(nil), NSDragOperationNone); |
| 274 EXPECT_EQ(Drop(), NSDragOperationNone); | 275 EXPECT_EQ(Drop(), NSDragOperationNone); |
| 275 } | 276 } |
| 276 | 277 |
| 277 // Tests if the drag and drop target can accept data without an OSExchangeData | 278 // Tests if the drag and drop target can accept data without an OSExchangeData |
| 278 // object. | 279 // object. |
| 279 TEST_F(DragDropClientMacTest, PasteboardToOSExchangeTest) { | 280 TEST_F(DragDropClientMacTest, PasteboardToOSExchangeTest) { |
| 280 target_->set_formats(ui::OSExchangeData::STRING); | 281 target_->set_formats(ui::OSExchangeData::STRING); |
| 281 | 282 |
| 282 NSPasteboard* pasteboard = [NSPasteboard pasteboardWithUniqueName]; | 283 scoped_refptr<ui::UniquePasteboard> pasteboard = new ui::UniquePasteboard; |
| 283 | 284 |
| 284 // The test should reject the data if the pasteboard is empty. | 285 // The test should reject the data if the pasteboard is empty. |
| 285 EXPECT_EQ(DragUpdate(pasteboard), NSDragOperationNone); | 286 EXPECT_EQ(DragUpdate(pasteboard->get()), NSDragOperationNone); |
| 286 EXPECT_EQ(Drop(), NSDragOperationNone); | 287 EXPECT_EQ(Drop(), NSDragOperationNone); |
| 287 drag_drop_client()->EndDrag(); | 288 drag_drop_client()->EndDrag(); |
| 288 | 289 |
| 289 // Add valid data to the pasteboard and check to see if the target accepts | 290 // Add valid data to the pasteboard and check to see if the target accepts |
| 290 // it. | 291 // it. |
| 291 [pasteboard setString:@"text" forType:NSPasteboardTypeString]; | 292 [pasteboard->get() setString:@"text" forType:NSPasteboardTypeString]; |
| 292 EXPECT_EQ(DragUpdate(pasteboard), NSDragOperationCopy); | 293 EXPECT_EQ(DragUpdate(pasteboard->get()), NSDragOperationCopy); |
| 293 EXPECT_EQ(Drop(), NSDragOperationMove); | 294 EXPECT_EQ(Drop(), NSDragOperationMove); |
| 294 } | 295 } |
| 295 | 296 |
| 296 } // namespace test | 297 } // namespace test |
| 297 } // namespace views | 298 } // namespace views |
| OLD | NEW |