Add AppDefaults app selection to control panel
[wine/gsoc-2012-control.git] / dlls / infosoft / tests / infosoft.c
blobefebedc0ff72b42afe8f38a9a16e813c66027ed4
1 /*
2 * tests for the language neutral word breaker
4 * Copyright 2006 Mike McCormack for CodeWeavers
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.
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.
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
21 #define COBJMACROS
22 #define CONST_VTABLE
24 #include <stdio.h>
25 #include <ole2.h>
26 #include "indexsrv.h"
28 #include "wine/test.h"
30 #include <initguid.h>
32 DEFINE_GUID(CLSID_wb_neutral, 0x369647e0,0x17b0,0x11ce,0x99,0x50,0x00,0xaa,0x00,0x4b,0xbb,0x1f);
33 DEFINE_GUID(_IID_IWordBreaker, 0xD53552C8,0x77E3,0x101A,0xB5,0x52,0x08,0x00,0x2B,0x33,0xB0,0xE6);
35 static WCHAR teststring[] = {
36 's','q','u','a','r','e',' ',
37 'c','i','r','c','l','e',' ',
38 't','r','i','a','n','g','l','e',' ',
39 'b','o','x',0
42 struct expected {
43 UINT ofs;
44 UINT len;
45 WCHAR data[10];
48 static int wordnum;
50 static struct expected testres[] = {
51 { 0, 6, {'s','q','u','a','r','e',0 }},
52 { 7, 6, {'c','i','r','c','l','e',0 }},
53 { 14, 8, {'t','r','i','a','n','g','l','e',0 }},
54 { 23, 3, {'b','o','x',0}},
57 static HRESULT WINAPI ws_QueryInterface(IWordSink *iface, REFIID riid, void **ppvObject)
59 ok(0, "not expected\n");
60 return E_NOINTERFACE;
63 static ULONG WINAPI ws_AddRef(IWordSink *iface)
65 ok(0, "not expected\n");
66 return 2;
69 static ULONG WINAPI ws_Release(IWordSink *iface)
71 ok(0, "not expected\n");
72 return 1;
75 static HRESULT WINAPI ws_PutWord(IWordSink *iface, ULONG cwc, const WCHAR *pwcInBuf,
76 ULONG cwcSrcLen, ULONG cwcSrcPos)
78 ok(testres[wordnum].len == cwcSrcLen, "wrong length\n");
79 ok(!cwcSrcPos ||(testres[wordnum].ofs == cwcSrcPos), "wrong offset\n");
80 ok(!memcmp(testres[wordnum].data, pwcInBuf, cwcSrcLen), "wrong data\n");
81 wordnum++;
82 return S_OK;
85 static HRESULT WINAPI ws_PutAltWord(IWordSink *iface, ULONG cwc, const WCHAR *pwcInBuf,
86 ULONG cwcSrcLen, ULONG cwcSrcPos)
88 ok(0, "not expected\n");
89 return S_OK;
92 static HRESULT WINAPI ws_StartAltPhrase(IWordSink *iface)
94 ok(0, "not expected\n");
95 return S_OK;
98 static HRESULT WINAPI ws_EndAltPhrase(IWordSink *iface)
100 ok(0, "not expected\n");
101 return S_OK;
104 static HRESULT WINAPI ws_PutBreak(IWordSink *iface, WORDREP_BREAK_TYPE breakType)
106 ok(0, "not expected\n");
107 return S_OK;
110 static const IWordSinkVtbl wsvt =
112 ws_QueryInterface,
113 ws_AddRef,
114 ws_Release,
115 ws_PutWord,
116 ws_PutAltWord,
117 ws_StartAltPhrase,
118 ws_EndAltPhrase,
119 ws_PutBreak,
122 typedef struct _wordsink_impl
124 IWordSink IWordSink_iface;
125 } wordsink_impl;
127 static wordsink_impl wordsink = { { &wsvt } };
129 static HRESULT WINAPI fillbuf_none(TEXT_SOURCE *ts)
131 return E_FAIL;
134 static HRESULT WINAPI fillbuf_many(TEXT_SOURCE *ts)
136 int i;
138 if (ts->awcBuffer == NULL)
139 ts->awcBuffer = teststring;
140 else
141 ts->awcBuffer += ts->iCur;
143 if (!ts->awcBuffer[0])
144 return E_FAIL;
146 for( i=0; ts->awcBuffer[i] && ts->awcBuffer[i] != ' '; i++)
148 if (ts->awcBuffer[i] == ' ')
149 i++;
151 ts->iCur = 0;
152 ts->iEnd = i;
154 return S_OK;
157 START_TEST(infosoft)
159 HRESULT r;
160 BOOL license;
161 IWordBreaker *wb = NULL;
162 TEXT_SOURCE ts;
164 r = CoInitialize(NULL);
165 ok( r == S_OK, "failed\n");
167 r = CoCreateInstance( &CLSID_wb_neutral, NULL, CLSCTX_INPROC_SERVER,
168 &_IID_IWordBreaker, (LPVOID)&wb);
170 if (FAILED(r))
171 return;
173 r = IWordBreaker_Init( wb, FALSE, 0x100, &license );
174 ok( r == S_OK, "failed to init the wordbreaker\n");
175 /* ok( license == TRUE, "should be no license\n"); */
177 wordnum = 0;
178 ts.pfnFillTextBuffer = fillbuf_none;
179 ts.awcBuffer = teststring;
180 ts.iEnd = lstrlenW(ts.awcBuffer);
181 ts.iCur = 0;
182 r = IWordBreaker_BreakText(wb, &ts, &wordsink.IWordSink_iface, NULL);
183 ok( r == S_OK, "failed\n");
185 ok(wordnum == 4, "words not processed\n");
187 wordnum = 0;
188 ts.pfnFillTextBuffer = fillbuf_many;
189 ts.awcBuffer = teststring;
190 ts.iEnd = 0;
191 ts.iCur = 0;
193 r = fillbuf_many(&ts);
194 ok( r == S_OK, "failed\n");
196 r = IWordBreaker_BreakText(wb, &ts, &wordsink.IWordSink_iface, NULL);
197 ok( r == S_OK, "failed\n");
199 ok(wordnum == 4, "words not processed\n");
200 IWordBreaker_Release( wb );
202 CoUninitialize();