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

Side by Side Diff: content/browser/web_contents/web_drag_dest_mac_unittest.mm

Issue 18281002: Move WebDropData to content::DropData and split off conversion function. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Mac build error. Created 7 years, 5 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 | Annotate | Revision Log
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_nsautorelease_pool.h" 5 #include "base/mac/scoped_nsautorelease_pool.h"
6 #import "base/mac/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/public/common/drop_data.h"
11 #include "content/test/test_web_contents.h" 12 #include "content/test/test_web_contents.h"
12 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
13 #import "third_party/mozilla/NSPasteboard+Utils.h" 14 #import "third_party/mozilla/NSPasteboard+Utils.h"
14 #import "ui/base/dragdrop/cocoa_dnd_util.h" 15 #import "ui/base/dragdrop/cocoa_dnd_util.h"
15 #import "ui/base/test/ui_cocoa_test_helper.h" 16 #import "ui/base/test/ui_cocoa_test_helper.h"
16 #include "webkit/common/webdropdata.h"
17 17
18 using content::DropData;
18 using content::RenderViewHostImplTestHarness; 19 using content::RenderViewHostImplTestHarness;
19 20
20 namespace { 21 namespace {
21 NSString* const kCrCorePasteboardFlavorType_url = 22 NSString* const kCrCorePasteboardFlavorType_url =
22 @"CorePasteboardFlavorType 0x75726C20"; // 'url ' url 23 @"CorePasteboardFlavorType 0x75726C20"; // 'url ' url
23 NSString* const kCrCorePasteboardFlavorType_urln = 24 NSString* const kCrCorePasteboardFlavorType_urln =
24 @"CorePasteboardFlavorType 0x75726C6E"; // 'urln' title 25 @"CorePasteboardFlavorType 0x75726C6E"; // 'urln' title
25 } // namespace 26 } // namespace
26 27
27 class WebDragDestTest : public RenderViewHostImplTestHarness { 28 class WebDragDestTest : public RenderViewHostImplTestHarness {
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 EXPECT_FALSE(ui::PopulateURLAndTitleFromPasteboard( 138 EXPECT_FALSE(ui::PopulateURLAndTitleFromPasteboard(
138 &result_url, &result_title, pboard, NO)); 139 &result_url, &result_title, pboard, NO));
139 EXPECT_TRUE(ui::PopulateURLAndTitleFromPasteboard( 140 EXPECT_TRUE(ui::PopulateURLAndTitleFromPasteboard(
140 &result_url, &result_title, pboard, YES)); 141 &result_url, &result_title, pboard, YES));
141 EXPECT_EQ("file://localhost/bin/sh", result_url.spec()); 142 EXPECT_EQ("file://localhost/bin/sh", result_url.spec());
142 EXPECT_EQ("sh", UTF16ToUTF8(result_title)); 143 EXPECT_EQ("sh", UTF16ToUTF8(result_title));
143 [pboard releaseGlobally]; 144 [pboard releaseGlobally];
144 } 145 }
145 146
146 TEST_F(WebDragDestTest, Data) { 147 TEST_F(WebDragDestTest, Data) {
147 WebDropData data; 148 DropData data;
148 NSPasteboard* pboard = [NSPasteboard pasteboardWithUniqueName]; 149 NSPasteboard* pboard = [NSPasteboard pasteboardWithUniqueName];
149 150
150 PutURLOnPasteboard(@"http://www.google.com", pboard); 151 PutURLOnPasteboard(@"http://www.google.com", pboard);
151 [pboard addTypes:[NSArray arrayWithObjects:NSHTMLPboardType, 152 [pboard addTypes:[NSArray arrayWithObjects:NSHTMLPboardType,
152 NSStringPboardType, nil] 153 NSStringPboardType, nil]
153 owner:nil]; 154 owner:nil];
154 NSString* htmlString = @"<html><body><b>hi there</b></body></html>"; 155 NSString* htmlString = @"<html><body><b>hi there</b></body></html>";
155 NSString* textString = @"hi there"; 156 NSString* textString = @"hi there";
156 [pboard setString:htmlString forType:NSHTMLPboardType]; 157 [pboard setString:htmlString forType:NSHTMLPboardType];
157 [pboard setString:textString forType:NSStringPboardType]; 158 [pboard setString:textString forType:NSStringPboardType];
158 [drag_dest_ populateWebDropData:&data fromPasteboard:pboard]; 159 [drag_dest_ populateDropData:&data fromPasteboard:pboard];
159 EXPECT_EQ(data.url.spec(), "http://www.google.com/"); 160 EXPECT_EQ(data.url.spec(), "http://www.google.com/");
160 EXPECT_EQ(base::SysNSStringToUTF16(textString), data.text.string()); 161 EXPECT_EQ(base::SysNSStringToUTF16(textString), data.text.string());
161 EXPECT_EQ(base::SysNSStringToUTF16(htmlString), data.html.string()); 162 EXPECT_EQ(base::SysNSStringToUTF16(htmlString), data.html.string());
162 163
163 [pboard releaseGlobally]; 164 [pboard releaseGlobally];
164 } 165 }
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_drag_dest_mac.mm ('k') | content/browser/web_contents/web_drag_dest_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698