Reactos
at master 81 lines 2.6 kB view raw
1/* 2 * PROJECT: ReactOS API tests 3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+) 4 * PURPOSE: Test for SHGetUnreadMailCountW 5 * COPYRIGHT: Copyright 2025 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com) 6 */ 7 8#include "shelltest.h" 9 10static VOID SetUnreadMailInfo(PDWORD pdwDisposition) 11{ 12 HKEY hKey; 13 LSTATUS error = RegCreateKeyExW( 14 HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\UnreadMail\\example.com", 15 0, NULL, 0, KEY_WRITE, NULL, &hKey, pdwDisposition); 16 ok_long(error, ERROR_SUCCESS); 17 18 DWORD dwCount = 1; 19 error = SHSetValueW(hKey, NULL, L"MessageCount", REG_DWORD, &dwCount, sizeof(dwCount)); 20 ok_long(error, ERROR_SUCCESS); 21 22 FILETIME FileTime; 23 GetSystemTimeAsFileTime(&FileTime); 24 error = SHSetValueW(hKey, NULL, L"TimeStamp", REG_BINARY, &FileTime, sizeof(FileTime)); 25 ok_long(error, ERROR_SUCCESS); 26 27 LPCWSTR pszApp = L"MyMailerApp"; 28 DWORD cbValue = (lstrlenW(pszApp) + 1) * sizeof(WCHAR); 29 error = SHSetValueW(hKey, NULL, L"Application", REG_SZ, pszApp, cbValue); 30 ok_long(error, ERROR_SUCCESS); 31 32 RegCloseKey(hKey); 33} 34 35START_TEST(SHGetUnreadMailCountW) 36{ 37 HRESULT hr; 38 39 DWORD dwDisposition; 40 SetUnreadMailInfo(&dwDisposition); 41 42 hr = SHGetUnreadMailCountW(NULL, L"example.com", NULL, NULL, NULL, 0); 43 ok_hex(hr, S_OK); 44 45 FILETIME FileTime; 46 ZeroMemory(&FileTime, sizeof(FileTime)); 47 hr = SHGetUnreadMailCountW(HKEY_CURRENT_USER, L"example.com", NULL, &FileTime, NULL, 0); 48 ok_hex(hr, S_OK); 49 ok(FileTime.dwHighDateTime != 0, "FileTime.dwHighDateTime was zero\n"); 50 51 DWORD dwCount = 0; 52 ZeroMemory(&FileTime, sizeof(FileTime)); 53 hr = SHGetUnreadMailCountW(NULL, NULL, &dwCount, &FileTime, NULL, 0); 54 ok_hex(hr, S_OK); 55 ok_long(dwCount, 1); 56 ok_long(FileTime.dwHighDateTime, 0); 57 58 dwCount = 0; 59 hr = SHGetUnreadMailCountW(NULL, L"example.com", &dwCount, NULL, NULL, 0); 60 ok_hex(hr, S_OK); 61 ok_long(dwCount, 1); 62 63 hr = SHGetUnreadMailCountW(NULL, NULL, &dwCount, NULL, NULL, 0); 64 ok_hex(hr, S_OK); 65 66 WCHAR szAppName[MAX_PATH]; 67 dwCount = 0; 68 hr = SHGetUnreadMailCountW(NULL, NULL, &dwCount, NULL, szAppName, _countof(szAppName)); 69 ok_hex(hr, E_INVALIDARG); 70 ok_long(dwCount, 0); 71 72 hr = SHGetUnreadMailCountW(NULL, L"example.com", NULL, NULL, szAppName, _countof(szAppName)); 73 ok_hex(hr, S_OK); 74 ok_wstr(szAppName, L"MyMailerApp"); 75 76 if (dwDisposition == REG_CREATED_NEW_KEY) 77 { 78 RegDeleteKeyW(HKEY_CURRENT_USER, 79 L"Software\\Microsoft\\Windows\\CurrentVersion\\UnreadMail\\example.com"); 80 } 81}