-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIN32KNT_APITEST] Add NtUserSetTimer API tests #7100
base: master
Are you sure you want to change the base?
Conversation
int countErrors = 0; | ||
|
||
int minMessages = (SLEEP_TIME / TEST1_INTERVAL) * (1 - TIME_TOLERANCE); | ||
int maxMessages = (SLEEP_TIME / TEST1_INTERVAL) * (1 + TIME_TOLERANCE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SLEEP_TIME
and TEST1_INTERVAL
are integers; 1 is also integer but TIME_TOLERANCE
is a float; I wonder whether you correctly get what you want here.
Namely, your 1 - TIME_TOLERANCE
going to be zero and 1 + TIME_TOLERANCE
going to be 1... 🤔 🤔
Co-authored-by: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito@reactos.org>
Co-authored-by: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito@reactos.org>
Co-authored-by: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito@reactos.org>
Co-authored-by: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito@reactos.org>
Co-authored-by: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito@reactos.org>
Co-authored-by: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito@reactos.org>
Co-authored-by: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito@reactos.org>
Co-authored-by: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito@reactos.org>
Co-authored-by: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito@reactos.org>
HBelusca I have modified the code based on your suggestions. |
HBelusca The number of messages is highly indicative, as it takes several milliseconds to initialize, etc. That's why there is a 50% tolerance to received messages count. It worked for me without overwriting, but I understand that if we change the values, it could lead to miscalculation. Anyway, we'll see how it behaves on the server, maybe we need to give the tolerance even higher. |
I'll separate the tests without and with the window. |
Helped with review comments, please recheck. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last suggestions:
- static-ize functions that are used only within this file;
- add a comment explaining for what they are used.
- MessageLoop() function seems to be unused.
Co-authored-by: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito@reactos.org>
Co-authored-by: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito@reactos.org>
Co-authored-by: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito@reactos.org>
Co-authored-by: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito@reactos.org>
Co-authored-by: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito@reactos.org>
Co-authored-by: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito@reactos.org>
Co-authored-by: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito@reactos.org>
I'm still wondering if it would be safer to have a timer count of 32767 instead of 32768 if some application used INT instead of UINT for SetTimer. Are we sure that windows has 32768? |
You mean, for the 2nd parameter Sorry to ask, in case this has been already addressed and discussed: in the SetTimer() msdn page, it's written:
Is this correctly handled? |
// TEST WITH MESSAGES WITHOUT WINDOW - test different ids | ||
TEST(test3()); | ||
|
||
WNDCLASS wc = { 0 }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using explicitly unicode window class & functions:
WNDCLASS wc = { 0 }; | |
WNDCLASSW wc = { 0 }; |
wc.lpszClassName = "TimerWindowClass"; | ||
RegisterClass(&wc); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wc.lpszClassName = "TimerWindowClass"; | |
RegisterClass(&wc); | |
wc.lpszClassName = L"TimerWindowClass"; | |
RegisterClassW(&wc); |
I wonder whether we should check the returned value from RegisterClass ...
wc.lpszClassName = "TimerWindowClass"; | ||
RegisterClass(&wc); | ||
|
||
HWND hwnd = CreateWindowEx(0, "TimerWindowClass", "Timer Window", 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HWND hwnd = CreateWindowEx(0, "TimerWindowClass", "Timer Window", 0, | |
HWND hwnd = CreateWindowExW(0, L"TimerWindowClass", L"Timer Window", 0, |
|
||
if (hwnd != NULL) | ||
DestroyWindow(hwnd); | ||
UnregisterClass("TimerWindowClass", GetModuleHandle(NULL)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hInstance comment:
UnregisterClass("TimerWindowClass", GetModuleHandle(NULL)); | |
UnregisterClassW(L"TimerWindowClass", NULL); |
2nd parameter is optional and when giving NULL it does the same thing as GetModuleHandle(NULL)
Alternatively if you want to keep GetModuleHandle explicit, I would suggest you add a
HINSTANCE hInstance = GetModuleHandle(NULL);
at the beginning of the START_TEST(...) function, and then use that hInstance
variable in all these places where you need it.
|
||
WNDCLASS wc = { 0 }; | ||
wc.lpfnWndProc = WindowProc; | ||
wc.hInstance = GetModuleHandle(NULL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See other hInstance comment.
|
||
HWND hwnd = CreateWindowEx(0, "TimerWindowClass", "Timer Window", 0, | ||
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, | ||
HWND_MESSAGE, NULL, GetModuleHandle(NULL), NULL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See other hInstance comment.
Purpose
Addition of apitests for NtUserSetTimer
JIRA issue: CORE-9141
Proposed changes
Test 1 - test of creating/canceling 20 timers and comparing the raw number of returned messages - without parent window
Test 2 - test of creating/cancelling 20 timers and comparing the raw number of returned messages - with parent window
Test 3 - test creation/cancellation of 40000 timers - without parent window
Test 4 - test of creation/cancellation of 40000 timers - with parent window
Test 5 - test creation/cancellation of 2 timers and compare their index to see if they differ - without parent window