| 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_nsautorelease_pool.h" | 5 #include "base/mac/scoped_nsautorelease_pool.h" |
| 6 #import "base/memory/scoped_nsobject.h" | 6 #import "base/mac/scoped_nsobject.h" |
| 7 #include "base/strings/sys_string_conversions.h" | 7 #include "base/strings/sys_string_conversions.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "content/browser/renderer_host/test_render_view_host.h" | 9 #include "content/browser/renderer_host/test_render_view_host.h" |
| 10 #import "content/browser/web_contents/web_drag_dest_mac.h" | 10 #import "content/browser/web_contents/web_drag_dest_mac.h" |
| 11 #include "content/test/test_web_contents.h" | 11 #include "content/test/test_web_contents.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 #import "third_party/mozilla/NSPasteboard+Utils.h" | 13 #import "third_party/mozilla/NSPasteboard+Utils.h" |
| 14 #import "ui/base/dragdrop/cocoa_dnd_util.h" | 14 #import "ui/base/dragdrop/cocoa_dnd_util.h" |
| 15 #import "ui/base/test/ui_cocoa_test_helper.h" | 15 #import "ui/base/test/ui_cocoa_test_helper.h" |
| 16 #include "webkit/common/webdropdata.h" | 16 #include "webkit/common/webdropdata.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 46 kCrCorePasteboardFlavorType_urln, | 46 kCrCorePasteboardFlavorType_urln, |
| 47 nil] | 47 nil] |
| 48 owner:nil]; | 48 owner:nil]; |
| 49 [pboard setString:urlString | 49 [pboard setString:urlString |
| 50 forType:kCrCorePasteboardFlavorType_url]; | 50 forType:kCrCorePasteboardFlavorType_url]; |
| 51 [pboard setString:title | 51 [pboard setString:title |
| 52 forType:kCrCorePasteboardFlavorType_urln]; | 52 forType:kCrCorePasteboardFlavorType_urln]; |
| 53 } | 53 } |
| 54 | 54 |
| 55 base::mac::ScopedNSAutoreleasePool pool_; | 55 base::mac::ScopedNSAutoreleasePool pool_; |
| 56 scoped_nsobject<WebDragDest> drag_dest_; | 56 base::scoped_nsobject<WebDragDest> drag_dest_; |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 // Make sure nothing leaks. | 59 // Make sure nothing leaks. |
| 60 TEST_F(WebDragDestTest, Init) { | 60 TEST_F(WebDragDestTest, Init) { |
| 61 EXPECT_TRUE(drag_dest_); | 61 EXPECT_TRUE(drag_dest_); |
| 62 } | 62 } |
| 63 | 63 |
| 64 // Test flipping of coordinates given a point in window coordinates. | 64 // Test flipping of coordinates given a point in window coordinates. |
| 65 TEST_F(WebDragDestTest, Flip) { | 65 TEST_F(WebDragDestTest, Flip) { |
| 66 NSPoint windowPoint = NSZeroPoint; | 66 NSPoint windowPoint = NSZeroPoint; |
| 67 scoped_nsobject<NSWindow> window([[CocoaTestHelperWindow alloc] init]); | 67 base::scoped_nsobject<NSWindow> window([[CocoaTestHelperWindow alloc] init]); |
| 68 NSPoint viewPoint = | 68 NSPoint viewPoint = |
| 69 [drag_dest_ flipWindowPointToView:windowPoint | 69 [drag_dest_ flipWindowPointToView:windowPoint |
| 70 view:[window contentView]]; | 70 view:[window contentView]]; |
| 71 NSPoint screenPoint = | 71 NSPoint screenPoint = |
| 72 [drag_dest_ flipWindowPointToScreen:windowPoint | 72 [drag_dest_ flipWindowPointToScreen:windowPoint |
| 73 view:[window contentView]]; | 73 view:[window contentView]]; |
| 74 EXPECT_EQ(0, viewPoint.x); | 74 EXPECT_EQ(0, viewPoint.x); |
| 75 EXPECT_EQ(600, viewPoint.y); | 75 EXPECT_EQ(600, viewPoint.y); |
| 76 EXPECT_EQ(0, screenPoint.x); | 76 EXPECT_EQ(0, screenPoint.x); |
| 77 // We can't put a value on the screen size since everyone will have a | 77 // We can't put a value on the screen size since everyone will have a |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 NSString* textString = @"hi there"; | 155 NSString* textString = @"hi there"; |
| 156 [pboard setString:htmlString forType:NSHTMLPboardType]; | 156 [pboard setString:htmlString forType:NSHTMLPboardType]; |
| 157 [pboard setString:textString forType:NSStringPboardType]; | 157 [pboard setString:textString forType:NSStringPboardType]; |
| 158 [drag_dest_ populateWebDropData:&data fromPasteboard:pboard]; | 158 [drag_dest_ populateWebDropData:&data fromPasteboard:pboard]; |
| 159 EXPECT_EQ(data.url.spec(), "http://www.google.com/"); | 159 EXPECT_EQ(data.url.spec(), "http://www.google.com/"); |
| 160 EXPECT_EQ(base::SysNSStringToUTF16(textString), data.text.string()); | 160 EXPECT_EQ(base::SysNSStringToUTF16(textString), data.text.string()); |
| 161 EXPECT_EQ(base::SysNSStringToUTF16(htmlString), data.html.string()); | 161 EXPECT_EQ(base::SysNSStringToUTF16(htmlString), data.html.string()); |
| 162 | 162 |
| 163 [pboard releaseGlobally]; | 163 [pboard releaseGlobally]; |
| 164 } | 164 } |
| OLD | NEW |