summaryrefslogtreecommitdiffstats
path: root/chrome/common/os_exchange_data_unittest.cc
diff options
context:
space:
mode:
authortc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-19 01:20:01 +0000
committertc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-19 01:20:01 +0000
commit22cf8687fe6c4fc4dbb2b9b2ac41d7d45f656d83 (patch)
treedf838980effe3721bdc41b6acea356bf6352df8e /chrome/common/os_exchange_data_unittest.cc
parent234ebdecf98582ca141b9066b1e5f4f74d3bdbff (diff)
downloadchromium_src-22cf8687fe6c4fc4dbb2b9b2ac41d7d45f656d83.zip
chromium_src-22cf8687fe6c4fc4dbb2b9b2ac41d7d45f656d83.tar.gz
chromium_src-22cf8687fe6c4fc4dbb2b9b2ac41d7d45f656d83.tar.bz2
Remove cf_html from webdropdata.h. This is windows
specific code so we should handle it before we get to webkit. CF_HTML needs the source URL to resolve relative URLs so I added that to the format and plumb it through from webcore. I also did some small refactoring so we only have one implementation of converting to/from CF_HTML and regular markup. We can tweak these converters (and add unit tests) in follow up changes. Review URL: http://codereview.chromium.org/11247 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5662 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/os_exchange_data_unittest.cc')
-rw-r--r--chrome/common/os_exchange_data_unittest.cc30
1 files changed, 24 insertions, 6 deletions
diff --git a/chrome/common/os_exchange_data_unittest.cc b/chrome/common/os_exchange_data_unittest.cc
index f54cb72..427208f 100644
--- a/chrome/common/os_exchange_data_unittest.cc
+++ b/chrome/common/os_exchange_data_unittest.cc
@@ -5,6 +5,7 @@
#include <atlbase.h>
#include <shlobj.h>
+#include "base/clipboard_util.h"
#include "base/pickle.h"
#include "base/ref_counted.h"
#include "base/scoped_handle.h"
@@ -313,16 +314,33 @@ TEST(OSExchangeDataTest, FileContents) {
TEST(OSExchangeDataTest, Html) {
scoped_refptr<OSExchangeData> data(new OSExchangeData);
- std::wstring html(L"Version:0.9\nStartHTML:71\nEndHTML:160\n"
- L"StartFragment:130\nEndFragment:150\n<HTML>\n<BODY>\n"
- L"<!--StartFragment-->\n<b>bold.</b> <i><b>This is bold italic.</b></i>\n"
- L"<!--EndFragment-->\n</BODY>\n</HTML>");
- data->SetCFHtml(html);
+ GURL url("http://www.google.com/");
+ std::wstring html(
+ L"<HTML>\n<BODY>\n"
+ L"<b>bold.</b> <i><b>This is bold italic.</b></i>\n"
+ L"</BODY>\n</HTML>");
+ data->SetHtml(html, url);
scoped_refptr<OSExchangeData> copy(new OSExchangeData(data.get()));
std::wstring read_html;
- EXPECT_TRUE(copy->GetCFHtml(&read_html));
+ EXPECT_TRUE(copy->GetHtml(&read_html, &url));
EXPECT_EQ(html, read_html);
+
+ // Check the CF_HTML too.
+ std::string expected_cf_html(
+ "Version:0.9\r\nStartHTML:0000000138\r\nEndHTML:0000000291\r\n"
+ "StartFragment:0000000176\r\nEndFragment:0000000253\r\n"
+ "SourceURL:http://www.google.com/\r\n<html>\r\n<body>\r\n"
+ "<!--StartFragment-->\r\n");
+ expected_cf_html += WideToUTF8(html);
+ expected_cf_html.append("\r\n<!--EndFragment-->\r\n</body>\r\n</html>");
+
+ STGMEDIUM medium;
+ EXPECT_EQ(S_OK, data->GetData(ClipboardUtil::GetHtmlFormat(), &medium));
+ ScopedHGlobal<char> glob(medium.hGlobal);
+ std::string output(glob.get(), glob.Size());
+ EXPECT_EQ(expected_cf_html, output);
+ ReleaseStgMedium(&medium);
}
TEST(OSExchangeDataTest, SetURLWithMaxPath) {