From 22cf8687fe6c4fc4dbb2b9b2ac41d7d45f656d83 Mon Sep 17 00:00:00 2001 From: "tc@google.com" Date: Wed, 19 Nov 2008 01:20:01 +0000 Subject: 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 --- chrome/common/os_exchange_data_unittest.cc | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'chrome/common/os_exchange_data_unittest.cc') 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 #include +#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 data(new OSExchangeData); - std::wstring html(L"Version:0.9\nStartHTML:71\nEndHTML:160\n" - L"StartFragment:130\nEndFragment:150\n\n\n" - L"\nbold. This is bold italic.\n" - L"\n\n"); - data->SetCFHtml(html); + GURL url("http://www.google.com/"); + std::wstring html( + L"\n\n" + L"bold. This is bold italic.\n" + L"\n"); + data->SetHtml(html, url); scoped_refptr 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\r\n\r\n" + "\r\n"); + expected_cf_html += WideToUTF8(html); + expected_cf_html.append("\r\n\r\n\r\n"); + + STGMEDIUM medium; + EXPECT_EQ(S_OK, data->GetData(ClipboardUtil::GetHtmlFormat(), &medium)); + ScopedHGlobal glob(medium.hGlobal); + std::string output(glob.get(), glob.Size()); + EXPECT_EQ(expected_cf_html, output); + ReleaseStgMedium(&medium); } TEST(OSExchangeDataTest, SetURLWithMaxPath) { -- cgit v1.1