/* * Implementation of hyperlinking (hlink.dll) * * Copyright 2006 Mike McCormack * * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #define COBJMACROS #include #include #include #include "wine/test.h" static void test_HlinkIsShortcut(void) { int i; HRESULT hres; static const WCHAR file0[] = {'f','i','l','e',0}; static const WCHAR file1[] = {'f','i','l','e','.','u','r','l',0}; static const WCHAR file2[] = {'f','i','l','e','.','l','n','k',0}; static const WCHAR file3[] = {'f','i','l','e','.','u','R','l',0}; static const WCHAR file4[] = {'f','i','l','e','u','r','l',0}; static const WCHAR file5[] = {'c',':','\\','f','i','l','e','.','u','r','l',0}; static const WCHAR file6[] = {'c',':','\\','f','i','l','e','.','l','n','k',0}; static const WCHAR file7[] = {'.','u','r','l',0}; static struct { LPCWSTR file; HRESULT hres; } shortcut_test[] = { {file0, S_FALSE}, {file1, S_OK}, {file2, S_FALSE}, {file3, S_OK}, {file4, S_FALSE}, {file5, S_OK}, {file6, S_FALSE}, {file7, S_OK}, {NULL, E_INVALIDARG} }; for(i=0; i= 56) && (i < 80 || i >= 84)))) { same = FALSE; break; } } ok(same, "%s: Saved data differs\n", testname); if (!same) { for (i = 0; i < data_size; i++) { if (i % 8 == 0) printf(" "); printf("0x%02x,", data[i]); if (i % 8 == 7) printf("\n"); } printf("\n"); } GlobalUnlock(hglobal); IStream_Release(stream); IPersistStream_Release(ps); } static void test_persist(void) { static const WCHAR url[] = { 'h','t','t','p',':','/','/','w','i','n','e','h','q','.','o','r','g',0 }; static const WCHAR rel_url[] = { 'i','n','d','e','x','.','h','t','m','l',0 }; static const WCHAR filename[] = { 'c',':','\\',0 }; static const WCHAR friendly_name[] = { 'W','i','n','e',' ','H','Q',0 }; static const WCHAR location[] = { '_','b','l','a','n','k',0 }; static const WCHAR target_frame_name[] = { 't','g','t','f','r','m',0 }; HRESULT hr; IHlink *lnk; hr = HlinkCreateFromString(url, NULL, NULL, NULL, 0, NULL, &IID_IHlink, (LPVOID*) &lnk); ok(hr == S_OK, "IHlinCreateFromString failed with error 0x%08x\n", hr); test_persist_save_data("url only", lnk, expected_hlink_data, sizeof(expected_hlink_data)); IHlink_Release(lnk); hr = HlinkCreateFromString(url, NULL, friendly_name, NULL, 0, NULL, &IID_IHlink, (LPVOID*) &lnk); ok(hr == S_OK, "IHlinCreateFromString failed with error 0x%08x\n", hr); test_persist_save_data("url + friendly name", lnk, expected_hlink_data2, sizeof(expected_hlink_data2)); IHlink_Release(lnk); hr = HlinkCreateFromString(url, location, friendly_name, NULL, 0, NULL, &IID_IHlink, (LPVOID*) &lnk); ok(hr == S_OK, "IHlinCreateFromString failed with error 0x%08x\n", hr); test_persist_save_data("url + friendly_name + location", lnk, expected_hlink_data3, sizeof(expected_hlink_data3)); IHlink_Release(lnk); hr = HlinkCreateFromString(rel_url, NULL, NULL, NULL, 0, NULL, &IID_IHlink, (LPVOID*) &lnk); ok(hr == S_OK, "IHlinCreateFromString failed with error 0x%08x\n", hr); test_persist_save_data("relative url", lnk, expected_hlink_data4, sizeof(expected_hlink_data4)); IHlink_Release(lnk); hr = HlinkCreateFromString(url, NULL, NULL, NULL, 0, NULL, &IID_IHlink, (LPVOID*) &lnk); ok(hr == S_OK, "IHlinCreateFromString failed with error 0x%08x\n", hr); hr = IHlink_SetTargetFrameName(lnk, target_frame_name); ok(hr == S_OK, "IHlink_SetTargetFrameName failed with error 0x%08x\n", hr); test_persist_save_data("url + target frame name", lnk, expected_hlink_data5, sizeof(expected_hlink_data5)); IHlink_Release(lnk); hr = HlinkCreateFromString(filename, NULL, NULL, NULL, 0, NULL, &IID_IHlink, (LPVOID*) &lnk); ok(hr == S_OK, "IHlinCreateFromString failed with error 0x%08x\n", hr); test_persist_save_data("filename", lnk, expected_hlink_data6, sizeof(expected_hlink_data6)); IHlink_Release(lnk); } START_TEST(hlink) { CoInitialize(NULL); test_HlinkIsShortcut(); test_reference(); test_persist(); CoUninitialize(); }