user32/tests: Skip tests for window messages if we failed to receive foreground status.
Signed-off-by: Zebediah Figura <z.figura12@gmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
f312758bf0
commit
7ae7fbcc91
|
@ -691,14 +691,17 @@ static struct message sent_messages[MAXKEYMESSAGES];
|
|||
static UINT sent_messages_cnt;
|
||||
|
||||
/* Verify that only specified key state transitions occur */
|
||||
static void compare_and_check(int id, BYTE *ks1, BYTE *ks2, const struct sendinput_test_s *test)
|
||||
static void compare_and_check(int id, BYTE *ks1, BYTE *ks2,
|
||||
const struct sendinput_test_s *test, BOOL foreground)
|
||||
{
|
||||
int i, failcount = 0;
|
||||
const struct transition_s *t = test->expected_transitions;
|
||||
UINT actual_cnt = 0;
|
||||
const struct message *expected = test->expected_messages;
|
||||
|
||||
while (t->wVk) {
|
||||
while (t->wVk && foreground) {
|
||||
/* We won't receive any information from GetKeyboardState() if we're
|
||||
* not the foreground window. */
|
||||
BOOL matched = ((ks1[t->wVk]&0x80) == (t->before_state&0x80)
|
||||
&& (ks2[t->wVk]&0x80) == (~t->before_state&0x80));
|
||||
|
||||
|
@ -781,6 +784,13 @@ static void compare_and_check(int id, BYTE *ks1, BYTE *ks2, const struct sendinp
|
|||
expected++;
|
||||
continue;
|
||||
}
|
||||
else if (!(expected->flags & hook) && !foreground)
|
||||
{
|
||||
/* If we weren't able to receive foreground status, we won't get
|
||||
* any window messages. */
|
||||
expected++;
|
||||
continue;
|
||||
}
|
||||
/* NT4 doesn't send SYSKEYDOWN/UP to hooks, only KEYDOWN/UP */
|
||||
else if ((expected->flags & hook) &&
|
||||
(expected->message == WM_SYSKEYDOWN || expected->message == WM_SYSKEYUP) &&
|
||||
|
@ -817,7 +827,7 @@ static void compare_and_check(int id, BYTE *ks1, BYTE *ks2, const struct sendinp
|
|||
expected++;
|
||||
}
|
||||
/* skip all optional trailing messages */
|
||||
while (expected->message && (expected->flags & optional))
|
||||
while (expected->message && ((expected->flags & optional) || (!(expected->flags & hook) && !foreground)))
|
||||
expected++;
|
||||
|
||||
|
||||
|
@ -897,6 +907,7 @@ static void test_Input_blackbox(void)
|
|||
int ii;
|
||||
BYTE ks1[256], ks2[256];
|
||||
LONG_PTR prevWndProc;
|
||||
BOOL foreground;
|
||||
HWND window;
|
||||
HHOOK hook;
|
||||
|
||||
|
@ -910,7 +921,9 @@ static void test_Input_blackbox(void)
|
|||
NULL, NULL);
|
||||
ok(window != NULL, "error: %d\n", (int) GetLastError());
|
||||
SetWindowPos( window, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE );
|
||||
SetForegroundWindow( window );
|
||||
foreground = SetForegroundWindow( window );
|
||||
if (!foreground)
|
||||
skip("Failed to set foreground window; some tests will be skipped.\n");
|
||||
|
||||
if (!(hook = SetWindowsHookExA(WH_KEYBOARD_LL, hook_proc, GetModuleHandleA( NULL ), 0)))
|
||||
{
|
||||
|
@ -939,15 +952,7 @@ static void test_Input_blackbox(void)
|
|||
pSendInput(1, (INPUT*)&i, sizeof(TEST_INPUT));
|
||||
empty_message_queue();
|
||||
GetKeyboardState(ks2);
|
||||
if (!ii && sent_messages_cnt <= 1 && !memcmp( ks1, ks2, sizeof(ks1) ))
|
||||
{
|
||||
win_skip( "window doesn't receive the queued input\n" );
|
||||
/* release the key */
|
||||
i.u.ki.dwFlags |= KEYEVENTF_KEYUP;
|
||||
pSendInput(1, (INPUT*)&i, sizeof(TEST_INPUT));
|
||||
break;
|
||||
}
|
||||
compare_and_check(ii, ks1, ks2, &sendinput_test[ii]);
|
||||
compare_and_check(ii, ks1, ks2, &sendinput_test[ii], foreground);
|
||||
}
|
||||
|
||||
empty_message_queue();
|
||||
|
|
Loading…
Reference in New Issue