OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 9 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
10 #import "chrome/browser/ui/cocoa/drag_util.h" | 10 #import "chrome/browser/ui/cocoa/drag_util.h" |
11 #import "chrome/browser/ui/cocoa/tab_contents/web_drop_target.h" | 11 #import "chrome/browser/ui/cocoa/tab_contents/web_drop_target.h" |
12 #include "content/browser/renderer_host/test_render_view_host.h" | 12 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
13 #include "content/browser/tab_contents/test_tab_contents.h" | 13 #include "content/browser/tab_contents/test_tab_contents.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 #import "third_party/mozilla/NSPasteboard+Utils.h" | 15 #import "third_party/mozilla/NSPasteboard+Utils.h" |
16 #include "webkit/glue/webdropdata.h" | 16 #include "webkit/glue/webdropdata.h" |
17 | 17 |
18 class WebDropTargetTest : public RenderViewHostTestHarness { | 18 class WebDropTargetTest : public ChromeRenderViewHostTestHarness { |
19 public: | 19 public: |
20 virtual void SetUp() { | 20 virtual void SetUp() { |
21 RenderViewHostTestHarness::SetUp(); | 21 ChromeRenderViewHostTestHarness::SetUp(); |
22 CocoaTest::BootstrapCocoa(); | 22 CocoaTest::BootstrapCocoa(); |
23 drop_target_.reset([[WebDropTarget alloc] initWithTabContents:contents()]); | 23 drop_target_.reset([[WebDropTarget alloc] initWithTabContents:contents()]); |
24 } | 24 } |
25 | 25 |
26 void PutURLOnPasteboard(NSString* urlString, NSPasteboard* pboard) { | 26 void PutURLOnPasteboard(NSString* urlString, NSPasteboard* pboard) { |
27 [pboard declareTypes:[NSArray arrayWithObject:NSURLPboardType] | 27 [pboard declareTypes:[NSArray arrayWithObject:NSURLPboardType] |
28 owner:nil]; | 28 owner:nil]; |
29 NSURL* url = [NSURL URLWithString:urlString]; | 29 NSURL* url = [NSURL URLWithString:urlString]; |
30 EXPECT_TRUE(url); | 30 EXPECT_TRUE(url); |
31 [url writeToPasteboard:pboard]; | 31 [url writeToPasteboard:pboard]; |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 NSString* textString = @"hi there"; | 147 NSString* textString = @"hi there"; |
148 [pboard setString:htmlString forType:NSHTMLPboardType]; | 148 [pboard setString:htmlString forType:NSHTMLPboardType]; |
149 [pboard setString:textString forType:NSStringPboardType]; | 149 [pboard setString:textString forType:NSStringPboardType]; |
150 [drop_target_ populateWebDropData:&data fromPasteboard:pboard]; | 150 [drop_target_ populateWebDropData:&data fromPasteboard:pboard]; |
151 EXPECT_EQ(data.url.spec(), "http://www.google.com/"); | 151 EXPECT_EQ(data.url.spec(), "http://www.google.com/"); |
152 EXPECT_EQ(base::SysNSStringToUTF16(textString), data.plain_text); | 152 EXPECT_EQ(base::SysNSStringToUTF16(textString), data.plain_text); |
153 EXPECT_EQ(base::SysNSStringToUTF16(htmlString), data.text_html); | 153 EXPECT_EQ(base::SysNSStringToUTF16(htmlString), data.text_html); |
154 | 154 |
155 [pboard releaseGlobally]; | 155 [pboard releaseGlobally]; |
156 } | 156 } |
OLD | NEW |