2008-06-20 02:10:59 +02:00
|
|
|
/*
|
|
|
|
* Tests for IRichEditOle and friends.
|
|
|
|
*
|
|
|
|
* Copyright 2008 Google (Dan Hipschman)
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
2011-09-27 00:15:07 +02:00
|
|
|
|
2008-06-20 02:10:59 +02:00
|
|
|
#include <windef.h>
|
|
|
|
#include <winbase.h>
|
|
|
|
#include <wingdi.h>
|
|
|
|
#include <winuser.h>
|
2008-07-08 16:17:17 +02:00
|
|
|
#include <initguid.h>
|
2008-06-20 02:10:59 +02:00
|
|
|
#include <ole2.h>
|
|
|
|
#include <richedit.h>
|
|
|
|
#include <richole.h>
|
2008-06-20 02:11:47 +02:00
|
|
|
#include <tom.h>
|
2008-06-20 02:10:59 +02:00
|
|
|
#include <wine/test.h>
|
|
|
|
|
|
|
|
static HMODULE hmoduleRichEdit;
|
|
|
|
|
2015-05-17 16:30:56 +02:00
|
|
|
DEFINE_GUID(GUID_NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
|
|
|
2015-05-17 16:26:33 +02:00
|
|
|
#define EXPECT_REF(obj,ref) _expect_ref((IUnknown*)obj, ref, __LINE__)
|
|
|
|
static void _expect_ref(IUnknown* obj, ULONG ref, int line)
|
|
|
|
{
|
|
|
|
ULONG rc;
|
|
|
|
IUnknown_AddRef(obj);
|
|
|
|
rc = IUnknown_Release(obj);
|
|
|
|
ok_(__FILE__,line)(rc == ref, "expected refcount %d, got %d\n", ref, rc);
|
|
|
|
}
|
|
|
|
|
2013-10-25 17:50:46 +02:00
|
|
|
static HWND new_window(LPCSTR lpClassName, DWORD dwStyle, HWND parent)
|
2008-06-20 02:10:59 +02:00
|
|
|
{
|
2013-10-25 17:50:46 +02:00
|
|
|
HWND hwnd = CreateWindowA(lpClassName, NULL,
|
|
|
|
dwStyle | WS_POPUP | WS_HSCROLL | WS_VSCROLL | WS_VISIBLE,
|
|
|
|
0, 0, 200, 60, parent, NULL, hmoduleRichEdit, NULL);
|
2008-06-20 02:10:59 +02:00
|
|
|
return hwnd;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HWND new_richedit(HWND parent)
|
|
|
|
{
|
2013-10-25 17:50:46 +02:00
|
|
|
return new_window(RICHEDIT_CLASS20A, ES_MULTILINE, parent);
|
2008-06-20 02:10:59 +02:00
|
|
|
}
|
|
|
|
|
2013-09-04 13:04:19 +02:00
|
|
|
static BOOL touch_file(LPCWSTR filename)
|
|
|
|
{
|
|
|
|
HANDLE file;
|
2008-06-20 02:10:59 +02:00
|
|
|
|
2013-09-04 13:04:19 +02:00
|
|
|
file = CreateFileW(filename, GENERIC_READ|GENERIC_WRITE, 0, NULL,
|
|
|
|
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
|
|
|
|
if(file == INVALID_HANDLE_VALUE)
|
|
|
|
return FALSE;
|
|
|
|
CloseHandle(file);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL is_existing_file(LPCWSTR filename)
|
|
|
|
{
|
|
|
|
HANDLE file;
|
|
|
|
|
|
|
|
file = CreateFileW(filename, GENERIC_READ, 0, NULL,
|
|
|
|
OPEN_EXISTING, 0, NULL);
|
|
|
|
if(file == INVALID_HANDLE_VALUE)
|
|
|
|
return FALSE;
|
|
|
|
CloseHandle(file);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void create_interfaces(HWND *w, IRichEditOle **reOle, ITextDocument **txtDoc,
|
|
|
|
ITextSelection **txtSel)
|
|
|
|
{
|
|
|
|
*w = new_richedit(NULL);
|
2013-10-25 17:50:46 +02:00
|
|
|
SendMessageA(*w, EM_GETOLEINTERFACE, 0, (LPARAM)reOle);
|
2013-09-04 13:04:19 +02:00
|
|
|
IRichEditOle_QueryInterface(*reOle, &IID_ITextDocument,
|
|
|
|
(void **) txtDoc);
|
|
|
|
ITextDocument_GetSelection(*txtDoc, txtSel);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void release_interfaces(HWND *w, IRichEditOle **reOle, ITextDocument **txtDoc,
|
|
|
|
ITextSelection **txtSel)
|
|
|
|
{
|
2014-09-12 14:33:29 +02:00
|
|
|
if(txtSel)
|
|
|
|
ITextSelection_Release(*txtSel);
|
2013-09-04 13:04:19 +02:00
|
|
|
ITextDocument_Release(*txtDoc);
|
|
|
|
IRichEditOle_Release(*reOle);
|
|
|
|
DestroyWindow(*w);
|
|
|
|
}
|
|
|
|
|
2014-06-30 18:08:28 +02:00
|
|
|
static ULONG get_refcount(IUnknown *iface)
|
|
|
|
{
|
|
|
|
IUnknown_AddRef(iface);
|
|
|
|
return IUnknown_Release(iface);
|
|
|
|
}
|
|
|
|
|
2013-09-04 13:04:19 +02:00
|
|
|
static void test_Interfaces(void)
|
2008-06-20 02:10:59 +02:00
|
|
|
{
|
2014-06-30 18:08:28 +02:00
|
|
|
IRichEditOle *reOle = NULL, *reOle1 = NULL;
|
2008-06-20 02:11:47 +02:00
|
|
|
ITextDocument *txtDoc = NULL;
|
2015-05-20 10:41:34 +02:00
|
|
|
ITextSelection *txtSel = NULL, *txtSel2;
|
2008-06-26 01:31:39 +02:00
|
|
|
IUnknown *punk;
|
2008-06-20 02:11:47 +02:00
|
|
|
HRESULT hres;
|
2008-06-20 02:10:59 +02:00
|
|
|
LRESULT res;
|
|
|
|
HWND w;
|
2014-06-30 18:08:28 +02:00
|
|
|
ULONG refcount;
|
2008-06-20 02:10:59 +02:00
|
|
|
|
|
|
|
w = new_richedit(NULL);
|
|
|
|
if (!w) {
|
|
|
|
skip("Couldn't create window\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-10-25 17:50:46 +02:00
|
|
|
res = SendMessageA(w, EM_GETOLEINTERFACE, 0, (LPARAM)&reOle);
|
2008-06-20 02:10:59 +02:00
|
|
|
ok(res, "SendMessage\n");
|
|
|
|
ok(reOle != NULL, "EM_GETOLEINTERFACE\n");
|
2015-05-21 10:25:24 +02:00
|
|
|
EXPECT_REF(reOle, 2);
|
2014-06-30 18:08:28 +02:00
|
|
|
|
|
|
|
res = SendMessageA(w, EM_GETOLEINTERFACE, 0, (LPARAM)&reOle1);
|
|
|
|
ok(res == 1, "SendMessage\n");
|
|
|
|
ok(reOle1 == reOle, "Should not return a new IRichEditOle interface\n");
|
2015-05-21 10:25:24 +02:00
|
|
|
EXPECT_REF(reOle, 3);
|
2008-06-20 02:10:59 +02:00
|
|
|
|
2012-08-24 11:03:56 +02:00
|
|
|
hres = IRichEditOle_QueryInterface(reOle, &IID_ITextDocument,
|
2008-06-20 02:11:47 +02:00
|
|
|
(void **) &txtDoc);
|
|
|
|
ok(hres == S_OK, "IRichEditOle_QueryInterface\n");
|
|
|
|
ok(txtDoc != NULL, "IRichEditOle_QueryInterface\n");
|
|
|
|
|
2014-03-25 16:53:59 +01:00
|
|
|
hres = ITextDocument_GetSelection(txtDoc, NULL);
|
|
|
|
ok(hres == E_INVALIDARG, "ITextDocument_GetSelection: 0x%x\n", hres);
|
|
|
|
|
2015-05-21 10:25:24 +02:00
|
|
|
EXPECT_REF(txtDoc, 4);
|
|
|
|
|
2015-05-20 10:41:34 +02:00
|
|
|
hres = ITextDocument_GetSelection(txtDoc, &txtSel);
|
|
|
|
ok(hres == S_OK, "got 0x%08x\n", hres);
|
|
|
|
|
2015-05-21 10:25:24 +02:00
|
|
|
EXPECT_REF(txtDoc, 4);
|
|
|
|
EXPECT_REF(txtSel, 2);
|
|
|
|
|
2015-05-20 10:41:34 +02:00
|
|
|
hres = ITextDocument_GetSelection(txtDoc, &txtSel2);
|
|
|
|
ok(hres == S_OK, "got 0x%08x\n", hres);
|
|
|
|
ok(txtSel2 == txtSel, "got %p, %p\n", txtSel, txtSel2);
|
2015-05-21 10:25:24 +02:00
|
|
|
|
|
|
|
EXPECT_REF(txtDoc, 4);
|
|
|
|
EXPECT_REF(txtSel, 3);
|
|
|
|
|
2015-05-20 10:41:34 +02:00
|
|
|
ITextSelection_Release(txtSel2);
|
2008-06-26 01:31:39 +02:00
|
|
|
|
|
|
|
punk = NULL;
|
|
|
|
hres = ITextSelection_QueryInterface(txtSel, &IID_ITextSelection, (void **) &punk);
|
|
|
|
ok(hres == S_OK, "ITextSelection_QueryInterface\n");
|
|
|
|
ok(punk != NULL, "ITextSelection_QueryInterface\n");
|
|
|
|
IUnknown_Release(punk);
|
|
|
|
|
|
|
|
punk = NULL;
|
|
|
|
hres = ITextSelection_QueryInterface(txtSel, &IID_ITextRange, (void **) &punk);
|
|
|
|
ok(hres == S_OK, "ITextSelection_QueryInterface\n");
|
|
|
|
ok(punk != NULL, "ITextSelection_QueryInterface\n");
|
|
|
|
IUnknown_Release(punk);
|
|
|
|
|
|
|
|
punk = NULL;
|
|
|
|
hres = ITextSelection_QueryInterface(txtSel, &IID_IDispatch, (void **) &punk);
|
|
|
|
ok(hres == S_OK, "ITextSelection_QueryInterface\n");
|
|
|
|
ok(punk != NULL, "ITextSelection_QueryInterface\n");
|
|
|
|
IUnknown_Release(punk);
|
|
|
|
|
2015-03-16 10:27:07 +01:00
|
|
|
punk = NULL;
|
|
|
|
hres = IRichEditOle_QueryInterface(reOle, &IID_IOleClientSite, (void **) &punk);
|
|
|
|
ok(hres == E_NOINTERFACE, "IRichEditOle_QueryInterface\n");
|
|
|
|
|
|
|
|
punk = NULL;
|
|
|
|
hres = IRichEditOle_QueryInterface(reOle, &IID_IOleWindow, (void **) &punk);
|
|
|
|
ok(hres == E_NOINTERFACE, "IRichEditOle_QueryInterface\n");
|
|
|
|
|
2015-03-17 09:17:39 +01:00
|
|
|
punk = NULL;
|
|
|
|
hres = IRichEditOle_QueryInterface(reOle, &IID_IOleInPlaceSite, (void **) &punk);
|
|
|
|
ok(hres == E_NOINTERFACE, "IRichEditOle_QueryInterface\n");
|
|
|
|
|
2008-06-20 02:11:47 +02:00
|
|
|
ITextDocument_Release(txtDoc);
|
2012-08-24 11:03:56 +02:00
|
|
|
IRichEditOle_Release(reOle);
|
2014-06-30 18:08:28 +02:00
|
|
|
refcount = IRichEditOle_Release(reOle);
|
|
|
|
ok(refcount == 1, "got wrong ref count: %d\n", refcount);
|
2008-06-20 02:10:59 +02:00
|
|
|
DestroyWindow(w);
|
2008-06-26 01:31:39 +02:00
|
|
|
|
|
|
|
/* Methods should return CO_E_RELEASED if the backing document has
|
|
|
|
been released. One test should suffice. */
|
|
|
|
hres = ITextSelection_CanEdit(txtSel, NULL);
|
|
|
|
ok(hres == CO_E_RELEASED, "ITextSelection after ITextDocument destroyed\n");
|
|
|
|
|
|
|
|
ITextSelection_Release(txtSel);
|
2008-06-20 02:10:59 +02:00
|
|
|
}
|
2013-09-04 13:04:19 +02:00
|
|
|
|
|
|
|
static void test_ITextDocument_Open(void)
|
|
|
|
{
|
|
|
|
IRichEditOle *reOle = NULL;
|
|
|
|
ITextDocument *txtDoc = NULL;
|
|
|
|
ITextSelection *txtSel = NULL;
|
|
|
|
HRESULT hres;
|
|
|
|
HWND w;
|
|
|
|
HANDLE hFile;
|
|
|
|
VARIANT testfile;
|
|
|
|
WCHAR filename[] = {'t', 'e', 's', 't','.','t','x','t', 0};
|
2014-02-11 12:05:33 +01:00
|
|
|
int result;
|
|
|
|
DWORD dw;
|
|
|
|
static const CHAR chACP[] = "TestSomeText";
|
|
|
|
static const CHAR chUTF8[] = "\xef\xbb\xbfTextWithUTF8BOM";
|
|
|
|
static const WCHAR chUTF16[] = {0xfeff, 'T', 'e', 's', 't', 'S', 'o', 'm',
|
|
|
|
'e', 'T', 'e', 'x', 't', 0};
|
|
|
|
|
|
|
|
#define MAX_BUF_LEN 1024
|
|
|
|
CHAR bufACP[MAX_BUF_LEN];
|
|
|
|
WCHAR bufUnicode[MAX_BUF_LEN];
|
2013-09-04 13:04:19 +02:00
|
|
|
|
|
|
|
static const int tomConstantsSingle[] =
|
|
|
|
{
|
|
|
|
tomReadOnly, tomShareDenyRead, tomShareDenyWrite,
|
|
|
|
tomCreateAlways, tomOpenExisting, tomOpenAlways,
|
|
|
|
tomTruncateExisting, tomRTF, tomText
|
|
|
|
};
|
|
|
|
|
|
|
|
static const int tomConstantsMulti[] =
|
|
|
|
{
|
|
|
|
tomReadOnly|tomShareDenyRead|tomPasteFile, tomReadOnly|tomPasteFile,
|
|
|
|
tomReadOnly|tomShareDenyWrite|tomPasteFile,
|
|
|
|
tomReadOnly|tomShareDenyRead|tomShareDenyWrite|tomPasteFile, tomShareDenyWrite|tomPasteFile,
|
|
|
|
tomShareDenyRead|tomShareDenyWrite|tomPasteFile, tomShareDenyRead|tomPasteFile,
|
|
|
|
tomShareDenyRead|tomShareDenyWrite, tomReadOnly|tomShareDenyRead|tomShareDenyWrite,
|
|
|
|
tomReadOnly|tomShareDenyWrite, tomReadOnly|tomShareDenyRead
|
|
|
|
};
|
|
|
|
|
|
|
|
int tomNumSingle = sizeof(tomConstantsSingle)/sizeof(tomConstantsSingle[0]);
|
|
|
|
int tomNumMulti = sizeof(tomConstantsMulti)/sizeof(tomConstantsMulti[0]);
|
|
|
|
int i;
|
2014-03-13 13:49:18 +01:00
|
|
|
|
2013-09-04 13:04:19 +02:00
|
|
|
V_VT(&testfile) = VT_BSTR;
|
|
|
|
V_BSTR(&testfile) = SysAllocString(filename);
|
|
|
|
|
|
|
|
for(i=0; i < tomNumSingle; i++)
|
|
|
|
{
|
|
|
|
touch_file(filename);
|
|
|
|
create_interfaces(&w, &reOle, &txtDoc, &txtSel);
|
|
|
|
hres = ITextDocument_Open(txtDoc, &testfile, tomConstantsSingle[i], CP_ACP);
|
|
|
|
todo_wine ok(hres == S_OK, "ITextDocument_Open: Filename:test.txt Flags:0x%x Codepage:CP_ACP hres:0x%x\n",
|
|
|
|
tomConstantsSingle[i], hres);
|
|
|
|
release_interfaces(&w, &reOle, &txtDoc, &txtSel);
|
|
|
|
DeleteFileW(filename);
|
|
|
|
|
|
|
|
touch_file(filename);
|
|
|
|
create_interfaces(&w, &reOle, &txtDoc, &txtSel);
|
|
|
|
hres = ITextDocument_Open(txtDoc, &testfile, tomConstantsSingle[i], CP_UTF8);
|
|
|
|
todo_wine ok(hres == S_OK, "ITextDocument_Open: Filename:test.txt Flags:0x%x Codepage:CP_UTF8 hres:0x%x\n",
|
|
|
|
tomConstantsSingle[i], hres);
|
|
|
|
release_interfaces(&w, &reOle, &txtDoc, &txtSel);
|
|
|
|
DeleteFileW(filename);
|
|
|
|
}
|
|
|
|
|
|
|
|
for(i=0; i < tomNumMulti; i++)
|
|
|
|
{
|
|
|
|
touch_file(filename);
|
|
|
|
create_interfaces(&w, &reOle, &txtDoc, &txtSel);
|
|
|
|
hres = ITextDocument_Open(txtDoc, &testfile, tomConstantsMulti[i], CP_ACP);
|
|
|
|
todo_wine ok(hres == S_OK, "ITextDocument_Open: Filename:test.txt Flags:0x%x Codepage:CP_ACP hres:0x%x\n",
|
|
|
|
tomConstantsMulti[i], hres);
|
|
|
|
release_interfaces(&w, &reOle, &txtDoc, &txtSel);
|
|
|
|
DeleteFileW(filename);
|
|
|
|
|
|
|
|
touch_file(filename);
|
|
|
|
create_interfaces(&w, &reOle, &txtDoc, &txtSel);
|
|
|
|
hres = ITextDocument_Open(txtDoc, &testfile, tomConstantsMulti[i], CP_UTF8);
|
|
|
|
todo_wine ok(hres == S_OK, "ITextDocument_Open: Filename:test.txt Flags:0x%x Codepage:CP_UTF8 hres:0x%x\n",
|
|
|
|
tomConstantsMulti[i], hres);
|
|
|
|
release_interfaces(&w, &reOle, &txtDoc, &txtSel);
|
|
|
|
DeleteFileW(filename);
|
|
|
|
}
|
|
|
|
|
|
|
|
create_interfaces(&w, &reOle, &txtDoc, &txtSel);
|
|
|
|
hres = ITextDocument_Open(txtDoc, &testfile, tomCreateAlways, CP_ACP);
|
|
|
|
todo_wine ok(hres == S_OK, "ITextDocument_Open should success Codepage:CP_ACP\n");
|
|
|
|
todo_wine ok(is_existing_file(filename), "ITextDocument_Open should create a file\n");
|
|
|
|
release_interfaces(&w, &reOle, &txtDoc, &txtSel);
|
|
|
|
DeleteFileW(filename);
|
|
|
|
|
|
|
|
create_interfaces(&w, &reOle, &txtDoc, &txtSel);
|
|
|
|
hres = ITextDocument_Open(txtDoc, &testfile, tomCreateAlways, CP_UTF8);
|
|
|
|
todo_wine ok(hres == S_OK, "ITextDocument_Open should success Codepage:CP_UTF8\n");
|
|
|
|
todo_wine ok(is_existing_file(filename), "ITextDocument_Open should create a file\n");
|
|
|
|
release_interfaces(&w, &reOle, &txtDoc, &txtSel);
|
|
|
|
DeleteFileW(filename);
|
|
|
|
|
|
|
|
create_interfaces(&w, &reOle, &txtDoc, &txtSel);
|
|
|
|
hres = ITextDocument_Open(txtDoc, &testfile, tomOpenAlways, CP_ACP);
|
|
|
|
todo_wine ok(hres == S_OK, "ITextDocument_Open should success Codepage:CP_ACP\n");
|
|
|
|
todo_wine ok(is_existing_file(filename), "ITextDocument_Open should create a file\n");
|
|
|
|
release_interfaces(&w, &reOle, &txtDoc, &txtSel);
|
|
|
|
DeleteFileW(filename);
|
|
|
|
|
|
|
|
create_interfaces(&w, &reOle, &txtDoc, &txtSel);
|
|
|
|
hres = ITextDocument_Open(txtDoc, &testfile, tomOpenAlways, CP_UTF8);
|
|
|
|
todo_wine ok(hres == S_OK, "ITextDocument_Open should success Codepage:CP_UTF8\n");
|
|
|
|
todo_wine ok(is_existing_file(filename), "ITextDocument_Open should create a file\n");
|
|
|
|
release_interfaces(&w, &reOle, &txtDoc, &txtSel);
|
|
|
|
DeleteFileW(filename);
|
|
|
|
|
|
|
|
create_interfaces(&w, &reOle, &txtDoc, &txtSel);
|
|
|
|
hres = ITextDocument_Open(txtDoc, &testfile, tomCreateNew, CP_ACP);
|
|
|
|
todo_wine ok(hres == S_OK, "ITextDocument_Open should success Codepage:CP_ACP\n");
|
|
|
|
todo_wine ok(is_existing_file(filename), "ITextDocument_Open should create a file\n");
|
|
|
|
release_interfaces(&w, &reOle, &txtDoc, &txtSel);
|
|
|
|
DeleteFileW(filename);
|
|
|
|
|
|
|
|
create_interfaces(&w, &reOle, &txtDoc, &txtSel);
|
|
|
|
hres = ITextDocument_Open(txtDoc, &testfile, tomCreateNew, CP_UTF8);
|
|
|
|
todo_wine ok(hres == S_OK, "ITextDocument_Open should success Codepage:CP_UTF8\n");
|
|
|
|
todo_wine ok(is_existing_file(filename), "ITextDocument_Open should create a file\n");
|
|
|
|
release_interfaces(&w, &reOle, &txtDoc, &txtSel);
|
|
|
|
DeleteFileW(filename);
|
|
|
|
|
|
|
|
create_interfaces(&w, &reOle, &txtDoc, &txtSel);
|
|
|
|
touch_file(filename);
|
|
|
|
hres = ITextDocument_Open(txtDoc, &testfile, tomCreateNew, CP_ACP);
|
|
|
|
todo_wine ok(hres == HRESULT_FROM_WIN32(ERROR_FILE_EXISTS), "ITextDocument_Open should fail Codepage:CP_ACP\n");
|
|
|
|
release_interfaces(&w, &reOle, &txtDoc, &txtSel);
|
|
|
|
DeleteFileW(filename);
|
|
|
|
|
|
|
|
create_interfaces(&w, &reOle, &txtDoc, &txtSel);
|
|
|
|
touch_file(filename);
|
|
|
|
hres = ITextDocument_Open(txtDoc, &testfile, tomCreateNew, CP_UTF8);
|
|
|
|
todo_wine ok(hres == HRESULT_FROM_WIN32(ERROR_FILE_EXISTS), "ITextDocument_Open should fail Codepage:CP_UTF8\n");
|
|
|
|
release_interfaces(&w, &reOle, &txtDoc, &txtSel);
|
|
|
|
DeleteFileW(filename);
|
|
|
|
|
|
|
|
create_interfaces(&w, &reOle, &txtDoc, &txtSel);
|
|
|
|
hres = ITextDocument_Open(txtDoc, &testfile, tomOpenExisting, CP_ACP);
|
|
|
|
todo_wine ok(hres == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "ITextDocument_Open should fail Codepage:CP_ACP\n");
|
|
|
|
release_interfaces(&w, &reOle, &txtDoc, &txtSel);
|
|
|
|
|
|
|
|
create_interfaces(&w, &reOle, &txtDoc, &txtSel);
|
|
|
|
hres = ITextDocument_Open(txtDoc, &testfile, tomOpenExisting, CP_UTF8);
|
|
|
|
todo_wine ok(hres == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "ITextDocument_Open should fail Codepage:CP_UTF8\n");
|
|
|
|
release_interfaces(&w, &reOle, &txtDoc, &txtSel);
|
|
|
|
|
|
|
|
create_interfaces(&w, &reOle, &txtDoc, &txtSel);
|
|
|
|
DeleteFileW(filename);
|
|
|
|
ITextDocument_Open(txtDoc, &testfile, tomText, CP_ACP);
|
|
|
|
todo_wine ok(is_existing_file(filename) == TRUE, "a file should be created default\n");
|
|
|
|
release_interfaces(&w, &reOle, &txtDoc, &txtSel);
|
|
|
|
DeleteFileW(filename);
|
|
|
|
|
|
|
|
/* test of share mode */
|
|
|
|
touch_file(filename);
|
|
|
|
create_interfaces(&w, &reOle, &txtDoc, &txtSel);
|
|
|
|
ITextDocument_Open(txtDoc, &testfile, tomShareDenyRead, CP_ACP);
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
hFile = CreateFileW(filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
|
|
|
|
FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
todo_wine ok(GetLastError() == ERROR_SHARING_VIOLATION, "ITextDocument_Open should fail\n");
|
|
|
|
CloseHandle(hFile);
|
|
|
|
release_interfaces(&w, &reOle, &txtDoc, &txtSel);
|
|
|
|
DeleteFileW(filename);
|
|
|
|
|
|
|
|
touch_file(filename);
|
|
|
|
create_interfaces(&w, &reOle, &txtDoc, &txtSel);
|
|
|
|
ITextDocument_Open(txtDoc, &testfile, tomShareDenyWrite, CP_ACP);
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
hFile = CreateFileW(filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
|
|
|
|
FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
todo_wine ok(GetLastError() == ERROR_SHARING_VIOLATION, "ITextDocument_Open should fail\n");
|
|
|
|
CloseHandle(hFile);
|
|
|
|
release_interfaces(&w, &reOle, &txtDoc, &txtSel);
|
|
|
|
DeleteFileW(filename);
|
|
|
|
|
|
|
|
touch_file(filename);
|
|
|
|
create_interfaces(&w, &reOle, &txtDoc, &txtSel);
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ITextDocument_Open(txtDoc, &testfile, tomShareDenyWrite|tomShareDenyRead, CP_ACP);
|
|
|
|
hFile = CreateFileW(filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
|
|
|
|
FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
todo_wine ok(GetLastError() == ERROR_SHARING_VIOLATION, "ITextDocument_Open should fail\n");
|
|
|
|
CloseHandle(hFile);
|
|
|
|
release_interfaces(&w, &reOle, &txtDoc, &txtSel);
|
|
|
|
DeleteFileW(filename);
|
2014-02-11 12:05:33 +01:00
|
|
|
|
|
|
|
/* tests to check the content */
|
|
|
|
hFile = CreateFileW(filename, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS,
|
|
|
|
FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
WriteFile(hFile, chACP, sizeof(chACP)-sizeof(CHAR), &dw, NULL);
|
|
|
|
CloseHandle(hFile);
|
|
|
|
create_interfaces(&w, &reOle, &txtDoc, &txtSel);
|
|
|
|
ITextDocument_Open(txtDoc, &testfile, tomReadOnly, CP_ACP);
|
|
|
|
result = SendMessageA(w, WM_GETTEXT, 1024, (LPARAM)bufACP);
|
|
|
|
todo_wine ok(result == 12, "ITextDocument_Open: Test ASCII returned %d, expected 12\n", result);
|
|
|
|
result = strcmp(bufACP, chACP);
|
|
|
|
todo_wine ok(result == 0, "ITextDocument_Open: Test ASCII set wrong text: Result: %s\n", bufACP);
|
|
|
|
release_interfaces(&w, &reOle, &txtDoc, &txtSel);
|
|
|
|
DeleteFileW(filename);
|
|
|
|
|
|
|
|
hFile = CreateFileW(filename, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS,
|
|
|
|
FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
WriteFile(hFile, chUTF8, sizeof(chUTF8)-sizeof(CHAR), &dw, NULL);
|
|
|
|
CloseHandle(hFile);
|
|
|
|
create_interfaces(&w, &reOle, &txtDoc, &txtSel);
|
|
|
|
ITextDocument_Open(txtDoc, &testfile, tomReadOnly, CP_UTF8);
|
|
|
|
result = SendMessageA(w, WM_GETTEXT, 1024, (LPARAM)bufACP);
|
|
|
|
todo_wine ok(result == 15, "ITextDocument_Open: Test UTF-8 returned %d, expected 15\n", result);
|
|
|
|
result = strcmp(bufACP, &chUTF8[3]);
|
|
|
|
todo_wine ok(result == 0, "ITextDocument_Open: Test UTF-8 set wrong text: Result: %s\n", bufACP);
|
|
|
|
release_interfaces(&w, &reOle, &txtDoc, &txtSel);
|
|
|
|
DeleteFileW(filename);
|
|
|
|
|
|
|
|
hFile = CreateFileW(filename, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS,
|
|
|
|
FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
WriteFile(hFile, chUTF16, sizeof(chUTF16)-sizeof(WCHAR), &dw, NULL);
|
|
|
|
CloseHandle(hFile);
|
|
|
|
create_interfaces(&w, &reOle, &txtDoc, &txtSel);
|
|
|
|
ITextDocument_Open(txtDoc, &testfile, tomReadOnly, 1200);
|
|
|
|
result = SendMessageW(w, WM_GETTEXT, 1024, (LPARAM)bufUnicode);
|
|
|
|
todo_wine ok(result == 12, "ITextDocument_Open: Test UTF-16 returned %d, expected 12\n", result);
|
|
|
|
result = lstrcmpW(bufUnicode, &chUTF16[1]);
|
|
|
|
todo_wine ok(result == 0, "ITextDocument_Open: Test UTF-16 set wrong text: Result: %s\n", wine_dbgstr_w(bufUnicode));
|
|
|
|
release_interfaces(&w, &reOle, &txtDoc, &txtSel);
|
|
|
|
DeleteFileW(filename);
|
2014-03-13 13:49:18 +01:00
|
|
|
|
|
|
|
VariantClear(&testfile);
|
2013-09-04 13:04:19 +02:00
|
|
|
}
|
|
|
|
|
2014-07-21 18:41:29 +02:00
|
|
|
static void test_ITextSelection_GetText(void)
|
|
|
|
{
|
|
|
|
HWND w;
|
|
|
|
IRichEditOle *reOle = NULL;
|
|
|
|
ITextDocument *txtDoc = NULL;
|
|
|
|
ITextSelection *txtSel = NULL;
|
|
|
|
HRESULT hres;
|
|
|
|
BSTR bstr = NULL;
|
|
|
|
int first, lim;
|
|
|
|
static const CHAR test_text1[] = "TestSomeText";
|
|
|
|
static const WCHAR bufW1[] = {'T', 'e', 's', 't', 0};
|
|
|
|
static const WCHAR bufW2[] = {'T', 'e', 'x', 't', '\r', 0};
|
|
|
|
static const WCHAR bufW3[] = {'T', 'e', 'x', 't', 0};
|
|
|
|
static const WCHAR bufW4[] = {'T', 'e', 's', 't', 'S', 'o', 'm',
|
|
|
|
'e', 'T', 'e', 'x', 't', '\r', 0};
|
|
|
|
static const WCHAR bufW5[] = {'\r', 0};
|
2014-07-22 20:38:33 +02:00
|
|
|
BOOL is64bit = sizeof(void *) > sizeof(int);
|
2014-07-21 18:41:29 +02:00
|
|
|
|
|
|
|
create_interfaces(&w, &reOle, &txtDoc, &txtSel);
|
|
|
|
SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
|
|
|
|
|
|
|
|
first = 0, lim = 4;
|
|
|
|
SendMessageA(w, EM_SETSEL, first, lim);
|
|
|
|
hres = ITextSelection_GetText(txtSel, &bstr);
|
|
|
|
ok(hres == S_OK, "ITextSelection_GetText\n");
|
|
|
|
ok(!lstrcmpW(bstr, bufW1), "got wrong text: %s\n", wine_dbgstr_w(bstr));
|
|
|
|
SysFreeString(bstr);
|
|
|
|
|
|
|
|
first = 4, lim = 0;
|
|
|
|
SendMessageA(w, EM_SETSEL, first, lim);
|
|
|
|
hres = ITextSelection_GetText(txtSel, &bstr);
|
|
|
|
ok(hres == S_OK, "ITextSelection_GetText\n");
|
|
|
|
ok(!lstrcmpW(bstr, bufW1), "got wrong text: %s\n", wine_dbgstr_w(bstr));
|
|
|
|
SysFreeString(bstr);
|
|
|
|
|
|
|
|
first = 1, lim = 1;
|
|
|
|
SendMessageA(w, EM_SETSEL, first, lim);
|
|
|
|
hres = ITextSelection_GetText(txtSel, &bstr);
|
|
|
|
ok(hres == S_OK, "ITextSelection_GetText\n");
|
|
|
|
ok(!bstr, "got wrong text: %s\n", wine_dbgstr_w(bstr));
|
|
|
|
|
2014-07-22 20:38:33 +02:00
|
|
|
if (!is64bit)
|
2014-07-21 18:41:29 +02:00
|
|
|
{
|
|
|
|
hres = ITextSelection_GetText(txtSel, NULL);
|
|
|
|
ok(hres == E_INVALIDARG, "ITextSelection_GetText\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
first = 8, lim = 12;
|
|
|
|
SendMessageA(w, EM_SETSEL, first, lim);
|
|
|
|
hres = ITextSelection_GetText(txtSel, &bstr);
|
|
|
|
ok(hres == S_OK, "ITextSelection_GetText\n");
|
|
|
|
ok(!lstrcmpW(bstr, bufW3), "got wrong text: %s\n", wine_dbgstr_w(bstr));
|
|
|
|
SysFreeString(bstr);
|
|
|
|
|
|
|
|
first = 8, lim = 13;
|
|
|
|
SendMessageA(w, EM_SETSEL, first, lim);
|
|
|
|
hres = ITextSelection_GetText(txtSel, &bstr);
|
|
|
|
ok(hres == S_OK, "ITextSelection_GetText\n");
|
|
|
|
ok(!lstrcmpW(bstr, bufW2), "got wrong text: %s\n", wine_dbgstr_w(bstr));
|
|
|
|
SysFreeString(bstr);
|
|
|
|
|
|
|
|
first = 12, lim = 13;
|
|
|
|
SendMessageA(w, EM_SETSEL, first, lim);
|
|
|
|
hres = ITextSelection_GetText(txtSel, &bstr);
|
|
|
|
ok(hres == S_OK, "ITextSelection_GetText\n");
|
|
|
|
ok(!lstrcmpW(bstr, bufW5), "got wrong text: %s\n", wine_dbgstr_w(bstr));
|
|
|
|
SysFreeString(bstr);
|
|
|
|
|
|
|
|
first = 0, lim = -1;
|
|
|
|
SendMessageA(w, EM_SETSEL, first, lim);
|
|
|
|
hres = ITextSelection_GetText(txtSel, &bstr);
|
|
|
|
ok(hres == S_OK, "ITextSelection_GetText\n");
|
|
|
|
ok(!lstrcmpW(bstr, bufW4), "got wrong text: %s\n", wine_dbgstr_w(bstr));
|
|
|
|
SysFreeString(bstr);
|
|
|
|
|
|
|
|
first = -1, lim = 9;
|
|
|
|
SendMessageA(w, EM_SETSEL, first, lim);
|
|
|
|
hres = ITextSelection_GetText(txtSel, &bstr);
|
|
|
|
ok(hres == S_OK, "ITextSelection_GetText\n");
|
|
|
|
ok(!bstr, "got wrong text: %s\n", wine_dbgstr_w(bstr));
|
|
|
|
|
2015-05-21 11:13:42 +02:00
|
|
|
release_interfaces(&w, &reOle, &txtDoc, NULL);
|
|
|
|
|
|
|
|
hres = ITextSelection_GetText(txtSel, &bstr);
|
|
|
|
ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres);
|
|
|
|
|
2015-05-22 10:17:21 +02:00
|
|
|
if (!is64bit)
|
|
|
|
{
|
|
|
|
hres = ITextSelection_GetText(txtSel, NULL);
|
|
|
|
ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres);
|
|
|
|
}
|
2015-05-21 11:13:42 +02:00
|
|
|
|
|
|
|
ITextSelection_Release(txtSel);
|
2014-07-21 18:41:29 +02:00
|
|
|
}
|
|
|
|
|
2014-09-12 14:33:29 +02:00
|
|
|
static void test_ITextDocument_Range(void)
|
|
|
|
{
|
|
|
|
HWND w;
|
|
|
|
IRichEditOle *reOle = NULL;
|
|
|
|
ITextDocument *txtDoc = NULL;
|
|
|
|
ITextRange *txtRge = NULL;
|
|
|
|
ITextRange *pointer = NULL;
|
|
|
|
HRESULT hres;
|
|
|
|
ULONG refcount;
|
|
|
|
|
|
|
|
create_interfaces(&w, &reOle, &txtDoc, NULL);
|
|
|
|
hres = ITextDocument_Range(txtDoc, 0, 0, &txtRge);
|
|
|
|
ok(hres == S_OK, "ITextDocument_Range fails 0x%x.\n", hres);
|
|
|
|
refcount = get_refcount((IUnknown *)txtRge);
|
|
|
|
ok(refcount == 1, "get wrong refcount: returned %d expected 1\n", refcount);
|
|
|
|
|
|
|
|
pointer = txtRge;
|
|
|
|
hres = ITextDocument_Range(txtDoc, 0, 0, &txtRge);
|
|
|
|
ok(hres == S_OK, "ITextDocument_Range fails 0x%x.\n", hres);
|
|
|
|
ok(pointer != txtRge, "A new pointer should be returned\n");
|
|
|
|
ITextRange_Release(pointer);
|
|
|
|
|
|
|
|
hres = ITextDocument_Range(txtDoc, 0, 0, NULL);
|
|
|
|
ok(hres == E_INVALIDARG, "ITextDocument_Range should fail 0x%x.\n", hres);
|
|
|
|
|
|
|
|
release_interfaces(&w, &reOle, &txtDoc, NULL);
|
|
|
|
hres = ITextRange_CanEdit(txtRge, NULL);
|
|
|
|
ok(hres == CO_E_RELEASED, "ITextRange after ITextDocument destroyed\n");
|
|
|
|
ITextRange_Release(txtRge);
|
|
|
|
}
|
|
|
|
|
2014-09-15 18:13:30 +02:00
|
|
|
static void test_ITextRange_GetChar(void)
|
|
|
|
{
|
|
|
|
HWND w;
|
|
|
|
IRichEditOle *reOle = NULL;
|
|
|
|
ITextDocument *txtDoc = NULL;
|
|
|
|
ITextRange *txtRge = NULL;
|
|
|
|
HRESULT hres;
|
|
|
|
LONG pch = 0xdeadbeef;
|
|
|
|
int first, lim;
|
|
|
|
static const CHAR test_text1[] = "TestSomeText";
|
|
|
|
|
|
|
|
first = 0, lim = 4;
|
|
|
|
create_interfaces(&w, &reOle, &txtDoc, NULL);
|
|
|
|
SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
|
|
|
|
ITextDocument_Range(txtDoc, first, lim, &txtRge);
|
|
|
|
pch = 0xdeadbeef;
|
|
|
|
hres = ITextRange_GetChar(txtRge, &pch);
|
|
|
|
ok(hres == S_OK, "ITextRange_GetChar\n");
|
|
|
|
ok(pch == 'T', "got wrong char: %c\n", pch);
|
|
|
|
ITextRange_Release(txtRge);
|
|
|
|
release_interfaces(&w, &reOle, &txtDoc, NULL);
|
|
|
|
|
|
|
|
first = 0, lim = 0;
|
|
|
|
create_interfaces(&w, &reOle, &txtDoc, NULL);
|
|
|
|
SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
|
|
|
|
ITextDocument_Range(txtDoc, first, lim, &txtRge);
|
|
|
|
pch = 0xdeadbeef;
|
|
|
|
hres = ITextRange_GetChar(txtRge, &pch);
|
|
|
|
ok(hres == S_OK, "ITextRange_GetChar\n");
|
|
|
|
ok(pch == 'T', "got wrong char: %c\n", pch);
|
|
|
|
ITextRange_Release(txtRge);
|
|
|
|
release_interfaces(&w, &reOle, &txtDoc, NULL);
|
|
|
|
|
|
|
|
first = 12, lim = 12;
|
|
|
|
create_interfaces(&w, &reOle, &txtDoc, NULL);
|
|
|
|
SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
|
|
|
|
ITextDocument_Range(txtDoc, first, lim, &txtRge);
|
|
|
|
pch = 0xdeadbeef;
|
|
|
|
hres = ITextRange_GetChar(txtRge, &pch);
|
|
|
|
ok(hres == S_OK, "ITextRange_GetChar\n");
|
|
|
|
ok(pch == '\r', "got wrong char: %c\n", pch);
|
|
|
|
ITextRange_Release(txtRge);
|
|
|
|
release_interfaces(&w, &reOle, &txtDoc, NULL);
|
|
|
|
|
|
|
|
first = 13, lim = 13;
|
|
|
|
create_interfaces(&w, &reOle, &txtDoc, NULL);
|
|
|
|
SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
|
|
|
|
ITextDocument_Range(txtDoc, first, lim, &txtRge);
|
|
|
|
pch = 0xdeadbeef;
|
|
|
|
hres = ITextRange_GetChar(txtRge, &pch);
|
|
|
|
ok(hres == S_OK, "ITextRange_GetChar\n");
|
|
|
|
ok(pch == '\r', "got wrong char: %c\n", pch);
|
|
|
|
ITextRange_Release(txtRge);
|
|
|
|
release_interfaces(&w, &reOle, &txtDoc, NULL);
|
|
|
|
|
|
|
|
create_interfaces(&w, &reOle, &txtDoc, NULL);
|
|
|
|
SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
|
|
|
|
first = 12, lim = 12;
|
|
|
|
ITextDocument_Range(txtDoc, first, lim, &txtRge);
|
|
|
|
hres = ITextRange_GetChar(txtRge, NULL);
|
|
|
|
ok(hres == E_INVALIDARG, "ITextRange_GetChar\n");
|
|
|
|
ITextRange_Release(txtRge);
|
|
|
|
release_interfaces(&w, &reOle, &txtDoc, NULL);
|
|
|
|
}
|
|
|
|
|
2014-09-15 18:13:51 +02:00
|
|
|
static void test_ITextSelection_GetChar(void)
|
|
|
|
{
|
|
|
|
HWND w;
|
|
|
|
IRichEditOle *reOle = NULL;
|
|
|
|
ITextDocument *txtDoc = NULL;
|
|
|
|
ITextSelection *txtSel = NULL;
|
|
|
|
HRESULT hres;
|
|
|
|
LONG pch = 0xdeadbeef;
|
|
|
|
int first, lim;
|
|
|
|
static const CHAR test_text1[] = "TestSomeText";
|
|
|
|
|
|
|
|
create_interfaces(&w, &reOle, &txtDoc, &txtSel);
|
|
|
|
SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
|
|
|
|
|
|
|
|
first = 0, lim = 4;
|
|
|
|
SendMessageA(w, EM_SETSEL, first, lim);
|
|
|
|
pch = 0xdeadbeef;
|
|
|
|
hres = ITextSelection_GetChar(txtSel, &pch);
|
|
|
|
ok(hres == S_OK, "ITextSelection_GetChar\n");
|
|
|
|
ok(pch == 'T', "got wrong char: %c\n", pch);
|
|
|
|
|
|
|
|
first = 0, lim = 0;
|
|
|
|
SendMessageA(w, EM_SETSEL, first, lim);
|
|
|
|
pch = 0xdeadbeef;
|
|
|
|
hres = ITextSelection_GetChar(txtSel, &pch);
|
|
|
|
ok(hres == S_OK, "ITextSelection_GetChar\n");
|
|
|
|
ok(pch == 'T', "got wrong char: %c\n", pch);
|
|
|
|
|
|
|
|
first = 12, lim = 12;
|
|
|
|
SendMessageA(w, EM_SETSEL, first, lim);
|
|
|
|
pch = 0xdeadbeef;
|
|
|
|
hres = ITextSelection_GetChar(txtSel, &pch);
|
|
|
|
ok(hres == S_OK, "ITextSelection_GetChar\n");
|
|
|
|
ok(pch == '\r', "got wrong char: %c\n", pch);
|
|
|
|
|
|
|
|
first = 13, lim = 13;
|
|
|
|
SendMessageA(w, EM_SETSEL, first, lim);
|
|
|
|
pch = 0xdeadbeef;
|
|
|
|
hres = ITextSelection_GetChar(txtSel, &pch);
|
|
|
|
ok(hres == S_OK, "ITextSelection_GetChar\n");
|
|
|
|
ok(pch == '\r', "got wrong char: %c\n", pch);
|
|
|
|
|
|
|
|
hres = ITextSelection_GetChar(txtSel, NULL);
|
|
|
|
ok(hres == E_INVALIDARG, "ITextSelection_GetChar\n");
|
|
|
|
|
|
|
|
release_interfaces(&w, &reOle, &txtDoc, &txtSel);
|
|
|
|
}
|
|
|
|
|
2014-09-16 12:38:56 +02:00
|
|
|
static void test_ITextRange_GetStart_GetEnd(void)
|
|
|
|
{
|
|
|
|
HWND w;
|
|
|
|
IRichEditOle *reOle = NULL;
|
|
|
|
ITextDocument *txtDoc = NULL;
|
|
|
|
ITextRange *txtRge = NULL;
|
|
|
|
HRESULT hres;
|
|
|
|
int first, lim, start, end;
|
|
|
|
static const CHAR test_text1[] = "TestSomeText";
|
|
|
|
|
|
|
|
create_interfaces(&w, &reOle, &txtDoc, NULL);
|
|
|
|
SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
|
|
|
|
|
|
|
|
first = 1, lim = 6;
|
|
|
|
ITextDocument_Range(txtDoc, first, lim, &txtRge);
|
|
|
|
start = 0xdeadbeef;
|
|
|
|
hres = ITextRange_GetStart(txtRge, &start);
|
|
|
|
ok(hres == S_OK, "ITextRange_GetStart\n");
|
|
|
|
ok(start == 1, "got wrong start value: %d\n", start);
|
|
|
|
end = 0xdeadbeef;
|
|
|
|
hres = ITextRange_GetEnd(txtRge, &end);
|
|
|
|
ok(hres == S_OK, "ITextRange_GetEnd\n");
|
|
|
|
ok(end == 6, "got wrong end value: %d\n", end);
|
|
|
|
ITextRange_Release(txtRge);
|
|
|
|
|
|
|
|
first = 6, lim = 1;
|
|
|
|
ITextDocument_Range(txtDoc, first, lim, &txtRge);
|
|
|
|
start = 0xdeadbeef;
|
|
|
|
hres = ITextRange_GetStart(txtRge, &start);
|
|
|
|
ok(hres == S_OK, "ITextRange_GetStart\n");
|
|
|
|
ok(start == 1, "got wrong start value: %d\n", start);
|
|
|
|
end = 0xdeadbeef;
|
|
|
|
hres = ITextRange_GetEnd(txtRge, &end);
|
|
|
|
ok(hres == S_OK, "ITextRange_GetEnd\n");
|
|
|
|
ok(end == 6, "got wrong end value: %d\n", end);
|
|
|
|
ITextRange_Release(txtRge);
|
|
|
|
|
|
|
|
first = -1, lim = 13;
|
|
|
|
ITextDocument_Range(txtDoc, first, lim, &txtRge);
|
|
|
|
start = 0xdeadbeef;
|
|
|
|
hres = ITextRange_GetStart(txtRge, &start);
|
|
|
|
ok(hres == S_OK, "ITextRange_GetStart\n");
|
|
|
|
ok(start == 0, "got wrong start value: %d\n", start);
|
|
|
|
end = 0xdeadbeef;
|
|
|
|
hres = ITextRange_GetEnd(txtRge, &end);
|
|
|
|
ok(hres == S_OK, "ITextRange_GetEnd\n");
|
|
|
|
ok(end == 13, "got wrong end value: %d\n", end);
|
|
|
|
ITextRange_Release(txtRge);
|
|
|
|
|
|
|
|
first = 13, lim = 13;
|
|
|
|
ITextDocument_Range(txtDoc, first, lim, &txtRge);
|
|
|
|
start = 0xdeadbeef;
|
|
|
|
hres = ITextRange_GetStart(txtRge, &start);
|
|
|
|
ok(hres == S_OK, "ITextRange_GetStart\n");
|
|
|
|
ok(start == 12, "got wrong start value: %d\n", start);
|
|
|
|
end = 0xdeadbeef;
|
|
|
|
hres = ITextRange_GetEnd(txtRge, &end);
|
|
|
|
ok(hres == S_OK, "ITextRange_GetEnd\n");
|
|
|
|
ok(end == 12, "got wrong end value: %d\n", end);
|
2015-05-17 16:28:41 +02:00
|
|
|
|
|
|
|
/* SetStart */
|
|
|
|
hres = ITextRange_SetStart(txtRge, 0);
|
|
|
|
ok(hres == S_OK, "got 0x%08x\n", hres);
|
|
|
|
|
|
|
|
/* same value */
|
|
|
|
hres = ITextRange_SetStart(txtRge, 0);
|
|
|
|
ok(hres == S_FALSE, "got 0x%08x\n", hres);
|
|
|
|
|
|
|
|
hres = ITextRange_SetStart(txtRge, 1);
|
|
|
|
ok(hres == S_OK, "got 0x%08x\n", hres);
|
|
|
|
|
|
|
|
/* negative resets to 0 */
|
|
|
|
hres = ITextRange_SetStart(txtRge, -1);
|
|
|
|
ok(hres == S_OK, "got 0x%08x\n", hres);
|
|
|
|
|
|
|
|
start = -1;
|
|
|
|
hres = ITextRange_GetStart(txtRge, &start);
|
|
|
|
ok(hres == S_OK, "got 0x%08x\n", hres);
|
|
|
|
ok(start == 0, "got %d\n", start);
|
|
|
|
|
|
|
|
/* greater than initial end, but less than total char count */
|
|
|
|
hres = ITextRange_SetStart(txtRge, 10);
|
|
|
|
ok(hres == S_OK, "got 0x%08x\n", hres);
|
|
|
|
|
|
|
|
start = 0;
|
|
|
|
hres = ITextRange_GetStart(txtRge, &start);
|
|
|
|
ok(hres == S_OK, "got 0x%08x\n", hres);
|
|
|
|
ok(start == 10, "got %d\n", start);
|
|
|
|
|
|
|
|
end = 0;
|
|
|
|
hres = ITextRange_GetEnd(txtRge, &end);
|
|
|
|
ok(hres == S_OK, "got 0x%08x\n", hres);
|
|
|
|
ok(end == 12, "got %d\n", end);
|
|
|
|
|
|
|
|
hres = ITextRange_SetStart(txtRge, 50);
|
|
|
|
ok(hres == S_OK, "got 0x%08x\n", hres);
|
|
|
|
|
|
|
|
start = 0;
|
|
|
|
hres = ITextRange_GetStart(txtRge, &start);
|
|
|
|
ok(hres == S_OK, "got 0x%08x\n", hres);
|
|
|
|
ok(start == 12, "got %d\n", start);
|
|
|
|
|
|
|
|
end = 0;
|
|
|
|
hres = ITextRange_GetEnd(txtRge, &end);
|
|
|
|
ok(hres == S_OK, "got 0x%08x\n", hres);
|
|
|
|
ok(end == 12, "got %d\n", end);
|
|
|
|
|
2015-05-17 16:30:06 +02:00
|
|
|
/* SetEnd */
|
|
|
|
hres = ITextRange_SetStart(txtRge, 0);
|
|
|
|
ok(hres == S_OK, "got 0x%08x\n", hres);
|
|
|
|
|
|
|
|
/* same value */
|
|
|
|
hres = ITextRange_SetEnd(txtRge, 5);
|
|
|
|
ok(hres == S_OK, "got 0x%08x\n", hres);
|
|
|
|
|
|
|
|
hres = ITextRange_SetEnd(txtRge, 5);
|
|
|
|
ok(hres == S_FALSE, "got 0x%08x\n", hres);
|
|
|
|
|
|
|
|
/* negative resets to 0 */
|
|
|
|
hres = ITextRange_SetEnd(txtRge, -1);
|
|
|
|
ok(hres == S_OK, "got 0x%08x\n", hres);
|
|
|
|
|
|
|
|
end = -1;
|
|
|
|
hres = ITextRange_GetEnd(txtRge, &end);
|
|
|
|
ok(hres == S_OK, "got 0x%08x\n", hres);
|
|
|
|
ok(end == 0, "got %d\n", end);
|
|
|
|
|
|
|
|
start = -1;
|
|
|
|
hres = ITextRange_GetStart(txtRge, &start);
|
|
|
|
ok(hres == S_OK, "got 0x%08x\n", hres);
|
|
|
|
ok(start == 0, "got %d\n", start);
|
|
|
|
|
|
|
|
/* greater than initial end, but less than total char count */
|
|
|
|
hres = ITextRange_SetStart(txtRge, 3);
|
|
|
|
ok(hres == S_OK, "got 0x%08x\n", hres);
|
|
|
|
|
|
|
|
hres = ITextRange_SetEnd(txtRge, 1);
|
|
|
|
ok(hres == S_OK, "got 0x%08x\n", hres);
|
|
|
|
|
|
|
|
start = 0;
|
|
|
|
hres = ITextRange_GetStart(txtRge, &start);
|
|
|
|
ok(hres == S_OK, "got 0x%08x\n", hres);
|
|
|
|
ok(start == 1, "got %d\n", start);
|
|
|
|
|
|
|
|
end = 0;
|
|
|
|
hres = ITextRange_GetEnd(txtRge, &end);
|
|
|
|
ok(hres == S_OK, "got 0x%08x\n", hres);
|
|
|
|
ok(end == 1, "got %d\n", end);
|
|
|
|
|
|
|
|
/* more than total count */
|
|
|
|
hres = ITextRange_SetEnd(txtRge, 50);
|
|
|
|
ok(hres == S_OK, "got 0x%08x\n", hres);
|
|
|
|
|
|
|
|
start = 0;
|
|
|
|
hres = ITextRange_GetStart(txtRge, &start);
|
|
|
|
ok(hres == S_OK, "got 0x%08x\n", hres);
|
|
|
|
ok(start == 1, "got %d\n", start);
|
|
|
|
|
|
|
|
end = 0;
|
|
|
|
hres = ITextRange_GetEnd(txtRge, &end);
|
|
|
|
ok(hres == S_OK, "got 0x%08x\n", hres);
|
|
|
|
ok(end == 13, "got %d\n", end);
|
|
|
|
|
|
|
|
/* zero */
|
|
|
|
hres = ITextRange_SetEnd(txtRge, 0);
|
|
|
|
ok(hres == S_OK, "got 0x%08x\n", hres);
|
|
|
|
|
|
|
|
start = 0;
|
|
|
|
hres = ITextRange_GetStart(txtRge, &start);
|
|
|
|
ok(hres == S_OK, "got 0x%08x\n", hres);
|
|
|
|
ok(start == 0, "got %d\n", start);
|
|
|
|
|
|
|
|
end = 0;
|
|
|
|
hres = ITextRange_GetEnd(txtRge, &end);
|
|
|
|
ok(hres == S_OK, "got 0x%08x\n", hres);
|
|
|
|
ok(end == 0, "got %d\n", end);
|
|
|
|
|
2014-09-16 12:38:56 +02:00
|
|
|
ITextRange_Release(txtRge);
|
|
|
|
|
|
|
|
release_interfaces(&w, &reOle, &txtDoc, NULL);
|
|
|
|
}
|
|
|
|
|
2014-09-16 12:39:10 +02:00
|
|
|
static void test_ITextSelection_GetStart_GetEnd(void)
|
|
|
|
{
|
|
|
|
HWND w;
|
|
|
|
IRichEditOle *reOle = NULL;
|
|
|
|
ITextDocument *txtDoc = NULL;
|
|
|
|
ITextSelection *txtSel = NULL;
|
|
|
|
HRESULT hres;
|
|
|
|
int first, lim, start, end;
|
|
|
|
static const CHAR test_text1[] = "TestSomeText";
|
|
|
|
|
|
|
|
create_interfaces(&w, &reOle, &txtDoc, &txtSel);
|
|
|
|
SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
|
|
|
|
|
|
|
|
first = 2, lim = 5;
|
|
|
|
SendMessageA(w, EM_SETSEL, first, lim);
|
|
|
|
start = 0xdeadbeef;
|
|
|
|
hres = ITextSelection_GetStart(txtSel, &start);
|
|
|
|
ok(hres == S_OK, "ITextSelection_GetStart\n");
|
|
|
|
ok(start == 2, "got wrong start value: %d\n", start);
|
|
|
|
end = 0xdeadbeef;
|
|
|
|
hres = ITextSelection_GetEnd(txtSel, &end);
|
|
|
|
ok(hres == S_OK, "ITextSelection_GetEnd\n");
|
|
|
|
ok(end == 5, "got wrong end value: %d\n", end);
|
|
|
|
|
|
|
|
first = 5, lim = 2;
|
|
|
|
SendMessageA(w, EM_SETSEL, first, lim);
|
|
|
|
start = 0xdeadbeef;
|
|
|
|
hres = ITextSelection_GetStart(txtSel, &start);
|
|
|
|
ok(hres == S_OK, "ITextSelection_GetStart\n");
|
|
|
|
ok(start == 2, "got wrong start value: %d\n", start);
|
|
|
|
end = 0xdeadbeef;
|
|
|
|
hres = ITextSelection_GetEnd(txtSel, &end);
|
|
|
|
ok(hres == S_OK, "ITextSelection_GetEnd\n");
|
|
|
|
ok(end == 5, "got wrong end value: %d\n", end);
|
|
|
|
|
|
|
|
first = 0, lim = -1;
|
|
|
|
SendMessageA(w, EM_SETSEL, first, lim);
|
|
|
|
start = 0xdeadbeef;
|
|
|
|
hres = ITextSelection_GetStart(txtSel, &start);
|
|
|
|
ok(hres == S_OK, "ITextSelection_GetStart\n");
|
|
|
|
ok(start == 0, "got wrong start value: %d\n", start);
|
|
|
|
end = 0xdeadbeef;
|
|
|
|
hres = ITextSelection_GetEnd(txtSel, &end);
|
|
|
|
ok(hres == S_OK, "ITextSelection_GetEnd\n");
|
|
|
|
ok(end == 13, "got wrong end value: %d\n", end);
|
|
|
|
|
|
|
|
first = 13, lim = 13;
|
|
|
|
SendMessageA(w, EM_SETSEL, first, lim);
|
|
|
|
start = 0xdeadbeef;
|
|
|
|
hres = ITextSelection_GetStart(txtSel, &start);
|
|
|
|
ok(hres == S_OK, "ITextSelection_GetStart\n");
|
|
|
|
ok(start == 12, "got wrong start value: %d\n", start);
|
|
|
|
end = 0xdeadbeef;
|
|
|
|
hres = ITextSelection_GetEnd(txtSel, &end);
|
|
|
|
ok(hres == S_OK, "ITextSelection_GetEnd\n");
|
|
|
|
ok(end == 12, "got wrong end value: %d\n", end);
|
|
|
|
|
|
|
|
release_interfaces(&w, &reOle, &txtDoc, &txtSel);
|
|
|
|
}
|
|
|
|
|
2014-09-17 11:36:44 +02:00
|
|
|
static void test_ITextRange_GetDuplicate(void)
|
|
|
|
{
|
|
|
|
HWND w;
|
|
|
|
IRichEditOle *reOle = NULL;
|
|
|
|
ITextDocument *txtDoc = NULL;
|
|
|
|
ITextRange *txtRge = NULL;
|
|
|
|
ITextRange *txtRgeDup = NULL;
|
|
|
|
HRESULT hres;
|
|
|
|
LONG first, lim, start, end;
|
|
|
|
static const CHAR test_text1[] = "TestSomeText";
|
|
|
|
|
|
|
|
create_interfaces(&w, &reOle, &txtDoc, NULL);
|
|
|
|
SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
|
|
|
|
first = 0, lim = 4;
|
|
|
|
hres = ITextDocument_Range(txtDoc, first, lim, &txtRge);
|
|
|
|
ok(hres == S_OK, "ITextDocument_Range fails 0x%x.\n", hres);
|
|
|
|
|
|
|
|
hres = ITextRange_GetDuplicate(txtRge, &txtRgeDup);
|
|
|
|
ok(hres == S_OK, "ITextRange_GetDuplicate\n");
|
|
|
|
ok(txtRgeDup != txtRge, "A new pointer should be returned\n");
|
|
|
|
ITextRange_GetStart(txtRgeDup, &start);
|
|
|
|
ok(start == first, "got wrong value: %d\n", start);
|
|
|
|
ITextRange_GetEnd(txtRgeDup, &end);
|
|
|
|
ok(end == lim, "got wrong value: %d\n", end);
|
|
|
|
|
|
|
|
ITextRange_Release(txtRgeDup);
|
|
|
|
|
|
|
|
hres = ITextRange_GetDuplicate(txtRge, NULL);
|
|
|
|
ok(hres == E_INVALIDARG, "ITextRange_GetDuplicate\n");
|
|
|
|
|
|
|
|
ITextRange_Release(txtRge);
|
|
|
|
release_interfaces(&w, &reOle, &txtDoc, NULL);
|
|
|
|
}
|
|
|
|
|
2014-09-17 11:38:31 +02:00
|
|
|
static void test_ITextRange_Collapse(void)
|
|
|
|
{
|
|
|
|
HWND w;
|
|
|
|
IRichEditOle *reOle = NULL;
|
|
|
|
ITextDocument *txtDoc = NULL;
|
|
|
|
ITextRange *txtRge = NULL;
|
|
|
|
HRESULT hres;
|
|
|
|
LONG first, lim, start, end;
|
|
|
|
static const CHAR test_text1[] = "TestSomeText";
|
|
|
|
|
|
|
|
create_interfaces(&w, &reOle, &txtDoc, NULL);
|
|
|
|
SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
|
|
|
|
|
|
|
|
first = 4, lim = 8;
|
|
|
|
ITextDocument_Range(txtDoc, first, lim, &txtRge);
|
|
|
|
hres = ITextRange_Collapse(txtRge, tomTrue);
|
|
|
|
ok(hres == S_OK, "ITextRange_Collapse\n");
|
|
|
|
ITextRange_GetStart(txtRge, &start);
|
|
|
|
ok(start == 4, "got wrong start value: %d\n", start);
|
|
|
|
ITextRange_GetEnd(txtRge, &end);
|
|
|
|
ok(end == 4, "got wrong end value: %d\n", end);
|
|
|
|
ITextRange_Release(txtRge);
|
|
|
|
|
|
|
|
ITextDocument_Range(txtDoc, first, lim, &txtRge);
|
|
|
|
hres = ITextRange_Collapse(txtRge, tomStart);
|
|
|
|
ok(hres == S_OK, "ITextRange_Collapse\n");
|
|
|
|
ITextRange_GetStart(txtRge, &start);
|
|
|
|
ok(start == 4, "got wrong start value: %d\n", start);
|
|
|
|
ITextRange_GetEnd(txtRge, &end);
|
|
|
|
ok(end == 4, "got wrong end value: %d\n", end);
|
|
|
|
ITextRange_Release(txtRge);
|
|
|
|
|
|
|
|
ITextDocument_Range(txtDoc, first, lim, &txtRge);
|
|
|
|
hres = ITextRange_Collapse(txtRge, tomFalse);
|
|
|
|
ok(hres == S_OK, "ITextRange_Collapse\n");
|
|
|
|
ITextRange_GetStart(txtRge, &start);
|
|
|
|
ok(start == 8, "got wrong start value: %d\n", start);
|
|
|
|
ITextRange_GetEnd(txtRge, &end);
|
|
|
|
ok(end == 8, "got wrong end value: %d\n", end);
|
|
|
|
ITextRange_Release(txtRge);
|
|
|
|
|
|
|
|
ITextDocument_Range(txtDoc, first, lim, &txtRge);
|
|
|
|
hres = ITextRange_Collapse(txtRge, tomEnd);
|
|
|
|
ok(hres == S_OK, "ITextRange_Collapse\n");
|
|
|
|
ITextRange_GetStart(txtRge, &start);
|
|
|
|
ok(start == 8, "got wrong start value: %d\n", start);
|
|
|
|
ITextRange_GetEnd(txtRge, &end);
|
|
|
|
ok(end == 8, "got wrong end value: %d\n", end);
|
|
|
|
ITextRange_Release(txtRge);
|
|
|
|
|
|
|
|
/* tomStart is the default */
|
|
|
|
ITextDocument_Range(txtDoc, first, lim, &txtRge);
|
|
|
|
hres = ITextRange_Collapse(txtRge, 256);
|
|
|
|
ok(hres == S_OK, "ITextRange_Collapse\n");
|
|
|
|
ITextRange_GetStart(txtRge, &start);
|
|
|
|
ok(start == 4, "got wrong start value: %d\n", start);
|
|
|
|
ITextRange_GetEnd(txtRge, &end);
|
|
|
|
ok(end == 4, "got wrong end value: %d\n", end);
|
|
|
|
ITextRange_Release(txtRge);
|
|
|
|
|
|
|
|
first = 6, lim = 6;
|
|
|
|
ITextDocument_Range(txtDoc, first, lim, &txtRge);
|
|
|
|
hres = ITextRange_Collapse(txtRge, tomEnd);
|
|
|
|
ok(hres == S_FALSE, "ITextRange_Collapse\n");
|
|
|
|
ITextRange_GetStart(txtRge, &start);
|
|
|
|
ok(start == 6, "got wrong start value: %d\n", start);
|
|
|
|
ITextRange_GetEnd(txtRge, &end);
|
|
|
|
ok(end == 6, "got wrong end value: %d\n", end);
|
|
|
|
ITextRange_Release(txtRge);
|
|
|
|
|
|
|
|
first = 8, lim = 8;
|
|
|
|
ITextDocument_Range(txtDoc, first, lim, &txtRge);
|
|
|
|
hres = ITextRange_Collapse(txtRge, tomStart);
|
|
|
|
ok(hres == S_FALSE, "ITextRange_Collapse\n");
|
|
|
|
ITextRange_GetStart(txtRge, &start);
|
|
|
|
ok(start == 8, "got wrong start value: %d\n", start);
|
|
|
|
ITextRange_GetEnd(txtRge, &end);
|
|
|
|
ok(end == 8, "got wrong end value: %d\n", end);
|
|
|
|
ITextRange_Release(txtRge);
|
|
|
|
|
|
|
|
release_interfaces(&w, &reOle, &txtDoc, NULL);
|
|
|
|
}
|
|
|
|
|
2014-09-17 11:38:47 +02:00
|
|
|
static void test_ITextSelection_Collapse(void)
|
|
|
|
{
|
|
|
|
HWND w;
|
|
|
|
IRichEditOle *reOle = NULL;
|
|
|
|
ITextDocument *txtDoc = NULL;
|
|
|
|
ITextSelection *txtSel = NULL;
|
|
|
|
HRESULT hres;
|
|
|
|
LONG first, lim, start, end;
|
|
|
|
static const CHAR test_text1[] = "TestSomeText";
|
|
|
|
|
|
|
|
create_interfaces(&w, &reOle, &txtDoc, &txtSel);
|
|
|
|
SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
|
|
|
|
|
|
|
|
first = 4, lim = 8;
|
|
|
|
SendMessageA(w, EM_SETSEL, first, lim);
|
|
|
|
hres = ITextSelection_Collapse(txtSel, tomTrue);
|
|
|
|
ok(hres == S_OK, "ITextSelection_Collapse\n");
|
|
|
|
SendMessageA(w, EM_GETSEL, (LPARAM)&start, (WPARAM)&end);
|
|
|
|
ok(start == 4, "got wrong start value: %d\n", start);
|
|
|
|
ok(end == 4, "got wrong end value: %d\n", end);
|
|
|
|
|
|
|
|
SendMessageA(w, EM_SETSEL, first, lim);
|
|
|
|
hres = ITextSelection_Collapse(txtSel, tomStart);
|
|
|
|
ok(hres == S_OK, "ITextSelection_Collapse\n");
|
|
|
|
SendMessageA(w, EM_GETSEL, (LPARAM)&start, (WPARAM)&end);
|
|
|
|
ok(start == 4, "got wrong start value: %d\n", start);
|
|
|
|
ok(end == 4, "got wrong end value: %d\n", end);
|
|
|
|
|
|
|
|
SendMessageA(w, EM_SETSEL, first, lim);
|
|
|
|
hres = ITextSelection_Collapse(txtSel, tomFalse);
|
|
|
|
ok(hres == S_OK, "ITextSelection_Collapse\n");
|
|
|
|
SendMessageA(w, EM_GETSEL, (LPARAM)&start, (WPARAM)&end);
|
|
|
|
ok(start == 8, "got wrong start value: %d\n", start);
|
|
|
|
ok(end == 8, "got wrong end value: %d\n", end);
|
|
|
|
|
|
|
|
SendMessageA(w, EM_SETSEL, first, lim);
|
|
|
|
hres = ITextSelection_Collapse(txtSel, tomEnd);
|
|
|
|
ok(hres == S_OK, "ITextSelection_Collapse\n");
|
|
|
|
SendMessageA(w, EM_GETSEL, (LPARAM)&start, (WPARAM)&end);
|
|
|
|
ok(start == 8, "got wrong start value: %d\n", start);
|
|
|
|
ok(end == 8, "got wrong end value: %d\n", end);
|
|
|
|
|
|
|
|
/* tomStart is the default */
|
|
|
|
SendMessageA(w, EM_SETSEL, first, lim);
|
|
|
|
hres = ITextSelection_Collapse(txtSel, 256);
|
|
|
|
ok(hres == S_OK, "ITextSelection_Collapse\n");
|
|
|
|
SendMessageA(w, EM_GETSEL, (LPARAM)&start, (WPARAM)&end);
|
|
|
|
ok(start == 4, "got wrong start value: %d\n", start);
|
|
|
|
ok(end == 4, "got wrong end value: %d\n", end);
|
|
|
|
|
|
|
|
first = 6, lim = 6;
|
|
|
|
SendMessageA(w, EM_SETSEL, first, lim);
|
|
|
|
hres = ITextSelection_Collapse(txtSel, tomEnd);
|
|
|
|
ok(hres == S_FALSE, "ITextSelection_Collapse\n");
|
|
|
|
SendMessageA(w, EM_GETSEL, (LPARAM)&start, (WPARAM)&end);
|
|
|
|
ok(start == 6, "got wrong start value: %d\n", start);
|
|
|
|
ok(end == 6, "got wrong end value: %d\n", end);
|
|
|
|
|
|
|
|
first = 8, lim = 8;
|
|
|
|
SendMessageA(w, EM_SETSEL, first, lim);
|
|
|
|
hres = ITextSelection_Collapse(txtSel, tomStart);
|
|
|
|
ok(hres == S_FALSE, "ITextSelection_Collapse\n");
|
|
|
|
SendMessageA(w, EM_GETSEL, (LPARAM)&start, (WPARAM)&end);
|
|
|
|
ok(start == 8, "got wrong start value: %d\n", start);
|
|
|
|
ok(end == 8, "got wrong end value: %d\n", end);
|
|
|
|
|
|
|
|
release_interfaces(&w, &reOle, &txtDoc, &txtSel);
|
|
|
|
}
|
|
|
|
|
2015-03-16 10:27:21 +01:00
|
|
|
static void test_IOleClientSite_QueryInterface(void)
|
|
|
|
{
|
|
|
|
HWND w;
|
|
|
|
IRichEditOle *reOle = NULL, *reOle1 = NULL;
|
|
|
|
ITextDocument *txtDoc = NULL;
|
|
|
|
IOleClientSite *clientSite = NULL, *clientSite1 = NULL, *clientSite2 = NULL;
|
|
|
|
IOleWindow *oleWin = NULL, *oleWin1 = NULL;
|
2015-03-17 09:17:39 +01:00
|
|
|
IOleInPlaceSite *olePlace = NULL, *olePlace1 = NULL;
|
2015-03-16 10:27:21 +01:00
|
|
|
HRESULT hres;
|
|
|
|
LONG refcount1, refcount2;
|
|
|
|
|
|
|
|
create_interfaces(&w, &reOle, &txtDoc, NULL);
|
|
|
|
hres = IRichEditOle_GetClientSite(reOle, &clientSite);
|
|
|
|
ok(hres == S_OK, "IRichEditOle_QueryInterface: 0x%08x\n", hres);
|
|
|
|
refcount1 = get_refcount((IUnknown *)clientSite);
|
|
|
|
todo_wine ok(refcount1 == 1, "got wrong ref count: %d\n", refcount1);
|
|
|
|
|
|
|
|
hres = IOleClientSite_QueryInterface(clientSite, &IID_IRichEditOle, (void **)&reOle1);
|
|
|
|
ok(hres == E_NOINTERFACE, "IOleClientSite_QueryInterface: %x\n", hres);
|
|
|
|
|
|
|
|
hres = IOleClientSite_QueryInterface(clientSite, &IID_IOleClientSite, (void **)&clientSite1);
|
|
|
|
ok(hres == S_OK, "IOleClientSite_QueryInterface: 0x%08x\n", hres);
|
|
|
|
ok(clientSite == clientSite1, "Should not return a new pointer.\n");
|
|
|
|
refcount1 = get_refcount((IUnknown *)clientSite);
|
|
|
|
todo_wine ok(refcount1 == 2, "got wrong ref count: %d\n", refcount1);
|
|
|
|
|
|
|
|
/* IOleWindow interface */
|
|
|
|
hres = IOleClientSite_QueryInterface(clientSite, &IID_IOleWindow, (void **)&oleWin);
|
|
|
|
ok(hres == S_OK, "IOleClientSite_QueryInterface: 0x%08x\n", hres);
|
|
|
|
refcount1 = get_refcount((IUnknown *)clientSite);
|
|
|
|
refcount2 = get_refcount((IUnknown *)oleWin);
|
|
|
|
ok(refcount1 == refcount2, "got wrong ref count.\n");
|
|
|
|
|
|
|
|
hres = IOleClientSite_QueryInterface(clientSite, &IID_IOleWindow, (void **)&oleWin1);
|
|
|
|
ok(hres == S_OK, "IOleClientSite_QueryInterface: 0x%08x\n", hres);
|
|
|
|
ok(oleWin == oleWin1, "Should not return a new pointer.\n");
|
|
|
|
refcount1 = get_refcount((IUnknown *)clientSite);
|
|
|
|
refcount2 = get_refcount((IUnknown *)oleWin);
|
|
|
|
ok(refcount1 == refcount2, "got wrong ref count.\n");
|
|
|
|
|
|
|
|
hres = IOleWindow_QueryInterface(oleWin, &IID_IOleClientSite, (void **)&clientSite2);
|
|
|
|
ok(hres == S_OK, "IOleWindow_QueryInterface: 0x%08x\n", hres);
|
|
|
|
ok(clientSite2 == clientSite1, "got wrong pointer\n");
|
|
|
|
|
2015-03-17 09:17:39 +01:00
|
|
|
/* IOleInPlaceSite interface */
|
|
|
|
hres = IOleClientSite_QueryInterface(clientSite, &IID_IOleInPlaceSite, (void **)&olePlace);
|
|
|
|
ok(hres == S_OK, "IOleClientSite_QueryInterface: 0x%08x\n", hres);
|
|
|
|
refcount1 = get_refcount((IUnknown *)olePlace);
|
|
|
|
refcount2 = get_refcount((IUnknown *)clientSite);
|
|
|
|
ok(refcount1 == refcount2, "got wrong ref count.\n");
|
|
|
|
|
|
|
|
hres = IOleClientSite_QueryInterface(clientSite, &IID_IOleInPlaceSite, (void **)&olePlace1);
|
|
|
|
ok(hres == S_OK, "IOleClientSite_QueryInterface: 0x%08x\n", hres);
|
|
|
|
ok(olePlace == olePlace1, "Should not return a new pointer.\n");
|
|
|
|
IOleInPlaceSite_Release(olePlace1);
|
|
|
|
|
|
|
|
hres = IOleWindow_QueryInterface(oleWin, &IID_IOleInPlaceSite, (void **)&olePlace1);
|
|
|
|
ok(hres == S_OK, "IOleWindow_QueryInterface: 0x%08x\n", hres);
|
|
|
|
refcount1 = get_refcount((IUnknown *)olePlace1);
|
|
|
|
refcount2 = get_refcount((IUnknown *)oleWin);
|
|
|
|
ok(refcount1 == refcount2, "got wrong ref count.\n");
|
|
|
|
|
|
|
|
IOleInPlaceSite_Release(olePlace1);
|
|
|
|
IOleInPlaceSite_Release(olePlace);
|
2015-03-16 10:27:21 +01:00
|
|
|
IOleWindow_Release(oleWin1);
|
|
|
|
IOleWindow_Release(oleWin);
|
|
|
|
IOleClientSite_Release(clientSite2);
|
|
|
|
IOleClientSite_Release(clientSite1);
|
|
|
|
IOleClientSite_Release(clientSite);
|
|
|
|
release_interfaces(&w, &reOle, &txtDoc, NULL);
|
|
|
|
}
|
|
|
|
|
2015-03-16 10:27:38 +01:00
|
|
|
static void test_IOleWindow_GetWindow(void)
|
|
|
|
{
|
|
|
|
HWND w;
|
|
|
|
IRichEditOle *reOle = NULL;
|
|
|
|
ITextDocument *txtDoc = NULL;
|
|
|
|
IOleClientSite *clientSite = NULL;
|
|
|
|
IOleWindow *oleWin = NULL;
|
|
|
|
HRESULT hres;
|
|
|
|
HWND hwnd;
|
|
|
|
|
|
|
|
create_interfaces(&w, &reOle, &txtDoc, NULL);
|
|
|
|
hres = IRichEditOle_GetClientSite(reOle, &clientSite);
|
|
|
|
ok(hres == S_OK, "IRichEditOle_QueryInterface: 0x%08x\n", hres);
|
|
|
|
|
|
|
|
hres = IOleClientSite_QueryInterface(clientSite, &IID_IOleWindow, (void **)&oleWin);
|
|
|
|
ok(hres == S_OK, "IOleClientSite_QueryInterface: 0x%08x\n", hres);
|
|
|
|
hres = IOleWindow_GetWindow(oleWin, &hwnd);
|
|
|
|
ok(hres == S_OK, "IOleClientSite_GetWindow: 0x%08x\n", hres);
|
|
|
|
ok(w == hwnd, "got wrong pointer\n");
|
|
|
|
|
|
|
|
hres = IOleWindow_GetWindow(oleWin, NULL);
|
|
|
|
ok(hres == E_INVALIDARG, "IOleClientSite_GetWindow: 0x%08x\n", hres);
|
|
|
|
|
|
|
|
IOleWindow_Release(oleWin);
|
|
|
|
IOleClientSite_Release(clientSite);
|
|
|
|
release_interfaces(&w, &reOle, &txtDoc, NULL);
|
|
|
|
}
|
|
|
|
|
2015-03-17 09:17:39 +01:00
|
|
|
static void test_IOleInPlaceSite_GetWindow(void)
|
|
|
|
{
|
|
|
|
HWND w;
|
|
|
|
IRichEditOle *reOle = NULL;
|
|
|
|
ITextDocument *txtDoc = NULL;
|
|
|
|
IOleClientSite *clientSite = NULL;
|
|
|
|
IOleInPlaceSite *olePlace = NULL;
|
|
|
|
HRESULT hres;
|
|
|
|
HWND hwnd;
|
|
|
|
|
|
|
|
create_interfaces(&w, &reOle, &txtDoc, NULL);
|
|
|
|
hres = IRichEditOle_GetClientSite(reOle, &clientSite);
|
|
|
|
ok(hres == S_OK, "IRichEditOle_QueryInterface: 0x%08x\n", hres);
|
|
|
|
|
|
|
|
hres = IOleClientSite_QueryInterface(clientSite, &IID_IOleInPlaceSite, (void **)&olePlace);
|
|
|
|
ok(hres == S_OK, "IOleClientSite_QueryInterface: 0x%08x\n", hres);
|
|
|
|
hres = IOleInPlaceSite_GetWindow(olePlace, &hwnd);
|
|
|
|
ok(hres == S_OK, "IOleInPlaceSite_GetWindow: 0x%08x\n", hres);
|
|
|
|
ok(w == hwnd, "got wrong pointer.\n");
|
|
|
|
|
|
|
|
hres = IOleInPlaceSite_GetWindow(olePlace, NULL);
|
|
|
|
ok(hres == E_INVALIDARG, "IOleInPlaceSite_GetWindow: 0x%08x\n", hres);
|
|
|
|
|
|
|
|
IOleInPlaceSite_Release(olePlace);
|
|
|
|
IOleClientSite_Release(clientSite);
|
|
|
|
release_interfaces(&w, &reOle, &txtDoc, NULL);
|
|
|
|
}
|
|
|
|
|
2015-05-17 16:26:33 +02:00
|
|
|
static void test_GetFont(void)
|
|
|
|
{
|
|
|
|
static const CHAR test_text1[] = "TestSomeText";
|
|
|
|
IRichEditOle *reOle = NULL;
|
|
|
|
ITextDocument *doc = NULL;
|
|
|
|
ITextRange *range = NULL;
|
2015-05-20 10:41:34 +02:00
|
|
|
ITextSelection *selection;
|
2015-05-17 16:26:33 +02:00
|
|
|
ITextFont *font, *font2;
|
2015-05-17 21:15:30 +02:00
|
|
|
CHARFORMAT2A cf;
|
|
|
|
LONG value;
|
2015-05-20 09:26:21 +02:00
|
|
|
float size;
|
2015-05-17 16:26:33 +02:00
|
|
|
HRESULT hr;
|
|
|
|
HWND hwnd;
|
2015-05-17 21:15:30 +02:00
|
|
|
BOOL ret;
|
2015-05-17 16:26:33 +02:00
|
|
|
|
|
|
|
create_interfaces(&hwnd, &reOle, &doc, NULL);
|
|
|
|
SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1);
|
|
|
|
|
2015-05-20 10:41:34 +02:00
|
|
|
hr = ITextDocument_GetSelection(doc, &selection);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
hr = ITextSelection_GetFont(selection, &font);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
hr = ITextSelection_GetFont(selection, &font2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(font != font2, "got %p, %p\n", font, font2);
|
|
|
|
ITextFont_Release(font2);
|
|
|
|
ITextFont_Release(font);
|
|
|
|
ITextSelection_Release(selection);
|
|
|
|
|
2015-05-17 16:26:33 +02:00
|
|
|
EXPECT_REF(reOle, 3);
|
|
|
|
EXPECT_REF(doc, 3);
|
|
|
|
|
|
|
|
hr = ITextDocument_Range(doc, 0, 4, &range);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
EXPECT_REF(reOle, 3);
|
|
|
|
EXPECT_REF(doc, 3);
|
|
|
|
EXPECT_REF(range, 1);
|
|
|
|
|
|
|
|
hr = ITextRange_GetFont(range, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = ITextRange_GetFont(range, &font);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
EXPECT_REF(reOle, 3);
|
|
|
|
EXPECT_REF(doc, 3);
|
|
|
|
EXPECT_REF(range, 2);
|
|
|
|
EXPECT_REF(font, 1);
|
|
|
|
|
|
|
|
hr = ITextRange_GetFont(range, &font2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(font != font2, "got %p, %p\n", font, font2);
|
|
|
|
|
|
|
|
EXPECT_REF(reOle, 3);
|
|
|
|
EXPECT_REF(doc, 3);
|
|
|
|
EXPECT_REF(range, 3);
|
|
|
|
EXPECT_REF(font, 1);
|
|
|
|
EXPECT_REF(font2, 1);
|
|
|
|
|
|
|
|
ITextFont_Release(font2);
|
2015-05-17 21:15:30 +02:00
|
|
|
|
|
|
|
/* set different font style within a range */
|
|
|
|
hr = ITextFont_GetItalic(font, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
|
2015-05-20 09:26:21 +02:00
|
|
|
hr = ITextFont_GetSize(font, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
size = 0.0;
|
|
|
|
hr = ITextFont_GetSize(font, &size);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(size > 0.0, "size %.2f\n", size);
|
|
|
|
|
2015-05-20 10:18:52 +02:00
|
|
|
value = 0;
|
|
|
|
hr = ITextFont_GetLanguageID(font, &value);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
todo_wine
|
2015-05-21 10:47:16 +02:00
|
|
|
ok(value == GetSystemDefaultLCID(), "got lcid %x, user lcid %x\n", value,
|
|
|
|
GetSystemDefaultLCID());
|
2015-05-20 10:18:52 +02:00
|
|
|
|
2015-05-17 21:15:30 +02:00
|
|
|
/* range is non-italic */
|
|
|
|
value = tomTrue;
|
|
|
|
hr = ITextFont_GetItalic(font, &value);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(value == tomFalse, "got %d\n", value);
|
|
|
|
|
|
|
|
cf.cbSize = sizeof(CHARFORMAT2A);
|
2015-05-20 09:26:21 +02:00
|
|
|
cf.dwMask = CFM_ITALIC|CFM_SIZE;
|
2015-05-17 21:15:30 +02:00
|
|
|
cf.dwEffects = CFE_ITALIC;
|
2015-05-20 09:26:21 +02:00
|
|
|
cf.yHeight = 24.0;
|
2015-05-17 21:15:30 +02:00
|
|
|
|
|
|
|
SendMessageA(hwnd, EM_SETSEL, 2, 3);
|
|
|
|
ret = SendMessageA(hwnd, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
|
|
|
|
ok(ret, "got %d\n", ret);
|
|
|
|
|
|
|
|
/* now range is partially italicized */
|
|
|
|
value = tomFalse;
|
|
|
|
hr = ITextFont_GetItalic(font, &value);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(value == tomUndefined, "got %d\n", value);
|
|
|
|
|
2015-05-20 09:26:21 +02:00
|
|
|
size = 0.0;
|
|
|
|
hr = ITextFont_GetSize(font, &size);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(size == tomUndefined, "size %.2f\n", size);
|
|
|
|
|
2015-05-17 21:15:30 +02:00
|
|
|
ITextFont_Release(font);
|
2015-05-17 16:26:33 +02:00
|
|
|
ITextRange_Release(range);
|
|
|
|
release_interfaces(&hwnd, &reOle, &doc, NULL);
|
|
|
|
}
|
|
|
|
|
2015-05-17 16:27:42 +02:00
|
|
|
static void test_GetPara(void)
|
|
|
|
{
|
|
|
|
static const CHAR test_text1[] = "TestSomeText";
|
|
|
|
IRichEditOle *reOle = NULL;
|
|
|
|
ITextDocument *doc = NULL;
|
|
|
|
ITextRange *range = NULL;
|
|
|
|
ITextPara *para, *para2;
|
|
|
|
HRESULT hr;
|
|
|
|
HWND hwnd;
|
|
|
|
|
|
|
|
create_interfaces(&hwnd, &reOle, &doc, NULL);
|
|
|
|
SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1);
|
|
|
|
|
|
|
|
EXPECT_REF(reOle, 3);
|
|
|
|
EXPECT_REF(doc, 3);
|
|
|
|
|
|
|
|
hr = ITextDocument_Range(doc, 0, 4, &range);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
EXPECT_REF(reOle, 3);
|
|
|
|
EXPECT_REF(doc, 3);
|
|
|
|
EXPECT_REF(range, 1);
|
|
|
|
|
|
|
|
hr = ITextRange_GetPara(range, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = ITextRange_GetPara(range, ¶);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
EXPECT_REF(reOle, 3);
|
|
|
|
EXPECT_REF(doc, 3);
|
|
|
|
EXPECT_REF(range, 2);
|
|
|
|
EXPECT_REF(para, 1);
|
|
|
|
|
|
|
|
hr = ITextRange_GetPara(range, ¶2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(para != para2, "got %p, %p\n", para, para2);
|
|
|
|
|
|
|
|
EXPECT_REF(reOle, 3);
|
|
|
|
EXPECT_REF(doc, 3);
|
|
|
|
EXPECT_REF(range, 3);
|
|
|
|
EXPECT_REF(para, 1);
|
|
|
|
EXPECT_REF(para2, 1);
|
|
|
|
|
|
|
|
ITextPara_Release(para);
|
|
|
|
ITextPara_Release(para2);
|
|
|
|
ITextRange_Release(range);
|
|
|
|
release_interfaces(&hwnd, &reOle, &doc, NULL);
|
|
|
|
}
|
|
|
|
|
2015-05-17 16:30:56 +02:00
|
|
|
static void test_dispatch(void)
|
|
|
|
{
|
|
|
|
static const WCHAR testnameW[] = {'G','e','t','T','e','x','t',0};
|
|
|
|
static const WCHAR testname2W[] = {'T','e','x','t',0};
|
|
|
|
IRichEditOle *reOle = NULL;
|
|
|
|
ITextDocument *doc = NULL;
|
|
|
|
ITextRange *range = NULL;
|
|
|
|
WCHAR *nameW;
|
|
|
|
DISPID dispid;
|
|
|
|
HRESULT hr;
|
|
|
|
HWND hwnd;
|
|
|
|
|
|
|
|
create_interfaces(&hwnd, &reOle, &doc, NULL);
|
|
|
|
|
|
|
|
range = NULL;
|
|
|
|
hr = ITextDocument_Range(doc, 0, 0, &range);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(range != NULL, "got %p\n", range);
|
|
|
|
|
|
|
|
dispid = 123;
|
|
|
|
nameW = (WCHAR*)testnameW;
|
|
|
|
hr = ITextRange_GetIDsOfNames(range, &IID_NULL, &nameW, 1, LOCALE_USER_DEFAULT, &dispid);
|
|
|
|
todo_wine {
|
|
|
|
ok(hr == DISP_E_UNKNOWNNAME, "got 0x%08x\n", hr);
|
|
|
|
ok(dispid == DISPID_UNKNOWN, "got %d\n", dispid);
|
|
|
|
}
|
|
|
|
dispid = 123;
|
|
|
|
nameW = (WCHAR*)testname2W;
|
|
|
|
hr = ITextRange_GetIDsOfNames(range, &IID_NULL, &nameW, 1, LOCALE_USER_DEFAULT, &dispid);
|
|
|
|
todo_wine {
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(dispid == DISPID_VALUE, "got %d\n", dispid);
|
|
|
|
}
|
|
|
|
ITextRange_Release(range);
|
|
|
|
release_interfaces(&hwnd, &reOle, &doc, NULL);
|
|
|
|
}
|
|
|
|
|
2015-05-21 10:25:24 +02:00
|
|
|
static void test_ITextFont(void)
|
|
|
|
{
|
|
|
|
static const WCHAR sysW[] = {'S','y','s','t','e','m',0};
|
|
|
|
static const WCHAR arialW[] = {'A','r','i','a','l',0};
|
|
|
|
static const CHAR test_text1[] = "TestSomeText";
|
|
|
|
IRichEditOle *reOle = NULL;
|
|
|
|
ITextDocument *doc = NULL;
|
|
|
|
ITextRange *range = NULL;
|
|
|
|
ITextFont *font;
|
|
|
|
CHARFORMAT2A cf;
|
2015-05-21 11:13:42 +02:00
|
|
|
LONG value;
|
|
|
|
float size;
|
2015-05-21 10:25:24 +02:00
|
|
|
HRESULT hr;
|
|
|
|
HWND hwnd;
|
|
|
|
BOOL ret;
|
|
|
|
BSTR str;
|
|
|
|
|
|
|
|
create_interfaces(&hwnd, &reOle, &doc, NULL);
|
|
|
|
SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1);
|
|
|
|
|
|
|
|
hr = ITextDocument_Range(doc, 0, 10, &range);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = ITextRange_GetFont(range, &font);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = ITextFont_GetName(font, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
/* default font name */
|
|
|
|
str = NULL;
|
|
|
|
hr = ITextFont_GetName(font, &str);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(!lstrcmpW(str, sysW), "got %s\n", wine_dbgstr_w(str));
|
|
|
|
SysFreeString(str);
|
|
|
|
|
|
|
|
/* change font name for an inner subrange */
|
|
|
|
memset(&cf, 0, sizeof(cf));
|
|
|
|
cf.cbSize = sizeof(cf);
|
|
|
|
cf.dwMask = CFM_FACE;
|
|
|
|
strcpy(cf.szFaceName, "Arial");
|
|
|
|
|
|
|
|
SendMessageA(hwnd, EM_SETSEL, 3, 4);
|
|
|
|
ret = SendMessageA(hwnd, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
|
|
|
|
ok(ret, "got %d\n", ret);
|
|
|
|
|
|
|
|
/* still original name */
|
|
|
|
str = NULL;
|
|
|
|
hr = ITextFont_GetName(font, &str);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(!lstrcmpW(str, sysW), "got %s\n", wine_dbgstr_w(str));
|
|
|
|
SysFreeString(str);
|
|
|
|
|
|
|
|
SendMessageA(hwnd, EM_SETSEL, 1, 2);
|
|
|
|
ret = SendMessageA(hwnd, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
|
|
|
|
ok(ret, "got %d\n", ret);
|
|
|
|
|
|
|
|
str = NULL;
|
|
|
|
hr = ITextFont_GetName(font, &str);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(!lstrcmpW(str, sysW), "got %s\n", wine_dbgstr_w(str));
|
|
|
|
SysFreeString(str);
|
|
|
|
|
|
|
|
/* name is returned for first position within a range */
|
|
|
|
SendMessageA(hwnd, EM_SETSEL, 0, 1);
|
|
|
|
ret = SendMessageA(hwnd, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
|
|
|
|
ok(ret, "got %d\n", ret);
|
|
|
|
|
|
|
|
str = NULL;
|
|
|
|
hr = ITextFont_GetName(font, &str);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(!lstrcmpW(str, arialW), "got %s\n", wine_dbgstr_w(str));
|
|
|
|
SysFreeString(str);
|
|
|
|
|
|
|
|
ITextRange_Release(range);
|
|
|
|
release_interfaces(&hwnd, &reOle, &doc, NULL);
|
2015-05-21 11:13:42 +02:00
|
|
|
|
|
|
|
hr = ITextFont_GetBold(font, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = ITextFont_GetBold(font, &value);
|
|
|
|
ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = ITextFont_GetForeColor(font, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = ITextFont_GetForeColor(font, &value);
|
|
|
|
ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = ITextFont_GetItalic(font, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = ITextFont_GetItalic(font, &value);
|
|
|
|
ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = ITextFont_GetLanguageID(font, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = ITextFont_GetLanguageID(font, &value);
|
|
|
|
ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = ITextFont_GetName(font, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = ITextFont_GetName(font, &str);
|
|
|
|
ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = ITextFont_GetSize(font, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = ITextFont_GetSize(font, &size);
|
|
|
|
ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = ITextFont_GetStrikeThrough(font, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = ITextFont_GetStrikeThrough(font, &value);
|
|
|
|
ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = ITextFont_GetSubscript(font, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = ITextFont_GetSubscript(font, &value);
|
|
|
|
ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = ITextFont_GetSuperscript(font, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = ITextFont_GetSuperscript(font, &value);
|
|
|
|
ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = ITextFont_GetUnderline(font, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = ITextFont_GetUnderline(font, &value);
|
|
|
|
ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
ITextFont_Release(font);
|
2015-05-21 10:25:24 +02:00
|
|
|
}
|
|
|
|
|
2013-09-04 13:04:19 +02:00
|
|
|
START_TEST(richole)
|
|
|
|
{
|
|
|
|
/* Must explicitly LoadLibrary(). The test has no references to functions in
|
|
|
|
* RICHED20.DLL, so the linker doesn't actually link to it. */
|
2013-10-01 23:09:53 +02:00
|
|
|
hmoduleRichEdit = LoadLibraryA("riched20.dll");
|
2013-09-04 13:04:19 +02:00
|
|
|
ok(hmoduleRichEdit != NULL, "error: %d\n", (int) GetLastError());
|
|
|
|
|
|
|
|
test_Interfaces();
|
|
|
|
test_ITextDocument_Open();
|
2014-07-21 18:41:29 +02:00
|
|
|
test_ITextSelection_GetText();
|
2014-09-15 18:13:51 +02:00
|
|
|
test_ITextSelection_GetChar();
|
2014-09-16 12:39:10 +02:00
|
|
|
test_ITextSelection_GetStart_GetEnd();
|
2014-09-17 11:38:47 +02:00
|
|
|
test_ITextSelection_Collapse();
|
2014-09-12 14:33:29 +02:00
|
|
|
test_ITextDocument_Range();
|
2014-09-15 18:13:30 +02:00
|
|
|
test_ITextRange_GetChar();
|
2014-09-16 12:38:56 +02:00
|
|
|
test_ITextRange_GetStart_GetEnd();
|
2014-09-17 11:36:44 +02:00
|
|
|
test_ITextRange_GetDuplicate();
|
2014-09-17 11:38:31 +02:00
|
|
|
test_ITextRange_Collapse();
|
2015-03-16 10:27:21 +01:00
|
|
|
test_IOleClientSite_QueryInterface();
|
2015-03-16 10:27:38 +01:00
|
|
|
test_IOleWindow_GetWindow();
|
2015-03-17 09:17:39 +01:00
|
|
|
test_IOleInPlaceSite_GetWindow();
|
2015-05-17 16:26:33 +02:00
|
|
|
test_GetFont();
|
2015-05-17 16:27:42 +02:00
|
|
|
test_GetPara();
|
2015-05-17 16:30:56 +02:00
|
|
|
test_dispatch();
|
2015-05-21 10:25:24 +02:00
|
|
|
test_ITextFont();
|
2013-09-04 13:04:19 +02:00
|
|
|
}
|