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

Side by Side Diff: app/clipboard/clipboard_unittest.cc

Issue 661429: Fix bug 17333: Can't copy-paste text from OpenOffice to a contenteditable DIV... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 9 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 | « no previous file | app/clipboard/clipboard_util_win.cc » ('j') | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 <string> 5 #include <string>
6 6
7 #include "app/clipboard/clipboard.h" 7 #include "app/clipboard/clipboard.h"
8 #if defined(OS_WIN)
9 #include "app/clipboard/clipboard_util_win.h"
10 #endif
8 #include "app/clipboard/scoped_clipboard_writer.h" 11 #include "app/clipboard/scoped_clipboard_writer.h"
9 #include "base/basictypes.h" 12 #include "base/basictypes.h"
10 #include "base/gfx/size.h" 13 #include "base/gfx/size.h"
11 #include "base/message_loop.h" 14 #include "base/message_loop.h"
12 #include "base/pickle.h" 15 #include "base/pickle.h"
13 #include "base/string_util.h" 16 #include "base/string_util.h"
14 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
15 #include "testing/platform_test.h" 18 #include "testing/platform_test.h"
16 19
17 #if defined(OS_WIN) 20 #if defined(OS_WIN)
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 Clipboard clipboard; 330 Clipboard clipboard;
328 331
329 { 332 {
330 ScopedClipboardWriter clipboard_writer(&clipboard); 333 ScopedClipboardWriter clipboard_writer(&clipboard);
331 clipboard_writer.WriteBitmapFromPixels(fake_bitmap, gfx::Size(3, 4)); 334 clipboard_writer.WriteBitmapFromPixels(fake_bitmap, gfx::Size(3, 4));
332 } 335 }
333 336
334 EXPECT_TRUE(clipboard.IsFormatAvailable(Clipboard::GetBitmapFormatType(), 337 EXPECT_TRUE(clipboard.IsFormatAvailable(Clipboard::GetBitmapFormatType(),
335 Clipboard::BUFFER_STANDARD)); 338 Clipboard::BUFFER_STANDARD));
336 } 339 }
340
341 void HtmlTestHelper(const std::string& cf_html,
342 const std::string& expected_html) {
343 std::string html;
344 ClipboardUtil::CFHtmlToHtml(cf_html, &html, NULL);
345 EXPECT_EQ(html, expected_html);
346 }
347
348 TEST_F(ClipboardTest, HtmlTest) {
349 // Test converting from CF_HTML format data with <!--StartFragment--> and
350 // <!--EndFragment--> comments, like from MS Word.
351 HtmlTestHelper("Version:1.0\r\n"
352 "StartHTML:0000000105\r\n"
353 "EndHTML:0000000199\r\n"
354 "StartFragment:0000000123\r\n"
355 "EndFragment:0000000161\r\n"
356 "\r\n"
357 "<html>\r\n"
358 "<body>\r\n"
359 "<!--StartFragment-->\r\n"
360 "\r\n"
361 "<p>Foo</p>\r\n"
362 "\r\n"
363 "<!--EndFragment-->\r\n"
364 "</body>\r\n"
365 "</html>\r\n\r\n",
366 "<p>Foo</p>");
367
368 // Test converting from CF_HTML format data without <!--StartFragment--> and
369 // <!--EndFragment--> comments, like from OpenOffice Writer.
370 HtmlTestHelper("Version:1.0\r\n"
371 "StartHTML:0000000105\r\n"
372 "EndHTML:0000000151\r\n"
373 "StartFragment:0000000121\r\n"
374 "EndFragment:0000000131\r\n"
375 "<html>\r\n"
376 "<body>\r\n"
377 "<p>Foo</p>\r\n"
378 "</body>\r\n"
379 "</html>\r\n\r\n",
380 "<p>Foo</p>");
381 }
337 #endif // defined(OS_WIN) 382 #endif // defined(OS_WIN)
338 383
339 // Test writing all formats we have simultaneously. 384 // Test writing all formats we have simultaneously.
340 TEST_F(ClipboardTest, WriteEverything) { 385 TEST_F(ClipboardTest, WriteEverything) {
341 Clipboard clipboard; 386 Clipboard clipboard;
342 387
343 { 388 {
344 ScopedClipboardWriter writer(&clipboard); 389 ScopedClipboardWriter writer(&clipboard);
345 writer.WriteText(UTF8ToUTF16("foo")); 390 writer.WriteText(UTF8ToUTF16("foo"));
346 writer.WriteURL(UTF8ToUTF16("foo")); 391 writer.WriteURL(UTF8ToUTF16("foo"));
347 writer.WriteHTML(UTF8ToUTF16("foo"), "bar"); 392 writer.WriteHTML(UTF8ToUTF16("foo"), "bar");
348 writer.WriteBookmark(UTF8ToUTF16("foo"), "bar"); 393 writer.WriteBookmark(UTF8ToUTF16("foo"), "bar");
349 writer.WriteHyperlink("foo", "bar"); 394 writer.WriteHyperlink("foo", "bar");
350 writer.WriteWebSmartPaste(); 395 writer.WriteWebSmartPaste();
351 // Left out: WriteFile, WriteFiles, WriteBitmapFromPixels, WritePickledData. 396 // Left out: WriteFile, WriteFiles, WriteBitmapFromPixels, WritePickledData.
352 } 397 }
353 398
354 // Passes if we don't crash. 399 // Passes if we don't crash.
355 } 400 }
OLDNEW
« no previous file with comments | « no previous file | app/clipboard/clipboard_util_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698