From 7fae4e4b27d9a6d1ff45a8bd57713edcfd863335 Mon Sep 17 00:00:00 2001 From: Reece Dunn Date: Sun, 7 Sep 2008 10:53:46 +0100 Subject: [PATCH] hlink: fix the tests for IE7. --- dlls/hlink/tests/hlink.c | 137 ++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 127 insertions(+), 10 deletions(-) diff --git a/dlls/hlink/tests/hlink.c b/dlls/hlink/tests/hlink.c index b0c7f30..8a8a0cd 100644 --- a/dlls/hlink/tests/hlink.c +++ b/dlls/hlink/tests/hlink.c @@ -175,6 +175,23 @@ static const unsigned char expected_hlink_data[] = 0x00,0x00, }; +/* url only (IE7) */ +static const unsigned char expected_hlink_data_ie7[] = +{ + 0x02,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0xe0,0xc9,0xea,0x79,0xf9,0xba,0xce,0x11, + 0x8c,0x82,0x00,0xaa,0x00,0x4b,0xa9,0x0b, + 0x3e,0x00,0x00,0x00,0x68,0x00,0x74,0x00, + 0x74,0x00,0x70,0x00,0x3a,0x00,0x2f,0x00, + 0x2f,0x00,0x77,0x00,0x69,0x00,0x6e,0x00, + 0x65,0x00,0x68,0x00,0x71,0x00,0x2e,0x00, + 0x6f,0x00,0x72,0x00,0x67,0x00,0x2f,0x00, + 0x00,0x00,0x79,0x58,0x81,0xf4,0x3b,0x1d, + 0x7f,0x48,0xaf,0x2c,0x82,0x5d,0xc4,0x85, + 0x27,0x63,0x00,0x00,0x00,0x00,0xa5,0xab, + 0x00,0x00, +}; + /* url + friendly name */ static const unsigned char expected_hlink_data2[] = { @@ -191,6 +208,25 @@ static const unsigned char expected_hlink_data2[] = 0x67,0x00,0x2f,0x00,0x00,0x00, }; +/* url + friendly name (IE7) */ +static const unsigned char expected_hlink_data2_ie7[] = +{ + 0x02,0x00,0x00,0x00,0x17,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x57,0x00,0x69,0x00, + 0x6e,0x00,0x65,0x00,0x20,0x00,0x48,0x00, + 0x51,0x00,0x00,0x00,0xe0,0xc9,0xea,0x79, + 0xf9,0xba,0xce,0x11,0x8c,0x82,0x00,0xaa, + 0x00,0x4b,0xa9,0x0b,0x3e,0x00,0x00,0x00, + 0x68,0x00,0x74,0x00,0x74,0x00,0x70,0x00, + 0x3a,0x00,0x2f,0x00,0x2f,0x00,0x77,0x00, + 0x69,0x00,0x6e,0x00,0x65,0x00,0x68,0x00, + 0x71,0x00,0x2e,0x00,0x6f,0x00,0x72,0x00, + 0x67,0x00,0x2f,0x00,0x00,0x00,0x79,0x58, + 0x81,0xf4,0x3b,0x1d,0x7f,0x48,0xaf,0x2c, + 0x82,0x5d,0xc4,0x85,0x27,0x63,0x00,0x00, + 0x00,0x00,0xa5,0xab,0x00,0x00, +}; + /* url + friendly name + location */ static const unsigned char expected_hlink_data3[] = { @@ -209,6 +245,27 @@ static const unsigned char expected_hlink_data3[] = 0x61,0x00,0x6e,0x00,0x6b,0x00,0x00,0x00, }; +/* url + friendly name + location (IE7) */ +static const unsigned char expected_hlink_data3_ie7[] = +{ + 0x02,0x00,0x00,0x00,0x1f,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x57,0x00,0x69,0x00, + 0x6e,0x00,0x65,0x00,0x20,0x00,0x48,0x00, + 0x51,0x00,0x00,0x00,0xe0,0xc9,0xea,0x79, + 0xf9,0xba,0xce,0x11,0x8c,0x82,0x00,0xaa, + 0x00,0x4b,0xa9,0x0b,0x3e,0x00,0x00,0x00, + 0x68,0x00,0x74,0x00,0x74,0x00,0x70,0x00, + 0x3a,0x00,0x2f,0x00,0x2f,0x00,0x77,0x00, + 0x69,0x00,0x6e,0x00,0x65,0x00,0x68,0x00, + 0x71,0x00,0x2e,0x00,0x6f,0x00,0x72,0x00, + 0x67,0x00,0x2f,0x00,0x00,0x00,0x79,0x58, + 0x81,0xf4,0x3b,0x1d,0x7f,0x48,0xaf,0x2c, + 0x82,0x5d,0xc4,0x85,0x27,0x63,0x00,0x00, + 0x00,0x00,0xa5,0xab,0x00,0x00,0x07,0x00, + 0x00,0x00,0x5f,0x00,0x62,0x00,0x6c,0x00, + 0x61,0x00,0x6e,0x00,0x6b,0x00,0x00,0x00, +}; + /* relative url */ static const unsigned char expected_hlink_data4[] = { @@ -239,6 +296,25 @@ static const unsigned char expected_hlink_data5[] = 0x2f,0x00,0x00,0x00, }; +/* url + target frame name (IE7) */ +static const unsigned char expected_hlink_data5_ie7[] = +{ + 0x02,0x00,0x00,0x00,0x83,0x00,0x00,0x00, + 0x07,0x00,0x00,0x00,0x74,0x00,0x67,0x00, + 0x74,0x00,0x66,0x00,0x72,0x00,0x6d,0x00, + 0x00,0x00,0xe0,0xc9,0xea,0x79,0xf9,0xba, + 0xce,0x11,0x8c,0x82,0x00,0xaa,0x00,0x4b, + 0xa9,0x0b,0x3e,0x00,0x00,0x00,0x68,0x00, + 0x74,0x00,0x74,0x00,0x70,0x00,0x3a,0x00, + 0x2f,0x00,0x2f,0x00,0x77,0x00,0x69,0x00, + 0x6e,0x00,0x65,0x00,0x68,0x00,0x71,0x00, + 0x2e,0x00,0x6f,0x00,0x72,0x00,0x67,0x00, + 0x2f,0x00,0x00,0x00,0x79,0x58,0x81,0xf4, + 0x3b,0x1d,0x7f,0x48,0xaf,0x2c,0x82,0x5d, + 0xc4,0x85,0x27,0x63,0x00,0x00,0x00,0x00, + 0xa5,0xab,0x00,0x00, +}; + /* filename */ static const unsigned char expected_hlink_data6[] = { @@ -256,7 +332,9 @@ static const unsigned char expected_hlink_data6[] = static void test_persist_save_data(const char *testname, IHlink *lnk, const unsigned char *expected_data, - unsigned int expected_data_size) + unsigned int expected_data_size, + const unsigned char *expected_data_alt, + unsigned int expected_data_alt_size) { HRESULT hr; IStream *stream; @@ -284,9 +362,9 @@ static void test_persist_save_data(const char *testname, IHlink *lnk, data = GlobalLock(hglobal); /* first check we have the right amount of data */ - ok(data_size == expected_data_size, - "%s: Size of saved data differs (expected %d, actual %d)\n", - testname, expected_data_size, data_size); + ok((data_size == expected_data_size) || (data_size == expected_data_alt_size), + "%s: Size of saved data differs (expected %d or %d, actual %d)\n", + testname, expected_data_size, expected_data_alt_size, data_size); same = TRUE; /* then do a byte-by-byte comparison */ @@ -302,6 +380,23 @@ static void test_persist_save_data(const char *testname, IHlink *lnk, } } + if (!same && (expected_data_alt != expected_data)) + { + /* then try the alternate data */ + same = TRUE; + for (i = 0; i < min(data_size, expected_data_alt_size); i++) + { + if ((expected_data_alt[i] != data[i]) && + (((expected_data_alt != expected_hlink_data2) && + (expected_data_alt != expected_hlink_data3)) || + ((i < 52 || i >= 56) && (i < 80 || i >= 84)))) + { + same = FALSE; + break; + } + } + } + ok(same, "%s: Saved data differs\n", testname); if (!same) { @@ -312,6 +407,16 @@ static void test_persist_save_data(const char *testname, IHlink *lnk, printf("0x%02x,", expected_data[i]); if (i % 8 == 7) printf("\n"); } + if (expected_data_alt != expected_data) + { + printf("\n or:\n"); + for (i = 0; i < expected_data_alt_size; i++) + { + if (i % 8 == 0) printf(" "); + printf("0x%02x,", expected_data_alt[i]); + if (i % 8 == 7) printf("\n"); + } + } printf("\n actual:\n"); for (i = 0; i < data_size; i++) { @@ -346,25 +451,33 @@ static void test_persist(void) skip("Can't create lnk, skipping test_persist. Was wineprefixcreate run properly?\n"); return; } - test_persist_save_data("url only", lnk, expected_hlink_data, sizeof(expected_hlink_data)); + test_persist_save_data("url only", lnk, + expected_hlink_data, sizeof(expected_hlink_data), + expected_hlink_data_ie7, sizeof(expected_hlink_data_ie7)); 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)); + test_persist_save_data("url + friendly name", lnk, + expected_hlink_data2, sizeof(expected_hlink_data2), + expected_hlink_data2_ie7, sizeof(expected_hlink_data2_ie7)); 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)); + test_persist_save_data("url + friendly_name + location", lnk, + expected_hlink_data3, sizeof(expected_hlink_data3), + expected_hlink_data3_ie7, sizeof(expected_hlink_data3_ie7)); 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)); + test_persist_save_data("relative url", lnk, + expected_hlink_data4, sizeof(expected_hlink_data4), + expected_hlink_data4, sizeof(expected_hlink_data4)); IHlink_Release(lnk); hr = HlinkCreateFromString(url, NULL, NULL, NULL, @@ -372,13 +485,17 @@ static void test_persist(void) 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)); + test_persist_save_data("url + target frame name", lnk, + expected_hlink_data5, sizeof(expected_hlink_data5), + expected_hlink_data5_ie7, sizeof(expected_hlink_data5_ie7)); 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)); + test_persist_save_data("filename", lnk, + expected_hlink_data6, sizeof(expected_hlink_data6), + expected_hlink_data6, sizeof(expected_hlink_data6)); IHlink_Release(lnk); } -- 1.5.6.1.1071.g76fb