[PATCH v5 4/4] msftedit: Add tests for interfaces.
Huw Davies
huw at codeweavers.com
Thu Sep 27 04:57:15 CDT 2018
On Wed, Sep 26, 2018 at 06:50:56PM +0800, Jactry Zeng wrote:
> +static void test_Interfaces(void)
> +{
> + IRichEditOle *reole = NULL, *reole1 = NULL;
> + ITextDocument *txtdoc = NULL;
> + ITextDocument2Old *txtdoc2old = NULL;
> + ITextDocument2 *txtdoc2 = NULL;
> + ITextSelection *txtsel = NULL, *txtsel2;
> + IUnknown *punk;
> + HRESULT hres;
> + LRESULT res;
> + HWND hwnd;
> + ULONG refcount;
> +
> + hwnd = new_window(MSFTEDIT_CLASS, ES_MULTILINE, NULL);
> + if (!hwnd)
> + {
> + skip("Couldn't create window.\n");
> + return;
> + }
> +
> + res = SendMessageA(hwnd, EM_GETOLEINTERFACE, 0, (LPARAM)&reole);
> + ok(res, "SendMessage\n");
> + ok(reole != NULL, "EM_GETOLEINTERFACE\n");
> + EXPECT_REF(reole, 2);
> +
> + res = SendMessageA(hwnd, EM_GETOLEINTERFACE, 0, (LPARAM)&reole1);
> + ok(res == 1, "SendMessage\n");
> + ok(reole1 == reole, "Should not return a new IRichEditOle interface.\n");
> + EXPECT_REF(reole, 3);
> +
> + hres = IRichEditOle_QueryInterface(reole, &IID_ITextDocument, (void **)&txtdoc);
> + ok(hres == S_OK, "IRichEditOle_QueryInterface failed: 0x%08x.\n", hres);
> + ok(txtdoc != NULL, "IRichEditOle_QueryInterface\n");
> +
> + hres = ITextDocument_GetSelection(txtdoc, NULL);
> + ok(hres == E_INVALIDARG, "ITextDocument_GetSelection: 0x%08x.\n", hres);
> +
> + EXPECT_REF(txtdoc, 4);
> +
> + hres = ITextDocument_GetSelection(txtdoc, &txtsel);
> + ok(hres == S_OK, "ITextDocument_GetSelection failed 0x%08x.\n", hres);
> +
> + EXPECT_REF(txtdoc, 4);
> + EXPECT_REF(txtsel, 2);
> +
> + hres = ITextDocument_GetSelection(txtdoc, &txtsel2);
> + ok(hres == S_OK, "ITextDocument_GetSelection failed: 0x%08x.\n", hres);
> + ok(txtsel2 == txtsel, "got %p, %p\n", txtsel, txtsel2);
> +
> + EXPECT_REF(txtdoc, 4);
> + EXPECT_REF(txtsel, 3);
> +
> + ITextSelection_Release(txtsel2);
> +
> + punk = NULL;
> + hres = ITextSelection_QueryInterface(txtsel, &IID_ITextSelection, (void **)&punk);
> + ok(hres == S_OK, "ITextSelection_QueryInterface failed: 0x%08x.\n", hres);
> + ok(punk != NULL, "ITextSelection_QueryInterface\n");
> + IUnknown_Release(punk);
> +
> + punk = NULL;
> + hres = ITextSelection_QueryInterface(txtsel, &IID_ITextRange, (void **)&punk);
> + ok(hres == S_OK, "ITextSelection_QueryInterface failed: 0x%08x.\n", hres);
> + ok(punk != NULL, "ITextSelection_QueryInterface\n");
> + IUnknown_Release(punk);
> +
> + punk = NULL;
> + hres = ITextSelection_QueryInterface(txtsel, &IID_IDispatch, (void **)&punk);
> + ok(hres == S_OK, "ITextSelection_QueryInterface failed: 0x%08x.\n", hres);
> + ok(punk != NULL, "ITextSelection_QueryInterface\n");
> + IUnknown_Release(punk);
> +
> + punk = NULL;
> + hres = IRichEditOle_QueryInterface(reole, &IID_IOleClientSite, (void **)&punk);
> + ok(hres == E_NOINTERFACE, "IRichEditOle_QueryInterface: 0x%08x.\n", hres);
> +
> + punk = NULL;
> + hres = IRichEditOle_QueryInterface(reole, &IID_IOleWindow, (void **)&punk);
> + ok(hres == E_NOINTERFACE, "IRichEditOle_QueryInterface: 0x%08x.\n", hres);
> +
> + punk = NULL;
> + hres = IRichEditOle_QueryInterface(reole, &IID_IOleInPlaceSite, (void **)&punk);
> + ok(hres == E_NOINTERFACE, "IRichEditOle_QueryInterface: 0x%08x.\n", hres);
> +
> + /* ITextDocument2 is implemented on msftedit after win8 for superseding ITextDocument2Old */
> + hres = IRichEditOle_QueryInterface(reole, &IID_ITextDocument2, (void **)&txtdoc2);
> + ok(hres == S_OK ||
> + hres == E_NOINTERFACE /* before win8 */, "IRichEditOle_QueryInterface: 0x%08x.\n", hres);
> + if (hres != E_NOINTERFACE)
> + {
> + ok(txtdoc2 != NULL, "IRichEditOle_QueryInterface\n");
> + ok((ITextDocument *)txtdoc2 == txtdoc, "Interface pointer isn't equal.\n");
> + EXPECT_REF(txtdoc2, 5);
> + EXPECT_REF(reole, 5);
> +
> + hres = ITextDocument2_QueryInterface(txtdoc2, &IID_ITextDocument2Old, (void **)&txtdoc2old);
> + ok(hres == S_OK, "ITextDocument2_QueryInterface failed: 0x%08x.\n", hres);
> + EXPECT_REF(txtdoc2, 5);
> + EXPECT_REF(reole, 5);
> + EXPECT_REF(txtdoc2old, 1);
> + ITextDocument2Old_Release(txtdoc2old);
> + ITextDocument2_Release(txtdoc2);
> +
> + hres = IRichEditOle_QueryInterface(reole, &IID_ITextDocument2Old, (void **)&txtdoc2old);
> + ok(hres == S_OK, "IRichEditOle_QueryInterface failed: 0x%08x.\n", hres);
> + ok(txtdoc2old != NULL, "IRichEditOle_QueryInterface\n");
> + ok((ITextDocument *)txtdoc2old != txtdoc, "Interface pointer is equal.\n");
> + EXPECT_REF(txtdoc2old, 1);
> + EXPECT_REF(reole, 4);
> + ITextDocument2Old_Release(txtdoc2old);
Not sure what you're trying to show in this block of 7 lines. Move the
txtdoc2old != txtdoc test to the previous block of 7 lines and get rid
of this block.
Huw.
More information about the wine-devel
mailing list