Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
0adb4ef4
Commit
0adb4ef4
authored
Aug 06, 2009
by
Nikolay Sivov
Committed by
Alexandre Julliard
Aug 06, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
comctl32/treeview: Make tests not depend from each other, replace some magics with macros.
parent
b32bccb4
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
178 additions
and
163 deletions
+178
-163
treeview.c
dlls/comctl32/tests/treeview.c
+178
-163
No files found.
dlls/comctl32/tests/treeview.c
View file @
0adb4ef4
...
...
@@ -37,104 +37,96 @@ const char *TEST_CALLBACK_TEXT = "callback_text";
#define NUM_MSG_SEQUENCES 1
#define TREEVIEW_SEQ_INDEX 0
#define expect(expected, got) ok(got == expected, "Expected %d, got %d\n", expected, got)
static
struct
msg_sequence
*
MsgSequences
[
NUM_MSG_SEQUENCES
];
static
const
struct
message
FillRootSeq
[]
=
{
{
TVM_INSERTITEM
,
sent
},
{
TVM_GETITEM
,
sent
},
{
TVM_INSERTITEM
,
sent
},
{
0
}
};
static
const
struct
message
DoTest1S
eq
[]
=
{
{
TVM_SELECTITEM
,
sent
|
wparam
,
0x0000000
9
},
{
TVM_SELECTITEM
,
sent
|
wparam
,
0x0000000
9
},
{
TVM_SELECTITEM
,
sent
|
wparam
,
0x0000000
9
},
{
TVM_SELECTITEM
,
sent
|
wparam
,
0x0000000
9
},
{
TVM_SELECTITEM
,
sent
|
wparam
,
0x0000000
9
},
{
TVM_SELECTITEM
,
sent
|
wparam
,
0x0000000
9
},
static
const
struct
message
rootnone_select_s
eq
[]
=
{
{
TVM_SELECTITEM
,
sent
|
wparam
,
9
},
{
TVM_SELECTITEM
,
sent
|
wparam
,
9
},
{
TVM_SELECTITEM
,
sent
|
wparam
,
9
},
{
TVM_SELECTITEM
,
sent
|
wparam
,
9
},
{
TVM_SELECTITEM
,
sent
|
wparam
,
9
},
{
TVM_SELECTITEM
,
sent
|
wparam
,
9
},
{
0
}
};
static
const
struct
message
DoTest2S
eq
[]
=
{
{
TVM_SELECTITEM
,
sent
|
wparam
,
0x0000000
9
},
{
TVM_SELECTITEM
,
sent
|
wparam
,
0x0000000
9
},
{
TVM_SELECTITEM
,
sent
|
wparam
,
0x0000000
9
},
{
TVM_SELECTITEM
,
sent
|
wparam
,
0x0000000
9
},
{
TVM_SELECTITEM
,
sent
|
wparam
,
0x0000000
9
},
{
TVM_SELECTITEM
,
sent
|
wparam
,
0x0000000
9
},
static
const
struct
message
rootchild_select_s
eq
[]
=
{
{
TVM_SELECTITEM
,
sent
|
wparam
,
9
},
{
TVM_SELECTITEM
,
sent
|
wparam
,
9
},
{
TVM_SELECTITEM
,
sent
|
wparam
,
9
},
{
TVM_SELECTITEM
,
sent
|
wparam
,
9
},
{
TVM_SELECTITEM
,
sent
|
wparam
,
9
},
{
TVM_SELECTITEM
,
sent
|
wparam
,
9
},
{
0
}
};
static
const
struct
message
DoTest3S
eq
[]
=
{
static
const
struct
message
getitemtext_s
eq
[]
=
{
{
TVM_INSERTITEM
,
sent
},
{
TVM_GETITEM
,
sent
},
{
TVM_DELETEITEM
,
sent
},
{
0
}
};
static
const
struct
message
DoFocusTestS
eq
[]
=
{
static
const
struct
message
focus_s
eq
[]
=
{
{
TVM_INSERTITEM
,
sent
},
{
TVM_INSERTITEM
,
sent
},
{
TVM_SELECTITEM
,
sent
|
wparam
,
9
},
/* The following end up out of order in wine */
{
WM_WINDOWPOSCHANGING
,
sent
|
defwinproc
},
{
WM_NCCALCSIZE
,
sent
|
wparam
|
defwinproc
,
0x00000001
},
{
WM_NCCALCSIZE
,
sent
|
wparam
|
defwinproc
,
TRUE
},
{
WM_WINDOWPOSCHANGED
,
sent
|
defwinproc
},
{
WM_SIZE
,
sent
|
defwinproc
},
{
WM_WINDOWPOSCHANGING
,
sent
},
{
WM_NCCALCSIZE
,
sent
|
wparam
,
0x00000001
},
{
WM_WINDOWPOSCHANGED
,
sent
},
{
WM_SIZE
,
sent
|
defwinproc
},
{
WM_WINDOWPOSCHANGING
,
sent
|
defwinproc
|
optional
},
{
WM_NCCALCSIZE
,
sent
|
wparam
|
defwinproc
|
optional
,
0x00000001
},
{
WM_WINDOWPOSCHANGED
,
sent
|
defwinproc
|
optional
},
{
WM_SIZE
,
sent
|
defwinproc
|
optional
},
{
TVM_SELECTITEM
,
sent
|
wparam
,
0x00000009
},
/* The following end up out of order in wine */
{
WM_PAINT
,
sent
|
defwinproc
},
{
WM_NCPAINT
,
sent
|
wparam
|
defwinproc
,
0x0000000
1
},
{
WM_NCPAINT
,
sent
|
wparam
|
defwinproc
,
1
},
{
WM_ERASEBKGND
,
sent
|
defwinproc
},
{
TVM_EDITLABEL
,
sent
},
{
WM_COMMAND
,
sent
|
wparam
|
defwinproc
,
0x04000000
},
{
WM_COMMAND
,
sent
|
wparam
|
defwinproc
,
0x03000000
},
{
WM_PARENTNOTIFY
,
sent
|
wparam
|
defwinproc
,
0x00000001
},
{
WM_COMMAND
,
sent
|
wparam
|
defwinproc
,
MAKEWPARAM
(
0
,
EN_UPDATE
)
},
{
WM_COMMAND
,
sent
|
wparam
|
defwinproc
,
MAKEWPARAM
(
0
,
EN_CHANGE
)
},
{
WM_PARENTNOTIFY
,
sent
|
wparam
|
defwinproc
,
MAKEWPARAM
(
WM_CREATE
,
0
)
},
{
WM_KILLFOCUS
,
sent
|
defwinproc
},
{
WM_PAINT
,
sent
|
defwinproc
},
{
WM_IME_SETCONTEXT
,
sent
|
defwinproc
|
optional
},
{
WM_COMMAND
,
sent
|
wparam
|
defwinproc
,
0x01000000
},
{
WM_ERASEBKGND
,
sent
|
defwinproc
},
{
WM_COMMAND
,
sent
|
wparam
|
defwinproc
,
MAKEWPARAM
(
0
,
EN_SETFOCUS
)
},
{
WM_CTLCOLOREDIT
,
sent
|
defwinproc
|
optional
},
{
WM_CTLCOLOREDIT
,
sent
|
defwinproc
|
optional
},
{
0
}
};
static
const
struct
message
TestGetSetBkColorSeq
[]
=
{
{
TVM_GETBKCOLOR
,
sent
|
wparam
|
lparam
,
0
x00000000
,
0x0000000
0
},
{
TVM_SETBKCOLOR
,
sent
|
wparam
|
lparam
,
0
x00000000
,
0x0000000
0
},
{
TVM_GETBKCOLOR
,
sent
|
wparam
|
lparam
,
0
x00000000
,
0x0000000
0
},
{
TVM_SETBKCOLOR
,
sent
|
wparam
|
lparam
,
0
x00000000
,
0x00ffffff
},
{
TVM_GETBKCOLOR
,
sent
|
wparam
|
lparam
,
0
x00000000
,
0x0000000
0
},
{
TVM_SETBKCOLOR
,
sent
|
wparam
|
lparam
,
0
x00000000
,
-
1
},
{
TVM_GETBKCOLOR
,
sent
|
wparam
|
lparam
,
0
,
0
},
{
TVM_SETBKCOLOR
,
sent
|
wparam
|
lparam
,
0
,
0
},
{
TVM_GETBKCOLOR
,
sent
|
wparam
|
lparam
,
0
,
0
},
{
TVM_SETBKCOLOR
,
sent
|
wparam
|
lparam
,
0
,
0x00ffffff
},
{
TVM_GETBKCOLOR
,
sent
|
wparam
|
lparam
,
0
,
0
},
{
TVM_SETBKCOLOR
,
sent
|
wparam
|
lparam
,
0
,
-
1
},
{
0
}
};
static
const
struct
message
TestGetSetImageListSeq
[]
=
{
{
TVM_SETIMAGELIST
,
sent
|
wparam
|
lparam
,
0
x00000000
,
0x0000000
0
},
{
TVM_GETIMAGELIST
,
sent
|
wparam
|
lparam
,
0
x00000000
,
0x0000000
0
},
{
TVM_SETIMAGELIST
,
sent
|
wparam
|
lparam
,
0
,
0
},
{
TVM_GETIMAGELIST
,
sent
|
wparam
|
lparam
,
0
,
0
},
{
0
}
};
static
const
struct
message
TestGetSetIndentSeq
[]
=
{
{
TVM_SETINDENT
,
sent
|
wparam
|
lparam
,
0
x00000000
,
0x0000000
0
},
{
TVM_GETINDENT
,
sent
|
wparam
|
lparam
,
0
x00000000
,
0x0000000
0
},
{
TVM_SETINDENT
,
sent
|
wparam
|
lparam
,
0
,
0
},
{
TVM_GETINDENT
,
sent
|
wparam
|
lparam
,
0
,
0
},
/* The actual amount to indent is dependent on the system for this message */
{
TVM_SETINDENT
,
sent
},
{
TVM_GETINDENT
,
sent
|
wparam
|
lparam
,
0
x00000000
,
0x0000000
0
},
{
TVM_GETINDENT
,
sent
|
wparam
|
lparam
,
0
,
0
},
{
0
}
};
static
const
struct
message
TestGetSetInsertMarkColorSeq
[]
=
{
{
TVM_SETINSERTMARKCOLOR
,
sent
|
wparam
|
lparam
,
0
x00000000
,
0x0000000
0
},
{
TVM_GETINSERTMARKCOLOR
,
sent
|
wparam
|
lparam
,
0
x00000000
,
0x0000000
0
},
{
TVM_SETINSERTMARKCOLOR
,
sent
|
wparam
|
lparam
,
0
,
0
},
{
TVM_GETINSERTMARKCOLOR
,
sent
|
wparam
|
lparam
,
0
,
0
},
{
0
}
};
...
...
@@ -147,50 +139,45 @@ static const struct message TestGetSetItemSeq[] = {
};
static
const
struct
message
TestGetSetItemHeightSeq
[]
=
{
{
TVM_GETITEMHEIGHT
,
sent
|
wparam
|
lparam
,
0x00000000
,
0x00000000
},
{
TVM_SETITEMHEIGHT
,
sent
|
wparam
|
lparam
,
-
1
,
0x00000000
},
{
TVM_GETITEMHEIGHT
,
sent
|
wparam
|
lparam
,
0x00000000
,
0x00000000
},
{
TVM_SETITEMHEIGHT
,
sent
|
lparam
,
0xcccccccc
,
0x00000000
},
{
TVM_GETITEMHEIGHT
,
sent
|
wparam
|
lparam
|
optional
,
0x00000000
,
0x00000000
},
{
TVM_SETITEMHEIGHT
,
sent
|
wparam
|
lparam
|
optional
,
0x00000009
,
0x00000000
},
{
WM_WINDOWPOSCHANGING
,
sent
|
defwinproc
},
{
WM_NCCALCSIZE
,
sent
|
wparam
|
defwinproc
,
0x00000001
},
{
WM_WINDOWPOSCHANGED
,
sent
|
defwinproc
},
{
WM_SIZE
,
sent
|
defwinproc
},
{
TVM_GETITEMHEIGHT
,
sent
|
wparam
|
lparam
,
0x00000000
,
0x00000000
},
{
TVM_GETITEMHEIGHT
,
sent
|
wparam
|
lparam
,
0
,
0
},
{
TVM_SETITEMHEIGHT
,
sent
|
wparam
|
lparam
,
-
1
,
0
},
{
TVM_GETITEMHEIGHT
,
sent
|
wparam
|
lparam
,
0
,
0
},
{
TVM_SETITEMHEIGHT
,
sent
|
lparam
,
0xcccccccc
,
0
},
{
TVM_GETITEMHEIGHT
,
sent
|
wparam
|
lparam
|
optional
,
0
,
0
},
{
TVM_SETITEMHEIGHT
,
sent
|
wparam
|
lparam
|
optional
,
9
,
0
},
{
TVM_GETITEMHEIGHT
,
sent
|
wparam
|
lparam
,
0
,
0
},
{
0
}
};
static
const
struct
message
TestGetSetScrollTimeSeq
[]
=
{
{
TVM_SETSCROLLTIME
,
sent
|
wparam
|
lparam
,
0x00000014
,
0x0000000
0
},
{
TVM_GETSCROLLTIME
,
sent
|
wparam
|
lparam
,
0
x00000000
,
0x0000000
0
},
{
TVM_SETSCROLLTIME
,
sent
|
wparam
|
lparam
,
20
,
0
},
{
TVM_GETSCROLLTIME
,
sent
|
wparam
|
lparam
,
0
,
0
},
{
0
}
};
static
const
struct
message
TestGetSetTextColorSeq
[]
=
{
{
TVM_GETTEXTCOLOR
,
sent
|
wparam
|
lparam
,
0
x00000000
,
0x0000000
0
},
{
TVM_SETTEXTCOLOR
,
sent
|
wparam
|
lparam
,
0
x00000000
,
0x0000000
0
},
{
TVM_GETTEXTCOLOR
,
sent
|
wparam
|
lparam
,
0
x00000000
,
0x0000000
0
},
{
TVM_SETTEXTCOLOR
,
sent
|
wparam
|
lparam
,
0
x00000000
,
0x00ffffff
},
{
TVM_GETTEXTCOLOR
,
sent
|
wparam
|
lparam
,
0
x00000000
,
0x0000000
0
},
{
TVM_SETTEXTCOLOR
,
sent
|
wparam
|
lparam
,
0
x00000000
,
-
1
},
{
TVM_GETTEXTCOLOR
,
sent
|
wparam
|
lparam
,
0
,
0
},
{
TVM_SETTEXTCOLOR
,
sent
|
wparam
|
lparam
,
0
,
0
},
{
TVM_GETTEXTCOLOR
,
sent
|
wparam
|
lparam
,
0
,
0
},
{
TVM_SETTEXTCOLOR
,
sent
|
wparam
|
lparam
,
0
,
0x00ffffff
},
{
TVM_GETTEXTCOLOR
,
sent
|
wparam
|
lparam
,
0
,
0
},
{
TVM_SETTEXTCOLOR
,
sent
|
wparam
|
lparam
,
0
,
-
1
},
{
0
}
};
static
const
struct
message
TestGetSetToolTipsSeq
[]
=
{
{
WM_COMMAND
,
sent
|
wparam
,
0x02000000
},
{
WM_PARENTNOTIFY
,
sent
|
wparam
|
defwinproc
,
0x00020002
},
{
TVM_SETTOOLTIPS
,
sent
|
wparam
|
lparam
,
0x00000000
,
0x00000000
},
{
TVM_GETTOOLTIPS
,
sent
|
wparam
|
lparam
,
0x00000000
,
0x00000000
},
{
WM_KILLFOCUS
,
sent
},
{
TVM_SETTOOLTIPS
,
sent
|
wparam
|
lparam
,
0
,
0
},
{
TVM_GETTOOLTIPS
,
sent
|
wparam
|
lparam
,
0
,
0
},
{
0
}
};
static
const
struct
message
TestGetSetUnicodeFormatSeq
[]
=
{
{
TVM_SETUNICODEFORMAT
,
sent
|
wparam
|
lparam
,
0x00000001
,
0x0000000
0
},
{
TVM_GETUNICODEFORMAT
,
sent
|
wparam
|
lparam
,
0
x00000000
,
0x0000000
0
},
{
TVM_SETUNICODEFORMAT
,
sent
|
wparam
|
lparam
,
0
x00000000
,
0x0000000
0
},
{
TVM_GETUNICODEFORMAT
,
sent
|
wparam
|
lparam
,
0
x00000000
,
0x0000000
0
},
{
TVM_SETUNICODEFORMAT
,
sent
|
wparam
|
lparam
,
0
x00000000
,
0x0000000
0
},
{
TVM_SETUNICODEFORMAT
,
sent
|
wparam
|
lparam
,
TRUE
,
0
},
{
TVM_GETUNICODEFORMAT
,
sent
|
wparam
|
lparam
,
0
,
0
},
{
TVM_SETUNICODEFORMAT
,
sent
|
wparam
|
lparam
,
0
,
0
},
{
TVM_GETUNICODEFORMAT
,
sent
|
wparam
|
lparam
,
0
,
0
},
{
TVM_SETUNICODEFORMAT
,
sent
|
wparam
|
lparam
,
0
,
0
},
{
0
}
};
...
...
@@ -231,45 +218,95 @@ static void IdentifyItem(HTREEITEM hItem)
AddItem
(
'?'
);
}
static
void
FillRoot
(
void
)
/* This function hooks in and records all messages to the treeview control */
static
LRESULT
WINAPI
TreeviewWndProc
(
HWND
hwnd
,
UINT
message
,
WPARAM
wParam
,
LPARAM
lParam
)
{
static
LONG
defwndproc_counter
=
0
;
LRESULT
ret
;
struct
message
msg
;
WNDPROC
lpOldProc
=
(
WNDPROC
)
GetWindowLongPtrA
(
hwnd
,
GWLP_USERDATA
);
msg
.
message
=
message
;
msg
.
flags
=
sent
|
wparam
|
lparam
;
if
(
defwndproc_counter
)
msg
.
flags
|=
defwinproc
;
msg
.
wParam
=
wParam
;
msg
.
lParam
=
lParam
;
add_message
(
MsgSequences
,
TREEVIEW_SEQ_INDEX
,
&
msg
);
defwndproc_counter
++
;
ret
=
CallWindowProcA
(
lpOldProc
,
hwnd
,
message
,
wParam
,
lParam
);
defwndproc_counter
--
;
return
ret
;
}
static
HWND
create_treeview_control
(
void
)
{
WNDPROC
pOldWndProc
;
HWND
hTree
;
hTree
=
CreateWindowExA
(
WS_EX_CLIENTEDGE
,
WC_TREEVIEWA
,
NULL
,
WS_CHILD
|
WS_VISIBLE
|
TVS_LINESATROOT
|
TVS_HASLINES
|
TVS_HASBUTTONS
|
TVS_EDITLABELS
,
0
,
0
,
120
,
100
,
hMainWnd
,
(
HMENU
)
100
,
GetModuleHandleA
(
0
),
0
);
SetFocus
(
hTree
);
/* Record the old WNDPROC so we can call it after recording the messages */
pOldWndProc
=
(
WNDPROC
)
SetWindowLongPtrA
(
hTree
,
GWLP_WNDPROC
,
(
LONG_PTR
)
TreeviewWndProc
);
SetWindowLongPtrA
(
hTree
,
GWLP_USERDATA
,
(
LONG_PTR
)
pOldWndProc
);
return
hTree
;
}
static
void
fill_tree
(
HWND
hTree
)
{
TVINSERTSTRUCTA
ins
;
TVITEM
tvi
;
static
CHAR
root
[]
=
"Root"
,
child
[]
=
"Child"
;
flush_sequences
(
MsgSequences
,
NUM_MSG_SEQUENCES
);
Clear
();
AddItem
(
'A'
);
ins
.
hParent
=
TVI_ROOT
;
ins
.
hInsertAfter
=
TVI_ROOT
;
U
(
ins
).
item
.
mask
=
TVIF_TEXT
;
U
(
ins
).
item
.
pszText
=
root
;
hRoot
=
TreeView_InsertItem
(
hTree
,
&
ins
);
assert
(
hRoot
);
/* UMLPad 1.15 depends on this being not -1 (I_IMAGECALLBACK) */
tvi
.
hItem
=
hRoot
;
tvi
.
mask
=
TVIF_IMAGE
|
TVIF_SELECTEDIMAGE
;
SendMessage
(
hTree
,
TVM_GETITEM
,
0
,
(
LPARAM
)
&
tvi
);
ok
(
tvi
.
iImage
==
0
,
"tvi.iImage=%d
\n
"
,
tvi
.
iImage
);
ok
(
tvi
.
iSelectedImage
==
0
,
"tvi.iSelectedImage=%d
\n
"
,
tvi
.
iSelectedImage
);
AddItem
(
'B'
);
ins
.
hParent
=
hRoot
;
ins
.
hInsertAfter
=
TVI_FIRST
;
U
(
ins
).
item
.
mask
=
TVIF_TEXT
;
U
(
ins
).
item
.
pszText
=
child
;
hChild
=
TreeView_InsertItem
(
hTree
,
&
ins
);
}
static
void
test_fillroot
(
void
)
{
TVITEM
tvi
;
hTree
=
create_treeview_control
();
flush_sequences
(
MsgSequences
,
NUM_MSG_SEQUENCES
);
fill_tree
(
hTree
);
Clear
();
AddItem
(
'A'
);
assert
(
hRoot
);
AddItem
(
'B'
);
assert
(
hChild
);
AddItem
(
'.'
);
ok_sequence
(
MsgSequences
,
TREEVIEW_SEQ_INDEX
,
FillRootSeq
,
"FillRoot"
,
FALSE
);
ok
(
!
strcmp
(
sequence
,
"AB."
),
"Item creation
\n
"
);
/* UMLPad 1.15 depends on this being not -1 (I_IMAGECALLBACK) */
tvi
.
hItem
=
hRoot
;
tvi
.
mask
=
TVIF_IMAGE
|
TVIF_SELECTEDIMAGE
;
SendMessage
(
hTree
,
TVM_GETITEM
,
0
,
(
LPARAM
)
&
tvi
);
ok
(
tvi
.
iImage
==
0
,
"tvi.iImage=%d
\n
"
,
tvi
.
iImage
);
ok
(
tvi
.
iSelectedImage
==
0
,
"tvi.iSelectedImage=%d
\n
"
,
tvi
.
iSelectedImage
);
DestroyWindow
(
hTree
);
}
static
void
TestC
allback
(
void
)
static
void
test_c
allback
(
void
)
{
HTREEITEM
hRoot
;
HTREEITEM
hItem1
,
hItem2
;
...
...
@@ -279,6 +316,9 @@ static void TestCallback(void)
CHAR
buf
[
128
];
LRESULT
ret
;
hTree
=
create_treeview_control
();
fill_tree
(
hTree
);
ret
=
TreeView_DeleteAllItems
(
hTree
);
ok
(
ret
==
TRUE
,
"ret
\n
"
);
ins
.
hParent
=
TVI_ROOT
;
...
...
@@ -329,14 +369,19 @@ static void TestCallback(void)
ok
(
ret
==
TRUE
,
"Expected GetItem return TRUE, got %ld
\n
"
,
ret
);
ok
(
strcmp
(
tvi
.
pszText
,
TEST_CALLBACK_TEXT
)
==
0
,
"Item text mismatch %s vs %s
\n
"
,
tvi
.
pszText
,
TEST_CALLBACK_TEXT
);
DestroyWindow
(
hTree
);
}
static
void
DoTest1
(
void
)
static
void
test_select
(
void
)
{
BOOL
r
;
flush_sequences
(
MsgSequences
,
NUM_MSG_SEQUENCES
);
hTree
=
create_treeview_control
();
fill_tree
(
hTree
);
/* root-none select tests */
flush_sequences
(
MsgSequences
,
NUM_MSG_SEQUENCES
);
r
=
TreeView_SelectItem
(
hTree
,
NULL
);
Clear
();
AddItem
(
'1'
);
...
...
@@ -351,15 +396,11 @@ static void DoTest1(void)
r
=
TreeView_SelectItem
(
hTree
,
hRoot
);
AddItem
(
'.'
);
ok
(
!
strcmp
(
sequence
,
"1(nR)nR23(Rn)Rn45(nR)nR."
),
"root-none select test
\n
"
);
ok_sequence
(
MsgSequences
,
TREEVIEW_SEQ_INDEX
,
DoTest1Seq
,
"DoTest1"
,
FALSE
);
}
static
void
DoTest2
(
void
)
{
BOOL
r
;
ok_sequence
(
MsgSequences
,
TREEVIEW_SEQ_INDEX
,
rootnone_select_seq
,
"root-none select seq"
,
FALSE
);
/* root-child select tests */
flush_sequences
(
MsgSequences
,
NUM_MSG_SEQUENCES
);
r
=
TreeView_SelectItem
(
hTree
,
NULL
);
Clear
();
AddItem
(
'1'
);
...
...
@@ -374,17 +415,23 @@ static void DoTest2(void)
r
=
TreeView_SelectItem
(
hTree
,
hRoot
);
AddItem
(
'.'
);
ok
(
!
strcmp
(
sequence
,
"1(nR)nR23(RC)RC45(CR)CR."
),
"root-child select test
\n
"
);
ok_sequence
(
MsgSequences
,
TREEVIEW_SEQ_INDEX
,
DoTest2Seq
,
"DoTest2"
,
FALSE
);
ok_sequence
(
MsgSequences
,
TREEVIEW_SEQ_INDEX
,
rootchild_select_seq
,
"root-child select seq"
,
FALSE
);
DestroyWindow
(
hTree
);
}
static
void
DoTest3
(
void
)
static
void
test_getitemtext
(
void
)
{
TVINSERTSTRUCTA
ins
;
HTREEITEM
hChild
;
TVITEM
tvi
;
int
nBufferSize
=
80
;
CHAR
szBuffer
[
80
]
=
"Blah"
;
int
nBufferSize
=
sizeof
(
szBuffer
)
/
sizeof
(
CHAR
);
hTree
=
create_treeview_control
();
fill_tree
(
hTree
);
flush_sequences
(
MsgSequences
,
NUM_MSG_SEQUENCES
);
...
...
@@ -406,16 +453,21 @@ static void DoTest3(void)
SendMessageA
(
hTree
,
TVM_GETITEM
,
0
,
(
LPARAM
)
&
tvi
);
ok
(
!
strcmp
(
szBuffer
,
""
),
"szBuffer=
\"
%s
\"
, expected
\"\"\n
"
,
szBuffer
);
ok
(
SendMessageA
(
hTree
,
TVM_DELETEITEM
,
0
,
(
LPARAM
)
hChild
),
"DeleteItem failed
\n
"
);
ok_sequence
(
MsgSequences
,
TREEVIEW_SEQ_INDEX
,
DoTest3Seq
,
"DoTest3"
,
FALSE
);
ok_sequence
(
MsgSequences
,
TREEVIEW_SEQ_INDEX
,
getitemtext_seq
,
"get item text seq"
,
FALSE
);
DestroyWindow
(
hTree
);
}
static
void
DoFocusTest
(
void
)
static
void
test_focus
(
void
)
{
TVINSERTSTRUCTA
ins
;
static
CHAR
child1
[]
=
"Edit"
,
child2
[]
=
"A really long string"
;
HTREEITEM
hChild1
,
hChild2
;
hTree
=
create_treeview_control
();
fill_tree
(
hTree
);
flush_sequences
(
MsgSequences
,
NUM_MSG_SEQUENCES
);
/* This test verifies that when a label is being edited, scrolling
...
...
@@ -436,12 +488,13 @@ static void DoFocusTest(void)
assert
(
hChild2
);
ShowWindow
(
hMainWnd
,
SW_SHOW
);
/* Using SendMessageA since Win98 doesn't have default unicode support */
SendMessageA
(
hTree
,
TVM_SELECTITEM
,
TVGN_CARET
,
(
LPARAM
)
hChild
);
hEdit
=
TreeView_EditLabel
(
hTree
,
hChild
);
ScrollWindowEx
(
hTree
,
-
10
,
0
,
NULL
,
NULL
,
NULL
,
NULL
,
SW_SCROLLCHILDREN
);
ok
(
GetFocus
()
==
hEdit
,
"Edit control should have focus
\n
"
);
ok_sequence
(
MsgSequences
,
TREEVIEW_SEQ_INDEX
,
DoFocusTestSeq
,
"DoFocusTest"
,
TRUE
);
ok_sequence
(
MsgSequences
,
TREEVIEW_SEQ_INDEX
,
focus_seq
,
"focus test"
,
TRUE
);
DestroyWindow
(
hTree
);
}
static
void
TestGetSetBkColor
(
void
)
...
...
@@ -620,8 +673,11 @@ static void TestGetSetUnicodeFormat(void)
SendMessage
(
hTree
,
TVM_SETUNICODEFORMAT
,
(
LPARAM
)
bPreviousSetting
,
0
);
}
static
void
TestGetS
et
(
void
)
static
void
test_gets
et
(
void
)
{
hTree
=
create_treeview_control
();
fill_tree
(
hTree
);
/* TVM_GETBKCOLOR and TVM_SETBKCOLOR */
flush_sequences
(
MsgSequences
,
NUM_MSG_SEQUENCES
);
TestGetSetBkColor
();
...
...
@@ -681,50 +737,13 @@ static void TestGetSet(void)
TestGetSetUnicodeFormat
();
ok_sequence
(
MsgSequences
,
TREEVIEW_SEQ_INDEX
,
TestGetSetUnicodeFormatSeq
,
"TestGetSetUnicodeFormat"
,
FALSE
);
}
/* This function hooks in and records all messages to the treeview control */
static
LRESULT
WINAPI
TreeviewWndProc
(
HWND
hwnd
,
UINT
message
,
WPARAM
wParam
,
LPARAM
lParam
)
{
static
LONG
defwndproc_counter
=
0
;
LRESULT
ret
;
struct
message
msg
;
WNDPROC
lpOldProc
=
(
WNDPROC
)
GetWindowLongPtrA
(
hwnd
,
GWLP_USERDATA
);
msg
.
message
=
message
;
msg
.
flags
=
sent
|
wparam
|
lparam
;
if
(
defwndproc_counter
)
msg
.
flags
|=
defwinproc
;
msg
.
wParam
=
wParam
;
msg
.
lParam
=
lParam
;
add_message
(
MsgSequences
,
TREEVIEW_SEQ_INDEX
,
&
msg
);
defwndproc_counter
++
;
ret
=
CallWindowProcA
(
lpOldProc
,
hwnd
,
message
,
wParam
,
lParam
);
defwndproc_counter
--
;
return
ret
;
DestroyWindow
(
hTree
);
}
static
LRESULT
CALLBACK
MyWndProc
(
HWND
hWnd
,
UINT
msg
,
WPARAM
wParam
,
LPARAM
lParam
)
{
WNDPROC
pOldWndProc
;
switch
(
msg
)
{
case
WM_CREATE
:
{
hTree
=
CreateWindowExA
(
WS_EX_CLIENTEDGE
,
WC_TREEVIEWA
,
NULL
,
WS_CHILD
|
WS_VISIBLE
|
TVS_LINESATROOT
|
TVS_HASLINES
|
TVS_HASBUTTONS
|
TVS_EDITLABELS
,
0
,
0
,
120
,
100
,
hWnd
,
(
HMENU
)
100
,
GetModuleHandleA
(
0
),
0
);
SetFocus
(
hTree
);
/* Record the old WNDPROC so we can call it after recording the messages */
pOldWndProc
=
(
WNDPROC
)
SetWindowLongPtrA
(
hTree
,
GWLP_WNDPROC
,
(
LONG_PTR
)
TreeviewWndProc
);
SetWindowLongPtrA
(
hTree
,
GWLP_USERDATA
,
(
LONG_PTR
)
pOldWndProc
);
return
0
;
}
case
WM_NOTIFY
:
{
NMHDR
*
pHdr
=
(
NMHDR
*
)
lParam
;
...
...
@@ -755,10 +774,6 @@ static LRESULT CALLBACK MyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa
return
0
;
}
case
WM_SIZE
:
MoveWindow
(
hTree
,
0
,
0
,
LOWORD
(
lParam
),
HIWORD
(
lParam
),
TRUE
);
break
;
case
WM_DESTROY
:
PostQuitMessage
(
0
);
break
;
...
...
@@ -769,7 +784,7 @@ static LRESULT CALLBACK MyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa
return
0L
;
}
static
void
TestExpandI
nvisible
(
void
)
static
void
test_expandi
nvisible
(
void
)
{
static
CHAR
nodeText
[][
5
]
=
{
"0"
,
"1"
,
"2"
,
"3"
,
"4"
};
TVINSERTSTRUCTA
ins
;
...
...
@@ -778,6 +793,8 @@ static void TestExpandInvisible(void)
BOOL
nodeVisible
;
LRESULT
ret
;
hTree
=
create_treeview_control
();
/* The test builds the following tree and expands then node 1, while node 0 is collapsed.
*
* 0
...
...
@@ -837,8 +854,9 @@ static void TestExpandInvisible(void)
ok
(
!
nodeVisible
,
"Node 3 should not be visible.
\n
"
);
nodeVisible
=
TreeView_GetItemRect
(
hTree
,
node
[
4
],
&
dummyRect
,
FALSE
);
ok
(
!
nodeVisible
,
"Node 4 should not be visible.
\n
"
);
}
DestroyWindow
(
hTree
);
}
START_TEST
(
treeview
)
{
...
...
@@ -880,16 +898,13 @@ START_TEST(treeview)
if
(
!
ok
(
hMainWnd
!=
NULL
,
"Failed to create parent window. Tests aborted.
\n
"
)
)
return
;
FillRoot
();
DoTest1
();
DoTest2
();
DoTest3
();
DoFocusTest
();
TestGetSet
();
/* Clears all the previous items */
TestCallback
();
/* Clears all the previous items */
TestExpandInvisible
();
test_fillroot
();
test_select
();
test_getitemtext
();
test_focus
();
test_getset
();
test_callback
();
test_expandinvisible
();
PostMessageA
(
hMainWnd
,
WM_CLOSE
,
0
,
0
);
while
(
GetMessageA
(
&
msg
,
0
,
0
,
0
))
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment