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

Side by Side Diff: chrome/browser/autocomplete/autocomplete_edit_view_mac_unittest.mm

Issue 159018: [Mac] Strip newlines from paste. (Closed)
Patch Set: Test empty clipboard Created 11 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #import "chrome/browser/autocomplete/autocomplete_edit_view_mac.h"
6
7 #include "base/clipboard.h"
8 #include "base/gfx/size.h"
9 #include "base/scoped_clipboard_writer.h"
10 #include "base/string_util.h"
11 #include "base/sys_string_conversions.h"
12 #include "chrome/browser/autocomplete/autocomplete.h"
13 #include "testing/platform_test.h"
14
15 namespace {
16
17 TEST(AutocompleteEditViewMacTest, GetClipboardText) {
18 Clipboard clipboard;
19 std::wstring text;
20
21 // Does an empty clipboard get empty text?
22 clipboard.WriteObjects(Clipboard::ObjectMap());
23 text = AutocompleteEditViewMac::GetClipboardText(&clipboard);
24 EXPECT_EQ(std::wstring(), text);
25
26 const string16 plainText(ASCIIToUTF16("test text"));
27 const std::string url("http://www.example.com/");
28 const string16 title(ASCIIToUTF16("The Example Company")), title_result;
29
30 // Can we pull straight text off the clipboard?
31 {
32 ScopedClipboardWriter clipboard_writer(&clipboard);
33 clipboard_writer.WriteText(plainText);
34 }
35
36 text = AutocompleteEditViewMac::GetClipboardText(&clipboard);
37 EXPECT_EQ(UTF16ToWide(plainText), text);
38
39 // Can we pull a bookmark off the clipboard?
40 {
41 ScopedClipboardWriter clipboard_writer(&clipboard);
42 clipboard_writer.WriteBookmark(title, url);
43 }
44
45 text = AutocompleteEditViewMac::GetClipboardText(&clipboard);
46 EXPECT_EQ(ASCIIToWide(url), text);
47
48 // Do we pull text in preference to a bookmark?
49 {
50 ScopedClipboardWriter clipboard_writer(&clipboard);
51 clipboard_writer.WriteText(plainText);
52 clipboard_writer.WriteBookmark(title, url);
53 }
54
55 text = AutocompleteEditViewMac::GetClipboardText(&clipboard);
56 EXPECT_EQ(UTF16ToWide(plainText), text);
57
58 // Do we get nothing if there is neither text nor a bookmark?
59 {
60 const string16 markup(ASCIIToUTF16("<strong>Hi!</string>"));
61 ScopedClipboardWriter clipboard_writer(&clipboard);
62 clipboard_writer.WriteHTML(markup, url);
63 }
64
65 text = AutocompleteEditViewMac::GetClipboardText(&clipboard);
66 EXPECT_TRUE(text.empty());
67 }
68
69 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_edit_view_mac.mm ('k') | chrome/browser/cocoa/autocomplete_text_field.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698