0

fix unittests

We need to trim whitespace off the URL and handle the
tricky html case by using rfind.

Review URL: http://codereview.chromium.org/11465

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5701 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
tc@google.com
2008-11-19 19:49:16 +00:00
parent 3a96c74353
commit 1b45fafeb5
2 changed files with 5 additions and 4 deletions

@ -53,7 +53,7 @@ TEST_F(ClipboardTest, TextTest) {
EXPECT_EQ(WideToUTF8(text), ascii_text);
}
TEST_F(ClipboardTest, DISABLED_HTMLTest) {
TEST_F(ClipboardTest, HTMLTest) {
Clipboard clipboard;
std::wstring markup(L"<string>Hi!</string>"), markup_result;
@ -75,7 +75,7 @@ TEST_F(ClipboardTest, DISABLED_HTMLTest) {
#endif
}
TEST_F(ClipboardTest, DISABLED_TrickyHTMLTest) {
TEST_F(ClipboardTest, TrickyHTMLTest) {
Clipboard clipboard;
std::wstring markup(L"<em>Bye!<!--EndFragment --></em>"), markup_result;
@ -118,7 +118,7 @@ TEST_F(ClipboardTest, BookmarkTest) {
}
#endif
TEST_F(ClipboardTest, DISABLED_MultiFormatTest) {
TEST_F(ClipboardTest, MultiFormatTest) {
Clipboard clipboard;
std::wstring text(L"Hi!"), text_result;

@ -466,6 +466,7 @@ void ClipboardUtil::CFHtmlToHtml(const std::string& cf_html,
size_t src_start = line_start + src_url_str.length();
if (src_end != std::string::npos && src_start != std::string::npos) {
*base_url = cf_html.substr(src_start, src_end - src_start);
TrimWhitespace(*base_url, TRIM_ALL, base_url);
}
}
@ -474,7 +475,7 @@ void ClipboardUtil::CFHtmlToHtml(const std::string& cf_html,
size_t markup_start = cf_html_lower.find("<html", 0);
size_t tag_start = cf_html.find("StartFragment", markup_start);
size_t fragment_start = cf_html.find('>', tag_start) + 1;
size_t tag_end = cf_html.find("EndFragment", fragment_start);
size_t tag_end = cf_html.rfind("EndFragment", std::string::npos);
size_t fragment_end = cf_html.rfind('<', tag_end);
if (fragment_start != std::string::npos &&
fragment_end != std::string::npos) {