1 /* 2 * Copyright 2006 Jacek Caban for CodeWeavers 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Lesser General Public 6 * License as published by the Free Software Foundation; either 7 * version 2.1 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Lesser General Public License for more details. 13 * 14 * You should have received a copy of the GNU Lesser General Public 15 * License along with this library; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 17 */ 18 19 #include "precomp.h" 20 21 #include <optary.h> 22 23 static void test_HTMLLoadOptions(void) 24 { 25 IHtmlLoadOptions *loadopts; 26 BYTE buf[100]; 27 DWORD size, i, data = 0xdeadbeef; 28 HRESULT hres; 29 30 hres = CoCreateInstance(&CLSID_HTMLLoadOptions, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER, 31 &IID_IHtmlLoadOptions, (void**)&loadopts); 32 ok(hres == S_OK, "creating HTMLLoadOptions failed: %08x\n", hres); 33 if(FAILED(hres)) 34 return; 35 36 for(i=0; i <= HTMLLOADOPTION_FRAMELOAD+3; i++) { 37 size = 0xdeadbeef; 38 memset(buf, 0xdd, sizeof(buf)); 39 hres = IHtmlLoadOptions_QueryOption(loadopts, i, NULL, &size); 40 ok(hres == S_OK, "QueryOption failed: %08x\n", hres); 41 ok(size == 0, "size = %d\n", size); 42 ok(buf[0] == 0xdd, "buf changed\n"); 43 } 44 45 size = 0xdeadbeef; 46 hres = IHtmlLoadOptions_QueryOption(loadopts, HTMLLOADOPTION_CODEPAGE, NULL, &size); 47 ok(hres == S_OK, "QueryOption failed: %08x\n", hres); 48 ok(size == 0, "size = %d\n", size); 49 50 hres = IHtmlLoadOptions_SetOption(loadopts, HTMLLOADOPTION_CODEPAGE, &data, sizeof(data)); 51 ok(hres == S_OK, "SetOption failed: %08x\n", hres); 52 53 size = sizeof(data); 54 memset(buf, 0xdd, sizeof(buf)); 55 hres = IHtmlLoadOptions_QueryOption(loadopts, HTMLLOADOPTION_CODEPAGE, buf, &size); 56 ok(hres == S_OK, "QueryOption failed: %08x\n", hres); 57 ok(size == sizeof(data), "size = %d\n", size); 58 ok(*(DWORD*)buf == data, "unexpected buf\n"); 59 60 size = sizeof(data)-1; 61 memset(buf, 0xdd, sizeof(buf)); 62 hres = IHtmlLoadOptions_QueryOption(loadopts, HTMLLOADOPTION_CODEPAGE, buf, &size); 63 ok(hres == E_FAIL, "QueryOption failed: %08x\n", hres); 64 ok(size == sizeof(data) || !size, "size = %d\n", size); 65 ok(buf[0] == 0xdd, "buf changed\n"); 66 67 data = 100; 68 hres = IHtmlLoadOptions_SetOption(loadopts, HTMLLOADOPTION_CODEPAGE, &data, 0); 69 ok(hres == S_OK, "SetOption failed: %08x\n", hres); 70 71 size = 0xdeadbeef; 72 memset(buf, 0xdd, sizeof(buf)); 73 hres = IHtmlLoadOptions_QueryOption(loadopts, HTMLLOADOPTION_CODEPAGE, buf, &size); 74 ok(hres == S_OK, "QueryOption failed: %08x\n", hres); 75 ok(size == 0, "size = %d\n", size); 76 ok(buf[0] == 0xdd, "buf changed\n"); 77 78 hres = IHtmlLoadOptions_SetOption(loadopts, HTMLLOADOPTION_CODEPAGE, NULL, 0); 79 ok(hres == S_OK, "SetOption failed: %08x\n", hres); 80 81 hres = IHtmlLoadOptions_SetOption(loadopts, 1000, &data, sizeof(data)); 82 ok(hres == S_OK, "SetOption failed: %08x\n", hres); 83 84 size = sizeof(data); 85 memset(buf, 0xdd, sizeof(buf)); 86 hres = IHtmlLoadOptions_QueryOption(loadopts, 1000, buf, &size); 87 ok(hres == S_OK, "QueryOption failed: %08x\n", hres); 88 ok(size == sizeof(data), "size = %d\n", size); 89 ok(*(DWORD*)buf == data, "unexpected buf\n"); 90 91 hres = IHtmlLoadOptions_SetOption(loadopts, 1000, buf, sizeof(buf)); 92 ok(hres == S_OK, "SetOption failed: %08x\n", hres); 93 94 size = 0xdeadbeef; 95 hres = IHtmlLoadOptions_QueryOption(loadopts, 1000, buf, &size); 96 ok(hres == S_OK, "QueryOption failed: %08x\n", hres); 97 ok(size == sizeof(buf), "size = %d\n", size); 98 99 IHtmlLoadOptions_Release(loadopts); 100 } 101 102 START_TEST(misc) 103 { 104 CoInitialize(NULL); 105 106 test_HTMLLoadOptions(); 107 108 CoUninitialize(); 109 } 110