Nikolay Sivov : scrrun: Implement Skip() for drive collection.
Module: wine Branch: master Commit: a30a2abbc40ce984c28d95b30b53a47c81c440a9 URL: http://source.winehq.org/git/wine.git/?a=commit;h=a30a2abbc40ce984c28d95b30b... Author: Nikolay Sivov <nsivov(a)codeweavers.com> Date: Tue Mar 11 00:20:48 2014 +0400 scrrun: Implement Skip() for drive collection. --- dlls/scrrun/filesystem.c | 18 ++++++++++------- dlls/scrrun/tests/filesystem.c | 42 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 7 deletions(-) diff --git a/dlls/scrrun/filesystem.c b/dlls/scrrun/filesystem.c index ccdb9ee..c052906 100644 --- a/dlls/scrrun/filesystem.c +++ b/dlls/scrrun/filesystem.c @@ -1103,16 +1103,18 @@ static HRESULT WINAPI drivecoll_enumvariant_Next(IEnumVARIANT *iface, ULONG celt { struct enumvariant *This = impl_from_IEnumVARIANT(iface); ULONG count = 0; - HRESULT hr; TRACE("(%p)->(%d %p %p)\n", This, celt, var, fetched); if (fetched) *fetched = 0; + if (!celt) return S_OK; + while (find_next_drive(This) == S_OK) { IDrive *drive; + HRESULT hr; hr = create_drive('A' + This->data.u.drivecoll.cur, &drive); if (FAILED(hr)) return hr; @@ -1123,22 +1125,24 @@ static HRESULT WINAPI drivecoll_enumvariant_Next(IEnumVARIANT *iface, ULONG celt if (++count >= celt) break; } - if (count < celt) - return S_FALSE; - if (fetched) *fetched = count; - return S_OK; + return (count < celt) ? S_FALSE : S_OK; } static HRESULT WINAPI drivecoll_enumvariant_Skip(IEnumVARIANT *iface, ULONG celt) { struct enumvariant *This = impl_from_IEnumVARIANT(iface); - FIXME("(%p)->(%d): stub\n", This, celt); + TRACE("(%p)->(%d)\n", This, celt); - return E_NOTIMPL; + if (!celt) return S_OK; + + while (celt && find_next_drive(This) == S_OK) + celt--; + + return celt ? S_FALSE : S_OK; } static HRESULT WINAPI drivecoll_enumvariant_Reset(IEnumVARIANT *iface) diff --git a/dlls/scrrun/tests/filesystem.c b/dlls/scrrun/tests/filesystem.c index a09d54b..c14e846 100644 --- a/dlls/scrrun/tests/filesystem.c +++ b/dlls/scrrun/tests/filesystem.c @@ -1142,6 +1142,47 @@ todo_wine IFileCollection_Release(files); } +static void test_DriveCollection(void) +{ + IDriveCollection *drives; + IEnumVARIANT *enumvar; + ULONG fetched; + VARIANT var; + HRESULT hr; + LONG count; + + hr = IFileSystem3_get_Drives(fs3, &drives); + ok(hr == S_OK, "got 0x%08x\n", hr); + + hr = IDriveCollection_get__NewEnum(drives, (IUnknown**)&enumvar); + ok(hr == S_OK, "got 0x%08x\n", hr); + + count = 0; + hr = IDriveCollection_get_Count(drives, &count); +todo_wine { + ok(hr == S_OK, "got 0x%08x\n", hr); + ok(count > 0, "got %d\n", count); +} + V_VT(&var) = VT_EMPTY; + fetched = -1; + hr = IEnumVARIANT_Next(enumvar, 0, &var, &fetched); + ok(hr == S_OK, "got 0x%08x\n", hr); + ok(fetched == 0, "got %d\n", fetched); + + hr = IEnumVARIANT_Skip(enumvar, 0); + ok(hr == S_OK, "got 0x%08x\n", hr); + + hr = IEnumVARIANT_Skip(enumvar, count); + ok(hr == S_OK, "got 0x%08x\n", hr); + + hr = IEnumVARIANT_Skip(enumvar, 1); +todo_wine + ok(hr == S_FALSE, "got 0x%08x\n", hr); + + IEnumVARIANT_Release(enumvar); + IDriveCollection_Release(drives); +} + START_TEST(filesystem) { HRESULT hr; @@ -1169,6 +1210,7 @@ START_TEST(filesystem) test_GetFolder(); test_FolderCollection(); test_FileCollection(); + test_DriveCollection(); IFileSystem3_Release(fs3);
participants (1)
-
Alexandre Julliard