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/memory/scoped_nsobject.h" |
7 #include "base/sys_string_conversions.h" | 7 #include "base/sys_string_conversions.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/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 #include "content/browser/tab_contents/test_tab_contents.h" | 10 #include "content/browser/tab_contents/test_tab_contents.h" |
11 #import "content/browser/tab_contents/web_drag_dest_mac.h" | 11 #import "content/browser/tab_contents/web_drag_dest_mac.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/glue/webdropdata.h" | 16 #include "webkit/glue/webdropdata.h" |
17 | 17 |
| 18 using content::RenderViewHostImplTestHarness; |
| 19 |
18 namespace { | 20 namespace { |
19 NSString* const kCrCorePasteboardFlavorType_url = | 21 NSString* const kCrCorePasteboardFlavorType_url = |
20 @"CorePasteboardFlavorType 0x75726C20"; // 'url ' url | 22 @"CorePasteboardFlavorType 0x75726C20"; // 'url ' url |
21 NSString* const kCrCorePasteboardFlavorType_urln = | 23 NSString* const kCrCorePasteboardFlavorType_urln = |
22 @"CorePasteboardFlavorType 0x75726C6E"; // 'urln' title | 24 @"CorePasteboardFlavorType 0x75726C6E"; // 'urln' title |
23 } // namespace | 25 } // namespace |
24 | 26 |
25 class WebDragDestTest : public RenderViewHostTestHarness { | 27 class WebDragDestTest : public RenderViewHostImplTestHarness { |
26 public: | 28 public: |
27 virtual void SetUp() { | 29 virtual void SetUp() { |
28 RenderViewHostTestHarness::SetUp(); | 30 RenderViewHostImplTestHarness::SetUp(); |
29 drag_dest_.reset([[WebDragDest alloc] initWithTabContents:contents()]); | 31 drag_dest_.reset([[WebDragDest alloc] initWithTabContents:contents()]); |
30 } | 32 } |
31 | 33 |
32 void PutURLOnPasteboard(NSString* urlString, NSPasteboard* pboard) { | 34 void PutURLOnPasteboard(NSString* urlString, NSPasteboard* pboard) { |
33 [pboard declareTypes:[NSArray arrayWithObject:NSURLPboardType] | 35 [pboard declareTypes:[NSArray arrayWithObject:NSURLPboardType] |
34 owner:nil]; | 36 owner:nil]; |
35 NSURL* url = [NSURL URLWithString:urlString]; | 37 NSURL* url = [NSURL URLWithString:urlString]; |
36 EXPECT_TRUE(url); | 38 EXPECT_TRUE(url); |
37 [url writeToPasteboard:pboard]; | 39 [url writeToPasteboard:pboard]; |
38 } | 40 } |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 NSString* textString = @"hi there"; | 155 NSString* textString = @"hi there"; |
154 [pboard setString:htmlString forType:NSHTMLPboardType]; | 156 [pboard setString:htmlString forType:NSHTMLPboardType]; |
155 [pboard setString:textString forType:NSStringPboardType]; | 157 [pboard setString:textString forType:NSStringPboardType]; |
156 [drag_dest_ populateWebDropData:&data fromPasteboard:pboard]; | 158 [drag_dest_ populateWebDropData:&data fromPasteboard:pboard]; |
157 EXPECT_EQ(data.url.spec(), "http://www.google.com/"); | 159 EXPECT_EQ(data.url.spec(), "http://www.google.com/"); |
158 EXPECT_EQ(base::SysNSStringToUTF16(textString), data.plain_text); | 160 EXPECT_EQ(base::SysNSStringToUTF16(textString), data.plain_text); |
159 EXPECT_EQ(base::SysNSStringToUTF16(htmlString), data.text_html); | 161 EXPECT_EQ(base::SysNSStringToUTF16(htmlString), data.text_html); |
160 | 162 |
161 [pboard releaseGlobally]; | 163 [pboard releaseGlobally]; |
162 } | 164 } |
OLD | NEW |