OLD | NEW |
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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 CLIPBOARD_TYPE_COPY_PASTE)); | 82 CLIPBOARD_TYPE_COPY_PASTE)); |
83 clipboard().ReadText(CLIPBOARD_TYPE_COPY_PASTE, &text_result); | 83 clipboard().ReadText(CLIPBOARD_TYPE_COPY_PASTE, &text_result); |
84 | 84 |
85 EXPECT_EQ(text, text_result); | 85 EXPECT_EQ(text, text_result); |
86 clipboard().ReadAsciiText(CLIPBOARD_TYPE_COPY_PASTE, &ascii_text); | 86 clipboard().ReadAsciiText(CLIPBOARD_TYPE_COPY_PASTE, &ascii_text); |
87 EXPECT_EQ(UTF16ToUTF8(text), ascii_text); | 87 EXPECT_EQ(UTF16ToUTF8(text), ascii_text); |
88 } | 88 } |
89 | 89 |
90 TEST_F(ClipboardTest, HTMLTest) { | 90 TEST_F(ClipboardTest, HTMLTest) { |
91 string16 markup(ASCIIToUTF16("<string>Hi!</string>")), markup_result; | 91 string16 markup(ASCIIToUTF16("<string>Hi!</string>")), markup_result; |
| 92 string16 plain(ASCIIToUTF16("Hi!")), plain_result; |
92 std::string url("http://www.example.com/"), url_result; | 93 std::string url("http://www.example.com/"), url_result; |
93 | 94 |
94 { | 95 { |
95 ScopedClipboardWriter clipboard_writer(&clipboard(), | 96 ScopedClipboardWriter clipboard_writer(&clipboard(), |
96 CLIPBOARD_TYPE_COPY_PASTE); | 97 CLIPBOARD_TYPE_COPY_PASTE); |
| 98 clipboard_writer.WriteText(plain); |
97 clipboard_writer.WriteHTML(markup, url); | 99 clipboard_writer.WriteHTML(markup, url); |
98 } | 100 } |
99 | 101 |
100 EXPECT_TRUE(clipboard().IsFormatAvailable(Clipboard::GetHtmlFormatType(), | 102 EXPECT_TRUE(clipboard().IsFormatAvailable(Clipboard::GetHtmlFormatType(), |
101 CLIPBOARD_TYPE_COPY_PASTE)); | 103 CLIPBOARD_TYPE_COPY_PASTE)); |
102 uint32 ignored; | 104 uint32 ignored; |
103 clipboard().ReadHTML(CLIPBOARD_TYPE_COPY_PASTE, &markup_result, &url_result, | 105 clipboard().ReadHTML(CLIPBOARD_TYPE_COPY_PASTE, &markup_result, &url_result, |
104 &ignored, &ignored); | 106 &ignored, &ignored); |
105 EXPECT_PRED2(MarkupMatches, markup, markup_result); | 107 EXPECT_PRED2(MarkupMatches, markup, markup_result); |
106 #if defined(OS_WIN) | 108 #if defined(OS_WIN) |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 &ignored, | 170 &ignored, |
169 &ignored); | 171 &ignored); |
170 EXPECT_PRED2(MarkupMatches, markup, markup_result); | 172 EXPECT_PRED2(MarkupMatches, markup, markup_result); |
171 } | 173 } |
172 #endif | 174 #endif |
173 | 175 |
174 TEST_F(ClipboardTest, TrickyHTMLTest) { | 176 TEST_F(ClipboardTest, TrickyHTMLTest) { |
175 string16 markup(ASCIIToUTF16("<em>Bye!<!--EndFragment --></em>")), | 177 string16 markup(ASCIIToUTF16("<em>Bye!<!--EndFragment --></em>")), |
176 markup_result; | 178 markup_result; |
177 std::string url, url_result; | 179 std::string url, url_result; |
| 180 string16 plain(ASCIIToUTF16("Bye!")), plain_result; |
178 | 181 |
179 { | 182 { |
180 ScopedClipboardWriter clipboard_writer(&clipboard(), | 183 ScopedClipboardWriter clipboard_writer(&clipboard(), |
181 CLIPBOARD_TYPE_COPY_PASTE); | 184 CLIPBOARD_TYPE_COPY_PASTE); |
| 185 clipboard_writer.WriteText(plain); |
182 clipboard_writer.WriteHTML(markup, url); | 186 clipboard_writer.WriteHTML(markup, url); |
183 } | 187 } |
184 | 188 |
185 EXPECT_TRUE(clipboard().IsFormatAvailable(Clipboard::GetHtmlFormatType(), | 189 EXPECT_TRUE(clipboard().IsFormatAvailable(Clipboard::GetHtmlFormatType(), |
186 CLIPBOARD_TYPE_COPY_PASTE)); | 190 CLIPBOARD_TYPE_COPY_PASTE)); |
187 uint32 ignored; | 191 uint32 ignored; |
188 clipboard().ReadHTML(CLIPBOARD_TYPE_COPY_PASTE, &markup_result, &url_result, | 192 clipboard().ReadHTML(CLIPBOARD_TYPE_COPY_PASTE, &markup_result, &url_result, |
189 &ignored, &ignored); | 193 &ignored, &ignored); |
190 EXPECT_PRED2(MarkupMatches, markup, markup_result); | 194 EXPECT_PRED2(MarkupMatches, markup, markup_result); |
191 #if defined(OS_WIN) | 195 #if defined(OS_WIN) |
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 EXPECT_TRUE(clipboard().IsFormatAvailable( | 670 EXPECT_TRUE(clipboard().IsFormatAvailable( |
667 Clipboard::GetPlainTextWFormatType(), CLIPBOARD_TYPE_COPY_PASTE)); | 671 Clipboard::GetPlainTextWFormatType(), CLIPBOARD_TYPE_COPY_PASTE)); |
668 | 672 |
669 // Make sure the text is what we inserted while simulating the other app | 673 // Make sure the text is what we inserted while simulating the other app |
670 std::string contents; | 674 std::string contents; |
671 clipboard().ReadAsciiText(CLIPBOARD_TYPE_COPY_PASTE, &contents); | 675 clipboard().ReadAsciiText(CLIPBOARD_TYPE_COPY_PASTE, &contents); |
672 EXPECT_EQ(contents, new_value); | 676 EXPECT_EQ(contents, new_value); |
673 } | 677 } |
674 #endif | 678 #endif |
675 } // namespace ui | 679 } // namespace ui |
OLD | NEW |