The msctf:inputprocessor test is not reliable

Francois Gouget fgouget at
Sat Sep 10 07:03:45 CDT 2011

This test is not reliable on my Debian desktop.

inputprocessor.c:2117: Test failed: OnSetFocus expected current focus 0x12b070 got 0x12b0d0
inputprocessor.c:538: Test failed: Unexpected ThreadMgrEventSink_OnSetFocus sink
inputprocessor.c:549: Test failed: Sink reports wrong previous focus

If I run it in a loop it fails about once every twelve times:

i=0;while ../../../tools/runtest inputprocessor.c && [ $i -lt 100 ];do i=`expr $i + 1`; echo $i; done

Introducing a single Sleep(50) as shown below makes it totally 
reliable here.

+    Sleep(50);

     test_CurrentFocus = FOCUS_SAVE;
     test_PrevFocus = FOCUS_SAVE;
     test_OnSetFocus = SINK_SAVE;
     /* ^^^ Line that fails! */

That seems pretty hacky though. I suspect this is all because 
processPendingMessages() will exit if there's no pending message right 
after we call SetFocus() without giving enough time for the asynchronous 
X event to arrive.

But I'm surprised that a single Sleep() fixes the issue, especially 
where it's placed. Also I don't know anything about msctf so I'm unsure 
how ThreadMgrEventSink_OnSetFocus() figures in all this.

So should I just submit a patch to add that Sleep()?

Or would it be better to change processPendingMessages() to look more 
like user32/tests/msg.c's flush_events() function although it looks like 
it's overkill for now?

Francois Gouget <fgouget at>    
                Linux: It is now safe to turn on your computer.

More information about the wine-devel mailing list