/* * Copyright 2005 Jacek Caban * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #define COBJMACROS #include #include #include "windef.h" #include "winbase.h" #include "ole2.h" #include "urlmon.h" static void test_CreateFormatEnum(void) { IEnumFORMATETC *fenum = NULL, *fenum2 = NULL; FORMATETC fetc[5]; ULONG ul; HRESULT hres; static DVTARGETDEVICE dev = {sizeof(dev),0,0,0,0,{0}}; static FORMATETC formatetc[] = { {0,&dev,0,0,0}, {0,&dev,0,1,0}, {0,NULL,0,2,0}, {0,NULL,0,3,0}, {0,NULL,0,4,0} }; hres = CreateFormatEnumerator(0, formatetc, &fenum); ok(hres == E_FAIL, "CreateFormatEnumerator failed: %08lx, expected E_FAIL\n", hres); hres = CreateFormatEnumerator(0, formatetc, NULL); ok(hres == E_INVALIDARG, "CreateFormatEnumerator failed: %08lx, expected E_INVALIDARG\n", hres); hres = CreateFormatEnumerator(5, formatetc, NULL); ok(hres == E_INVALIDARG, "CreateFormatEnumerator failed: %08lx, expected E_INVALIDARG\n", hres); hres = CreateFormatEnumerator(5, formatetc, &fenum); ok(hres == S_OK, "CreateFormatEnumerator failed: %08lx\n", hres); if(FAILED(hres)) return; hres = IEnumFORMATETC_Next(fenum, 2, NULL, &ul); ok(hres == E_INVALIDARG, "Next failed: %08lx, expected E_INVALIDARG\n", hres); ul = 100; hres = IEnumFORMATETC_Next(fenum, 0, fetc, &ul); ok(hres == S_OK, "Next failed: %08lx\n", hres); ok(ul == 0, "ul=%ld, expected 0\n", ul); hres = IEnumFORMATETC_Next(fenum, 2, fetc, &ul); ok(hres == S_OK, "Next failed: %08lx\n", hres); ok(fetc[0].lindex == 0, "fetc[0].lindex=%ld, expected 0\n", fetc[0].lindex); ok(fetc[1].lindex == 1, "fetc[1].lindex=%ld, expected 1\n", fetc[1].lindex); ok(fetc[0].ptd == &dev, "fetc[0].ptd=%p, expected %p\n", fetc[0].ptd, &dev); ok(ul == 2, "ul=%ld, expected 2\n", ul); hres = IEnumFORMATETC_Skip(fenum, 1); ok(hres == S_OK, "Skip failed: %08lx\n", hres); hres = IEnumFORMATETC_Next(fenum, 4, fetc, &ul); ok(hres == S_FALSE, "Next failed: %08lx, expected S_FALSE\n", hres); ok(fetc[0].lindex == 3, "fetc[0].lindex=%ld, expected 3\n", fetc[0].lindex); ok(fetc[1].lindex == 4, "fetc[1].lindex=%ld, expected 4\n", fetc[1].lindex); ok(fetc[0].ptd == NULL, "fetc[0].ptd=%p, expected NULL\n", fetc[0].ptd); ok(ul == 2, "ul=%ld, expected 2\n", ul); hres = IEnumFORMATETC_Next(fenum, 4, fetc, &ul); ok(hres == S_FALSE, "Next failed: %08lx, expected S_FALSE\n", hres); ok(ul == 0, "ul=%ld, expected 0\n", ul); ul = 100; hres = IEnumFORMATETC_Next(fenum, 0, fetc, &ul); ok(hres == S_OK, "Next failed: %08lx\n", hres); ok(ul == 0, "ul=%ld, expected 0\n", ul); hres = IEnumFORMATETC_Skip(fenum, 3); ok(hres == S_FALSE, "Skip failed: %08lx, expected S_FALSE\n", hres); hres = IEnumFORMATETC_Reset(fenum); ok(hres == S_OK, "Reset failed: %08lx\n", hres); hres = IEnumFORMATETC_Next(fenum, 5, fetc, NULL); ok(hres == S_OK, "Next failed: %08lx\n", hres); ok(fetc[0].lindex == 0, "fetc[0].lindex=%ld, expected 0\n", fetc[0].lindex); hres = IEnumFORMATETC_Reset(fenum); ok(hres == S_OK, "Reset failed: %08lx\n", hres); hres = IEnumFORMATETC_Skip(fenum, 2); ok(hres == S_OK, "Skip failed: %08lx\n", hres); hres = IEnumFORMATETC_Clone(fenum, NULL); ok(hres == E_INVALIDARG, "Clone failed: %08lx, expected E_INVALIDARG\n", hres); hres = IEnumFORMATETC_Clone(fenum, &fenum2); ok(hres == S_OK, "Clone failed: %08lx\n", hres); if(SUCCEEDED(hres)) { ok(fenum != fenum2, "fenum == fenum2\n"); hres = IEnumFORMATETC_Next(fenum2, 2, fetc, &ul); ok(hres == S_OK, "Next failed: %08lx\n", hres); ok(fetc[0].lindex == 2, "fetc[0].lindex=%ld, expected 2\n", fetc[0].lindex); IEnumFORMATETC_Release(fenum2); } hres = IEnumFORMATETC_Next(fenum, 2, fetc, &ul); ok(hres == S_OK, "Next failed: %08lx\n", hres); ok(fetc[0].lindex == 2, "fetc[0].lindex=%ld, expected 2\n", fetc[0].lindex); hres = IEnumFORMATETC_Skip(fenum, 1); ok(hres == S_OK, "Skip failed: %08lx\n", hres); IEnumFORMATETC_Release(fenum); } START_TEST(misc) { test_CreateFormatEnum(); }