Example #1
0
static void test_unicodeformat(void)
{
    const INT nTabs = 5;
    INT unicodeFormat;
    HWND hTab;

    hTab = createFilledTabControl(parent_wnd, TCS_FIXEDWIDTH, TCIF_TEXT|TCIF_IMAGE, nTabs);
    ok(hTab != NULL, "Failed to create tab control\n");

    flush_sequences(sequences, NUM_MSG_SEQUENCES);

    unicodeFormat = SendMessage(hTab, TCM_SETUNICODEFORMAT, TRUE, 0);
    todo_wine{
        expect(0, unicodeFormat);
    }
    unicodeFormat = SendMessage(hTab, TCM_GETUNICODEFORMAT, 0, 0);
    expect(1, unicodeFormat);

    unicodeFormat = SendMessage(hTab, TCM_SETUNICODEFORMAT, FALSE, 0);
    expect(1, unicodeFormat);
    unicodeFormat = SendMessage(hTab, TCM_GETUNICODEFORMAT, 0, 0);
    expect(0, unicodeFormat);

    unicodeFormat = SendMessage(hTab, TCM_SETUNICODEFORMAT, TRUE, 0);
    expect(0, unicodeFormat);

    ok_sequence(sequences, TAB_SEQ_INDEX, getset_unicode_format_seq, "Getset unicodeFormat test sequence", FALSE);
    ok_sequence(sequences, PARENT_SEQ_INDEX, empty_sequence, "Getset unicodeFormat test parent sequence", FALSE);

    DestroyWindow(hTab);
}
Example #2
0
File: tab.c Project: wesgarner/wine
static void test_misc(HWND parent_wnd, INT nTabs)
{
    HWND hTab;
    RECT rTab;
    INT nTabsRetrieved;
    INT rowCount;
    INT dpi;
    HDC hdc;

    ok(parent_wnd != NULL, "no parent window!\n");
    flush_sequences(sequences, NUM_MSG_SEQUENCES);

    hTab = createFilledTabControl(parent_wnd, TCS_FIXEDWIDTH, TCIF_TEXT|TCIF_IMAGE, nTabs);
    ok(hTab != NULL, "Failed to create tab control\n");

    if(!winetest_interactive)
        ok_sequence(sequences, TAB_SEQ_INDEX, add_tab_to_parent,
                    "Tab sequence, after adding tab control to parent", TRUE);
    else
        ok_sequence(sequences, TAB_SEQ_INDEX, add_tab_to_parent_interactive,
                    "Tab sequence, after adding tab control to parent", TRUE);

    if(!winetest_interactive)
        ok_sequence(sequences, PARENT_SEQ_INDEX, add_tab_control_parent_seq,
                    "Parent after sequence, adding tab control to parent", TRUE);
    else
        ok_sequence(sequences, PARENT_SEQ_INDEX, add_tab_control_parent_seq_interactive,
                    "Parent after sequence, adding tab control to parent", TRUE);

    flush_sequences(sequences, NUM_MSG_SEQUENCES);
    ok(SendMessage(hTab, TCM_SETMINTABWIDTH, 0, -1) > 0,"TCM_SETMINTABWIDTH returned < 0\n");
    ok_sequence(sequences, PARENT_SEQ_INDEX, empty_sequence, "Set minTabWidth test parent sequence", FALSE);

    /* Testing GetItemCount */
    flush_sequences(sequences, NUM_MSG_SEQUENCES);
    nTabsRetrieved = SendMessage(hTab, TCM_GETITEMCOUNT, 0, 0);
    expect(nTabs, nTabsRetrieved);
    ok_sequence(sequences, TAB_SEQ_INDEX, get_item_count_seq, "Get itemCount test sequence", FALSE);
    ok_sequence(sequences, PARENT_SEQ_INDEX, empty_sequence, "Getset itemCount test parent sequence", FALSE);

    /* Testing GetRowCount */
    flush_sequences(sequences, NUM_MSG_SEQUENCES);
    rowCount = SendMessage(hTab, TCM_GETROWCOUNT, 0, 0);
    expect(1, rowCount);
    ok_sequence(sequences, TAB_SEQ_INDEX, get_row_count_seq, "Get rowCount test sequence", FALSE);
    ok_sequence(sequences, PARENT_SEQ_INDEX, empty_sequence, "Get rowCount test parent sequence", FALSE);

    /* Testing GetItemRect */
    flush_sequences(sequences, NUM_MSG_SEQUENCES);
    ok(SendMessage(hTab, TCM_GETITEMRECT, 0, (LPARAM) &rTab), "GetItemRect failed.\n");

    hdc = GetDC(hTab);
    dpi = GetDeviceCaps(hdc, LOGPIXELSX);
    ReleaseDC(hTab, hdc);
    CheckSize(hTab, dpi, -1 , "Default Width");
    ok_sequence(sequences, TAB_SEQ_INDEX, get_item_rect_seq, "Get itemRect test sequence", FALSE);
    ok_sequence(sequences, PARENT_SEQ_INDEX, empty_sequence, "Get itemRect test parent sequence", FALSE);

    DestroyWindow(hTab);
}
Example #3
0
static void test_extendedstyle(void)
{
    const INT nTabs = 5;
    DWORD prevExtendedStyle;
    DWORD extendedStyle;
    HWND hTab;

    hTab = createFilledTabControl(parent_wnd, TCS_FIXEDWIDTH, TCIF_TEXT|TCIF_IMAGE, nTabs);
    ok(hTab != NULL, "Failed to create tab control\n");

    flush_sequences(sequences, NUM_MSG_SEQUENCES);

    /* Testing Flat Separators */
    extendedStyle = SendMessage(hTab, TCM_GETEXTENDEDSTYLE, 0, 0);
    prevExtendedStyle = SendMessage(hTab, TCM_SETEXTENDEDSTYLE, 0, TCS_EX_FLATSEPARATORS);
    expect(extendedStyle, prevExtendedStyle);

    extendedStyle = SendMessage(hTab, TCM_GETEXTENDEDSTYLE, 0, 0);
    expect(TCS_EX_FLATSEPARATORS, extendedStyle);

    /* Testing Register Drop */
    prevExtendedStyle = SendMessage(hTab, TCM_SETEXTENDEDSTYLE, 0, TCS_EX_REGISTERDROP);
    expect(extendedStyle, prevExtendedStyle);

    extendedStyle = SendMessage(hTab, TCM_GETEXTENDEDSTYLE, 0, 0);
    todo_wine{
        expect(TCS_EX_REGISTERDROP, extendedStyle);
    }

    ok_sequence(sequences, TAB_SEQ_INDEX, getset_extended_style_seq, "Getset extendedStyle test sequence", FALSE);
    ok_sequence(sequences, PARENT_SEQ_INDEX, empty_sequence, "Getset extendedStyle test parent sequence", FALSE);

    DestroyWindow(hTab);
}
Example #4
0
static void test_curfocus(void)
{
    const INT nTabs = 5;
    INT focusIndex;
    HWND hTab;

    hTab = createFilledTabControl(parent_wnd, TCS_FIXEDWIDTH, TCIF_TEXT|TCIF_IMAGE, nTabs);
    ok(hTab != NULL, "Failed to create tab control\n");

    flush_sequences(sequences, NUM_MSG_SEQUENCES);

    /* Testing CurFocus with largest appropriate value */
    SendMessage(hTab, TCM_SETCURFOCUS, nTabs-1, 0);
    focusIndex = SendMessage(hTab, TCM_GETCURFOCUS, 0, 0);
    expect(nTabs-1, focusIndex);

    /* Testing CurFocus with negative value */
    SendMessage(hTab, TCM_SETCURFOCUS, -10, 0);
    focusIndex = SendMessage(hTab, TCM_GETCURFOCUS, 0, 0);
    expect(-1, focusIndex);

    /* Testing CurFocus with value larger than number of tabs */
    focusIndex = SendMessage(hTab, TCM_SETCURSEL, 1, 0);
    expect(-1, focusIndex);

    SendMessage(hTab, TCM_SETCURFOCUS, nTabs+1, 0);
    focusIndex = SendMessage(hTab, TCM_GETCURFOCUS, 0, 0);
    expect(1, focusIndex);

    ok_sequence(sequences, TAB_SEQ_INDEX, getset_cur_focus_seq, "Getset curFoc test sequence", FALSE);

    DestroyWindow(hTab);
}
Example #5
0
static void test_cursel(void)
{
    const INT nTabs = 5;
    INT selectionIndex;
    INT focusIndex;
    TCITEM tcItem;
    HWND hTab;

    hTab = createFilledTabControl(parent_wnd, TCS_FIXEDWIDTH, TCIF_TEXT|TCIF_IMAGE, nTabs);
    ok(hTab != NULL, "Failed to create tab control\n");

    flush_sequences(sequences, NUM_MSG_SEQUENCES);

    /* Testing CurSel with largest appropriate value */
    selectionIndex = SendMessage(hTab, TCM_SETCURSEL, nTabs-1, 0);
    expect(0, selectionIndex);
    selectionIndex = SendMessage(hTab, TCM_GETCURSEL, 0, 0);
    expect(nTabs-1, selectionIndex);

    /* Focus should switch with selection */
    focusIndex = SendMessage(hTab, TCM_GETCURFOCUS, 0, 0);
    expect(nTabs-1, focusIndex);

    /* Testing CurSel with negative value */
    SendMessage(hTab, TCM_SETCURSEL, -10, 0);
    selectionIndex = SendMessage(hTab, TCM_GETCURSEL, 0, 0);
    expect(-1, selectionIndex);

    /* Testing CurSel with value larger than number of tabs */
    selectionIndex = SendMessage(hTab, TCM_SETCURSEL, 1, 0);
    expect(-1, selectionIndex);

    selectionIndex = SendMessage(hTab, TCM_SETCURSEL, nTabs+1, 0);
    expect(-1, selectionIndex);
    selectionIndex = SendMessage(hTab, TCM_GETCURFOCUS, 0, 0);
    expect(1, selectionIndex);

    ok_sequence(sequences, TAB_SEQ_INDEX, getset_cur_sel_seq, "Getset curSel test sequence", FALSE);
    ok_sequence(sequences, PARENT_SEQ_INDEX, empty_sequence, "Getset curSel test parent sequence", FALSE);

    /* selected item should have TCIS_BUTTONPRESSED state
       It doesn't depend on button state */
    memset(&tcItem, 0, sizeof(TCITEM));
    tcItem.mask = TCIF_STATE;
    tcItem.dwStateMask = TCIS_BUTTONPRESSED;
    selectionIndex = SendMessage(hTab, TCM_GETCURSEL, 0, 0);
    SendMessage(hTab, TCM_GETITEM, selectionIndex, (LPARAM) &tcItem);
    ok (tcItem.dwState & TCIS_BUTTONPRESSED || broken(tcItem.dwState == 0), /* older comctl32 */
        "Selected item should have TCIS_BUTTONPRESSED\n");

    DestroyWindow(hTab);
}
Example #6
0
File: tab.c Project: devyn/wine
static void test_delete_focus(HWND parent_wnd)
{
    HWND hTab;
    INT nTabsRetrieved;
    INT r;

    ok(parent_wnd != NULL, "no parent window!\n");

    hTab = createFilledTabControl(parent_wnd, TCS_FIXEDWIDTH, TCIF_TEXT|TCIF_IMAGE, 2);
    ok(hTab != NULL, "Failed to create tab control\n");

    flush_sequences(sequences, NUM_MSG_SEQUENCES);

    nTabsRetrieved = SendMessage(hTab, TCM_GETITEMCOUNT, 0, 0);
    expect(2, nTabsRetrieved);

    r = SendMessage(hTab, TCM_GETCURFOCUS, 0, 0);
    expect(0, r);

    r = SendMessage(hTab, TCM_DELETEITEM, 1, 0);
    expect(1, r);

    nTabsRetrieved = SendMessage(hTab, TCM_GETITEMCOUNT, 0, 0);
    expect(1, nTabsRetrieved);

    r = SendMessage(hTab, TCM_GETCURFOCUS, 0, 0);
    expect(0, r);

    r = SendMessage(hTab, TCM_SETCURFOCUS, -1, 0);
    expect(0, r);

    r = SendMessage(hTab, TCM_GETCURFOCUS, 0, 0);
    expect(-1, r);

    r = SendMessage(hTab, TCM_DELETEITEM, 0, 0);
    expect(1, r);

    nTabsRetrieved = SendMessage(hTab, TCM_GETITEMCOUNT, 0, 0);
    expect(0, nTabsRetrieved);

    r = SendMessage(hTab, TCM_GETCURFOCUS, 0, 0);
    expect(-1, r);

    ok_sequence(sequences, TAB_SEQ_INDEX, delete_focus_seq, "delete_focus test sequence", FALSE);
    ok_sequence(sequences, PARENT_SEQ_INDEX, empty_sequence, "delete_focus parent test sequence", FALSE);

    DestroyWindow(hTab);
}
Example #7
0
File: tab.c Project: devyn/wine
static void test_adjustrect(HWND parent_wnd)
{
    HWND hTab;
    INT r;

    ok(parent_wnd != NULL, "no parent window!\n");

    hTab = createFilledTabControl(parent_wnd, TCS_FIXEDWIDTH, 0, 0);
    ok(hTab != NULL, "Failed to create tab control\n");

    r = SendMessage(hTab, TCM_ADJUSTRECT, FALSE, 0);
    expect(-1, r);

    r = SendMessage(hTab, TCM_ADJUSTRECT, TRUE, 0);
    expect(-1, r);
}
Example #8
0
static void test_delete_selection(void)
{
    HWND hTab;
    INT ret;

    hTab = createFilledTabControl(parent_wnd, TCS_FIXEDWIDTH, TCIF_TEXT|TCIF_IMAGE, 4);
    ok(hTab != NULL, "Failed to create tab control\n");

    ret = SendMessage(hTab, TCM_SETCURSEL, 3, 0);
    expect(0, ret);
    ret = SendMessage(hTab, TCM_GETCURSEL, 0, 0);
    expect(3, ret);
    /* delete selected item - selection goes to -1 */
    ret = SendMessage(hTab, TCM_DELETEITEM, 3, 0);
    expect(TRUE, ret);

    ret = SendMessage(hTab, TCM_GETCURSEL, 0, 0);
    expect(-1, ret);

    DestroyWindow(hTab);
}
Example #9
0
File: tab.c Project: wesgarner/wine
static void test_getset_tooltips(HWND parent_wnd, INT nTabs)
{
    HWND hTab, toolTip;
    char toolTipText[32] = "ToolTip Text Test";

    hTab = createFilledTabControl(parent_wnd, TCS_FIXEDWIDTH, TCIF_TEXT|TCIF_IMAGE, nTabs);
    ok(hTab != NULL, "Failed to create tab control\n");

    flush_sequences(sequences, NUM_MSG_SEQUENCES);

    toolTip = create_tooltip(hTab, toolTipText);
    SendMessage(hTab, TCM_SETTOOLTIPS, (LPARAM) toolTip, 0);
    ok (toolTip == (HWND) SendMessage(hTab,TCM_GETTOOLTIPS,0,0), "ToolTip was set incorrectly.\n");

    SendMessage(hTab, TCM_SETTOOLTIPS, 0, 0);
    ok (NULL  == (HWND) SendMessage(hTab,TCM_GETTOOLTIPS,0,0), "ToolTip was set incorrectly.\n");

    ok_sequence(sequences, TAB_SEQ_INDEX, getset_tooltip_seq, "Getset tooltip test sequence", TRUE);
    ok_sequence(sequences, PARENT_SEQ_INDEX, getset_tooltip_parent_seq, "Getset tooltip test parent sequence", TRUE);

    DestroyWindow(hTab);
}
Example #10
0
static void test_TCM_SETITEMEXTRA(void)
{
    HWND hTab;
    DWORD ret;

    hTab = CreateWindowA(
	WC_TABCONTROLA,
	"TestTab",
	WS_CLIPSIBLINGS | WS_CLIPCHILDREN | TCS_FOCUSNEVER | TCS_FIXEDWIDTH,
        10, 10, 300, 100,
        parent_wnd, NULL, NULL, 0);

    /* zero is valid size too */
    ret = SendMessageA(hTab, TCM_SETITEMEXTRA, 0, 0);
    if (ret == FALSE)
    {
        win_skip("TCM_SETITEMEXTRA not supported\n");
        DestroyWindow(hTab);
        return;
    }

    ret = SendMessageA(hTab, TCM_SETITEMEXTRA, -1, 0);
    ok(ret == FALSE, "got %d\n", ret);

    ret = SendMessageA(hTab, TCM_SETITEMEXTRA, 2, 0);
    ok(ret == TRUE, "got %d\n", ret);
    DestroyWindow(hTab);

    /* it's not possible to change extra data size for control with tabs */
    hTab = createFilledTabControl(parent_wnd, TCS_FIXEDWIDTH, TCIF_TEXT|TCIF_IMAGE, 4);
    ok(hTab != NULL, "Failed to create tab control\n");

    ret = SendMessageA(hTab, TCM_SETITEMEXTRA, 2, 0);
    ok(ret == FALSE, "got %d\n", ret);
    DestroyWindow(hTab);
}
Example #11
0
File: tab.c Project: devyn/wine
static void test_insert_focus(HWND parent_wnd)
{
    HWND hTab;
    INT nTabsRetrieved;
    INT r;
    TCITEM tcNewTab;
    DWORD mask = TCIF_TEXT|TCIF_IMAGE;
    static char tabName[] = "TAB";
    tcNewTab.mask = mask;
    tcNewTab.pszText = tabName;

    ok(parent_wnd != NULL, "no parent window!\n");

    hTab = createFilledTabControl(parent_wnd, TCS_FIXEDWIDTH, mask, 0);
    ok(hTab != NULL, "Failed to create tab control\n");

    flush_sequences(sequences, NUM_MSG_SEQUENCES);

    nTabsRetrieved = SendMessage(hTab, TCM_GETITEMCOUNT, 0, 0);
    expect(0, nTabsRetrieved);

    r = SendMessage(hTab, TCM_GETCURFOCUS, 0, 0);
    expect(-1, r);

    tcNewTab.iImage = 1;
    r = SendMessage(hTab, TCM_INSERTITEM, 1, (LPARAM) &tcNewTab);
    expect(0, r);

    nTabsRetrieved = SendMessage(hTab, TCM_GETITEMCOUNT, 0, 0);
    expect(1, nTabsRetrieved);

    r = SendMessage(hTab, TCM_GETCURFOCUS, 0, 0);
    expect(0, r);

    tcNewTab.iImage = 2;
    r = SendMessage(hTab, TCM_INSERTITEM, 2, (LPARAM) &tcNewTab);
    expect(1, r);

    nTabsRetrieved = SendMessage(hTab, TCM_GETITEMCOUNT, 0, 0);
    expect(2, nTabsRetrieved);

    r = SendMessage(hTab, TCM_GETCURFOCUS, 0, 0);
    expect(0, r);

    r = SendMessage(hTab, TCM_SETCURFOCUS, -1, 0);
    expect(0, r);

    r = SendMessage(hTab, TCM_GETCURFOCUS, 0, 0);
    expect(-1, r);

    tcNewTab.iImage = 3;
    r = SendMessage(hTab, TCM_INSERTITEM, 3, (LPARAM) &tcNewTab);
    expect(2, r);

    r = SendMessage(hTab, TCM_GETCURFOCUS, 0, 0);
    expect(2, r);

    ok_sequence(sequences, TAB_SEQ_INDEX, insert_focus_seq, "insert_focus test sequence", TRUE);
    ok_sequence(sequences, PARENT_SEQ_INDEX, empty_sequence, "insert_focus parent test sequence", FALSE);

    DestroyWindow(hTab);
}
Example #12
0
File: tab.c Project: devyn/wine
static void test_getters_setters(HWND parent_wnd, INT nTabs)
{
    HWND hTab;
    RECT rTab;
    INT nTabsRetrieved;
    INT rowCount;
    INT dpi;
    HDC hdc;

    ok(parent_wnd != NULL, "no parent window!\n");
    flush_sequences(sequences, NUM_MSG_SEQUENCES);

    hTab = createFilledTabControl(parent_wnd, TCS_FIXEDWIDTH, TCIF_TEXT|TCIF_IMAGE, nTabs);
    ok(hTab != NULL, "Failed to create tab control\n");

    if(!winetest_interactive)
        ok_sequence(sequences, TAB_SEQ_INDEX, add_tab_to_parent,
                    "Tab sequence, after adding tab control to parent", TRUE);
    else
        ok_sequence(sequences, TAB_SEQ_INDEX, add_tab_to_parent_interactive,
                    "Tab sequence, after adding tab control to parent", TRUE);

    if(!winetest_interactive)
        ok_sequence(sequences, PARENT_SEQ_INDEX, add_tab_control_parent_seq,
                    "Parent after sequence, adding tab control to parent", TRUE);
    else
        ok_sequence(sequences, PARENT_SEQ_INDEX, add_tab_control_parent_seq_interactive,
                    "Parent after sequence, adding tab control to parent", TRUE);

    flush_sequences(sequences, NUM_MSG_SEQUENCES);
    ok(SendMessage(hTab, TCM_SETMINTABWIDTH, 0, -1) > 0,"TCM_SETMINTABWIDTH returned < 0\n");
    ok_sequence(sequences, PARENT_SEQ_INDEX, empty_sequence, "Set minTabWidth test parent sequence", FALSE);

    /* Testing GetItemCount */
    flush_sequences(sequences, NUM_MSG_SEQUENCES);
    nTabsRetrieved = SendMessage(hTab, TCM_GETITEMCOUNT, 0, 0);
    expect(nTabs, nTabsRetrieved);
    ok_sequence(sequences, TAB_SEQ_INDEX, get_item_count_seq, "Get itemCount test sequence", FALSE);
    ok_sequence(sequences, PARENT_SEQ_INDEX, empty_sequence, "Getset itemCount test parent sequence", FALSE);

    /* Testing GetRowCount */
    flush_sequences(sequences, NUM_MSG_SEQUENCES);
    rowCount = SendMessage(hTab, TCM_GETROWCOUNT, 0, 0);
    expect(1, rowCount);
    ok_sequence(sequences, TAB_SEQ_INDEX, get_row_count_seq, "Get rowCount test sequence", FALSE);
    ok_sequence(sequences, PARENT_SEQ_INDEX, empty_sequence, "Get rowCount test parent sequence", FALSE);

    /* Testing GetItemRect */
    flush_sequences(sequences, NUM_MSG_SEQUENCES);
    ok(SendMessage(hTab, TCM_GETITEMRECT, 0, (LPARAM) &rTab), "GetItemRect failed.\n");

    hdc = GetDC(hTab);
    dpi = GetDeviceCaps(hdc, LOGPIXELSX);
    ReleaseDC(hTab, hdc);
    CheckSize(hTab, dpi, -1 , "Default Width");
    ok_sequence(sequences, TAB_SEQ_INDEX, get_item_rect_seq, "Get itemRect test sequence", FALSE);
    ok_sequence(sequences, PARENT_SEQ_INDEX, empty_sequence, "Get itemRect test parent sequence", FALSE);

    /* Testing CurFocus */
    {
        INT focusIndex;

        flush_sequences(sequences, NUM_MSG_SEQUENCES);

        /* Testing CurFocus with largest appropriate value */
        SendMessage(hTab, TCM_SETCURFOCUS, nTabs-1, 0);
        focusIndex = SendMessage(hTab, TCM_GETCURFOCUS, 0, 0);
            expect(nTabs-1, focusIndex);

        /* Testing CurFocus with negative value */
        SendMessage(hTab, TCM_SETCURFOCUS, -10, 0);
        focusIndex = SendMessage(hTab, TCM_GETCURFOCUS, 0, 0);
            expect(-1, focusIndex);

        /* Testing CurFocus with value larger than number of tabs */
        focusIndex = SendMessage(hTab, TCM_SETCURSEL, 1, 0);
        todo_wine{
            expect(-1, focusIndex);
        }

        SendMessage(hTab, TCM_SETCURFOCUS, nTabs+1, 0);
        focusIndex = SendMessage(hTab, TCM_GETCURFOCUS, 0, 0);
            expect(1, focusIndex);

        ok_sequence(sequences, TAB_SEQ_INDEX, getset_cur_focus_seq, "Getset curFoc test sequence", FALSE);
    }

    /* Testing CurSel */
    {
        INT selectionIndex;
        INT focusIndex;

        flush_sequences(sequences, NUM_MSG_SEQUENCES);

        /* Testing CurSel with largest appropriate value */
        selectionIndex = SendMessage(hTab, TCM_SETCURSEL, nTabs-1, 0);
            expect(1, selectionIndex);
        selectionIndex = SendMessage(hTab, TCM_GETCURSEL, 0, 0);
            expect(nTabs-1, selectionIndex);

        /* Focus should switch with selection */
        focusIndex = SendMessage(hTab, TCM_GETCURFOCUS, 0, 0);
            expect(nTabs-1, focusIndex);

        /* Testing CurSel with negative value */
        SendMessage(hTab, TCM_SETCURSEL, -10, 0);
        selectionIndex = SendMessage(hTab, TCM_GETCURSEL, 0, 0);
            expect(-1, selectionIndex);

        /* Testing CurSel with value larger than number of tabs */
        selectionIndex = SendMessage(hTab, TCM_SETCURSEL, 1, 0);
            expect(-1, selectionIndex);

        selectionIndex = SendMessage(hTab, TCM_SETCURSEL, nTabs+1, 0);
            expect(-1, selectionIndex);
        selectionIndex = SendMessage(hTab, TCM_GETCURFOCUS, 0, 0);
            expect(1, selectionIndex);

        ok_sequence(sequences, TAB_SEQ_INDEX, getset_cur_sel_seq, "Getset curSel test sequence", FALSE);
        ok_sequence(sequences, PARENT_SEQ_INDEX, empty_sequence, "Getset curSel test parent sequence", FALSE);
    }

    /* Testing ExtendedStyle */
    {
        DWORD prevExtendedStyle;
        DWORD extendedStyle;

        flush_sequences(sequences, NUM_MSG_SEQUENCES);

        /* Testing Flat Separators */
        extendedStyle = SendMessage(hTab, TCM_GETEXTENDEDSTYLE, 0, 0);
        prevExtendedStyle = SendMessage(hTab, TCM_SETEXTENDEDSTYLE, 0, TCS_EX_FLATSEPARATORS);
            expect(extendedStyle, prevExtendedStyle);

        extendedStyle = SendMessage(hTab, TCM_GETEXTENDEDSTYLE, 0, 0);
        todo_wine{
            expect(TCS_EX_FLATSEPARATORS, extendedStyle);
        }

        /* Testing Register Drop */
        prevExtendedStyle = SendMessage(hTab, TCM_SETEXTENDEDSTYLE, 0, TCS_EX_REGISTERDROP);
            expect(extendedStyle, prevExtendedStyle);

        extendedStyle = SendMessage(hTab, TCM_GETEXTENDEDSTYLE, 0, 0);
        todo_wine{
            expect(TCS_EX_REGISTERDROP, extendedStyle);
        }

        ok_sequence(sequences, TAB_SEQ_INDEX, getset_extended_style_seq, "Getset extendedStyle test sequence", FALSE);
        ok_sequence(sequences, PARENT_SEQ_INDEX, empty_sequence, "Getset extendedStyle test parent sequence", FALSE);
    }

    /* Testing UnicodeFormat */
    {
        INT unicodeFormat;

        flush_sequences(sequences, NUM_MSG_SEQUENCES);

        unicodeFormat = SendMessage(hTab, TCM_SETUNICODEFORMAT, TRUE, 0);
        todo_wine{
            expect(0, unicodeFormat);
        }
        unicodeFormat = SendMessage(hTab, TCM_GETUNICODEFORMAT, 0, 0);
            expect(1, unicodeFormat);

        unicodeFormat = SendMessage(hTab, TCM_SETUNICODEFORMAT, FALSE, 0);
            expect(1, unicodeFormat);
        unicodeFormat = SendMessage(hTab, TCM_GETUNICODEFORMAT, 0, 0);
            expect(0, unicodeFormat);

        unicodeFormat = SendMessage(hTab, TCM_SETUNICODEFORMAT, TRUE, 0);
            expect(0, unicodeFormat);

        ok_sequence(sequences, TAB_SEQ_INDEX, getset_unicode_format_seq, "Getset unicodeFormat test sequence", FALSE);
        ok_sequence(sequences, PARENT_SEQ_INDEX, empty_sequence, "Getset unicodeFormat test parent sequence", FALSE);
    }

    /* Testing GetSet Item */
    {
        TCITEM tcItem;
        char szText[32] = "New Label";

        flush_sequences(sequences, NUM_MSG_SEQUENCES);

        tcItem.mask = TCIF_TEXT;
        tcItem.pszText = &szText[0];
        tcItem.cchTextMax = sizeof(szText);

        ok ( SendMessage(hTab, TCM_SETITEM, 0, (LPARAM) &tcItem), "Setting new item failed.\n");
        ok ( SendMessage(hTab, TCM_GETITEM, 0, (LPARAM) &tcItem), "Getting item failed.\n");
        expect_str("New Label", tcItem.pszText);

        ok ( SendMessage(hTab, TCM_GETITEM, 1, (LPARAM) &tcItem), "Getting item failed.\n");
        expect_str("Tab 2", tcItem.pszText);

        ok_sequence(sequences, TAB_SEQ_INDEX, getset_item_seq, "Getset item test sequence", FALSE);
        ok_sequence(sequences, PARENT_SEQ_INDEX, empty_sequence, "Getset item test parent sequence", FALSE);
    }

    /* Testing GetSet ToolTip */
    {
        HWND toolTip;
        char toolTipText[32] = "ToolTip Text Test";

        flush_sequences(sequences, NUM_MSG_SEQUENCES);

        toolTip = create_tooltip(hTab, toolTipText);
        SendMessage(hTab, TCM_SETTOOLTIPS, (LPARAM) toolTip, 0);
        ok (toolTip == (HWND) SendMessage(hTab,TCM_GETTOOLTIPS,0,0), "ToolTip was set incorrectly.\n");

        SendMessage(hTab, TCM_SETTOOLTIPS, 0, 0);
        ok (NULL  == (HWND) SendMessage(hTab,TCM_GETTOOLTIPS,0,0), "ToolTip was set incorrectly.\n");

        ok_sequence(sequences, TAB_SEQ_INDEX, getset_tooltip_seq, "Getset tooltip test sequence", TRUE);
        ok_sequence(sequences, PARENT_SEQ_INDEX, getset_tooltip_parent_seq, "Getset tooltip test parent sequence", TRUE);
    }

    DestroyWindow(hTab);
}
Example #13
0
static void test_getset_item(void)
{
    char szText[32] = "New Label";
    const INT nTabs = 5;
    TCITEM tcItem;
    LPARAM lparam;
    DWORD ret;
    HWND hTab;

    hTab = CreateWindowA(
	WC_TABCONTROLA,
	"TestTab",
	WS_CLIPSIBLINGS | WS_CLIPCHILDREN | TCS_FOCUSNEVER | TCS_FIXEDWIDTH | TCS_OWNERDRAWFIXED,
        10, 10, 300, 100,
        parent_wnd, NULL, NULL, 0);

    ok(GetParent(hTab) == NULL, "got %p, expected null parent\n", GetParent(hTab));

    ret = SendMessageA(hTab, TCM_SETITEMEXTRA, sizeof(LPARAM)-1, 0);
    ok(ret == TRUE, "got %d\n", ret);

    /* set some item data */
    tcItem.lParam = ~0;
    tcItem.mask = TCIF_PARAM;

    ret = SendMessageA(hTab, TCM_INSERTITEMA, 0, (LPARAM)&tcItem);
    ok(ret == 0, "got %d\n", ret);

    /* all sizeof(LPARAM) returned anyway when using sizeof(LPARAM)-1 size */
    memset(&lparam, 0xaa, sizeof(lparam));
    tcItem.lParam = lparam;
    tcItem.mask = TCIF_PARAM;
    ret = SendMessage(hTab, TCM_GETITEM, 0, (LPARAM)&tcItem);
    expect(TRUE, ret);
    /* everything higher specified size is preserved */
    memset(&lparam, 0xff, sizeof(lparam)-1);
    ok(tcItem.lParam == lparam, "Expected 0x%lx, got 0x%lx\n", lparam, tcItem.lParam);

    DestroyWindow(hTab);

    hTab = createFilledTabControl(parent_wnd, TCS_FIXEDWIDTH, TCIF_TEXT|TCIF_IMAGE, nTabs);
    ok(hTab != NULL, "Failed to create tab control\n");

    /* passing invalid index should result in initialization to zero
       for members mentioned in mask requested */

    /* valid range here is [0,4] */
    memset(&tcItem, 0xcc, sizeof(tcItem));
    tcItem.mask = TCIF_PARAM;
    ret = SendMessage(hTab, TCM_GETITEM, 5, (LPARAM)&tcItem);
    expect(FALSE, ret);
    ok(tcItem.lParam == 0, "Expected zero lParam, got %lu\n", tcItem.lParam);

    memset(&tcItem, 0xcc, sizeof(tcItem));
    tcItem.mask = TCIF_IMAGE;
    ret = SendMessage(hTab, TCM_GETITEM, 5, (LPARAM)&tcItem);
    expect(FALSE, ret);
    expect(0, tcItem.iImage);

    memset(&tcItem, 0xcc, sizeof(tcItem));
    tcItem.mask = TCIF_TEXT;
    tcItem.pszText = szText;
    szText[0] = 'a';
    ret = SendMessage(hTab, TCM_GETITEM, 5, (LPARAM)&tcItem);
    expect(FALSE, ret);
    expect('a', szText[0]);

    memset(&tcItem, 0xcc, sizeof(tcItem));
    tcItem.mask = TCIF_STATE;
    tcItem.dwStateMask = 0;
    tcItem.dwState = TCIS_BUTTONPRESSED;
    ret = SendMessage(hTab, TCM_GETITEM, 5, (LPARAM)&tcItem);
    expect(FALSE, ret);
    ok(tcItem.dwState == 0, "Expected zero dwState, got %u\n", tcItem.dwState);

    memset(&tcItem, 0xcc, sizeof(tcItem));
    tcItem.mask = TCIF_STATE;
    tcItem.dwStateMask = TCIS_BUTTONPRESSED;
    tcItem.dwState = TCIS_BUTTONPRESSED;
    ret = SendMessage(hTab, TCM_GETITEM, 5, (LPARAM)&tcItem);
    expect(FALSE, ret);
    ok(tcItem.dwState == 0, "Expected zero dwState\n");

    /* check with negative index to be sure */
    memset(&tcItem, 0xcc, sizeof(tcItem));
    tcItem.mask = TCIF_PARAM;
    ret = SendMessage(hTab, TCM_GETITEM, -1, (LPARAM)&tcItem);
    expect(FALSE, ret);
    ok(tcItem.lParam == 0, "Expected zero lParam, got %lu\n", tcItem.lParam);

    memset(&tcItem, 0xcc, sizeof(tcItem));
    tcItem.mask = TCIF_PARAM;
    ret = SendMessage(hTab, TCM_GETITEM, -2, (LPARAM)&tcItem);
    expect(FALSE, ret);
    ok(tcItem.lParam == 0, "Expected zero lParam, got %lu\n", tcItem.lParam);

    flush_sequences(sequences, NUM_MSG_SEQUENCES);

    tcItem.mask = TCIF_TEXT;
    tcItem.pszText = &szText[0];
    tcItem.cchTextMax = sizeof(szText);

    strcpy(szText, "New Label");
    ok ( SendMessage(hTab, TCM_SETITEM, 0, (LPARAM) &tcItem), "Setting new item failed.\n");
    ok ( SendMessage(hTab, TCM_GETITEM, 0, (LPARAM) &tcItem), "Getting item failed.\n");
    expect_str("New Label", tcItem.pszText);

    ok ( SendMessage(hTab, TCM_GETITEM, 1, (LPARAM) &tcItem), "Getting item failed.\n");
    expect_str("Tab 2", tcItem.pszText);

    ok_sequence(sequences, TAB_SEQ_INDEX, getset_item_seq, "Getset item test sequence", FALSE);
    ok_sequence(sequences, PARENT_SEQ_INDEX, empty_sequence, "Getset item test parent sequence", FALSE);

    /* TCIS_BUTTONPRESSED doesn't depend on tab style */
    memset(&tcItem, 0, sizeof(tcItem));
    tcItem.mask = TCIF_STATE;
    tcItem.dwStateMask = TCIS_BUTTONPRESSED;
    tcItem.dwState = TCIS_BUTTONPRESSED;
    ok ( SendMessage(hTab, TCM_SETITEM, 0, (LPARAM) &tcItem), "Setting new item failed.\n");
    tcItem.dwState = 0;
    ok ( SendMessage(hTab, TCM_GETITEM, 0, (LPARAM) &tcItem), "Getting item failed.\n");
    if (tcItem.dwState)
    {
        ok (tcItem.dwState == TCIS_BUTTONPRESSED, "TCIS_BUTTONPRESSED should be set.\n");
        /* next highlight item, test that dwStateMask actually masks */
        tcItem.mask = TCIF_STATE;
        tcItem.dwStateMask = TCIS_HIGHLIGHTED;
        tcItem.dwState = TCIS_HIGHLIGHTED;
        ok ( SendMessage(hTab, TCM_SETITEM, 0, (LPARAM) &tcItem), "Setting new item failed.\n");
        tcItem.dwState = 0;
        ok ( SendMessage(hTab, TCM_GETITEM, 0, (LPARAM) &tcItem), "Getting item failed.\n");
        ok (tcItem.dwState == TCIS_HIGHLIGHTED, "TCIS_HIGHLIGHTED should be set.\n");
        tcItem.mask = TCIF_STATE;
        tcItem.dwStateMask = TCIS_BUTTONPRESSED;
        tcItem.dwState = 0;
        ok ( SendMessage(hTab, TCM_GETITEM, 0, (LPARAM) &tcItem), "Getting item failed.\n");
        ok (tcItem.dwState == TCIS_BUTTONPRESSED, "TCIS_BUTTONPRESSED should be set.\n");
    }
    else win_skip( "Item state mask not supported\n" );

    DestroyWindow(hTab);
}
Example #14
0
static void test_TCS_OWNERDRAWFIXED(void)
{
    LPARAM lparam;
    ULONG_PTR itemdata, itemdata2;
    TCITEMA item;
    HWND hTab;
    BOOL ret;

    hTab = createFilledTabControl(parent_wnd, TCS_FIXEDWIDTH|TCS_OWNERDRAWFIXED, TCIF_TEXT|TCIF_IMAGE, 4);
    ok(hTab != NULL, "Failed to create tab control\n");

    ok(GetParent(hTab) == NULL, "got %p, expected null parent\n", GetParent(hTab));

    /* set some item data */
    memset(&lparam, 0xde, sizeof(LPARAM));

    item.mask = TCIF_PARAM;
    item.lParam = lparam;
    ret = SendMessageA(hTab, TCM_SETITEMA, 0, (LPARAM)&item);
    ok(ret == TRUE, "got %d\n", ret);

    memset(&g_drawitem, 0, sizeof(g_drawitem));

    ShowWindow(hTab, SW_SHOW);
    RedrawWindow(hTab, NULL, 0, RDW_UPDATENOW);

    itemdata = 0;
    memset(&itemdata, 0xde, 4);
    ok(g_drawitem.itemData == itemdata, "got 0x%lx, expected 0x%lx\n", g_drawitem.itemData, itemdata);

    DestroyWindow(hTab);

    /* now with custom extra data length */
    hTab = CreateWindowA(
	WC_TABCONTROLA,
	"TestTab",
	WS_CLIPSIBLINGS | WS_CLIPCHILDREN | TCS_FOCUSNEVER | TCS_FIXEDWIDTH | TCS_OWNERDRAWFIXED,
        10, 10, 300, 100,
        parent_wnd, NULL, NULL, 0);

    ok(GetParent(hTab) == NULL, "got %p, expected null parent\n", GetParent(hTab));

    ret = SendMessageA(hTab, TCM_SETITEMEXTRA, sizeof(LPARAM)+1, 0);
    ok(ret == TRUE, "got %d\n", ret);

    /* set some item data */
    memset(&lparam, 0xde, sizeof(LPARAM));
    item.mask = TCIF_PARAM;
    item.lParam = lparam;

    ret = SendMessageA(hTab, TCM_INSERTITEMA, 0, (LPARAM)&item);
    ok(ret == 0, "got %d\n", ret);

    memset(&g_drawitem, 0, sizeof(g_drawitem));

    ShowWindow(hTab, SW_SHOW);
    RedrawWindow(hTab, NULL, 0, RDW_UPDATENOW);

    memset(&itemdata, 0xde, sizeof(ULONG_PTR));
    ok(*(ULONG_PTR*)g_drawitem.itemData == itemdata, "got 0x%lx, expected 0x%lx\n", g_drawitem.itemData, itemdata);

    DestroyWindow(hTab);

    /* same thing, but size smaller than default */
    hTab = CreateWindowA(
	WC_TABCONTROLA,
	"TestTab",
	WS_CLIPSIBLINGS | WS_CLIPCHILDREN | TCS_FOCUSNEVER | TCS_FIXEDWIDTH | TCS_OWNERDRAWFIXED,
        10, 10, 300, 100,
        parent_wnd, NULL, NULL, 0);

    ok(GetParent(hTab) == NULL, "got %p, expected null parent\n", GetParent(hTab));

    ret = SendMessageA(hTab, TCM_SETITEMEXTRA, sizeof(LPARAM)-1, 0);
    ok(ret == TRUE, "got %d\n", ret);

    memset(&lparam, 0xde, sizeof(lparam));
    item.mask = TCIF_PARAM;
    item.lParam = lparam;

    ret = SendMessageA(hTab, TCM_INSERTITEMA, 0, (LPARAM)&item);
    ok(ret == 0, "got %d\n", ret);

    memset(&g_drawitem, 0, sizeof(g_drawitem));

    ShowWindow(hTab, SW_SHOW);
    RedrawWindow(hTab, NULL, 0, RDW_UPDATENOW);

    itemdata = itemdata2 = 0;
    memset(&itemdata, 0xde, 4);
    memset(&itemdata2, 0xde, sizeof(LPARAM)-1);
    ok(g_drawitem.itemData == itemdata || broken(g_drawitem.itemData == itemdata2) /* win98 */,
        "got 0x%lx, expected 0x%lx\n", g_drawitem.itemData, itemdata);

    DestroyWindow(hTab);
}
Example #15
0
File: tab.c Project: wesgarner/wine
static void test_getset_item(HWND parent_wnd, INT nTabs)
{
    TCITEM tcItem;
    DWORD ret;
    char szText[32] = "New Label";
    HWND hTab;

    hTab = createFilledTabControl(parent_wnd, TCS_FIXEDWIDTH, TCIF_TEXT|TCIF_IMAGE, nTabs);
    ok(hTab != NULL, "Failed to create tab control\n");

    /* passing invalid index should result in initialization to zero
       for members mentioned in mask requested */

    /* valid range here is [0,4] */
    memset(&tcItem, 0xcc, sizeof(tcItem));
    tcItem.mask = TCIF_PARAM;
    ret = SendMessage(hTab, TCM_GETITEM, 5, (LPARAM)&tcItem);
    expect(FALSE, ret);
    ok(tcItem.lParam == 0, "Expected zero lParam, got %lu\n", tcItem.lParam);

    memset(&tcItem, 0xcc, sizeof(tcItem));
    tcItem.mask = TCIF_IMAGE;
    ret = SendMessage(hTab, TCM_GETITEM, 5, (LPARAM)&tcItem);
    expect(FALSE, ret);
    expect(0, tcItem.iImage);

    memset(&tcItem, 0xcc, sizeof(tcItem));
    tcItem.mask = TCIF_TEXT;
    tcItem.pszText = szText;
    szText[0] = 'a';
    ret = SendMessage(hTab, TCM_GETITEM, 5, (LPARAM)&tcItem);
    expect(FALSE, ret);
    expect('a', szText[0]);

    memset(&tcItem, 0xcc, sizeof(tcItem));
    tcItem.mask = TCIF_STATE;
    tcItem.dwStateMask = 0;
    tcItem.dwState = TCIS_BUTTONPRESSED;
    ret = SendMessage(hTab, TCM_GETITEM, 5, (LPARAM)&tcItem);
    expect(FALSE, ret);
    ok(tcItem.dwState == 0, "Expected zero dwState, got %u\n", tcItem.dwState);

    memset(&tcItem, 0xcc, sizeof(tcItem));
    tcItem.mask = TCIF_STATE;
    tcItem.dwStateMask = TCIS_BUTTONPRESSED;
    tcItem.dwState = TCIS_BUTTONPRESSED;
    ret = SendMessage(hTab, TCM_GETITEM, 5, (LPARAM)&tcItem);
    expect(FALSE, ret);
    ok(tcItem.dwState == 0, "Expected zero dwState\n");

    /* check with negative index to be sure */
    memset(&tcItem, 0xcc, sizeof(tcItem));
    tcItem.mask = TCIF_PARAM;
    ret = SendMessage(hTab, TCM_GETITEM, -1, (LPARAM)&tcItem);
    expect(FALSE, ret);
    ok(tcItem.lParam == 0, "Expected zero lParam, got %lu\n", tcItem.lParam);

    memset(&tcItem, 0xcc, sizeof(tcItem));
    tcItem.mask = TCIF_PARAM;
    ret = SendMessage(hTab, TCM_GETITEM, -2, (LPARAM)&tcItem);
    expect(FALSE, ret);
    ok(tcItem.lParam == 0, "Expected zero lParam, got %lu\n", tcItem.lParam);

    flush_sequences(sequences, NUM_MSG_SEQUENCES);

    tcItem.mask = TCIF_TEXT;
    tcItem.pszText = &szText[0];
    tcItem.cchTextMax = sizeof(szText);

    strcpy(szText, "New Label");
    ok ( SendMessage(hTab, TCM_SETITEM, 0, (LPARAM) &tcItem), "Setting new item failed.\n");
    ok ( SendMessage(hTab, TCM_GETITEM, 0, (LPARAM) &tcItem), "Getting item failed.\n");
    expect_str("New Label", tcItem.pszText);

    ok ( SendMessage(hTab, TCM_GETITEM, 1, (LPARAM) &tcItem), "Getting item failed.\n");
    expect_str("Tab 2", tcItem.pszText);

    ok_sequence(sequences, TAB_SEQ_INDEX, getset_item_seq, "Getset item test sequence", FALSE);
    ok_sequence(sequences, PARENT_SEQ_INDEX, empty_sequence, "Getset item test parent sequence", FALSE);

    /* TCIS_BUTTONPRESSED doesn't depend on tab style */
    memset(&tcItem, 0, sizeof(tcItem));
    tcItem.mask = TCIF_STATE;
    tcItem.dwStateMask = TCIS_BUTTONPRESSED;
    tcItem.dwState = TCIS_BUTTONPRESSED;
    ok ( SendMessage(hTab, TCM_SETITEM, 0, (LPARAM) &tcItem), "Setting new item failed.\n");
    tcItem.dwState = 0;
    ok ( SendMessage(hTab, TCM_GETITEM, 0, (LPARAM) &tcItem), "Getting item failed.\n");
    if (tcItem.dwState)
    {
        ok (tcItem.dwState == TCIS_BUTTONPRESSED, "TCIS_BUTTONPRESSED should be set.\n");
        /* next highlight item, test that dwStateMask actually masks */
        tcItem.mask = TCIF_STATE;
        tcItem.dwStateMask = TCIS_HIGHLIGHTED;
        tcItem.dwState = TCIS_HIGHLIGHTED;
        ok ( SendMessage(hTab, TCM_SETITEM, 0, (LPARAM) &tcItem), "Setting new item failed.\n");
        tcItem.dwState = 0;
        ok ( SendMessage(hTab, TCM_GETITEM, 0, (LPARAM) &tcItem), "Getting item failed.\n");
        ok (tcItem.dwState == TCIS_HIGHLIGHTED, "TCIS_HIGHLIGHTED should be set.\n");
        tcItem.mask = TCIF_STATE;
        tcItem.dwStateMask = TCIS_BUTTONPRESSED;
        tcItem.dwState = 0;
        ok ( SendMessage(hTab, TCM_GETITEM, 0, (LPARAM) &tcItem), "Getting item failed.\n");
        ok (tcItem.dwState == TCIS_BUTTONPRESSED, "TCIS_BUTTONPRESSED should be set.\n");
    }
    else win_skip( "Item state mask not supported\n" );

    DestroyWindow(hTab);
}