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
194450d8
Commit
194450d8
authored
Jul 12, 2004
by
Mike McCormack
Committed by
Alexandre Julliard
Jul 12, 2004
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a regression test for accelerators.
parent
e983f757
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
198 additions
and
2 deletions
+198
-2
resource.c
dlls/user/tests/resource.c
+198
-2
No files found.
dlls/user/tests/resource.c
View file @
194450d8
/* Unit test suite for resources.
*
* Copyright 2004 Ferenc Wagner
* Copyright 2003, 2004 Mike McCormack
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
...
...
@@ -22,8 +23,7 @@
#include "wine/test.h"
void
test_LoadStringA
(
void
)
static
void
test_LoadStringA
(
void
)
{
HINSTANCE
hInst
=
GetModuleHandle
(
NULL
);
static
const
char
str
[]
=
"String resource"
;
/* same in resource.rc */
...
...
@@ -53,7 +53,203 @@ test_LoadStringA (void)
}
}
static
void
test_accel1
(
void
)
{
UINT
r
,
n
;
HACCEL
hAccel
;
ACCEL
ac
[
10
];
/* now create our own valid accelerator table */
n
=
0
;
ac
[
n
].
cmd
=
1000
;
ac
[
n
].
key
=
'A'
;
ac
[
n
++
].
fVirt
=
FVIRTKEY
|
FNOINVERT
;
ac
[
n
].
cmd
=
1001
;
ac
[
n
].
key
=
'B'
;
ac
[
n
++
].
fVirt
=
FNOINVERT
;
ac
[
n
].
cmd
=
0
;
ac
[
n
].
key
=
0
;
ac
[
n
++
].
fVirt
=
0
;
hAccel
=
CreateAcceleratorTable
(
&
ac
[
0
],
n
);
ok
(
hAccel
!=
NULL
,
"create accelerator table
\n
"
);
r
=
DestroyAcceleratorTable
(
hAccel
);
ok
(
r
,
"destroy accelerator table
\n
"
);
/* now try create an invalid one */
n
=
0
;
ac
[
n
].
cmd
=
1000
;
ac
[
n
].
key
=
'A'
;
ac
[
n
++
].
fVirt
=
FVIRTKEY
|
FNOINVERT
;
ac
[
n
].
cmd
=
0xffff
;
ac
[
n
].
key
=
0xffff
;
ac
[
n
++
].
fVirt
=
(
SHORT
)
0xffff
;
ac
[
n
].
cmd
=
0xfff0
;
ac
[
n
].
key
=
0xffff
;
ac
[
n
++
].
fVirt
=
(
SHORT
)
0xfff0
;
ac
[
n
].
cmd
=
0xfff0
;
ac
[
n
].
key
=
0xffff
;
ac
[
n
++
].
fVirt
=
(
SHORT
)
0x0000
;
ac
[
n
].
cmd
=
0xfff0
;
ac
[
n
].
key
=
0xffff
;
ac
[
n
++
].
fVirt
=
(
SHORT
)
0x0001
;
hAccel
=
CreateAcceleratorTable
(
&
ac
[
0
],
n
);
ok
(
hAccel
!=
NULL
,
"create accelerator table
\n
"
);
r
=
CopyAcceleratorTable
(
hAccel
,
NULL
,
0
);
ok
(
r
==
n
,
"two entries in table
\n
"
);
r
=
CopyAcceleratorTable
(
hAccel
,
&
ac
[
0
],
r
);
ok
(
r
==
n
,
"still should be two entries in table
\n
"
);
n
=
0
;
ok
(
ac
[
n
].
cmd
==
1000
,
"cmd 0 not preserved
\n
"
);
ok
(
ac
[
n
].
key
==
'A'
,
"key 0 not preserved
\n
"
);
ok
(
ac
[
n
].
fVirt
==
(
FVIRTKEY
|
FNOINVERT
),
"fVirt 0 not preserved
\n
"
);
n
++
;
ok
(
ac
[
n
].
cmd
==
0xffff
,
"cmd 1 not preserved
\n
"
);
ok
(
ac
[
n
].
key
==
0xffff
,
"key 1 not preserved
\n
"
);
ok
(
ac
[
n
].
fVirt
==
0x007f
,
"fVirt 1 not changed
\n
"
);
n
++
;
ok
(
ac
[
n
].
cmd
==
0xfff0
,
"cmd 2 not preserved
\n
"
);
ok
(
ac
[
n
].
key
==
0x00ff
,
"key 2 not preserved
\n
"
);
ok
(
ac
[
n
].
fVirt
==
0x0070
,
"fVirt 2 not changed
\n
"
);
n
++
;
ok
(
ac
[
n
].
cmd
==
0xfff0
,
"cmd 3 not preserved
\n
"
);
ok
(
ac
[
n
].
key
==
0x00ff
,
"key 3 not preserved
\n
"
);
ok
(
ac
[
n
].
fVirt
==
0x0000
,
"fVirt 3 not changed
\n
"
);
n
++
;
ok
(
ac
[
n
].
cmd
==
0xfff0
,
"cmd 4 not preserved
\n
"
);
ok
(
ac
[
n
].
key
==
0xffff
,
"key 4 not preserved
\n
"
);
ok
(
ac
[
n
].
fVirt
==
0x0001
,
"fVirt 4 not changed
\n
"
);
r
=
DestroyAcceleratorTable
(
hAccel
);
ok
(
r
,
"destroy accelerator table
\n
"
);
hAccel
=
CreateAcceleratorTable
(
&
ac
[
0
],
0
);
ok
(
!
hAccel
,
"zero elements should fail
\n
"
);
/* these will on crash win2k
hAccel = CreateAcceleratorTable( NULL, 1 );
hAccel = CreateAcceleratorTable( &ac[0], -1 );
*/
}
/*
* memcmp on the tables works in Windows, but does not work in wine, as
* there is an extra undefined and unused byte between fVirt and the key
*/
static
void
test_accel2
(
void
)
{
ACCEL
ac
[
2
],
out
[
2
];
HACCEL
hac
;
ac
[
0
].
cmd
=
0
;
ac
[
0
].
fVirt
=
0
;
ac
[
0
].
key
=
0
;
ac
[
1
].
cmd
=
0
;
ac
[
1
].
fVirt
=
0
;
ac
[
1
].
key
=
0
;
/*
* crashes on win2k
* hac = CreateAcceleratorTable( NULL, 1 );
*/
/* try a zero count */
hac
=
CreateAcceleratorTable
(
&
ac
[
0
],
0
);
ok
(
!
hac
,
"fail
\n
"
);
ok
(
!
DestroyAcceleratorTable
(
hac
),
"destroy failed
\n
"
);
/* creating one accelerator should work */
hac
=
CreateAcceleratorTable
(
&
ac
[
0
],
1
);
ok
(
hac
!=
NULL
,
"fail
\n
"
);
ok
(
1
==
CopyAcceleratorTable
(
hac
,
out
,
1
),
"copy failed
\n
"
);
ok
(
DestroyAcceleratorTable
(
hac
),
"destroy failed
\n
"
);
/* how about two of the same type? */
hac
=
CreateAcceleratorTable
(
&
ac
[
0
],
2
);
ok
(
hac
!=
NULL
,
"fail
\n
"
);
ok
(
2
==
CopyAcceleratorTable
(
hac
,
NULL
,
100
),
"copy null failed
\n
"
);
ok
(
2
==
CopyAcceleratorTable
(
hac
,
NULL
,
0
),
"copy null failed
\n
"
);
ok
(
2
==
CopyAcceleratorTable
(
hac
,
NULL
,
1
),
"copy null failed
\n
"
);
ok
(
1
==
CopyAcceleratorTable
(
hac
,
out
,
1
),
"copy 1 failed
\n
"
);
ok
(
2
==
CopyAcceleratorTable
(
hac
,
out
,
2
),
"copy 2 failed
\n
"
);
ok
(
DestroyAcceleratorTable
(
hac
),
"destroy failed
\n
"
);
/* ok( !memcmp( ac, out, sizeof ac ), "tables different\n"); */
/* how about two of the same type with a non-zero key? */
ac
[
0
].
key
=
0x20
;
ac
[
1
].
key
=
0x20
;
hac
=
CreateAcceleratorTable
(
&
ac
[
0
],
2
);
ok
(
hac
!=
NULL
,
"fail
\n
"
);
ok
(
2
==
CopyAcceleratorTable
(
hac
,
out
,
2
),
"copy 2 failed
\n
"
);
ok
(
DestroyAcceleratorTable
(
hac
),
"destroy failed
\n
"
);
/* ok( !memcmp( ac, out, sizeof ac ), "tables different\n"); */
/* how about two of the same type with a non-zero virtual key? */
ac
[
0
].
fVirt
=
FVIRTKEY
;
ac
[
0
].
key
=
0x40
;
ac
[
1
].
fVirt
=
FVIRTKEY
;
ac
[
1
].
key
=
0x40
;
hac
=
CreateAcceleratorTable
(
&
ac
[
0
],
2
);
ok
(
hac
!=
NULL
,
"fail
\n
"
);
ok
(
2
==
CopyAcceleratorTable
(
hac
,
out
,
2
),
"copy 2 failed
\n
"
);
/* ok( !memcmp( ac, out, sizeof ac ), "tables different\n"); */
ok
(
DestroyAcceleratorTable
(
hac
),
"destroy failed
\n
"
);
/* how virtual key codes */
ac
[
0
].
fVirt
=
FVIRTKEY
;
hac
=
CreateAcceleratorTable
(
&
ac
[
0
],
1
);
ok
(
hac
!=
NULL
,
"fail
\n
"
);
ok
(
1
==
CopyAcceleratorTable
(
hac
,
out
,
2
),
"copy 2 failed
\n
"
);
/* ok( !memcmp( ac, out, sizeof ac/2 ), "tables different\n"); */
ok
(
DestroyAcceleratorTable
(
hac
),
"destroy failed
\n
"
);
/* how turning on all bits? */
ac
[
0
].
cmd
=
0xffff
;
ac
[
0
].
fVirt
=
0xff
;
ac
[
0
].
key
=
0xffff
;
hac
=
CreateAcceleratorTable
(
&
ac
[
0
],
1
);
ok
(
hac
!=
NULL
,
"fail
\n
"
);
ok
(
1
==
CopyAcceleratorTable
(
hac
,
out
,
1
),
"copy 1 failed
\n
"
);
/* ok( memcmp( ac, out, sizeof ac/2 ), "tables not different\n"); */
ok
(
out
[
0
].
cmd
==
ac
[
0
].
cmd
,
"cmd modified
\n
"
);
ok
(
out
[
0
].
fVirt
==
(
ac
[
0
].
fVirt
&
0x7f
),
"fVirt not modified
\n
"
);
ok
(
out
[
0
].
key
==
ac
[
0
].
key
,
"key modified
\n
"
);
ok
(
DestroyAcceleratorTable
(
hac
),
"destroy failed
\n
"
);
/* how turning on all bits? */
memset
(
ac
,
0xff
,
sizeof
ac
);
hac
=
CreateAcceleratorTable
(
&
ac
[
0
],
2
);
ok
(
hac
!=
NULL
,
"fail
\n
"
);
ok
(
2
==
CopyAcceleratorTable
(
hac
,
out
,
2
),
"copy 2 failed
\n
"
);
/* ok( memcmp( ac, out, sizeof ac ), "tables not different\n"); */
ok
(
out
[
0
].
cmd
==
ac
[
0
].
cmd
,
"cmd modified
\n
"
);
ok
(
out
[
0
].
fVirt
==
(
ac
[
0
].
fVirt
&
0x7f
),
"fVirt not modified
\n
"
);
ok
(
out
[
0
].
key
==
ac
[
0
].
key
,
"key modified
\n
"
);
ok
(
out
[
1
].
cmd
==
ac
[
1
].
cmd
,
"cmd modified
\n
"
);
ok
(
out
[
1
].
fVirt
==
(
ac
[
1
].
fVirt
&
0x7f
),
"fVirt not modified
\n
"
);
ok
(
out
[
1
].
key
==
ac
[
1
].
key
,
"key modified
\n
"
);
ok
(
DestroyAcceleratorTable
(
hac
),
"destroy failed
\n
"
);
}
START_TEST
(
resource
)
{
test_LoadStringA
();
test_accel1
();
test_accel2
();
}
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