James Hawkins escribió:
Hi Alex,
The following commit introduces several windows test failures across
the board in riched20:
commit 0e9ed5c10e3ac6b253712037f0b30046a5656239
Author: Alex Villacís Lasso <[EMAIL PROTECTED]>
Date: Sun May 11 09:54:58 2008 -0500
richedit: Empty text should result in a scroll range of 0. Tests
for this behavior.
Please take a look at the test results and either fix the tests or
send in a patch to remove them.
http://test.winehq.org
Thanks,
James Hawkins
I am trying to debug the cause of this. However, I have run into a
strange problem.
The root cause of the failing tests is that GetScrollInfo() is failing
when applied to the newly created richedit window. On Windows XP-SP2 it
fails and sets GetLastError() to ERROR_NO_SCROLLBARS. On Win9x, it
fails, but leaves the last error unset. To figure out the behavior of
the richedit scrollbars, I decided to add a test for the standard
scrollbars on a generic window, so that I have a standard to compare the
richedit windows against.
The result of this is the attached patch. What I can deduce is the
following: on window creation, the scrollbars are set to a range of 0 to
100 with page 0 and position 0, but attempts to read such ranges will
fail if the window lacks both the WS_VSCROLL and the WS_HSCROLL styles -
until a range is explicitly assigned to either scrollbar, in which it
suddenly becomes readable for both. As it stands, this test passes on
WinXP-SP2 (but not in Wine). The problem is that, on Win9x only, it
seems that the styles WS_VSCROLL and WS_HSCROLL are not being set even
when requested in the CreateWindowExA(). The end result is that on Win9x
(but not on WinXP-SP2), the following failure appears
Unexpected WS_HSCROLL style, found 0 expected 1
or
Unexpected WS_VSCROLL style, found 0 expected 1
I refuse to believe this to be a genuine difference between Win9x and
WinXP-SP2, but I cannot figure out yet what I am doing wrong. Do you
have any ideas?
--
perl -e '$x=2.4;print sprintf("%.0f + %.0f = %.0f\n",$x,$x,$x+$x);'
diff --git a/dlls/user32/tests/scroll.c b/dlls/user32/tests/scroll.c
index 3bc407a..03eea9b 100644
--- a/dlls/user32/tests/scroll.c
+++ b/dlls/user32/tests/scroll.c
@@ -127,6 +127,191 @@ static void scrollbar_test3(void)
}
+static void scrollbar_test4(int fnBar, BOOL hBarEnabled, BOOL vBarEnabled)
+{
+ SCROLLINFO si;
+ LRESULT r;
+ BOOL r2;
+
+ trace("Testing bar type %d with initial style (%d,%d)\n", fnBar, hBarEnabled, vBarEnabled);
+
+ r = GetWindowLongW(hMainWnd, GWL_STYLE);
+ ok(((r & WS_HSCROLL) != 0) == hBarEnabled,
+ "Unexpected WS_HSCROLL style, found %d expected %d\n",
+ ((r & WS_HSCROLL) != 0), hBarEnabled);
+ ok(((r & WS_VSCROLL) != 0) == vBarEnabled,
+ "Unexpected WS_VSCROLL style, found %d expected %d\n",
+ ((r & WS_VSCROLL) != 0), vBarEnabled);
+ hBarEnabled = ((r & WS_HSCROLL) != 0);
+ vBarEnabled = ((r & WS_VSCROLL) != 0);
+
+ si.cbSize = sizeof(si);
+ si.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
+ si.nMin = si.nMax = si.nPos = si.nPage = 0xdeadbeef;
+ SetLastError(0xdeadbeef);
+ r2 = GetScrollInfo(hMainWnd, fnBar, &si);
+ r = GetLastError();
+ if (!(hBarEnabled || vBarEnabled)) {
+ ok(!r2, "GetScrollInfo incorrectly succeeded\n");
+ ok( r == ERROR_NO_SCROLLBARS /* WinXP */
+ || r == 0xdeadbeef /* Win98 */,
+ "GetLastError returned 0x%08lx expected 0x%08x (ERROR_NO_SCROLLBARS) or 0xdeadbeef\n",
+ r, ERROR_NO_SCROLLBARS);
+ ok(si.nMin == 0xdeadbeef, "si.nMin == 0x%x, expected 0xdeadbeef\n", si.nMin);
+ ok(si.nMax == 0xdeadbeef, "si.nMax == 0x%x, expected 0xdeadbeef\n", si.nMax);
+ ok(si.nPos == 0xdeadbeef, "si.nPos == 0x%x, expected 0xdeadbeef\n", si.nPos);
+ ok(si.nPage == 0xdeadbeef, "si.nPage == 0x%x, expected 0xdeadbeef\n", si.nPage);
+ } else {
+ ok(r2, "GetScrollInfo failed, error is %ld (0x%08lx)\n", r, r);
+ ok(si.nMin == 0, "si.nMin == %d, expected 0\n", si.nMin);
+ ok(si.nMax == 100, "si.nMax == %d, expected 100\n", si.nMax);
+ ok(si.nPos == 0, "si.nPos == %d, expected 0\n", si.nPos);
+ ok(si.nPage == 0, "si.nPage == %d, expected 0\n", si.nPage);
+ }
+
+ /* Merely removing the style has no effect on success of GetScrollInfo() */
+ SetWindowLongW(hMainWnd, GWL_STYLE, r & ~(WS_HSCROLL|WS_VSCROLL));
+ si.cbSize = sizeof(si);
+ si.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
+ si.nMin = si.nMax = si.nPos = si.nPage = 0xdeadbeef;
+ SetLastError(0xdeadbeef);
+ r2 = GetScrollInfo(hMainWnd, fnBar, &si);
+ r = GetLastError();
+ if (!(hBarEnabled || vBarEnabled)) {
+ ok(!r2, "GetScrollInfo incorrectly succeeded\n");
+ ok( r == ERROR_NO_SCROLLBARS /* WinXP */
+ || r == 0xdeadbeef /* Win98 */,
+ "GetLastError returned 0x%08lx expected 0x%08x (ERROR_NO_SCROLLBARS) or 0xdeadbeef\n",
+ r, ERROR_NO_SCROLLBARS);
+ ok(si.nMin == 0xdeadbeef, "si.nMin == 0x%x, expected 0xdeadbeef\n", si.nMin);
+ ok(si.nMax == 0xdeadbeef, "si.nMax == 0x%x, expected 0xdeadbeef\n", si.nMax);
+ ok(si.nPos == 0xdeadbeef, "si.nPos == 0x%x, expected 0xdeadbeef\n", si.nPos);
+ ok(si.nPage == 0xdeadbeef, "si.nPage == 0x%x, expected 0xdeadbeef\n", si.nPage);
+ } else {
+ ok(r2, "GetScrollInfo failed, error is %ld (0x%08lx)\n", r, r);
+ ok(si.nMin == 0, "si.nMin == %d, expected 0\n", si.nMin);
+ ok(si.nMax == 100, "si.nMax == %d, expected 100\n", si.nMax);
+ ok(si.nPos == 0, "si.nPos == %d, expected 0\n", si.nPos);
+ ok(si.nPage == 0, "si.nPage == %d, expected 0\n", si.nPage);
+ }
+
+ /* Merely setting the style has no effect on success of GetScrollInfo() */
+ SetWindowLongW(hMainWnd, GWL_STYLE, r | (WS_HSCROLL|WS_VSCROLL));
+ si.cbSize = sizeof(si);
+ si.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
+ si.nMin = si.nMax = si.nPos = si.nPage = 0xdeadbeef;
+ SetLastError(0xdeadbeef);
+ r2 = GetScrollInfo(hMainWnd, fnBar, &si);
+ r = GetLastError();
+ if (!(hBarEnabled || vBarEnabled)) {
+ ok(!r2, "GetScrollInfo incorrectly succeeded\n");
+ ok( r == ERROR_NO_SCROLLBARS /* WinXP */
+ || r == 0xdeadbeef /* Win98 */,
+ "GetLastError returned 0x%08lx expected 0x%08x (ERROR_NO_SCROLLBARS) or 0xdeadbeef\n",
+ r, ERROR_NO_SCROLLBARS);
+ ok(si.nMin == 0xdeadbeef, "si.nMin == 0x%x, expected 0xdeadbeef\n", si.nMin);
+ ok(si.nMax == 0xdeadbeef, "si.nMax == 0x%x, expected 0xdeadbeef\n", si.nMax);
+ ok(si.nPos == 0xdeadbeef, "si.nPos == 0x%x, expected 0xdeadbeef\n", si.nPos);
+ ok(si.nPage == 0xdeadbeef, "si.nPage == 0x%x, expected 0xdeadbeef\n", si.nPage);
+ } else {
+ ok(r2, "GetScrollInfo failed, error is %ld (0x%08lx)\n", r, r);
+ ok(si.nMin == 0, "si.nMin == %d, expected 0\n", si.nMin);
+ ok(si.nMax == 100, "si.nMax == %d, expected 100\n", si.nMax);
+ ok(si.nPos == 0, "si.nPos == %d, expected 0\n", si.nPos);
+ ok(si.nPage == 0, "si.nPage == %d, expected 0\n", si.nPage);
+ }
+
+ si.cbSize = sizeof(si);
+ si.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
+ si.nMin = 0;
+ si.nMax = 1024;
+ si.nPos = 512;
+ si.nPage = 16;
+ SetScrollInfo(hMainWnd, fnBar, &si, TRUE);
+ si.cbSize = sizeof(si);
+ si.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
+ si.nMin = si.nMax = si.nPos = si.nPage = 0xdeadbeef;
+ r2 = GetScrollInfo(hMainWnd, fnBar, &si);
+ ok(r2, "GetScrollInfo failed, error is %ld (0x%08lx)\n", r, r);
+ ok(si.nMin == 0, "si.nMin == %d, expected 0\n", si.nMin);
+ ok(si.nMax == 1024, "si.nMax == %d, expected 1024\n", si.nMax);
+ ok(si.nPos == 512, "si.nPos == %d, expected 512\n", si.nPos);
+ ok(si.nPage == 16, "si.nPage == %d, expected 16\n", si.nPage);
+
+ if (!(hBarEnabled || vBarEnabled)) {
+ /* What is the effect on GetScrollInfo(SB_VERT) of settings values
+ in SB_HORZ, and viceversa? */
+ si.cbSize = sizeof(si);
+ si.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
+ si.nMin = si.nMax = si.nPos = si.nPage = 0xdeadbeef;
+ r2 = GetScrollInfo(hMainWnd, ((fnBar == SB_VERT) ? SB_HORZ : SB_VERT), &si);
+ ok(r2, "GetScrollInfo failed, error is %ld (0x%08lx)\n", r, r);
+ ok(si.nMin == 0, "si.nMin == %d, expected 0\n", si.nMin);
+ ok(si.nMax == 100, "si.nMax == %d, expected 100\n", si.nMax);
+ ok(si.nPos == 0, "si.nPos == %d, expected 0\n", si.nPos);
+ ok(si.nPage == 0, "si.nPage == %d, expected 0\n", si.nPage);
+ }
+
+ SetWindowLongW(hMainWnd, GWL_STYLE, r & ~(WS_HSCROLL|WS_VSCROLL));
+ si.cbSize = sizeof(si);
+ si.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
+ si.nMin = si.nMax = si.nPos = si.nPage = 0xdeadbeef;
+ SetLastError(0xdeadbeef);
+ r2 = GetScrollInfo(hMainWnd, fnBar, &si);
+ r = GetLastError();
+ ok(r2, "GetScrollInfo failed, error is %ld (0x%08lx)\n", r, r);
+ ok(si.nMin == 0, "si.nMin == %d, expected 0\n", si.nMin);
+ ok(si.nMax == 1024, "si.nMax == %d, expected 1024\n", si.nMax);
+ ok(si.nPos == 512, "si.nPos == %d, expected 512\n", si.nPos);
+ ok(si.nPage == 16, "si.nPage == %d, expected 16\n", si.nPage);
+}
+
+static void scrollbar_test5()
+{
+ SCROLLINFO si;
+ LRESULT r;
+
+ /* Window style before assigning values */
+ r = GetWindowLongW(hMainWnd, GWL_STYLE);
+ ok (((r & (WS_VSCROLL|WS_HSCROLL)) == 0),
+ "Incorrect initial style\n");
+
+ si.cbSize = sizeof(si);
+ si.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
+ si.nMin = 0;
+ si.nMax = 1024;
+ si.nPos = 512;
+ si.nPage = 16;
+ SetScrollInfo(hMainWnd, SB_VERT, &si, TRUE);
+
+ /* Test that setting values does, in fact, set the window style */
+ r = GetWindowLongW(hMainWnd, GWL_STYLE);
+ ok (((r & (WS_VSCROLL|WS_HSCROLL)) == WS_VSCROLL),
+ "Incorrect end style style\n");
+
+ si.cbSize = sizeof(si);
+ si.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
+ si.nMin = 0;
+ si.nMax = 0;
+ si.nPos = 0;
+ si.nPage = 0;
+ SetScrollInfo(hMainWnd, SB_VERT, &si, TRUE);
+ r = GetWindowLongW(hMainWnd, GWL_STYLE);
+ ok (((r & (WS_VSCROLL|WS_HSCROLL)) == 0),
+ "Incorrect end style style\n");
+
+ si.cbSize = sizeof(si);
+ si.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
+ si.nMin = 0;
+ si.nMax = 100;
+ si.nPos = 0;
+ si.nPage = 0;
+ SetScrollInfo(hMainWnd, SB_VERT, &si, TRUE);
+ r = GetWindowLongW(hMainWnd, GWL_STYLE);
+ ok (((r & (WS_VSCROLL|WS_HSCROLL)) == WS_VSCROLL),
+ "Incorrect end style style\n");
+}
+
START_TEST ( scroll )
{
WNDCLASSA wc;
@@ -157,4 +342,64 @@ START_TEST ( scroll )
DestroyWindow(hScroll);
DestroyWindow(hMainWnd);
+
+ hMainWnd = CreateWindowExA(0, "MyTestWnd", "ScrollWindow",
+ WS_OVERLAPPEDWINDOW,
+ CW_USEDEFAULT, CW_USEDEFAULT, 100, 100, NULL, NULL, GetModuleHandleA(NULL), 0);
+ DestroyWindow(hScroll);
+ scrollbar_test4(SB_VERT, FALSE, FALSE);
+ DestroyWindow(hMainWnd);
+ hMainWnd = CreateWindowExA(0, "MyTestWnd", "ScrollWindow",
+ WS_OVERLAPPEDWINDOW,
+ CW_USEDEFAULT, CW_USEDEFAULT, 100, 100, NULL, NULL, GetModuleHandleA(NULL), 0);
+ DestroyWindow(hScroll);
+ scrollbar_test4(SB_HORZ, FALSE, FALSE);
+ DestroyWindow(hMainWnd);
+
+ hMainWnd = CreateWindowExA(0, "MyTestWnd", "ScrollWindow",
+ WS_OVERLAPPEDWINDOW|WS_VSCROLL,
+ CW_USEDEFAULT, CW_USEDEFAULT, 100, 100, NULL, NULL, GetModuleHandleA(NULL), 0);
+ DestroyWindow(hScroll);
+ scrollbar_test4(SB_VERT, FALSE, TRUE);
+ DestroyWindow(hMainWnd);
+ hMainWnd = CreateWindowExA(0, "MyTestWnd", "ScrollWindow",
+ WS_OVERLAPPEDWINDOW|WS_VSCROLL,
+ CW_USEDEFAULT, CW_USEDEFAULT, 100, 100, NULL, NULL, GetModuleHandleA(NULL), 0);
+ DestroyWindow(hScroll);
+ scrollbar_test4(SB_HORZ, FALSE, TRUE);
+ DestroyWindow(hMainWnd);
+
+ hMainWnd = CreateWindowExA(0, "MyTestWnd", "ScrollWindow",
+ WS_OVERLAPPEDWINDOW|WS_HSCROLL,
+ CW_USEDEFAULT, CW_USEDEFAULT, 100, 100, NULL, NULL, GetModuleHandleA(NULL), 0);
+ DestroyWindow(hScroll);
+ scrollbar_test4(SB_VERT, TRUE, FALSE);
+ DestroyWindow(hMainWnd);
+ hMainWnd = CreateWindowExA(0, "MyTestWnd", "ScrollWindow",
+ WS_OVERLAPPEDWINDOW|WS_HSCROLL,
+ CW_USEDEFAULT, CW_USEDEFAULT, 100, 100, NULL, NULL, GetModuleHandleA(NULL), 0);
+ DestroyWindow(hScroll);
+ scrollbar_test4(SB_HORZ, TRUE, FALSE);
+ DestroyWindow(hMainWnd);
+
+ hMainWnd = CreateWindowExA(0, "MyTestWnd", "ScrollWindow",
+ WS_OVERLAPPEDWINDOW|WS_VSCROLL|WS_HSCROLL,
+ CW_USEDEFAULT, CW_USEDEFAULT, 100, 100, NULL, NULL, GetModuleHandleA(NULL), 0);
+ DestroyWindow(hScroll);
+ scrollbar_test4(SB_VERT, TRUE, TRUE);
+ DestroyWindow(hMainWnd);
+ hMainWnd = CreateWindowExA(0, "MyTestWnd", "ScrollWindow",
+ WS_OVERLAPPEDWINDOW|WS_VSCROLL|WS_HSCROLL,
+ CW_USEDEFAULT, CW_USEDEFAULT, 100, 100, NULL, NULL, GetModuleHandleA(NULL), 0);
+ DestroyWindow(hScroll);
+ scrollbar_test4(SB_HORZ, TRUE, TRUE);
+ DestroyWindow(hMainWnd);
+
+ hMainWnd = CreateWindowExA(0, "MyTestWnd", "ScrollWindow",
+ WS_OVERLAPPEDWINDOW,
+ CW_USEDEFAULT, CW_USEDEFAULT, 100, 100, NULL, NULL, GetModuleHandleA(NULL), 0);
+ DestroyWindow(hScroll);
+ scrollbar_test5();
+ DestroyWindow(hMainWnd);
+
}