コード例 #1
0
ファイル: olefont.c プロジェクト: reactos/reactos
static void test_QueryInterface(void)
{
    LPVOID pvObj = NULL;
    HRESULT hr;
    IFont*  font = NULL;
    LONG ref;

    hr = pOleCreateFontIndirect(NULL, &IID_IFont, NULL);
    EXPECT_HR(hr, E_POINTER);

    hr = pOleCreateFontIndirect(NULL, &IID_IFont, &pvObj);
    font = pvObj;

    EXPECT_HR(hr, S_OK);
    ok(font != NULL,"OCFI (NULL,..) returns NULL, instead of !NULL\n");

    pvObj = NULL;
    hr = IFont_QueryInterface( font, &IID_IFont, &pvObj);
    EXPECT_HR(hr, S_OK);

    /* Test if QueryInterface increments ref counter for IFONTs */
    ref = IFont_AddRef(font);
    ok(ref == 3 ||
       broken(ref == 1), /* win95 */
           "IFont_QI expected ref value 3 but instead got %d\n", ref);
    IFont_Release(font);

    ok(pvObj != NULL,"IFont_QI does return NULL, instead of a ptr\n");

    IFont_Release(font);
    IFont_Release(font);
}
コード例 #2
0
ファイル: olefont.c プロジェクト: r6144/wine
static void test_QueryInterface(void)
{
    LPVOID pvObj = NULL;
    HRESULT hres;
    IFont*  font = NULL;
    LONG ret;

    hres = pOleCreateFontIndirect(NULL, &IID_IFont, NULL);
    ok(hres == E_POINTER, "got 0x%08x\n", hres);

    hres = pOleCreateFontIndirect(NULL, &IID_IFont, &pvObj);
    font = pvObj;

    ok(hres == S_OK,"OCFI (NULL,..) does not return 0, but 0x%08x\n",hres);
    ok(font != NULL,"OCFI (NULL,..) returns NULL, instead of !NULL\n");

    pvObj = NULL;
    hres = IFont_QueryInterface( font, &IID_IFont, &pvObj);

    /* Test if QueryInterface increments ref counter for IFONTs */
    ret = IFont_AddRef(font);
    ok(ret == 3 ||
       broken(ret == 1), /* win95 */
       "IFont_QI expected ref value 3 but instead got %d\n",ret);
    IFont_Release(font);

    ok(hres == S_OK,"IFont_QI does not return S_OK, but 0x%08x\n", hres);
    ok(pvObj != NULL,"IFont_QI does return NULL, instead of a ptr\n");

    /* Original ref and QueryInterface ref both have to be released */
    IFont_Release(font);
    IFont_Release(font);
}