diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/clipboard/clipboard_linux.cc | 14 | ||||
-rw-r--r-- | app/clipboard/clipboard_unittest.cc | 19 |
2 files changed, 26 insertions, 7 deletions
diff --git a/app/clipboard/clipboard_linux.cc b/app/clipboard/clipboard_linux.cc index dba93f0..eb05331 100644 --- a/app/clipboard/clipboard_linux.cc +++ b/app/clipboard/clipboard_linux.cc @@ -166,11 +166,17 @@ void Clipboard::WriteHTML(const char* markup_data, size_t markup_len, const char* url_data, size_t url_len) { - // TODO(estade): might not want to ignore |url_data| - char* data = new char[markup_len]; - memcpy(data, markup_data, markup_len); + // TODO(estade): We need to expand relative links with |url_data|. + static const char* html_prefix = "<meta http-equiv=\"content-type\" " + "content=\"text/html; charset=utf-8\">"; + int html_prefix_len = strlen(html_prefix); + int total_len = html_prefix_len + markup_len; - InsertMapping(kMimeHtml, data, markup_len); + char* data = new char[total_len]; + snprintf(data, total_len, "%s", html_prefix); + memcpy(data + html_prefix_len, markup_data, markup_len); + + InsertMapping(kMimeHtml, data, total_len); } // Write an extra flavor that signifies WebKit was the last to modify the diff --git a/app/clipboard/clipboard_unittest.cc b/app/clipboard/clipboard_unittest.cc index 84cc69c..6f19d97 100644 --- a/app/clipboard/clipboard_unittest.cc +++ b/app/clipboard/clipboard_unittest.cc @@ -30,6 +30,19 @@ class ClipboardTest : public PlatformTest { typedef PlatformTest ClipboardTest; #endif // defined(OS_WIN) +namespace { + +bool ClipboardContentsIsExpected(const string16& copied_markup, + const string16& pasted_markup) { +#if defined(OS_LINUX) + return pasted_markup.find(copied_markup) != string16::npos; +#else + return copied_markup == pasted_markup; +#endif +} + +} // namespace + TEST_F(ClipboardTest, ClearTest) { Clipboard clipboard; @@ -85,7 +98,7 @@ TEST_F(ClipboardTest, HTMLTest) { EXPECT_TRUE(clipboard.IsFormatAvailable(Clipboard::GetHtmlFormatType(), Clipboard::BUFFER_STANDARD)); clipboard.ReadHTML(Clipboard::BUFFER_STANDARD, &markup_result, &url_result); - EXPECT_EQ(markup, markup_result); + EXPECT_TRUE(ClipboardContentsIsExpected(markup, markup_result)); #if defined(OS_WIN) // TODO(playmobil): It's not clear that non windows clipboards need to support // this. @@ -108,7 +121,7 @@ TEST_F(ClipboardTest, TrickyHTMLTest) { EXPECT_TRUE(clipboard.IsFormatAvailable(Clipboard::GetHtmlFormatType(), Clipboard::BUFFER_STANDARD)); clipboard.ReadHTML(Clipboard::BUFFER_STANDARD, &markup_result, &url_result); - EXPECT_EQ(markup, markup_result); + EXPECT_TRUE(ClipboardContentsIsExpected(markup, markup_result)); #if defined(OS_WIN) // TODO(playmobil): It's not clear that non windows clipboards need to support // this. @@ -158,7 +171,7 @@ TEST_F(ClipboardTest, MultiFormatTest) { EXPECT_TRUE(clipboard.IsFormatAvailable( Clipboard::GetPlainTextFormatType(), Clipboard::BUFFER_STANDARD)); clipboard.ReadHTML(Clipboard::BUFFER_STANDARD, &markup_result, &url_result); - EXPECT_EQ(markup, markup_result); + EXPECT_TRUE(ClipboardContentsIsExpected(markup, markup_result)); #if defined(OS_WIN) // TODO(playmobil): It's not clear that non windows clipboards need to support // this. |