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

Side by Side Diff: chrome/browser/cocoa/web_drop_target_unittest.mm

Issue 192061: Attempt to fix memory leak in some mac tests. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 3 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
« no previous file with comments | « chrome/browser/cocoa/download_util_mac_unittest.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/scoped_nsautorelease_pool.h" 5 #include "base/scoped_nsautorelease_pool.h"
6 #include "base/sys_string_conversions.h" 6 #include "base/sys_string_conversions.h"
7 #import "chrome/browser/cocoa/cocoa_test_helper.h" 7 #import "chrome/browser/cocoa/cocoa_test_helper.h"
8 #import "chrome/browser/cocoa/web_drop_target.h" 8 #import "chrome/browser/cocoa/web_drop_target.h"
9 #include "chrome/browser/renderer_host/test/test_render_view_host.h" 9 #include "chrome/browser/renderer_host/test/test_render_view_host.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 } 59 }
60 60
61 TEST_F(WebDropTargetTest, URL) { 61 TEST_F(WebDropTargetTest, URL) {
62 WebDropData data; 62 WebDropData data;
63 63
64 // Put a URL on the pasteboard and check it. 64 // Put a URL on the pasteboard and check it.
65 NSPasteboard* pboard = [NSPasteboard pasteboardWithUniqueName]; 65 NSPasteboard* pboard = [NSPasteboard pasteboardWithUniqueName];
66 PutURLOnPasteboard(@"http://www.google.com", pboard); 66 PutURLOnPasteboard(@"http://www.google.com", pboard);
67 [drop_target_ populateURLAndTitle:&data fromPasteboard:pboard]; 67 [drop_target_ populateURLAndTitle:&data fromPasteboard:pboard];
68 EXPECT_EQ(data.url.spec(), "http://www.google.com/"); 68 EXPECT_EQ(data.url.spec(), "http://www.google.com/");
69 [pboard releaseGlobally];
69 70
70 // Put a 'url ' and 'urln' on the pasteboard and check it. 71 // Put a 'url ' and 'urln' on the pasteboard and check it.
71 NSString* title = @"Title of Awesomeness!"; 72 NSString* title = @"Title of Awesomeness!";
72 pboard = [NSPasteboard pasteboardWithUniqueName]; 73 pboard = [NSPasteboard pasteboardWithUniqueName];
73 [pboard declareTypes:[NSArray arrayWithObjects:kCorePasteboardFlavorType_url, 74 [pboard declareTypes:[NSArray arrayWithObjects:kCorePasteboardFlavorType_url,
74 kCorePasteboardFlavorType_urln, nil] 75 kCorePasteboardFlavorType_urln, nil]
75 owner:nil]; 76 owner:nil];
76 [pboard setString:@"http://www.something.com/" 77 [pboard setString:@"http://www.something.com/"
77 forType:kCorePasteboardFlavorType_url]; 78 forType:kCorePasteboardFlavorType_url];
78 [pboard setString:title 79 [pboard setString:title
79 forType:kCorePasteboardFlavorType_urln]; 80 forType:kCorePasteboardFlavorType_urln];
80 [drop_target_ populateURLAndTitle:&data fromPasteboard:pboard]; 81 [drop_target_ populateURLAndTitle:&data fromPasteboard:pboard];
81 EXPECT_EQ(data.url.spec(), "http://www.something.com/"); 82 EXPECT_EQ(data.url.spec(), "http://www.something.com/");
82 EXPECT_EQ(data.url_title, base::SysNSStringToUTF16(title)); 83 EXPECT_EQ(data.url_title, base::SysNSStringToUTF16(title));
84
85 [pboard releaseGlobally];
83 } 86 }
84 87
85 TEST_F(WebDropTargetTest, Data) { 88 TEST_F(WebDropTargetTest, Data) {
86 WebDropData data; 89 WebDropData data;
87 NSPasteboard* pboard = [NSPasteboard pasteboardWithUniqueName]; 90 NSPasteboard* pboard = [NSPasteboard pasteboardWithUniqueName];
88 91
89 PutURLOnPasteboard(@"http://www.google.com", pboard); 92 PutURLOnPasteboard(@"http://www.google.com", pboard);
90 [pboard addTypes:[NSArray arrayWithObjects:NSHTMLPboardType, 93 [pboard addTypes:[NSArray arrayWithObjects:NSHTMLPboardType,
91 NSStringPboardType, nil] 94 NSStringPboardType, nil]
92 owner:nil]; 95 owner:nil];
93 NSString* htmlString = @"<html><body><b>hi there</b></body></html>"; 96 NSString* htmlString = @"<html><body><b>hi there</b></body></html>";
94 NSString* textString = @"hi there"; 97 NSString* textString = @"hi there";
95 [pboard setString:htmlString forType:NSHTMLPboardType]; 98 [pboard setString:htmlString forType:NSHTMLPboardType];
96 [pboard setString:textString forType:NSStringPboardType]; 99 [pboard setString:textString forType:NSStringPboardType];
97 [drop_target_ populateWebDropData:&data fromPasteboard:pboard]; 100 [drop_target_ populateWebDropData:&data fromPasteboard:pboard];
98 EXPECT_EQ(data.url.spec(), "http://www.google.com/"); 101 EXPECT_EQ(data.url.spec(), "http://www.google.com/");
99 EXPECT_EQ(data.plain_text, base::SysNSStringToUTF16(textString)); 102 EXPECT_EQ(data.plain_text, base::SysNSStringToUTF16(textString));
100 EXPECT_EQ(data.text_html, base::SysNSStringToUTF16(htmlString)); 103 EXPECT_EQ(data.text_html, base::SysNSStringToUTF16(htmlString));
104
105 [pboard releaseGlobally];
101 } 106 }
102 107
103 TEST_F(WebDropTargetTest, EnterExitDrop) { 108 TEST_F(WebDropTargetTest, EnterExitDrop) {
104 // TODO(pinkerton): Call enter/exit/drop and see what happens. This is a bit 109 // TODO(pinkerton): Call enter/exit/drop and see what happens. This is a bit
105 // harder to test. 110 // harder to test.
106 } 111 }
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/download_util_mac_unittest.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698