1 /* Unit test suite for IP Address control. 2 * 3 * Copyright 2009 Nikolay Sivov 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Lesser General Public 7 * License as published by the Free Software Foundation; either 8 * version 2.1 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public 16 * License along with this library; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 18 */ 19 20 #include "precomp.h" 21 22 #define expect(expected, got) ok(expected == got, "expected %d, got %d\n", expected,got) 23 24 static HWND create_ipaddress_control (void) 25 { 26 HWND handle; 27 28 handle = CreateWindowExA(0, WC_IPADDRESSA, NULL, 29 WS_BORDER|WS_VISIBLE, 0, 0, 0, 0, 30 NULL, NULL, NULL, NULL); 31 return handle; 32 } 33 34 static void test_get_set_text(void) 35 { 36 HWND hwnd; 37 CHAR ip[16]; 38 INT r; 39 40 hwnd = create_ipaddress_control(); 41 if (!hwnd) 42 { 43 win_skip("IPAddress control not implemented\n"); 44 return; 45 } 46 47 /* check text just after creation */ 48 r = GetWindowTextA(hwnd, ip, sizeof(ip)/sizeof(CHAR)); 49 expect(7, r); 50 ok(strcmp(ip, "0.0.0.0") == 0, "Expected null IP address, got %s\n", ip); 51 52 SendMessageA(hwnd, IPM_SETADDRESS, 0, MAKEIPADDRESS(127, 0, 0, 1)); 53 r = GetWindowTextA(hwnd, ip, sizeof(ip)/sizeof(CHAR)); 54 expect(9, r); 55 ok(strcmp(ip, "127.0.0.1") == 0, "Expected 127.0.0.1, got %s\n", ip); 56 57 DestroyWindow(hwnd); 58 } 59 60 static BOOL init(void) 61 { 62 HMODULE hComctl32; 63 BOOL (WINAPI *pInitCommonControlsEx)(const INITCOMMONCONTROLSEX*); 64 INITCOMMONCONTROLSEX iccex; 65 66 hComctl32 = GetModuleHandleA("comctl32.dll"); 67 pInitCommonControlsEx = (void*)GetProcAddress(hComctl32, "InitCommonControlsEx"); 68 if (!pInitCommonControlsEx) 69 { 70 win_skip("InitCommonControlsEx() is missing.\n"); 71 return FALSE; 72 } 73 74 iccex.dwSize = sizeof(iccex); 75 /* W2K and below need ICC_INTERNET_CLASSES for the IP Address Control */ 76 iccex.dwICC = ICC_INTERNET_CLASSES; 77 pInitCommonControlsEx(&iccex); 78 79 return TRUE; 80 } 81 82 START_TEST(ipaddress) 83 { 84 if (!init()) 85 return; 86 87 test_get_set_text(); 88 } 89