Module: wine Branch: master Commit: 86ea6b582088ea347c712be333b85f41aadb1026 URL: http://source.winehq.org/git/wine.git/?a=commit;h=86ea6b582088ea347c712be333...
Author: Farshad Agah f_agah@yahoo.com Date: Fri Mar 16 00:34:36 2007 -0700
comctl32: monthcal: Correct the return value in MCM_SETFIRSTDAYOFWEEK.
---
dlls/comctl32/monthcal.c | 20 +++++---- dlls/comctl32/tests/monthcal.c | 89 +++++++++++++++++++++++++++------------ 2 files changed, 73 insertions(+), 36 deletions(-)
diff --git a/dlls/comctl32/monthcal.c b/dlls/comctl32/monthcal.c index ded5c5c..9f25689 100644 --- a/dlls/comctl32/monthcal.c +++ b/dlls/comctl32/monthcal.c @@ -897,19 +897,23 @@ static LRESULT MONTHCAL_SetFirstDayOfWeek(MONTHCAL_INFO *infoPtr, LPARAM lParam) { int prev = infoPtr->firstDay; + int localFirstDay; WCHAR buf[40];
TRACE("day %ld\n", lParam);
- if((lParam >= 0) && (lParam < 7)) { - infoPtr->firstDay = (int)lParam; - } + GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_IFIRSTDAYOFWEEK, buf, countof(buf)); + TRACE("%s %d\n", debugstr_w(buf), strlenW(buf)); + + localFirstDay = atoiW(buf); + + if(lParam == -1) + infoPtr->firstDay = MAKELONG(localFirstDay, FALSE); + else if(lParam >= 7) + infoPtr->firstDay = MAKELONG(localFirstDay, TRUE); else - { - GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_IFIRSTDAYOFWEEK, buf, countof(buf)); - TRACE("%s %d\n", debugstr_w(buf), strlenW(buf)); - infoPtr->firstDay = (atoiW(buf)+1)%7; - } + infoPtr->firstDay = MAKELONG(lParam, TRUE); + return prev; }
diff --git a/dlls/comctl32/tests/monthcal.c b/dlls/comctl32/tests/monthcal.c index 5552ba9..47648a1 100644 --- a/dlls/comctl32/tests/monthcal.c +++ b/dlls/comctl32/tests/monthcal.c @@ -135,26 +135,56 @@ static const struct message monthcal_curr_date_seq[] = {
static const struct message monthcal_first_day_seq[] = { { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0}, - { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0},
+ { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, -5}, { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0}, - { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 1},
+ { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, -4}, { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0}, - { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 2},
+ { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, -3}, { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0}, - { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 3},
+ { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, -2}, { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0}, - { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 4},
+ { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, -1}, + { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0}, + + { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0}, + { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0}, + + { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 1}, + { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0}, + + { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 2}, { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0}, - { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 5},
+ { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 3}, { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0}, + + { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 4}, + { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0}, + + { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 5}, + { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0}, + { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 6}, + { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0}, + + { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 7}, + { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0}, + + { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 8}, + { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0}, + + { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 9}, + { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0},
+ { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 10}, + { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0}, + + { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 11}, { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0}, { 0 } }; @@ -583,40 +613,43 @@ static void test_monthcal_currDate(HWND hwnd)
static void test_monthcal_firstDay(HWND hwnd) { - int res, fday, i, temp; + int res, fday, i, prev; TCHAR b[128]; LCID lcid = LOCALE_USER_DEFAULT;
flush_sequences(sequences, NUM_MSG_SEQUENCES);
/* Setter and Getters for first day of week */ - todo_wine { - /* check for locale first day */ - if(GetLocaleInfo(lcid, LOCALE_IFIRSTDAYOFWEEK, b, 128)){ - fday = atoi(b); - res = SendMessage(hwnd, MCM_GETFIRSTDAYOFWEEK, 0, 0); - expect(fday, res); - res = SendMessage(hwnd, MCM_SETFIRSTDAYOFWEEK, 0, (LPARAM) 0); - expect(fday, res); - }else{ - skip("Cannot retrieve first day of the week\n"); - SendMessage(hwnd, MCM_SETFIRSTDAYOFWEEK, 0, (LPARAM) 0); - } + /* check for locale first day */ + if(GetLocaleInfo(lcid, LOCALE_IFIRSTDAYOFWEEK, b, 128)){ + fday = atoi(b); + res = SendMessage(hwnd, MCM_GETFIRSTDAYOFWEEK, 0, 0); + expect(fday, res); + prev = fday;
- /* check for days of the week*/ - for (i = 1, temp = 0x10000; i < 7; i++, temp++){ - res = SendMessage(hwnd, MCM_GETFIRSTDAYOFWEEK, 0, 0); - expect(temp, res); + /* checking for the values that actually will be stored as */ + /* current first day when we set a new value */ + for (i = -5; i < 12; i++){ res = SendMessage(hwnd, MCM_SETFIRSTDAYOFWEEK, 0, (LPARAM) i); - expect(temp, res); + expect(prev, res); + res = SendMessage(hwnd, MCM_GETFIRSTDAYOFWEEK, 0, 0); + prev = res; + + if (i == -1){ + expect(MAKELONG(fday, FALSE), res); + }else if (i >= 7){ + expect(MAKELONG(fday, TRUE), res); + }else{ + expect(MAKELONG(i, TRUE), res); + } }
- /* check for returning to the original first day */ - res = SendMessage(hwnd, MCM_GETFIRSTDAYOFWEEK, 0, 0); - todo_wine {expect(temp, res);} + ok_sequence(sequences, MONTHCAL_SEQ_INDEX, monthcal_first_day_seq, "monthcal firstDay", FALSE); + + }else{ + skip("Cannot retrieve first day of the week\n"); }
- ok_sequence(sequences, MONTHCAL_SEQ_INDEX, monthcal_first_day_seq, "monthcal firstDay", FALSE); }
static void test_monthcal_unicode(HWND hwnd)