msctf: Added msctf tests.
[wine] / dlls / msctf / tests / inputprocessor.c
1 /*
2  * Unit tests for ITfInputProcessor
3  *
4  * Copyright 2009 Aric Stewart, CodeWeavers
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #include <stdio.h>
22
23 #define COBJMACROS
24 #include "wine/test.h"
25 #include "winuser.h"
26 #include "shlwapi.h"
27 #include "shlguid.h"
28 #include "comcat.h"
29 #include "initguid.h"
30 #include "msctf.h"
31
32 static ITfInputProcessorProfiles* g_ipp;
33 static LANGID gLangid;
34
35 DEFINE_GUID(CLSID_FakeService, 0xEDE1A7AD,0x66DE,0x47E0,0xB6,0x20,0x3E,0x92,0xF8,0x24,0x6B,0xF3);
36
37 static HRESULT initialize(void)
38 {
39     HRESULT hr;
40     CoInitialize(NULL);
41     hr = CoCreateInstance (&CLSID_TF_InputProcessorProfiles, NULL,
42           CLSCTX_INPROC_SERVER, &IID_ITfInputProcessorProfiles, (void**)&g_ipp);
43     return hr;
44 }
45
46 static void cleanup(void)
47 {
48     if (g_ipp)
49         ITfInputProcessorProfiles_Release(g_ipp);
50     CoUninitialize();
51 }
52
53 static void test_Register(void)
54 {
55     HRESULT hr;
56
57     static const WCHAR szDesc[] = {'F','a','k','e',' ','W','i','n','e',' ','S','e','r','v','i','c','e',0};
58     static const WCHAR szFile[] = {'F','a','k','e',' ','W','i','n','e',' ','S','e','r','v','i','c','e',' ','F','i','l','e',0};
59
60     hr = ITfInputProcessorProfiles_Register(g_ipp, &CLSID_FakeService);
61     ok(SUCCEEDED(hr),"Unable to register text service(%x)\n",hr);
62     hr = ITfInputProcessorProfiles_AddLanguageProfile(g_ipp, &CLSID_FakeService, gLangid, &CLSID_FakeService, szDesc, sizeof(szDesc)/sizeof(WCHAR), szFile, sizeof(szFile)/sizeof(WCHAR), 1);
63     ok(SUCCEEDED(hr),"Unable to add Language Profile (%x)\n",hr);
64 }
65
66 static void test_Unregister(void)
67 {
68     HRESULT hr;
69     hr = ITfInputProcessorProfiles_Unregister(g_ipp, &CLSID_FakeService);
70     todo_wine ok(SUCCEEDED(hr),"Unable to unregister text service(%x)\n",hr);
71 }
72
73 START_TEST(inputprocessor)
74 {
75     if (SUCCEEDED(initialize()))
76     {
77         gLangid = GetUserDefaultLCID();
78         test_Register();
79         test_Unregister();
80     }
81     else
82         skip("Unable to create InputProcessor\n");
83     cleanup();
84 }