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

Unified 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, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | app/clipboard/clipboard_util_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: app/clipboard/clipboard_unittest.cc
===================================================================
--- app/clipboard/clipboard_unittest.cc (revision 40346)
+++ app/clipboard/clipboard_unittest.cc (working copy)
@@ -5,6 +5,9 @@
#include <string>
#include "app/clipboard/clipboard.h"
+#if defined(OS_WIN)
+#include "app/clipboard/clipboard_util_win.h"
+#endif
#include "app/clipboard/scoped_clipboard_writer.h"
#include "base/basictypes.h"
#include "base/gfx/size.h"
@@ -334,6 +337,48 @@
EXPECT_TRUE(clipboard.IsFormatAvailable(Clipboard::GetBitmapFormatType(),
Clipboard::BUFFER_STANDARD));
}
+
+void HtmlTestHelper(const std::string& cf_html,
+ const std::string& expected_html) {
+ std::string html;
+ ClipboardUtil::CFHtmlToHtml(cf_html, &html, NULL);
+ EXPECT_EQ(html, expected_html);
+}
+
+TEST_F(ClipboardTest, HtmlTest) {
+ // Test converting from CF_HTML format data with <!--StartFragment--> and
+ // <!--EndFragment--> comments, like from MS Word.
+ HtmlTestHelper("Version:1.0\r\n"
+ "StartHTML:0000000105\r\n"
+ "EndHTML:0000000199\r\n"
+ "StartFragment:0000000123\r\n"
+ "EndFragment:0000000161\r\n"
+ "\r\n"
+ "<html>\r\n"
+ "<body>\r\n"
+ "<!--StartFragment-->\r\n"
+ "\r\n"
+ "<p>Foo</p>\r\n"
+ "\r\n"
+ "<!--EndFragment-->\r\n"
+ "</body>\r\n"
+ "</html>\r\n\r\n",
+ "<p>Foo</p>");
+
+ // Test converting from CF_HTML format data without <!--StartFragment--> and
+ // <!--EndFragment--> comments, like from OpenOffice Writer.
+ HtmlTestHelper("Version:1.0\r\n"
+ "StartHTML:0000000105\r\n"
+ "EndHTML:0000000151\r\n"
+ "StartFragment:0000000121\r\n"
+ "EndFragment:0000000131\r\n"
+ "<html>\r\n"
+ "<body>\r\n"
+ "<p>Foo</p>\r\n"
+ "</body>\r\n"
+ "</html>\r\n\r\n",
+ "<p>Foo</p>");
+}
#endif // defined(OS_WIN)
// Test writing all formats we have simultaneously.
« 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