OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <atlbase.h> | 5 #include <atlbase.h> |
6 #include <shlobj.h> | 6 #include <shlobj.h> |
7 | 7 |
8 #include "base/pickle.h" | 8 #include "base/pickle.h" |
9 #include "base/ref_counted.h" | 9 #include "base/ref_counted.h" |
10 #include "base/scoped_handle.h" | 10 #include "base/scoped_handle.h" |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 // File contents access via COM | 258 // File contents access via COM |
259 CComPtr<IDataObject> com_data(data); | 259 CComPtr<IDataObject> com_data(data); |
260 { | 260 { |
261 CLIPFORMAT cfstr_file_contents = RegisterClipboardFormat(CFSTR_FILECONTENTS)
; | 261 CLIPFORMAT cfstr_file_contents = RegisterClipboardFormat(CFSTR_FILECONTENTS)
; |
262 FORMATETC format_etc = | 262 FORMATETC format_etc = |
263 { cfstr_file_contents, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; | 263 { cfstr_file_contents, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; |
264 EXPECT_EQ(S_OK, com_data->QueryGetData(&format_etc)); | 264 EXPECT_EQ(S_OK, com_data->QueryGetData(&format_etc)); |
265 | 265 |
266 STGMEDIUM medium; | 266 STGMEDIUM medium; |
267 EXPECT_EQ(S_OK, com_data->GetData(&format_etc, &medium)); | 267 EXPECT_EQ(S_OK, com_data->GetData(&format_etc, &medium)); |
268 std::string output = | 268 ScopedHGlobal<char> glob(medium.hGlobal); |
269 ScopedHGlobal<char>(medium.hGlobal).get(); | 269 std::string output(glob.get(), glob.Size()); |
270 std::string file_contents = "[InternetShortcut]\r\nURL=" + url_spec + "\r\n"
; | 270 std::string file_contents = "[InternetShortcut]\r\nURL=" + url_spec + "\r\n"
; |
271 EXPECT_EQ(file_contents, output); | 271 EXPECT_EQ(file_contents, output); |
272 ReleaseStgMedium(&medium); | 272 ReleaseStgMedium(&medium); |
273 } | 273 } |
274 | 274 |
275 // Need to manually free data2 since we never stuff it into a COMPtr. | 275 // Need to manually free data2 since we never stuff it into a COMPtr. |
276 delete data2; | 276 delete data2; |
277 } | 277 } |
278 | 278 |
279 TEST(OSExchangeDataTest, TestPickledData) { | 279 TEST(OSExchangeDataTest, TestPickledData) { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 data->SetString(L"http://google.com"); | 336 data->SetString(L"http://google.com"); |
337 | 337 |
338 scoped_ptr<OSExchangeData> data2(new OSExchangeData(data.get())); | 338 scoped_ptr<OSExchangeData> data2(new OSExchangeData(data.get())); |
339 ASSERT_TRUE(data2->HasURL()); | 339 ASSERT_TRUE(data2->HasURL()); |
340 GURL read_url; | 340 GURL read_url; |
341 std::wstring title; | 341 std::wstring title; |
342 EXPECT_TRUE(data2->GetURLAndTitle(&read_url, &title)); | 342 EXPECT_TRUE(data2->GetURLAndTitle(&read_url, &title)); |
343 EXPECT_EQ(GURL("http://google.com"), read_url); | 343 EXPECT_EQ(GURL("http://google.com"), read_url); |
344 } | 344 } |
345 | 345 |
OLD | NEW |