Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Side by Side Diff: ui/base/dragdrop/os_exchange_data_win_unittest.cc

Issue 2824773002: Rename ScopedComPtr::get() to ScopedComPtr::Get() (Closed)
Patch Set: Update to 5293966 Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/base/dragdrop/os_exchange_data_provider_win.cc ('k') | ui/base/win/shell.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "ui/base/dragdrop/os_exchange_data.h" 5 #include "ui/base/dragdrop/os_exchange_data.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 // This should clobber the existing data. 97 // This should clobber the existing data.
98 { 98 {
99 HGLOBAL glob = GlobalAlloc(GPTR, sizeof(wchar_t) * (input2.size() + 1)); 99 HGLOBAL glob = GlobalAlloc(GPTR, sizeof(wchar_t) * (input2.size() + 1));
100 base::win::ScopedHGlobal<wchar_t*> global_lock(glob); 100 base::win::ScopedHGlobal<wchar_t*> global_lock(glob);
101 wchar_t* buffer_handle = global_lock.get(); 101 wchar_t* buffer_handle = global_lock.get();
102 wcscpy_s(buffer_handle, input2.size() + 1, input2.c_str()); 102 wcscpy_s(buffer_handle, input2.size() + 1, input2.c_str());
103 medium.hGlobal = glob; 103 medium.hGlobal = glob;
104 medium.pUnkForRelease = NULL; 104 medium.pUnkForRelease = NULL;
105 EXPECT_EQ(S_OK, com_data->SetData(&format_etc, &medium, TRUE)); 105 EXPECT_EQ(S_OK, com_data->SetData(&format_etc, &medium, TRUE));
106 } 106 }
107 EXPECT_EQ(1u, static_cast<DataObjectImpl*>(com_data.get())->size()); 107 EXPECT_EQ(1u, static_cast<DataObjectImpl*>(com_data.Get())->size());
108 108
109 // Construct a new object with the old object so that we can use our access 109 // Construct a new object with the old object so that we can use our access
110 // APIs. 110 // APIs.
111 OSExchangeData data2(data.provider().Clone()); 111 OSExchangeData data2(data.provider().Clone());
112 EXPECT_TRUE(data2.HasURL(OSExchangeData::CONVERT_FILENAMES)); 112 EXPECT_TRUE(data2.HasURL(OSExchangeData::CONVERT_FILENAMES));
113 GURL url_from_data; 113 GURL url_from_data;
114 std::wstring title; 114 std::wstring title;
115 EXPECT_TRUE(data2.GetURLAndTitle( 115 EXPECT_TRUE(data2.GetURLAndTitle(
116 OSExchangeData::CONVERT_FILENAMES, &url_from_data, &title)); 116 OSExchangeData::CONVERT_FILENAMES, &url_from_data, &title));
117 EXPECT_EQ(GURL(input2).spec(), url_from_data.spec()); 117 EXPECT_EQ(GURL(input2).spec(), url_from_data.spec());
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 data.SetURL(GURL("http://www.google.com/"), L""); 177 data.SetURL(GURL("http://www.google.com/"), L"");
178 data.SetString(L"O hai googlz."); 178 data.SetString(L"O hai googlz.");
179 179
180 CLIPFORMAT cfstr_file_group_descriptor = 180 CLIPFORMAT cfstr_file_group_descriptor =
181 RegisterClipboardFormat(CFSTR_FILEDESCRIPTOR); 181 RegisterClipboardFormat(CFSTR_FILEDESCRIPTOR);
182 CLIPFORMAT text_x_moz_url = RegisterClipboardFormat(L"text/x-moz-url"); 182 CLIPFORMAT text_x_moz_url = RegisterClipboardFormat(L"text/x-moz-url");
183 183
184 base::win::ScopedComPtr<IDataObject> com_data( 184 base::win::ScopedComPtr<IDataObject> com_data(
185 OSExchangeDataProviderWin::GetIDataObject(data)); 185 OSExchangeDataProviderWin::GetIDataObject(data));
186 base::win::ScopedComPtr<IEnumFORMATETC> enumerator; 186 base::win::ScopedComPtr<IEnumFORMATETC> enumerator;
187 EXPECT_EQ(S_OK, com_data.get()->EnumFormatEtc(DATADIR_GET, 187 EXPECT_EQ(S_OK, com_data.Get()->EnumFormatEtc(DATADIR_GET,
188 enumerator.Receive())); 188 enumerator.Receive()));
189 189
190 // Test that we can get one item. 190 // Test that we can get one item.
191 { 191 {
192 // Explictly don't reset the first time, to verify the creation state is 192 // Explictly don't reset the first time, to verify the creation state is
193 // OK. 193 // OK.
194 ULONG retrieved = 0; 194 ULONG retrieved = 0;
195 FORMATETC elements_array[1]; 195 FORMATETC elements_array[1];
196 EXPECT_EQ(S_OK, enumerator->Next(1, 196 EXPECT_EQ(S_OK, enumerator->Next(1,
197 reinterpret_cast<FORMATETC*>(&elements_array), &retrieved)); 197 reinterpret_cast<FORMATETC*>(&elements_array), &retrieved));
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 EXPECT_EQ(1u, retrieved); 231 EXPECT_EQ(1u, retrieved);
232 EXPECT_EQ(cfstr_file_group_descriptor, elements_array[0].cfFormat); 232 EXPECT_EQ(cfstr_file_group_descriptor, elements_array[0].cfFormat);
233 } 233 }
234 234
235 // Test that we can skip the first item, and create a clone that matches in 235 // Test that we can skip the first item, and create a clone that matches in
236 // this state, and modify the original without affecting the clone. 236 // this state, and modify the original without affecting the clone.
237 { 237 {
238 EXPECT_EQ(S_OK, enumerator->Reset()); 238 EXPECT_EQ(S_OK, enumerator->Reset());
239 EXPECT_EQ(S_OK, enumerator->Skip(1)); 239 EXPECT_EQ(S_OK, enumerator->Skip(1));
240 base::win::ScopedComPtr<IEnumFORMATETC> cloned_enumerator; 240 base::win::ScopedComPtr<IEnumFORMATETC> cloned_enumerator;
241 EXPECT_EQ(S_OK, enumerator.get()->Clone(cloned_enumerator.Receive())); 241 EXPECT_EQ(S_OK, enumerator.Get()->Clone(cloned_enumerator.Receive()));
242 EXPECT_EQ(S_OK, enumerator.get()->Reset()); 242 EXPECT_EQ(S_OK, enumerator.Get()->Reset());
243 243
244 { 244 {
245 ULONG retrieved = 0; 245 ULONG retrieved = 0;
246 FORMATETC elements_array[1]; 246 FORMATETC elements_array[1];
247 EXPECT_EQ(S_OK, cloned_enumerator->Next(1, 247 EXPECT_EQ(S_OK, cloned_enumerator->Next(1,
248 reinterpret_cast<FORMATETC*>(&elements_array), &retrieved)); 248 reinterpret_cast<FORMATETC*>(&elements_array), &retrieved));
249 EXPECT_EQ(1u, retrieved); 249 EXPECT_EQ(1u, retrieved);
250 EXPECT_EQ(cfstr_file_group_descriptor, elements_array[0].cfFormat); 250 EXPECT_EQ(cfstr_file_group_descriptor, elements_array[0].cfFormat);
251 } 251 }
252 252
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 OSExchangeData data2(data.provider().Clone()); 344 OSExchangeData data2(data.provider().Clone());
345 ASSERT_TRUE(data2.HasURL(OSExchangeData::CONVERT_FILENAMES)); 345 ASSERT_TRUE(data2.HasURL(OSExchangeData::CONVERT_FILENAMES));
346 GURL read_url; 346 GURL read_url;
347 std::wstring title; 347 std::wstring title;
348 EXPECT_TRUE(data2.GetURLAndTitle( 348 EXPECT_TRUE(data2.GetURLAndTitle(
349 OSExchangeData::CONVERT_FILENAMES, &read_url, &title)); 349 OSExchangeData::CONVERT_FILENAMES, &read_url, &title));
350 EXPECT_EQ(GURL("http://google.com"), read_url); 350 EXPECT_EQ(GURL("http://google.com"), read_url);
351 } 351 }
352 352
353 } // namespace ui 353 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/dragdrop/os_exchange_data_provider_win.cc ('k') | ui/base/win/shell.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698