summaryrefslogtreecommitdiffstats
path: root/app/clipboard/clipboard_unittest.cc
diff options
context:
space:
mode:
authorjianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-03 18:26:08 +0000
committerjianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-03 18:26:08 +0000
commit3acb7453d8ab3234cbf005176d4c36e19cdc2cc4 (patch)
tree20fb06a3f4f5272ca90174f6d394f3fdbb3724f2 /app/clipboard/clipboard_unittest.cc
parenta493faf3fe87e23bcd4baa659427b06b90dff0d5 (diff)
downloadchromium_src-3acb7453d8ab3234cbf005176d4c36e19cdc2cc4.zip
chromium_src-3acb7453d8ab3234cbf005176d4c36e19cdc2cc4.tar.gz
chromium_src-3acb7453d8ab3234cbf005176d4c36e19cdc2cc4.tar.bz2
Fix bug 17333: Can't copy-paste text from OpenOffice to a contenteditable DIV
BUG=17333 TEST=ClipboardTest.HtmlTest Review URL: http://codereview.chromium.org/661429 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40523 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app/clipboard/clipboard_unittest.cc')
-rw-r--r--app/clipboard/clipboard_unittest.cc45
1 files changed, 45 insertions, 0 deletions
diff --git a/app/clipboard/clipboard_unittest.cc b/app/clipboard/clipboard_unittest.cc
index 034e3a3..a980679 100644
--- a/app/clipboard/clipboard_unittest.cc
+++ b/app/clipboard/clipboard_unittest.cc
@@ -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 @@ TEST_F(ClipboardTest, BitmapTest) {
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.