| 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 26 matching lines...) Expand all Loading... |
| 37 protected: | 37 protected: |
| 38 Clipboard& clipboard() { return clipboard_; } | 38 Clipboard& clipboard() { return clipboard_; } |
| 39 | 39 |
| 40 private: | 40 private: |
| 41 base::MessageLoopForUI message_loop_; | 41 base::MessageLoopForUI message_loop_; |
| 42 Clipboard clipboard_; | 42 Clipboard clipboard_; |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 namespace { | 45 namespace { |
| 46 | 46 |
| 47 bool MarkupMatches(const string16& expected_markup, | 47 bool MarkupMatches(const base::string16& expected_markup, |
| 48 const string16& actual_markup) { | 48 const base::string16& actual_markup) { |
| 49 return actual_markup.find(expected_markup) != string16::npos; | 49 return actual_markup.find(expected_markup) != base::string16::npos; |
| 50 } | 50 } |
| 51 | 51 |
| 52 } // namespace | 52 } // namespace |
| 53 | 53 |
| 54 TEST_F(ClipboardTest, ClearTest) { | 54 TEST_F(ClipboardTest, ClearTest) { |
| 55 { | 55 { |
| 56 ScopedClipboardWriter clipboard_writer(&clipboard(), | 56 ScopedClipboardWriter clipboard_writer(&clipboard(), |
| 57 CLIPBOARD_TYPE_COPY_PASTE); | 57 CLIPBOARD_TYPE_COPY_PASTE); |
| 58 clipboard_writer.WriteText(ASCIIToUTF16("clear me")); | 58 clipboard_writer.WriteText(ASCIIToUTF16("clear me")); |
| 59 } | 59 } |
| 60 | 60 |
| 61 clipboard().Clear(CLIPBOARD_TYPE_COPY_PASTE); | 61 clipboard().Clear(CLIPBOARD_TYPE_COPY_PASTE); |
| 62 | 62 |
| 63 EXPECT_FALSE(clipboard().IsFormatAvailable( | 63 EXPECT_FALSE(clipboard().IsFormatAvailable( |
| 64 Clipboard::GetPlainTextWFormatType(), CLIPBOARD_TYPE_COPY_PASTE)); | 64 Clipboard::GetPlainTextWFormatType(), CLIPBOARD_TYPE_COPY_PASTE)); |
| 65 EXPECT_FALSE(clipboard().IsFormatAvailable( | 65 EXPECT_FALSE(clipboard().IsFormatAvailable( |
| 66 Clipboard::GetPlainTextFormatType(), CLIPBOARD_TYPE_COPY_PASTE)); | 66 Clipboard::GetPlainTextFormatType(), CLIPBOARD_TYPE_COPY_PASTE)); |
| 67 } | 67 } |
| 68 | 68 |
| 69 TEST_F(ClipboardTest, TextTest) { | 69 TEST_F(ClipboardTest, TextTest) { |
| 70 string16 text(ASCIIToUTF16("This is a string16!#$")), text_result; | 70 base::string16 text(ASCIIToUTF16("This is a base::string16!#$")), text_result; |
| 71 std::string ascii_text; | 71 std::string ascii_text; |
| 72 | 72 |
| 73 { | 73 { |
| 74 ScopedClipboardWriter clipboard_writer(&clipboard(), | 74 ScopedClipboardWriter clipboard_writer(&clipboard(), |
| 75 CLIPBOARD_TYPE_COPY_PASTE); | 75 CLIPBOARD_TYPE_COPY_PASTE); |
| 76 clipboard_writer.WriteText(text); | 76 clipboard_writer.WriteText(text); |
| 77 } | 77 } |
| 78 | 78 |
| 79 EXPECT_TRUE(clipboard().IsFormatAvailable( | 79 EXPECT_TRUE(clipboard().IsFormatAvailable( |
| 80 Clipboard::GetPlainTextWFormatType(), CLIPBOARD_TYPE_COPY_PASTE)); | 80 Clipboard::GetPlainTextWFormatType(), CLIPBOARD_TYPE_COPY_PASTE)); |
| 81 EXPECT_TRUE(clipboard().IsFormatAvailable(Clipboard::GetPlainTextFormatType(), | 81 EXPECT_TRUE(clipboard().IsFormatAvailable(Clipboard::GetPlainTextFormatType(), |
| 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 base::string16 markup(ASCIIToUTF16("<string>Hi!</string>")), markup_result; |
| 92 string16 plain(ASCIIToUTF16("Hi!")), plain_result; | 92 base::string16 plain(ASCIIToUTF16("Hi!")), plain_result; |
| 93 std::string url("http://www.example.com/"), url_result; | 93 std::string url("http://www.example.com/"), url_result; |
| 94 | 94 |
| 95 { | 95 { |
| 96 ScopedClipboardWriter clipboard_writer(&clipboard(), | 96 ScopedClipboardWriter clipboard_writer(&clipboard(), |
| 97 CLIPBOARD_TYPE_COPY_PASTE); | 97 CLIPBOARD_TYPE_COPY_PASTE); |
| 98 clipboard_writer.WriteText(plain); | 98 clipboard_writer.WriteText(plain); |
| 99 clipboard_writer.WriteHTML(markup, url); | 99 clipboard_writer.WriteHTML(markup, url); |
| 100 } | 100 } |
| 101 | 101 |
| 102 EXPECT_TRUE(clipboard().IsFormatAvailable(Clipboard::GetHtmlFormatType(), | 102 EXPECT_TRUE(clipboard().IsFormatAvailable(Clipboard::GetHtmlFormatType(), |
| (...skipping 23 matching lines...) Expand all Loading... |
| 126 | 126 |
| 127 EXPECT_TRUE(clipboard().IsFormatAvailable(Clipboard::GetRtfFormatType(), | 127 EXPECT_TRUE(clipboard().IsFormatAvailable(Clipboard::GetRtfFormatType(), |
| 128 CLIPBOARD_TYPE_COPY_PASTE)); | 128 CLIPBOARD_TYPE_COPY_PASTE)); |
| 129 std::string result; | 129 std::string result; |
| 130 clipboard().ReadRTF(CLIPBOARD_TYPE_COPY_PASTE, &result); | 130 clipboard().ReadRTF(CLIPBOARD_TYPE_COPY_PASTE, &result); |
| 131 EXPECT_EQ(rtf, result); | 131 EXPECT_EQ(rtf, result); |
| 132 } | 132 } |
| 133 | 133 |
| 134 #if defined(TOOLKIT_GTK) | 134 #if defined(TOOLKIT_GTK) |
| 135 TEST_F(ClipboardTest, MultipleBufferTest) { | 135 TEST_F(ClipboardTest, MultipleBufferTest) { |
| 136 string16 text(ASCIIToUTF16("Standard")), text_result; | 136 base::string16 text(ASCIIToUTF16("Standard")), text_result; |
| 137 string16 markup(ASCIIToUTF16("<string>Selection</string>")), markup_result; | 137 base::string16 markup(ASCIIToUTF16("<string>Selection</string>")); |
| 138 std::string url("http://www.example.com/"), url_result; | 138 std::string url("http://www.example.com/"), url_result; |
| 139 | 139 |
| 140 { | 140 { |
| 141 ScopedClipboardWriter clipboard_writer(&clipboard(), | 141 ScopedClipboardWriter clipboard_writer(&clipboard(), |
| 142 CLIPBOARD_TYPE_COPY_PASTE); | 142 CLIPBOARD_TYPE_COPY_PASTE); |
| 143 clipboard_writer.WriteText(text); | 143 clipboard_writer.WriteText(text); |
| 144 } | 144 } |
| 145 | 145 |
| 146 { | 146 { |
| 147 ScopedClipboardWriter clipboard_writer(&clipboard(), | 147 ScopedClipboardWriter clipboard_writer(&clipboard(), |
| 148 CLIPBOARD_TYPE_SELECTION); | 148 CLIPBOARD_TYPE_SELECTION); |
| 149 clipboard_writer.WriteHTML(markup, url); | 149 clipboard_writer.WriteHTML(markup, url); |
| 150 } | 150 } |
| 151 | 151 |
| 152 EXPECT_TRUE(clipboard().IsFormatAvailable(Clipboard::GetPlainTextFormatType(), | 152 EXPECT_TRUE(clipboard().IsFormatAvailable(Clipboard::GetPlainTextFormatType(), |
| 153 CLIPBOARD_TYPE_COPY_PASTE)); | 153 CLIPBOARD_TYPE_COPY_PASTE)); |
| 154 EXPECT_FALSE(clipboard().IsFormatAvailable( | 154 EXPECT_FALSE(clipboard().IsFormatAvailable( |
| 155 Clipboard::GetPlainTextFormatType(), | 155 Clipboard::GetPlainTextFormatType(), |
| 156 CLIPBOARD_TYPE_SELECTION)); | 156 CLIPBOARD_TYPE_SELECTION)); |
| 157 | 157 |
| 158 EXPECT_FALSE(clipboard().IsFormatAvailable(Clipboard::GetHtmlFormatType(), | 158 EXPECT_FALSE(clipboard().IsFormatAvailable(Clipboard::GetHtmlFormatType(), |
| 159 CLIPBOARD_TYPE_COPY_PASTE)); | 159 CLIPBOARD_TYPE_COPY_PASTE)); |
| 160 EXPECT_TRUE(clipboard().IsFormatAvailable(Clipboard::GetHtmlFormatType(), | 160 EXPECT_TRUE(clipboard().IsFormatAvailable(Clipboard::GetHtmlFormatType(), |
| 161 CLIPBOARD_TYPE_SELECTION)); | 161 CLIPBOARD_TYPE_SELECTION)); |
| 162 | 162 |
| 163 clipboard().ReadText(CLIPBOARD_TYPE_COPY_PASTE, &text_result); | 163 clipboard().ReadText(CLIPBOARD_TYPE_COPY_PASTE, &text_result); |
| 164 EXPECT_EQ(text, text_result); | 164 EXPECT_EQ(text, text_result); |
| 165 | 165 |
| 166 uint32 ignored; | 166 uint32 ignored; |
| 167 base::string16 markup_result; |
| 167 clipboard().ReadHTML(CLIPBOARD_TYPE_SELECTION, | 168 clipboard().ReadHTML(CLIPBOARD_TYPE_SELECTION, |
| 168 &markup_result, | 169 &markup_result, |
| 169 &url_result, | 170 &url_result, |
| 170 &ignored, | 171 &ignored, |
| 171 &ignored); | 172 &ignored); |
| 172 EXPECT_PRED2(MarkupMatches, markup, markup_result); | 173 EXPECT_PRED2(MarkupMatches, markup, markup_result); |
| 173 } | 174 } |
| 174 #endif | 175 #endif |
| 175 | 176 |
| 176 TEST_F(ClipboardTest, TrickyHTMLTest) { | 177 TEST_F(ClipboardTest, TrickyHTMLTest) { |
| 177 string16 markup(ASCIIToUTF16("<em>Bye!<!--EndFragment --></em>")), | 178 base::string16 markup(ASCIIToUTF16("<em>Bye!<!--EndFragment --></em>")), |
| 178 markup_result; | 179 markup_result; |
| 179 std::string url, url_result; | 180 std::string url, url_result; |
| 180 string16 plain(ASCIIToUTF16("Bye!")), plain_result; | 181 base::string16 plain(ASCIIToUTF16("Bye!")), plain_result; |
| 181 | 182 |
| 182 { | 183 { |
| 183 ScopedClipboardWriter clipboard_writer(&clipboard(), | 184 ScopedClipboardWriter clipboard_writer(&clipboard(), |
| 184 CLIPBOARD_TYPE_COPY_PASTE); | 185 CLIPBOARD_TYPE_COPY_PASTE); |
| 185 clipboard_writer.WriteText(plain); | 186 clipboard_writer.WriteText(plain); |
| 186 clipboard_writer.WriteHTML(markup, url); | 187 clipboard_writer.WriteHTML(markup, url); |
| 187 } | 188 } |
| 188 | 189 |
| 189 EXPECT_TRUE(clipboard().IsFormatAvailable(Clipboard::GetHtmlFormatType(), | 190 EXPECT_TRUE(clipboard().IsFormatAvailable(Clipboard::GetHtmlFormatType(), |
| 190 CLIPBOARD_TYPE_COPY_PASTE)); | 191 CLIPBOARD_TYPE_COPY_PASTE)); |
| 191 uint32 ignored; | 192 uint32 ignored; |
| 192 clipboard().ReadHTML(CLIPBOARD_TYPE_COPY_PASTE, &markup_result, &url_result, | 193 clipboard().ReadHTML(CLIPBOARD_TYPE_COPY_PASTE, &markup_result, &url_result, |
| 193 &ignored, &ignored); | 194 &ignored, &ignored); |
| 194 EXPECT_PRED2(MarkupMatches, markup, markup_result); | 195 EXPECT_PRED2(MarkupMatches, markup, markup_result); |
| 195 #if defined(OS_WIN) | 196 #if defined(OS_WIN) |
| 196 // TODO(playmobil): It's not clear that non windows clipboards need to support | 197 // TODO(playmobil): It's not clear that non windows clipboards need to support |
| 197 // this. | 198 // this. |
| 198 EXPECT_EQ(url, url_result); | 199 EXPECT_EQ(url, url_result); |
| 199 #endif // defined(OS_WIN) | 200 #endif // defined(OS_WIN) |
| 200 } | 201 } |
| 201 | 202 |
| 202 #if defined(OS_WIN) | 203 #if defined(OS_WIN) |
| 203 TEST_F(ClipboardTest, UniodeHTMLTest) { | 204 TEST_F(ClipboardTest, UniodeHTMLTest) { |
| 204 string16 markup(UTF8ToUTF16("<div>A \xc3\xb8 \xe6\xb0\xb4</div>")), | 205 base::string16 markup(UTF8ToUTF16("<div>A \xc3\xb8 \xe6\xb0\xb4</div>")), |
| 205 markup_result; | 206 markup_result; |
| 206 std::string url, url_result; | 207 std::string url, url_result; |
| 207 | 208 |
| 208 { | 209 { |
| 209 ScopedClipboardWriter clipboard_writer(&clipboard(), | 210 ScopedClipboardWriter clipboard_writer(&clipboard(), |
| 210 CLIPBOARD_TYPE_COPY_PASTE); | 211 CLIPBOARD_TYPE_COPY_PASTE); |
| 211 clipboard_writer.WriteHTML(markup, url); | 212 clipboard_writer.WriteHTML(markup, url); |
| 212 } | 213 } |
| 213 | 214 |
| 214 EXPECT_TRUE(clipboard().IsFormatAvailable(Clipboard::GetHtmlFormatType(), | 215 EXPECT_TRUE(clipboard().IsFormatAvailable(Clipboard::GetHtmlFormatType(), |
| (...skipping 15 matching lines...) Expand all Loading... |
| 230 TEST_F(ClipboardTest, EmptyHTMLTest) { | 231 TEST_F(ClipboardTest, EmptyHTMLTest) { |
| 231 // ScopedClipboardWriter doesn't let us write empty data to the clipboard. | 232 // ScopedClipboardWriter doesn't let us write empty data to the clipboard. |
| 232 clipboard().clipboard_data_ = new Clipboard::TargetMap(); | 233 clipboard().clipboard_data_ = new Clipboard::TargetMap(); |
| 233 // The 1 is so the compiler doesn't warn about allocating an empty array. | 234 // The 1 is so the compiler doesn't warn about allocating an empty array. |
| 234 char* empty = new char[1]; | 235 char* empty = new char[1]; |
| 235 clipboard().InsertMapping("text/html", empty, 0U); | 236 clipboard().InsertMapping("text/html", empty, 0U); |
| 236 clipboard().SetGtkClipboard(CLIPBOARD_TYPE_COPY_PASTE); | 237 clipboard().SetGtkClipboard(CLIPBOARD_TYPE_COPY_PASTE); |
| 237 | 238 |
| 238 EXPECT_TRUE(clipboard().IsFormatAvailable(Clipboard::GetHtmlFormatType(), | 239 EXPECT_TRUE(clipboard().IsFormatAvailable(Clipboard::GetHtmlFormatType(), |
| 239 CLIPBOARD_TYPE_COPY_PASTE)); | 240 CLIPBOARD_TYPE_COPY_PASTE)); |
| 240 string16 markup_result; | 241 base::string16 markup_result; |
| 241 std::string url_result; | 242 std::string url_result; |
| 242 uint32 ignored; | 243 uint32 ignored; |
| 243 clipboard().ReadHTML(CLIPBOARD_TYPE_COPY_PASTE, &markup_result, &url_result, | 244 clipboard().ReadHTML(CLIPBOARD_TYPE_COPY_PASTE, &markup_result, &url_result, |
| 244 &ignored, &ignored); | 245 &ignored, &ignored); |
| 245 EXPECT_PRED2(MarkupMatches, string16(), markup_result); | 246 EXPECT_PRED2(MarkupMatches, base::string16(), markup_result); |
| 246 } | 247 } |
| 247 #endif | 248 #endif |
| 248 | 249 |
| 249 // TODO(estade): Port the following test (decide what target we use for urls) | 250 // TODO(estade): Port the following test (decide what target we use for urls) |
| 250 #if !defined(OS_POSIX) || defined(OS_MACOSX) | 251 #if !defined(OS_POSIX) || defined(OS_MACOSX) |
| 251 TEST_F(ClipboardTest, BookmarkTest) { | 252 TEST_F(ClipboardTest, BookmarkTest) { |
| 252 string16 title(ASCIIToUTF16("The Example Company")), title_result; | 253 base::string16 title(ASCIIToUTF16("The Example Company")), title_result; |
| 253 std::string url("http://www.example.com/"), url_result; | 254 std::string url("http://www.example.com/"), url_result; |
| 254 | 255 |
| 255 { | 256 { |
| 256 ScopedClipboardWriter clipboard_writer(&clipboard(), | 257 ScopedClipboardWriter clipboard_writer(&clipboard(), |
| 257 CLIPBOARD_TYPE_COPY_PASTE); | 258 CLIPBOARD_TYPE_COPY_PASTE); |
| 258 clipboard_writer.WriteBookmark(title, url); | 259 clipboard_writer.WriteBookmark(title, url); |
| 259 } | 260 } |
| 260 | 261 |
| 261 EXPECT_TRUE(clipboard().IsFormatAvailable(Clipboard::GetUrlWFormatType(), | 262 EXPECT_TRUE(clipboard().IsFormatAvailable(Clipboard::GetUrlWFormatType(), |
| 262 CLIPBOARD_TYPE_COPY_PASTE)); | 263 CLIPBOARD_TYPE_COPY_PASTE)); |
| 263 clipboard().ReadBookmark(&title_result, &url_result); | 264 clipboard().ReadBookmark(&title_result, &url_result); |
| 264 EXPECT_EQ(title, title_result); | 265 EXPECT_EQ(title, title_result); |
| 265 EXPECT_EQ(url, url_result); | 266 EXPECT_EQ(url, url_result); |
| 266 } | 267 } |
| 267 #endif // defined(OS_WIN) | 268 #endif // defined(OS_WIN) |
| 268 | 269 |
| 269 TEST_F(ClipboardTest, MultiFormatTest) { | 270 TEST_F(ClipboardTest, MultiFormatTest) { |
| 270 string16 text(ASCIIToUTF16("Hi!")), text_result; | 271 base::string16 text(ASCIIToUTF16("Hi!")), text_result; |
| 271 string16 markup(ASCIIToUTF16("<strong>Hi!</string>")), markup_result; | 272 base::string16 markup(ASCIIToUTF16("<strong>Hi!</string>")), markup_result; |
| 272 std::string url("http://www.example.com/"), url_result; | 273 std::string url("http://www.example.com/"), url_result; |
| 273 std::string ascii_text; | 274 std::string ascii_text; |
| 274 | 275 |
| 275 { | 276 { |
| 276 ScopedClipboardWriter clipboard_writer(&clipboard(), | 277 ScopedClipboardWriter clipboard_writer(&clipboard(), |
| 277 CLIPBOARD_TYPE_COPY_PASTE); | 278 CLIPBOARD_TYPE_COPY_PASTE); |
| 278 clipboard_writer.WriteHTML(markup, url); | 279 clipboard_writer.WriteHTML(markup, url); |
| 279 clipboard_writer.WriteText(text); | 280 clipboard_writer.WriteText(text); |
| 280 } | 281 } |
| 281 | 282 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 294 // this. | 295 // this. |
| 295 EXPECT_EQ(url, url_result); | 296 EXPECT_EQ(url, url_result); |
| 296 #endif // defined(OS_WIN) | 297 #endif // defined(OS_WIN) |
| 297 clipboard().ReadText(CLIPBOARD_TYPE_COPY_PASTE, &text_result); | 298 clipboard().ReadText(CLIPBOARD_TYPE_COPY_PASTE, &text_result); |
| 298 EXPECT_EQ(text, text_result); | 299 EXPECT_EQ(text, text_result); |
| 299 clipboard().ReadAsciiText(CLIPBOARD_TYPE_COPY_PASTE, &ascii_text); | 300 clipboard().ReadAsciiText(CLIPBOARD_TYPE_COPY_PASTE, &ascii_text); |
| 300 EXPECT_EQ(UTF16ToUTF8(text), ascii_text); | 301 EXPECT_EQ(UTF16ToUTF8(text), ascii_text); |
| 301 } | 302 } |
| 302 | 303 |
| 303 TEST_F(ClipboardTest, URLTest) { | 304 TEST_F(ClipboardTest, URLTest) { |
| 304 string16 url(ASCIIToUTF16("http://www.google.com/")); | 305 base::string16 url(ASCIIToUTF16("http://www.google.com/")); |
| 305 | 306 |
| 306 { | 307 { |
| 307 ScopedClipboardWriter clipboard_writer(&clipboard(), | 308 ScopedClipboardWriter clipboard_writer(&clipboard(), |
| 308 CLIPBOARD_TYPE_COPY_PASTE); | 309 CLIPBOARD_TYPE_COPY_PASTE); |
| 309 clipboard_writer.WriteURL(url); | 310 clipboard_writer.WriteURL(url); |
| 310 } | 311 } |
| 311 | 312 |
| 312 EXPECT_TRUE(clipboard().IsFormatAvailable( | 313 EXPECT_TRUE(clipboard().IsFormatAvailable( |
| 313 Clipboard::GetPlainTextWFormatType(), CLIPBOARD_TYPE_COPY_PASTE)); | 314 Clipboard::GetPlainTextWFormatType(), CLIPBOARD_TYPE_COPY_PASTE)); |
| 314 EXPECT_TRUE(clipboard().IsFormatAvailable(Clipboard::GetPlainTextFormatType(), | 315 EXPECT_TRUE(clipboard().IsFormatAvailable(Clipboard::GetPlainTextFormatType(), |
| 315 CLIPBOARD_TYPE_COPY_PASTE)); | 316 CLIPBOARD_TYPE_COPY_PASTE)); |
| 316 string16 text_result; | 317 base::string16 text_result; |
| 317 clipboard().ReadText(CLIPBOARD_TYPE_COPY_PASTE, &text_result); | 318 clipboard().ReadText(CLIPBOARD_TYPE_COPY_PASTE, &text_result); |
| 318 | 319 |
| 319 EXPECT_EQ(text_result, url); | 320 EXPECT_EQ(text_result, url); |
| 320 | 321 |
| 321 std::string ascii_text; | 322 std::string ascii_text; |
| 322 clipboard().ReadAsciiText(CLIPBOARD_TYPE_COPY_PASTE, &ascii_text); | 323 clipboard().ReadAsciiText(CLIPBOARD_TYPE_COPY_PASTE, &ascii_text); |
| 323 EXPECT_EQ(UTF16ToUTF8(url), ascii_text); | 324 EXPECT_EQ(UTF16ToUTF8(url), ascii_text); |
| 324 | 325 |
| 325 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) | 326 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) |
| 326 ascii_text.clear(); | 327 ascii_text.clear(); |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 | 619 |
| 619 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) | 620 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) |
| 620 TEST_F(ClipboardTest, HyperlinkTest) { | 621 TEST_F(ClipboardTest, HyperlinkTest) { |
| 621 const std::string kTitle("The <Example> Company's \"home page\""); | 622 const std::string kTitle("The <Example> Company's \"home page\""); |
| 622 const std::string kUrl("http://www.example.com?x=3<=3#\"'<>"); | 623 const std::string kUrl("http://www.example.com?x=3<=3#\"'<>"); |
| 623 const std::string kExpectedHtml( | 624 const std::string kExpectedHtml( |
| 624 "<a href=\"http://www.example.com?x=3&lt=3#"'<>\">" | 625 "<a href=\"http://www.example.com?x=3&lt=3#"'<>\">" |
| 625 "The <Example> Company's "home page"</a>"); | 626 "The <Example> Company's "home page"</a>"); |
| 626 | 627 |
| 627 std::string url_result; | 628 std::string url_result; |
| 628 string16 html_result; | 629 base::string16 html_result; |
| 629 { | 630 { |
| 630 ScopedClipboardWriter clipboard_writer(&clipboard(), | 631 ScopedClipboardWriter clipboard_writer(&clipboard(), |
| 631 CLIPBOARD_TYPE_COPY_PASTE); | 632 CLIPBOARD_TYPE_COPY_PASTE); |
| 632 clipboard_writer.WriteHyperlink(ASCIIToUTF16(kTitle), kUrl); | 633 clipboard_writer.WriteHyperlink(ASCIIToUTF16(kTitle), kUrl); |
| 633 } | 634 } |
| 634 | 635 |
| 635 EXPECT_TRUE(clipboard().IsFormatAvailable(Clipboard::GetHtmlFormatType(), | 636 EXPECT_TRUE(clipboard().IsFormatAvailable(Clipboard::GetHtmlFormatType(), |
| 636 CLIPBOARD_TYPE_COPY_PASTE)); | 637 CLIPBOARD_TYPE_COPY_PASTE)); |
| 637 uint32 ignored; | 638 uint32 ignored; |
| 638 clipboard().ReadHTML(CLIPBOARD_TYPE_COPY_PASTE, &html_result, &url_result, | 639 clipboard().ReadHTML(CLIPBOARD_TYPE_COPY_PASTE, &html_result, &url_result, |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 775 EXPECT_TRUE(clipboard().IsFormatAvailable( | 776 EXPECT_TRUE(clipboard().IsFormatAvailable( |
| 776 Clipboard::GetPlainTextWFormatType(), CLIPBOARD_TYPE_COPY_PASTE)); | 777 Clipboard::GetPlainTextWFormatType(), CLIPBOARD_TYPE_COPY_PASTE)); |
| 777 | 778 |
| 778 // Make sure the text is what we inserted while simulating the other app | 779 // Make sure the text is what we inserted while simulating the other app |
| 779 std::string contents; | 780 std::string contents; |
| 780 clipboard().ReadAsciiText(CLIPBOARD_TYPE_COPY_PASTE, &contents); | 781 clipboard().ReadAsciiText(CLIPBOARD_TYPE_COPY_PASTE, &contents); |
| 781 EXPECT_EQ(contents, new_value); | 782 EXPECT_EQ(contents, new_value); |
| 782 } | 783 } |
| 783 #endif | 784 #endif |
| 784 } // namespace ui | 785 } // namespace ui |
| OLD | NEW |