blob: da52d28e17612e80ac88c21041eaa8efdba0dca0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "chrome/browser/autocomplete/autocomplete_edit_view_mac.h"
#include "base/string_util.h"
#include "base/sys_string_conversions.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/autocomplete/autocomplete.h"
#include "gfx/size.h"
#include "testing/platform_test.h"
#include "ui/base/clipboard/clipboard.h"
#include "ui/base/clipboard/scoped_clipboard_writer.h"
namespace {
TEST(AutocompleteEditViewMacTest, GetClipboardText) {
ui::Clipboard clipboard;
std::wstring text;
// Does an empty clipboard get empty text?
clipboard.WriteObjects(ui::Clipboard::ObjectMap());
text = AutocompleteEditViewMac::GetClipboardText(&clipboard);
EXPECT_EQ(std::wstring(), text);
const string16 plainText(ASCIIToUTF16("test text"));
const std::string url("http://www.example.com/");
const string16 title(ASCIIToUTF16("The Example Company")), title_result;
// Can we pull straight text off the clipboard?
{
ui::ScopedClipboardWriter clipboard_writer(&clipboard);
clipboard_writer.WriteText(plainText);
}
text = AutocompleteEditViewMac::GetClipboardText(&clipboard);
EXPECT_EQ(UTF16ToWide(plainText), text);
// Can we pull a bookmark off the clipboard?
{
ui::ScopedClipboardWriter clipboard_writer(&clipboard);
clipboard_writer.WriteBookmark(title, url);
}
text = AutocompleteEditViewMac::GetClipboardText(&clipboard);
EXPECT_EQ(ASCIIToWide(url), text);
// Do we pull text in preference to a bookmark?
{
ui::ScopedClipboardWriter clipboard_writer(&clipboard);
clipboard_writer.WriteText(plainText);
clipboard_writer.WriteBookmark(title, url);
}
text = AutocompleteEditViewMac::GetClipboardText(&clipboard);
EXPECT_EQ(UTF16ToWide(plainText), text);
// Do we get nothing if there is neither text nor a bookmark?
{
const string16 markup(ASCIIToUTF16("<strong>Hi!</string>"));
ui::ScopedClipboardWriter clipboard_writer(&clipboard);
clipboard_writer.WriteHTML(markup, url);
}
text = AutocompleteEditViewMac::GetClipboardText(&clipboard);
EXPECT_TRUE(text.empty());
}
TEST(AutocompleteEditViewMacTest, GetFieldFont) {
EXPECT_TRUE(AutocompleteEditViewMac::GetFieldFont());
}
} // namespace
|