| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/memory/ref_counted.h" | 5 #include "base/memory/ref_counted.h" |
| 6 #include "base/memory/scoped_handle.h" | 6 #include "base/memory/scoped_handle.h" |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/pickle.h" | 8 #include "base/pickle.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "base/win/scoped_hglobal.h" | 10 #include "base/win/scoped_hglobal.h" |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 L"</BODY>\n</HTML>"); | 380 L"</BODY>\n</HTML>"); |
| 381 data.SetHtml(html, url); | 381 data.SetHtml(html, url); |
| 382 | 382 |
| 383 OSExchangeData copy(CloneProvider(data)); | 383 OSExchangeData copy(CloneProvider(data)); |
| 384 std::wstring read_html; | 384 std::wstring read_html; |
| 385 EXPECT_TRUE(copy.GetHtml(&read_html, &url)); | 385 EXPECT_TRUE(copy.GetHtml(&read_html, &url)); |
| 386 EXPECT_EQ(html, read_html); | 386 EXPECT_EQ(html, read_html); |
| 387 | 387 |
| 388 // Check the CF_HTML too. | 388 // Check the CF_HTML too. |
| 389 std::string expected_cf_html( | 389 std::string expected_cf_html( |
| 390 "Version:0.9\r\nStartHTML:0000000139\r\nEndHTML:0000000292\r\n" | 390 "Version:0.9\r\nStartHTML:0000000139\r\nEndHTML:0000000288\r\n" |
| 391 "StartFragment:0000000177\r\nEndFragment:0000000254\r\n" | 391 "StartFragment:0000000175\r\nEndFragment:0000000252\r\n" |
| 392 "SourceURL:http://www.google.com/\r\n<html>\r\n<body>\r\n" | 392 "SourceURL:http://www.google.com/\r\n<html>\r\n<body>\r\n" |
| 393 "<!--StartFragment-->\r\n"); | 393 "<!--StartFragment-->"); |
| 394 expected_cf_html += WideToUTF8(html); | 394 expected_cf_html += WideToUTF8(html); |
| 395 expected_cf_html.append("\r\n<!--EndFragment-->\r\n</body>\r\n</html>"); | 395 expected_cf_html.append("<!--EndFragment-->\r\n</body>\r\n</html>"); |
| 396 | 396 |
| 397 STGMEDIUM medium; | 397 STGMEDIUM medium; |
| 398 IDataObject* data_object = OSExchangeDataProviderWin::GetIDataObject(data); | 398 IDataObject* data_object = OSExchangeDataProviderWin::GetIDataObject(data); |
| 399 EXPECT_EQ(S_OK, | 399 EXPECT_EQ(S_OK, |
| 400 data_object->GetData(ui::ClipboardUtil::GetHtmlFormat(), &medium)); | 400 data_object->GetData(ui::ClipboardUtil::GetHtmlFormat(), &medium)); |
| 401 base::win::ScopedHGlobal<char> glob(medium.hGlobal); | 401 base::win::ScopedHGlobal<char> glob(medium.hGlobal); |
| 402 std::string output(glob.get(), glob.Size()); | 402 std::string output(glob.get(), glob.Size()); |
| 403 EXPECT_EQ(expected_cf_html, output); | 403 EXPECT_EQ(expected_cf_html, output); |
| 404 ReleaseStgMedium(&medium); | 404 ReleaseStgMedium(&medium); |
| 405 } | 405 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 416 | 416 |
| 417 OSExchangeData data2(CloneProvider(data)); | 417 OSExchangeData data2(CloneProvider(data)); |
| 418 ASSERT_TRUE(data2.HasURL()); | 418 ASSERT_TRUE(data2.HasURL()); |
| 419 GURL read_url; | 419 GURL read_url; |
| 420 std::wstring title; | 420 std::wstring title; |
| 421 EXPECT_TRUE(data2.GetURLAndTitle(&read_url, &title)); | 421 EXPECT_TRUE(data2.GetURLAndTitle(&read_url, &title)); |
| 422 EXPECT_EQ(GURL("http://google.com"), read_url); | 422 EXPECT_EQ(GURL("http://google.com"), read_url); |
| 423 } | 423 } |
| 424 | 424 |
| 425 } // namespace ui | 425 } // namespace ui |
| OLD | NEW |