ReactOS  0.4.15-dev-2979-gfd8baca
richole.c File Reference
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <wingdi.h>
#include <winuser.h>
#include <initguid.h>
#include <ole2.h>
#include <richedit.h>
#include <richole.h>
#include <tom.h>
#include <wine/test.h>
Include dependency graph for richole.c:

Go to the source code of this file.

Macros

#define COBJMACROS
 
#define EXPECT_REF(obj, ref)   _expect_ref((IUnknown*)obj, ref, __LINE__)
 
#define MAX_BUF_LEN   1024
 
#define CHECK_REOBJECT_STRUCT(reobj, poleobj, pstg, polesite, user)   _check_reobject_struct(reobj, poleobj, pstg, polesite, user, __LINE__)
 
#define RESET_RANGE(range, start, end)   _reset_range(range, start, end, __LINE__)
 
#define CHECK_RANGE(range, expected_start, expected_end)   _check_range(range, expected_start, expected_end, __LINE__)
 
#define RESET_SELECTION(selection, start, end)   _reset_selection(selection, start, end, __LINE__)
 
#define CHECK_SELECTION(selection, expected_start, expected_end)   _check_selection(selection, expected_start, expected_end, __LINE__)
 
#define TEST_TXTRGE_SETSTART(cp, expected_start, expected_end)
 
#define TEST_TXTRGE_SETEND(cp, expected_start, expected_end)
 
#define TEST_TXTSEL_SETSTART(cp, expected_start, expected_end)
 
#define TEST_TXTSEL_SETEND(cp, expected_start, expected_end)
 

Functions

 DEFINE_GUID (GUID_NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
 
static void _expect_ref (IUnknown *obj, ULONG ref, int line)
 
static HWND new_window (LPCSTR lpClassName, DWORD dwStyle, HWND parent)
 
static HWND new_richedit (HWND parent)
 
static BOOL touch_file (LPCWSTR filename)
 
static BOOL is_existing_file (LPCWSTR filename)
 
static void create_interfaces (HWND *w, IRichEditOle **reOle, ITextDocument **txtDoc, ITextSelection **txtSel)
 
static void release_interfaces (HWND *w, IRichEditOle **reOle, ITextDocument **txtDoc, ITextSelection **txtSel)
 
static ULONG get_refcount (IUnknown *iface)
 
static void test_Interfaces (void)
 
static void test_ITextDocument_Open (void)
 
static void test_GetText (void)
 
static void test_ITextDocument_Range (void)
 
static void test_ITextRange_GetChar (void)
 
static void check_range (HWND w, ITextDocument *doc, int first, int lim, LONG bStart, int expected_nonzero)
 
static void test_ITextRange_ScrollIntoView (void)
 
static void test_ITextSelection_GetChar (void)
 
static void test_ITextRange_GetStart_GetEnd (void)
 
static void test_ITextSelection_GetStart_GetEnd (void)
 
static void test_ITextRange_GetDuplicate (void)
 
static void test_ITextRange_Collapse (void)
 
static void test_ITextSelection_Collapse (void)
 
static void test_GetClientSite (void)
 
static void test_IOleWindow_GetWindow (void)
 
static void test_IOleInPlaceSite_GetWindow (void)
 
static void test_GetFont (void)
 
static void test_GetPara (void)
 
static void test_dispatch (void)
 
static void test_detached_font_getters (ITextFont *font, BOOL duplicate)
 
static void test_textfont_global_defaults (ITextFont *font)
 
static void test_textfont_undefined (ITextFont *font)
 
static FLOAT twips_to_points (LONG value)
 
static void test_ITextFont (void)
 
static void test_Delete (void)
 
static void test_SetText (void)
 
static void test_InRange (void)
 
static void test_ITextRange_IsEqual (void)
 
static void test_Select (void)
 
static void test_GetStoryType (void)
 
static void test_SetFont (void)
 
static void fill_reobject_struct (REOBJECT *reobj, LONG cp, LPOLEOBJECT poleobj, LPSTORAGE pstg, LPOLECLIENTSITE polesite, LONG sizel_cx, LONG sizel_cy, DWORD aspect, DWORD flags, DWORD user)
 
static void _check_reobject_struct (REOBJECT reobj, LPOLEOBJECT poleobj, LPSTORAGE pstg, LPOLECLIENTSITE polesite, DWORD user, int line)
 
static void test_InsertObject (void)
 
static void test_GetStoryLength (void)
 
static void test_ITextSelection_GetDuplicate (void)
 
static void _reset_range (ITextRange *range, LONG start, LONG end, int line)
 
static void _check_range (ITextRange *range, LONG expected_start, LONG expected_end, int line)
 
static void _reset_selection (ITextSelection *selection, LONG start, LONG end, int line)
 
static void _check_selection (ITextSelection *selection, LONG expected_start, LONG expected_end, int line)
 
static void test_ITextRange_SetRange (void)
 
static void test_Expand (void)
 
static void test_MoveEnd (void)
 
static void test_ITextRange_SetStart (void)
 
static void test_ITextRange_SetEnd (void)
 
static void test_ITextSelection_SetStart (void)
 
static void test_ITextSelection_SetEnd (void)
 
static void test_ITextRange_GetFont (void)
 
static void test_ITextSelection_GetFont (void)
 
static void test_ITextRange_GetPara (void)
 
 START_TEST (richole)
 

Variables

static HMODULE hmoduleRichEdit
 
static const WCHAR sysW [] = {'S','y','s','t','e','m',0}
 

Macro Definition Documentation

◆ CHECK_RANGE

#define CHECK_RANGE (   range,
  expected_start,
  expected_end 
)    _check_range(range, expected_start, expected_end, __LINE__)

Definition at line 3557 of file richole.c.

◆ CHECK_REOBJECT_STRUCT

#define CHECK_REOBJECT_STRUCT (   reobj,
  poleobj,
  pstg,
  polesite,
  user 
)    _check_reobject_struct(reobj, poleobj, pstg, polesite, user, __LINE__)

Definition at line 3216 of file richole.c.

◆ CHECK_SELECTION

#define CHECK_SELECTION (   selection,
  expected_start,
  expected_end 
)    _check_selection(selection, expected_start, expected_end, __LINE__)

Definition at line 3586 of file richole.c.

◆ COBJMACROS

#define COBJMACROS

Definition at line 21 of file richole.c.

◆ EXPECT_REF

#define EXPECT_REF (   obj,
  ref 
)    _expect_ref((IUnknown*)obj, ref, __LINE__)

Definition at line 42 of file richole.c.

◆ MAX_BUF_LEN

#define MAX_BUF_LEN   1024

◆ RESET_RANGE

#define RESET_RANGE (   range,
  start,
  end 
)    _reset_range(range, start, end, __LINE__)

Definition at line 3545 of file richole.c.

◆ RESET_SELECTION

#define RESET_SELECTION (   selection,
  start,
  end 
)    _reset_selection(selection, start, end, __LINE__)

Definition at line 3574 of file richole.c.

◆ TEST_TXTRGE_SETEND

#define TEST_TXTRGE_SETEND (   cp,
  expected_start,
  expected_end 
)
Value:
hres = ITextRange_SetEnd(txtRge, cp); \
ok(hres == S_OK, "ITextRange_SetEnd\n"); \
ITextRange_GetStart(txtRge, &start); \
ITextRange_GetEnd(txtRge, &end); \
ok(start == expected_start, "got wrong start value: %d\n", start); \
ok(end == expected_end, "got wrong end value: %d\n", end);
HRESULT hres
Definition: protocol.c:465
GLuint GLuint end
Definition: gl.h:1545
#define S_OK
Definition: intsafe.h:52
GLuint start
Definition: gl.h:1545
POINT cp
Definition: magnifier.c:59

◆ TEST_TXTRGE_SETSTART

#define TEST_TXTRGE_SETSTART (   cp,
  expected_start,
  expected_end 
)
Value:
hres = ITextRange_SetStart(txtRge, cp); \
ok(hres == S_OK, "ITextRange_SetStart\n"); \
ITextRange_GetStart(txtRge, &start); \
ITextRange_GetEnd(txtRge, &end); \
ok(start == expected_start, "got wrong start value: %d\n", start); \
ok(end == expected_end, "got wrong end value: %d\n", end);
HRESULT hres
Definition: protocol.c:465
GLuint GLuint end
Definition: gl.h:1545
#define S_OK
Definition: intsafe.h:52
GLuint start
Definition: gl.h:1545
POINT cp
Definition: magnifier.c:59

◆ TEST_TXTSEL_SETEND

#define TEST_TXTSEL_SETEND (   cp,
  expected_start,
  expected_end 
)
Value:
hres = ITextSelection_SetEnd(txtSel, cp); \
ok(hres == S_OK, "ITextSelection_SetEnd\n"); \
SendMessageA(w, EM_GETSEL, (LPARAM)&start, (WPARAM)&end); \
ok(start == expected_start, "got wrong start value: %d\n", start); \
ok(end == expected_end, "got wrong end value: %d\n", end);
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
UINT_PTR WPARAM
Definition: windef.h:207
#define EM_GETSEL
Definition: winuser.h:1979
LONG_PTR LPARAM
Definition: windef.h:208
HRESULT hres
Definition: protocol.c:465
GLuint GLuint end
Definition: gl.h:1545
#define S_OK
Definition: intsafe.h:52
GLuint start
Definition: gl.h:1545
POINT cp
Definition: magnifier.c:59

◆ TEST_TXTSEL_SETSTART

#define TEST_TXTSEL_SETSTART (   cp,
  expected_start,
  expected_end 
)
Value:
hres = ITextSelection_SetStart(txtSel, cp); \
ok(hres == S_OK, "ITextSelection_SetStart\n"); \
SendMessageA(w, EM_GETSEL, (LPARAM)&start, (WPARAM)&end); \
ok(start == expected_start, "got wrong start value: %d\n", start); \
ok(end == expected_end, "got wrong end value: %d\n", end);
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
UINT_PTR WPARAM
Definition: windef.h:207
#define EM_GETSEL
Definition: winuser.h:1979
LONG_PTR LPARAM
Definition: windef.h:208
HRESULT hres
Definition: protocol.c:465
GLuint GLuint end
Definition: gl.h:1545
#define S_OK
Definition: intsafe.h:52
GLuint start
Definition: gl.h:1545
POINT cp
Definition: magnifier.c:59

Function Documentation

◆ _check_range()

static void _check_range ( ITextRange range,
LONG  expected_start,
LONG  expected_end,
int  line 
)
static

Definition at line 3559 of file richole.c.

3560 {
3561  HRESULT hr;
3562  LONG value;
3563 
3564  hr = ITextRange_GetStart(range, &value);
3565  ok_(__FILE__,line)(hr == S_OK, "GetStart failed: 0x%08x\n", hr);
3566  ok_(__FILE__,line)(value == expected_start, "Expected start %d got %d\n",
3567  expected_start, value);
3568  hr = ITextRange_GetEnd(range, &value);
3569  ok_(__FILE__,line)(hr == S_OK, "GetEnd failed: 0x%08x\n", hr);
3570  ok_(__FILE__,line)(value == expected_end, "Expected end %d got %d\n",
3571  expected_end, value);
3572 }
Definition: pdh_main.c:93
HRESULT hr
Definition: shlfolder.c:183
long LONG
Definition: pedump.c:60
Definition: parser.c:48
LONG HRESULT
Definition: typedefs.h:79
GLsizei const GLfloat * value
Definition: glext.h:6069
GLenum GLint * range
Definition: glext.h:7539
#define S_OK
Definition: intsafe.h:52
#define ok_(x1, x2)
Definition: atltest.h:61

◆ _check_reobject_struct()

static void _check_reobject_struct ( REOBJECT  reobj,
LPOLEOBJECT  poleobj,
LPSTORAGE  pstg,
LPOLECLIENTSITE  polesite,
DWORD  user,
int  line 
)
static

Definition at line 3218 of file richole.c.

3220 {
3221  ok_(__FILE__,line)(reobj.poleobj == poleobj, "got wrong object interface.\n");
3222  ok_(__FILE__,line)(reobj.pstg == pstg, "got wrong storage interface.\n");
3223  ok_(__FILE__,line)(reobj.polesite == polesite, "got wrong site interface.\n");
3224  ok_(__FILE__,line)(reobj.dwUser == user, "got wrong user-defined value.\n");
3225 }
Definition: parser.c:48
void user(int argc, const char *argv[])
Definition: cmds.c:1350
#define ok_(x1, x2)
Definition: atltest.h:61

◆ _check_selection()

static void _check_selection ( ITextSelection selection,
LONG  expected_start,
LONG  expected_end,
int  line 
)
static

Definition at line 3588 of file richole.c.

3589 {
3590  HRESULT hr;
3591  LONG value;
3592 
3593  hr = ITextSelection_GetStart(selection, &value);
3594  ok_(__FILE__,line)(hr == S_OK, "GetStart failed: 0x%08x\n", hr);
3595  ok_(__FILE__,line)(value == expected_start, "Expected start %d got %d\n",
3596  expected_start, value);
3597  hr = ITextSelection_GetEnd(selection, &value);
3598  ok_(__FILE__,line)(hr == S_OK, "GetEnd failed: 0x%08x\n", hr);
3599  ok_(__FILE__,line)(value == expected_end, "Expected end %d got %d\n",
3600  expected_end, value);
3601 }
Definition: pdh_main.c:93
HRESULT hr
Definition: shlfolder.c:183
int selection
Definition: ctm.c:92
long LONG
Definition: pedump.c:60
Definition: parser.c:48
LONG HRESULT
Definition: typedefs.h:79
GLsizei const GLfloat * value
Definition: glext.h:6069
#define S_OK
Definition: intsafe.h:52
#define ok_(x1, x2)
Definition: atltest.h:61

◆ _expect_ref()

static void _expect_ref ( IUnknown obj,
ULONG  ref,
int  line 
)
static

Definition at line 43 of file richole.c.

44 {
45  ULONG rc;
46  IUnknown_AddRef(obj);
47  rc = IUnknown_Release(obj);
48  ok_(__FILE__,line)(rc == ref, "expected refcount %d, got %d\n", ref, rc);
49 }
GLenum GLint ref
Definition: glext.h:6028
Definition: parser.c:48
unsigned int ULONG
Definition: retypes.h:1
#define ok_(x1, x2)
Definition: atltest.h:61

◆ _reset_range()

static void _reset_range ( ITextRange range,
LONG  start,
LONG  end,
int  line 
)
static

Definition at line 3547 of file richole.c.

3548 {
3549  HRESULT hr;
3550 
3551  hr = ITextRange_SetStart(range, start);
3552  ok_(__FILE__,line)(hr == S_OK, "SetStart failed: 0x%08x\n", hr);
3553  hr = ITextRange_SetEnd(range, end);
3554  ok_(__FILE__,line)(hr == S_OK, "SetEnd failed: 0x%08x\n", hr);
3555 }
HRESULT hr
Definition: shlfolder.c:183
Definition: parser.c:48
LONG HRESULT
Definition: typedefs.h:79
GLuint GLuint end
Definition: gl.h:1545
GLenum GLint * range
Definition: glext.h:7539
#define S_OK
Definition: intsafe.h:52
GLuint start
Definition: gl.h:1545
#define ok_(x1, x2)
Definition: atltest.h:61

◆ _reset_selection()

static void _reset_selection ( ITextSelection selection,
LONG  start,
LONG  end,
int  line 
)
static

Definition at line 3576 of file richole.c.

3577 {
3578  HRESULT hr;
3579 
3580  hr = ITextSelection_SetStart(selection, start);
3581  ok_(__FILE__,line)(hr == S_OK, "SetStart failed: 0x%08x\n", hr);
3582  hr = ITextSelection_SetEnd(selection, end);
3583  ok_(__FILE__,line)(hr == S_OK, "SetEnd failed: 0x%08x\n", hr);
3584 }
HRESULT hr
Definition: shlfolder.c:183
int selection
Definition: ctm.c:92
Definition: parser.c:48
LONG HRESULT
Definition: typedefs.h:79
GLuint GLuint end
Definition: gl.h:1545
#define S_OK
Definition: intsafe.h:52
GLuint start
Definition: gl.h:1545
#define ok_(x1, x2)
Definition: atltest.h:61

◆ check_range()

static void check_range ( HWND  w,
ITextDocument doc,
int  first,
int  lim,
LONG  bStart,
int  expected_nonzero 
)
static

Definition at line 826 of file richole.c.

828 {
829  SCROLLINFO si;
830  ITextRange *txtRge = NULL;
831  HRESULT hres;
832 
833  si.cbSize = sizeof(SCROLLINFO);
834  si.fMask = SIF_POS | SIF_RANGE;
835 
836  hres = ITextDocument_Range(doc, first, lim, &txtRge);
837  ok(hres == S_OK, "got 0x%08x\n", hres);
838  hres = ITextRange_ScrollIntoView(txtRge, bStart);
839  ok(hres == S_OK, "got 0x%08x\n", hres);
840  GetScrollInfo(w, SB_VERT, &si);
841  if (expected_nonzero) {
842  ok(si.nPos != 0,
843  "Scrollbar at 0, should be >0. (TextRange %d-%d, scroll range %d-%d.)\n",
844  first, lim, si.nMin, si.nMax);
845  } else {
846  ok(si.nPos == 0,
847  "Scrollbar at %d, should be 0. (TextRange %d-%d, scroll range %d-%d.)\n",
848  si.nPos, first, lim, si.nMin, si.nMax);
849  }
850 }
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
#define SIF_RANGE
Definition: winuser.h:1221
#define SB_VERT
Definition: winuser.h:553
const GLint * first
Definition: glext.h:5794
struct tagSCROLLINFO SCROLLINFO
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:79
BOOL WINAPI GetScrollInfo(_In_ HWND, _In_ int, _Inout_ LPSCROLLINFO)
#define SIF_POS
Definition: winuser.h:1220
#define S_OK
Definition: intsafe.h:52
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112

Referenced by test_ITextRange_ScrollIntoView().

◆ create_interfaces()

static void create_interfaces ( HWND w,
IRichEditOle **  reOle,
ITextDocument **  txtDoc,
ITextSelection **  txtSel 
)
static

Definition at line 90 of file richole.c.

92 {
93  *w = new_richedit(NULL);
95  IRichEditOle_QueryInterface(*reOle, &IID_ITextDocument,
96  (void **) txtDoc);
97  ITextDocument_GetSelection(*txtDoc, txtSel);
98 }
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define EM_GETOLEINTERFACE
Definition: richedit.h:93
static HWND new_richedit(HWND parent)
Definition: richole.c:60
LONG_PTR LPARAM
Definition: windef.h:208
#define NULL
Definition: types.h:112

Referenced by test_Delete(), test_dispatch(), test_Expand(), test_GetClientSite(), test_GetFont(), test_GetPara(), test_GetStoryLength(), test_GetStoryType(), test_GetText(), test_InRange(), test_InsertObject(), test_IOleInPlaceSite_GetWindow(), test_IOleWindow_GetWindow(), test_ITextDocument_Open(), test_ITextDocument_Range(), test_ITextFont(), test_ITextRange_Collapse(), test_ITextRange_GetChar(), test_ITextRange_GetDuplicate(), test_ITextRange_GetFont(), test_ITextRange_GetPara(), test_ITextRange_GetStart_GetEnd(), test_ITextRange_IsEqual(), test_ITextRange_ScrollIntoView(), test_ITextRange_SetEnd(), test_ITextRange_SetRange(), test_ITextRange_SetStart(), test_ITextSelection_Collapse(), test_ITextSelection_GetChar(), test_ITextSelection_GetDuplicate(), test_ITextSelection_GetFont(), test_ITextSelection_GetStart_GetEnd(), test_ITextSelection_SetEnd(), test_ITextSelection_SetStart(), test_MoveEnd(), test_Select(), test_SetFont(), and test_SetText().

◆ DEFINE_GUID()

DEFINE_GUID ( GUID_NULL  ,
,
,
,
,
,
,
,
,
,
,
 
)

◆ fill_reobject_struct()

static void fill_reobject_struct ( REOBJECT reobj,
LONG  cp,
LPOLEOBJECT  poleobj,
LPSTORAGE  pstg,
LPOLECLIENTSITE  polesite,
LONG  sizel_cx,
LONG  sizel_cy,
DWORD  aspect,
DWORD  flags,
DWORD  user 
)
static

Definition at line 3199 of file richole.c.

3202 {
3203  reobj->cbStruct = sizeof(*reobj);
3204  reobj->clsid = CLSID_NULL;
3205  reobj->cp = cp;
3206  reobj->poleobj = poleobj;
3207  reobj->pstg = pstg;
3208  reobj->polesite = polesite;
3209  reobj->sizel.cx = sizel_cx;
3210  reobj->sizel.cy = sizel_cy;
3211  reobj->dvaspect = aspect;
3212  reobj->dwFlags = flags;
3213  reobj->dwUser = user;
3214 }
#define CLSID_NULL
Definition: guiddef.h:99
GLbitfield flags
Definition: glext.h:7161
POINT cp
Definition: magnifier.c:59
void user(int argc, const char *argv[])
Definition: cmds.c:1350

Referenced by test_InsertObject().

◆ get_refcount()

static ULONG get_refcount ( IUnknown iface)
static

Definition at line 110 of file richole.c.

111 {
112  IUnknown_AddRef(iface);
113  return IUnknown_Release(iface);
114 }

Referenced by test_GetClientSite(), test_ITextRange_GetFont(), test_ITextRange_GetPara(), and test_ITextSelection_GetFont().

◆ is_existing_file()

static BOOL is_existing_file ( LPCWSTR  filename)
static

Definition at line 78 of file richole.c.

79 {
80  HANDLE file;
81 
83  OPEN_EXISTING, 0, NULL);
85  return FALSE;
87  return TRUE;
88 }
#define CloseHandle
Definition: compat.h:598
#define TRUE
Definition: types.h:120
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
const char * filename
Definition: ioapi.h:135
#define FALSE
Definition: types.h:117
#define OPEN_EXISTING
Definition: compat.h:634
const char file[]
Definition: icontest.c:11
#define GENERIC_READ
Definition: compat.h:135
#define NULL
Definition: types.h:112
#define CreateFileW
Definition: compat.h:600
Definition: fci.c:126

Referenced by test_ITextDocument_Open().

◆ new_richedit()

static HWND new_richedit ( HWND  parent)
static

Definition at line 60 of file richole.c.

61 {
63 }
#define ES_MULTILINE
Definition: pedump.c:667
static HWND new_window(LPCSTR lpClassName, DWORD dwStyle, HWND parent)
Definition: richole.c:51
r parent
Definition: btrfs.c:2944
#define RICHEDIT_CLASS20A
Definition: richedit.h:43

Referenced by create_interfaces(), and test_Interfaces().

◆ new_window()

static HWND new_window ( LPCSTR  lpClassName,
DWORD  dwStyle,
HWND  parent 
)
static

Definition at line 51 of file richole.c.

52 {
53  HWND hwnd = CreateWindowA(lpClassName, NULL,
54  dwStyle | WS_POPUP | WS_HSCROLL | WS_VSCROLL | WS_VISIBLE,
55  0, 0, 200, 60, parent, NULL, hmoduleRichEdit, NULL);
56  ok(hwnd != NULL, "class: %s, error: %d\n", lpClassName, (int) GetLastError());
57  return hwnd;
58 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
static HMODULE hmoduleRichEdit
Definition: richole.c:36
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4290
r parent
Definition: btrfs.c:2944
#define WS_HSCROLL
Definition: pedump.c:628
#define ok(value,...)
Definition: atltest.h:57
#define WS_POPUP
Definition: pedump.c:616
#define NULL
Definition: types.h:112
#define WS_VSCROLL
Definition: pedump.c:627
#define WS_VISIBLE
Definition: pedump.c:620

Referenced by new_richedit().

◆ release_interfaces()

◆ START_TEST()

START_TEST ( richole  )

Definition at line 4089 of file richole.c.

4090 {
4091  /* Must explicitly LoadLibrary(). The test has no references to functions in
4092  * RICHED20.DLL, so the linker doesn't actually link to it. */
4093  hmoduleRichEdit = LoadLibraryA("riched20.dll");
4094  ok(hmoduleRichEdit != NULL, "error: %d\n", (int) GetLastError());
4095 
4096  test_Interfaces();
4098  test_GetText();
4119  test_GetFont();
4120  test_GetPara();
4121  test_dispatch();
4122  test_ITextFont();
4123  test_Delete();
4124  test_SetText();
4125  test_InRange();
4127  test_Select();
4129  test_SetFont();
4133  test_Expand();
4134  test_MoveEnd();
4135 }
static void test_Interfaces(void)
Definition: richole.c:143
static HMODULE hmoduleRichEdit
Definition: richole.c:36
static void test_InsertObject(void)
Definition: richole.c:3227
static void test_ITextDocument_Open(void)
Definition: richole.c:272
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
static void test_InRange(void)
Definition: richole.c:2787
static void test_ITextRange_GetFont(void)
Definition: richole.c:3952
static void test_ITextRange_GetDuplicate(void)
Definition: richole.c:1369
static void test_IOleInPlaceSite_GetWindow(void)
Definition: richole.c:1703
static void test_ITextFont(void)
Definition: richole.c:2304
static void test_ITextRange_GetPara(void)
Definition: richole.c:4043
static void test_ITextSelection_SetEnd(void)
Definition: richole.c:3920
static void test_GetStoryLength(void)
Definition: richole.c:3403
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
static void test_ITextSelection_GetFont(void)
Definition: richole.c:3998
static void test_IOleWindow_GetWindow(void)
Definition: richole.c:1675
static void test_MoveEnd(void)
Definition: richole.c:3707
static void test_ITextRange_Collapse(void)
Definition: richole.c:1412
static void test_ITextSelection_SetStart(void)
Definition: richole.c:3888
static void test_ITextSelection_GetStart_GetEnd(void)
Definition: richole.c:1163
static void test_Delete(void)
Definition: richole.c:2645
static void test_GetText(void)
Definition: richole.c:520
static void test_SetText(void)
Definition: richole.c:2700
static void test_GetClientSite(void)
Definition: richole.c:1600
static void test_ITextDocument_Range(void)
Definition: richole.c:705
static void test_ITextSelection_GetDuplicate(void)
Definition: richole.c:3471
static void test_GetPara(void)
Definition: richole.c:1849
static void test_Select(void)
Definition: richole.c:3012
static void test_ITextRange_SetEnd(void)
Definition: richole.c:3854
#define ok(value,...)
Definition: atltest.h:57
static void test_ITextRange_GetChar(void)
Definition: richole.c:747
static void test_ITextRange_GetStart_GetEnd(void)
Definition: richole.c:944
#define NULL
Definition: types.h:112
static void test_ITextSelection_Collapse(void)
Definition: richole.c:1523
static void test_Expand(void)
Definition: richole.c:3648
static void test_SetFont(void)
Definition: richole.c:3112
static void test_ITextRange_ScrollIntoView(void)
Definition: richole.c:852
static void test_GetStoryType(void)
Definition: richole.c:3056
static void test_ITextRange_SetRange(void)
Definition: richole.c:3603
static void test_ITextSelection_GetChar(void)
Definition: richole.c:888
static void test_ITextRange_IsEqual(void)
Definition: richole.c:2897
static void test_dispatch(void)
Definition: richole.c:1933
static void test_GetFont(void)
Definition: richole.c:1731
static void test_ITextRange_SetStart(void)
Definition: richole.c:3821

◆ test_Delete()

static void test_Delete ( void  )
static

Definition at line 2645 of file richole.c.

2646 {
2647  static const CHAR test_text1[] = "TestSomeText";
2648  IRichEditOle *reOle = NULL;
2649  ITextDocument *doc = NULL;
2650  ITextRange *range, *range2;
2651  LONG value;
2652  HRESULT hr;
2653  HWND hwnd;
2654 
2655  create_interfaces(&hwnd, &reOle, &doc, NULL);
2656  SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1);
2657 
2658  hr = ITextDocument_Range(doc, 0, 4, &range);
2659  ok(hr == S_OK, "got 0x%08x\n", hr);
2660 
2661  hr = ITextDocument_Range(doc, 1, 2, &range2);
2662  ok(hr == S_OK, "got 0x%08x\n", hr);
2663 
2664  hr = ITextRange_GetEnd(range, &value);
2665  ok(hr == S_OK, "got 0x%08x\n", hr);
2666  ok(value == 4, "got %d\n", value);
2667 
2668  /* unit type doesn't matter is count is 0 */
2669  value = 0;
2670  hr = ITextRange_Delete(range2, tomSentence, 0, &value);
2671 todo_wine {
2672  ok(hr == S_OK, "got 0x%08x\n", hr);
2673  ok(value == 1, "got %d\n", value);
2674 }
2675  value = 1;
2676  hr = ITextRange_Delete(range2, tomCharacter, 0, &value);
2677 todo_wine {
2678  ok(hr == S_FALSE, "got 0x%08x\n", hr);
2679  ok(value == 0, "got %d\n", value);
2680 }
2681  hr = ITextRange_GetEnd(range, &value);
2682  ok(hr == S_OK, "got 0x%08x\n", hr);
2683 todo_wine
2684  ok(value == 3, "got %d\n", value);
2685 
2686  hr = ITextRange_GetStart(range2, &value);
2687  ok(hr == S_OK, "got 0x%08x\n", hr);
2688  ok(value == 1, "got %d\n", value);
2689 
2690  hr = ITextRange_GetEnd(range2, &value);
2691  ok(hr == S_OK, "got 0x%08x\n", hr);
2692 todo_wine
2693  ok(value == 1, "got %d\n", value);
2694 
2695  ITextRange_Release(range);
2696  ITextRange_Release(range2);
2697  release_interfaces(&hwnd, &reOle, &doc, NULL);
2698 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
Definition: pdh_main.c:93
HRESULT hr
Definition: shlfolder.c:183
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
char CHAR
Definition: xmlstorage.h:175
static void create_interfaces(HWND *w, IRichEditOle **reOle, ITextDocument **txtDoc, ITextSelection **txtSel)
Definition: richole.c:90
long LONG
Definition: pedump.c:60
#define S_FALSE
Definition: winerror.h:2357
LONG_PTR LPARAM
Definition: windef.h:208
#define WM_SETTEXT
Definition: winuser.h:1599
LONG HRESULT
Definition: typedefs.h:79
#define todo_wine
Definition: test.h:164
GLsizei const GLfloat * value
Definition: glext.h:6069
static void release_interfaces(HWND *w, IRichEditOle **reOle, ITextDocument **txtDoc, ITextSelection **txtSel)
Definition: richole.c:100
GLenum GLint * range
Definition: glext.h:7539
#define S_OK
Definition: intsafe.h:52
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112

Referenced by START_TEST().

◆ test_detached_font_getters()

static void test_detached_font_getters ( ITextFont font,
BOOL  duplicate 
)
static

Definition at line 1980 of file richole.c.

1981 {
1982  HRESULT hr, hrexp = duplicate ? S_OK : CO_E_RELEASED;
1983  LONG value;
1984  float size;
1985  BSTR str;
1986 
1987  hr = ITextFont_GetBold(font, NULL);
1988  ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
1989 
1990  hr = ITextFont_GetBold(font, &value);
1991  ok(hr == hrexp, "got 0x%08x\n", hr);
1992 
1993  hr = ITextFont_GetForeColor(font, NULL);
1994  ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
1995 
1996  hr = ITextFont_GetForeColor(font, &value);
1997  ok(hr == hrexp, "got 0x%08x\n", hr);
1998 
1999  hr = ITextFont_GetItalic(font, NULL);
2000  ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2001 
2002  hr = ITextFont_GetItalic(font, &value);
2003  ok(hr == hrexp, "got 0x%08x\n", hr);
2004 
2005  hr = ITextFont_GetLanguageID(font, NULL);
2006  ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2007 
2008  hr = ITextFont_GetLanguageID(font, &value);
2009  ok(hr == hrexp, "got 0x%08x\n", hr);
2010 
2011  hr = ITextFont_GetName(font, NULL);
2012  ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2013 
2014  hr = ITextFont_GetName(font, &str);
2015  ok(hr == hrexp, "got 0x%08x\n", hr);
2016 
2017  hr = ITextFont_GetSize(font, NULL);
2018  ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2019 
2020  hr = ITextFont_GetSize(font, &size);
2021  ok(hr == hrexp, "got 0x%08x\n", hr);
2022 
2023  hr = ITextFont_GetStrikeThrough(font, NULL);
2024  ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2025 
2026  hr = ITextFont_GetStrikeThrough(font, &value);
2027  ok(hr == hrexp, "got 0x%08x\n", hr);
2028 
2029  hr = ITextFont_GetSubscript(font, NULL);
2030  ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2031 
2032  hr = ITextFont_GetSubscript(font, &value);
2033  ok(hr == hrexp, "got 0x%08x\n", hr);
2034 
2035  hr = ITextFont_GetSuperscript(font, NULL);
2036  ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2037 
2038  hr = ITextFont_GetSuperscript(font, &value);
2039  ok(hr == hrexp, "got 0x%08x\n", hr);
2040 
2041  hr = ITextFont_GetUnderline(font, NULL);
2042  ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2043 
2044  hr = ITextFont_GetUnderline(font, &value);
2045  ok(hr == hrexp, "got 0x%08x\n", hr);
2046 }
Definition: pdh_main.c:93
HRESULT hr
Definition: shlfolder.c:183
Definition: mk_font.cpp:20
#define CO_E_RELEASED
Definition: winerror.h:2818
OLECHAR * BSTR
Definition: compat.h:2152
long LONG
Definition: pedump.c:60
#define E_INVALIDARG
Definition: ddrawi.h:101
const WCHAR * str
GLsizeiptr size
Definition: glext.h:5919
LONG HRESULT
Definition: typedefs.h:79
GLsizei const GLfloat * value
Definition: glext.h:6069
#define S_OK
Definition: intsafe.h:52
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112

Referenced by test_ITextFont().

◆ test_dispatch()

static void test_dispatch ( void  )
static

Definition at line 1933 of file richole.c.

1934 {
1935  static const WCHAR testnameW[] = {'G','e','t','T','e','x','t',0};
1936  static const WCHAR testname2W[] = {'T','e','x','t',0};
1937  IRichEditOle *reOle = NULL;
1938  ITextDocument *doc = NULL;
1939  ITextRange *range = NULL;
1940  WCHAR *nameW;
1941  DISPID dispid;
1942  HRESULT hr;
1943  UINT count;
1944  HWND hwnd;
1945 
1946  create_interfaces(&hwnd, &reOle, &doc, NULL);
1947 
1948  range = NULL;
1949  hr = ITextDocument_Range(doc, 0, 0, &range);
1950  ok(hr == S_OK, "got 0x%08x\n", hr);
1951  ok(range != NULL, "got %p\n", range);
1952 
1953  dispid = 123;
1954  nameW = (WCHAR*)testnameW;
1955  hr = ITextRange_GetIDsOfNames(range, &IID_NULL, &nameW, 1, LOCALE_USER_DEFAULT, &dispid);
1956  ok(hr == DISP_E_UNKNOWNNAME, "got 0x%08x\n", hr);
1957  ok(dispid == DISPID_UNKNOWN, "got %d\n", dispid);
1958 
1959  dispid = 123;
1960  nameW = (WCHAR*)testname2W;
1961  hr = ITextRange_GetIDsOfNames(range, &IID_NULL, &nameW, 1, LOCALE_USER_DEFAULT, &dispid);
1962  ok(hr == S_OK, "got 0x%08x\n", hr);
1963  ok(dispid == DISPID_VALUE, "got %d\n", dispid);
1964 
1965  release_interfaces(&hwnd, &reOle, &doc, NULL);
1966 
1967  /* try dispatch methods on detached range */
1968  hr = ITextRange_GetTypeInfoCount(range, &count);
1969  ok(hr == S_OK, "got 0x%08x\n", hr);
1970 
1971  dispid = 123;
1972  nameW = (WCHAR*)testname2W;
1973  hr = ITextRange_GetIDsOfNames(range, &IID_NULL, &nameW, 1, LOCALE_USER_DEFAULT, &dispid);
1974  ok(hr == S_OK, "got 0x%08x\n", hr);
1975  ok(dispid == DISPID_VALUE, "got %d\n", dispid);
1976 
1977  ITextRange_Release(range);
1978 }
#define DISP_E_UNKNOWNNAME
Definition: winerror.h:2515
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
HRESULT hr
Definition: shlfolder.c:183
#define LOCALE_USER_DEFAULT
GLuint GLuint GLsizei count
Definition: gl.h:1545
static void create_interfaces(HWND *w, IRichEditOle **reOle, ITextDocument **txtDoc, ITextSelection **txtSel)
Definition: richole.c:90
static const WCHAR nameW[]
Definition: main.c:46
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
#define IID_NULL
Definition: guiddef.h:98
static void release_interfaces(HWND *w, IRichEditOle **reOle, ITextDocument **txtDoc, ITextSelection **txtSel)
Definition: richole.c:100
GLenum GLint * range
Definition: glext.h:7539
#define S_OK
Definition: intsafe.h:52
static VARIANTARG static DISPID
Definition: ordinal.c:49
#define ok(value,...)
Definition: atltest.h:57
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112

Referenced by START_TEST().

◆ test_Expand()

static void test_Expand ( void  )
static

Definition at line 3648 of file richole.c.

3649 {
3650  static const char test_text1[] = "TestSomeText";
3651  IRichEditOle *reole = NULL;
3652  ITextDocument *doc = NULL;
3654  ITextRange *range;
3655  LONG value;
3656  HRESULT hr;
3657  HWND hwnd;
3658 
3659  create_interfaces(&hwnd, &reole, &doc, &selection);
3660  SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1);
3661  SendMessageA(hwnd, EM_SETSEL, 1, 2);
3662 
3663  hr = ITextDocument_Range(doc, 0, 4, &range);
3664  ok(hr == S_OK, "got 0x%08x\n", hr);
3665 
3666  hr = ITextRange_Expand(range, tomStory, NULL);
3667  ok(hr == S_OK, "got 0x%08x\n", hr);
3668  CHECK_RANGE(range, 0, 13);
3669 
3670  hr = ITextSelection_Expand(selection, tomStory, NULL);
3671  ok(hr == S_OK, "got 0x%08x\n", hr);
3672  CHECK_SELECTION(selection, 0, 13);
3673 
3674  RESET_RANGE(range, 1, 2);
3675  RESET_SELECTION(selection, 1, 2);
3676 
3677  value = 0;
3678  hr = ITextRange_Expand(range, tomStory, &value);
3679  ok(hr == S_OK, "got 0x%08x\n", hr);
3680  ok(value == 12, "got %d\n", value);
3681  CHECK_RANGE(range, 0, 13);
3682 
3683  value = 0;
3684  hr = ITextSelection_Expand(selection, tomStory, &value);
3685  ok(hr == S_OK, "got 0x%08x\n", hr);
3686  ok(value == 12, "got %d\n", value);
3687  CHECK_SELECTION(selection, 0, 13);
3688 
3689  release_interfaces(&hwnd, &reole, &doc, NULL);
3690 
3691  hr = ITextRange_Expand(range, tomStory, NULL);
3692  ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
3693 
3694  hr = ITextRange_Expand(range, tomStory, &value);
3695  ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
3696 
3697  hr = ITextSelection_Expand(selection, tomStory, NULL);
3698  ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
3699 
3700  hr = ITextSelection_Expand(selection, tomStory, &value);
3701  ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
3702 
3703  ITextSelection_Release(selection);
3704  ITextRange_Release(range);
3705 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
Definition: pdh_main.c:93
#define CHECK_RANGE(range, expected_start, expected_end)
Definition: richole.c:3557
HRESULT hr
Definition: shlfolder.c:183
#define RESET_SELECTION(selection, start, end)
Definition: richole.c:3574
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define CO_E_RELEASED
Definition: winerror.h:2818
static void create_interfaces(HWND *w, IRichEditOle **reOle, ITextDocument **txtDoc, ITextSelection **txtSel)
Definition: richole.c:90
int selection
Definition: ctm.c:92
long LONG
Definition: pedump.c:60
LONG_PTR LPARAM
Definition: windef.h:208
#define WM_SETTEXT
Definition: winuser.h:1599
LONG HRESULT
Definition: typedefs.h:79
#define EM_SETSEL
Definition: winuser.h:2000
#define CHECK_SELECTION(selection, expected_start, expected_end)
Definition: richole.c:3586
GLsizei const GLfloat * value
Definition: glext.h:6069
static void release_interfaces(HWND *w, IRichEditOle **reOle, ITextDocument **txtDoc, ITextSelection **txtSel)
Definition: richole.c:100
GLenum GLint * range
Definition: glext.h:7539
#define RESET_RANGE(range, start, end)
Definition: richole.c:3545
#define S_OK
Definition: intsafe.h:52
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112

Referenced by START_TEST().

◆ test_GetClientSite()

static void test_GetClientSite ( void  )
static

Definition at line 1600 of file richole.c.

1601 {
1602  HWND w;
1603  IRichEditOle *reOle = NULL, *reOle1 = NULL;
1604  ITextDocument *txtDoc = NULL;
1605  IOleClientSite *clientSite = NULL, *clientSite1 = NULL, *clientSite2 = NULL;
1606  IOleWindow *oleWin = NULL, *oleWin1 = NULL;
1607  IOleInPlaceSite *olePlace = NULL, *olePlace1 = NULL;
1608  HRESULT hres;
1609  LONG refcount1, refcount2;
1610 
1611  create_interfaces(&w, &reOle, &txtDoc, NULL);
1612  hres = IRichEditOle_GetClientSite(reOle, &clientSite);
1613  ok(hres == S_OK, "IRichEditOle_QueryInterface: 0x%08x\n", hres);
1614  EXPECT_REF(clientSite, 1);
1615 
1616  hres = IOleClientSite_QueryInterface(clientSite, &IID_IRichEditOle, (void **)&reOle1);
1617  ok(hres == E_NOINTERFACE, "IOleClientSite_QueryInterface: %x\n", hres);
1618 
1619  hres = IRichEditOle_GetClientSite(reOle, &clientSite1);
1620  ok(hres == S_OK, "got 0x%08x\n", hres);
1621  ok(clientSite != clientSite1, "got %p, %p\n", clientSite, clientSite1);
1622  IOleClientSite_Release(clientSite1);
1623 
1624  hres = IOleClientSite_QueryInterface(clientSite, &IID_IOleClientSite, (void **)&clientSite1);
1625  ok(hres == S_OK, "IOleClientSite_QueryInterface: 0x%08x\n", hres);
1626  ok(clientSite == clientSite1, "Should not return a new pointer.\n");
1627  EXPECT_REF(clientSite, 2);
1628 
1629  /* IOleWindow interface */
1630  hres = IOleClientSite_QueryInterface(clientSite, &IID_IOleWindow, (void **)&oleWin);
1631  ok(hres == S_OK, "IOleClientSite_QueryInterface: 0x%08x\n", hres);
1632  refcount1 = get_refcount((IUnknown *)clientSite);
1633  refcount2 = get_refcount((IUnknown *)oleWin);
1634  ok(refcount1 == refcount2, "got wrong ref count.\n");
1635 
1636  hres = IOleClientSite_QueryInterface(clientSite, &IID_IOleWindow, (void **)&oleWin1);
1637  ok(hres == S_OK, "IOleClientSite_QueryInterface: 0x%08x\n", hres);
1638  ok(oleWin == oleWin1, "Should not return a new pointer.\n");
1639  refcount1 = get_refcount((IUnknown *)clientSite);
1640  refcount2 = get_refcount((IUnknown *)oleWin);
1641  ok(refcount1 == refcount2, "got wrong ref count.\n");
1642 
1643  hres = IOleWindow_QueryInterface(oleWin, &IID_IOleClientSite, (void **)&clientSite2);
1644  ok(hres == S_OK, "IOleWindow_QueryInterface: 0x%08x\n", hres);
1645  ok(clientSite2 == clientSite1, "got wrong pointer\n");
1646 
1647  /* IOleInPlaceSite interface */
1648  hres = IOleClientSite_QueryInterface(clientSite, &IID_IOleInPlaceSite, (void **)&olePlace);
1649  ok(hres == S_OK, "IOleClientSite_QueryInterface: 0x%08x\n", hres);
1650  refcount1 = get_refcount((IUnknown *)olePlace);
1651  refcount2 = get_refcount((IUnknown *)clientSite);
1652  ok(refcount1 == refcount2, "got wrong ref count.\n");
1653 
1654  hres = IOleClientSite_QueryInterface(clientSite, &IID_IOleInPlaceSite, (void **)&olePlace1);
1655  ok(hres == S_OK, "IOleClientSite_QueryInterface: 0x%08x\n", hres);
1656  ok(olePlace == olePlace1, "Should not return a new pointer.\n");
1657  IOleInPlaceSite_Release(olePlace1);
1658 
1659  hres = IOleWindow_QueryInterface(oleWin, &IID_IOleInPlaceSite, (void **)&olePlace1);
1660  ok(hres == S_OK, "IOleWindow_QueryInterface: 0x%08x\n", hres);
1661  refcount1 = get_refcount((IUnknown *)olePlace1);
1662  refcount2 = get_refcount((IUnknown *)oleWin);
1663  ok(refcount1 == refcount2, "got wrong ref count.\n");
1664 
1665  IOleInPlaceSite_Release(olePlace1);
1666  IOleInPlaceSite_Release(olePlace);
1667  IOleWindow_Release(oleWin1);
1668  IOleWindow_Release(oleWin);
1669  IOleClientSite_Release(clientSite2);
1670  IOleClientSite_Release(clientSite1);
1671  IOleClientSite_Release(clientSite);
1672  release_interfaces(&w, &reOle, &txtDoc, NULL);
1673 }
#define E_NOINTERFACE
Definition: winerror.h:2364
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
const GUID IID_IOleInPlaceSite
const GUID IID_IOleClientSite
static void create_interfaces(HWND *w, IRichEditOle **reOle, ITextDocument **txtDoc, ITextSelection **txtSel)
Definition: richole.c:90
long LONG
Definition: pedump.c:60
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:79
static void release_interfaces(HWND *w, IRichEditOle **reOle, ITextDocument **txtDoc, ITextSelection **txtSel)
Definition: richole.c:100
#define S_OK
Definition: intsafe.h:52
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define EXPECT_REF(obj, ref)
Definition: richole.c:42
const GUID IID_IOleWindow
static ULONG get_refcount(IUnknown *iface)
Definition: richole.c:110

Referenced by START_TEST().

◆ test_GetFont()

static void test_GetFont ( void  )
static

Definition at line 1731 of file richole.c.

1732 {
1733  static const CHAR test_text1[] = "TestSomeText";
1734  IRichEditOle *reOle = NULL;
1735  ITextDocument *doc = NULL;
1736  ITextRange *range = NULL;
1738  ITextFont *font, *font2;
1739  CHARFORMAT2A cf;
1740  LONG value;
1741  float size;
1742  HRESULT hr;
1743  HWND hwnd;
1744  BOOL ret;
1745 
1746  create_interfaces(&hwnd, &reOle, &doc, NULL);
1747  SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1);
1748 
1749  hr = ITextDocument_GetSelection(doc, &selection);
1750  ok(hr == S_OK, "got 0x%08x\n", hr);
1751  hr = ITextSelection_GetFont(selection, &font);
1752  ok(hr == S_OK, "got 0x%08x\n", hr);
1753  hr = ITextSelection_GetFont(selection, &font2);
1754  ok(hr == S_OK, "got 0x%08x\n", hr);
1755  ok(font != font2, "got %p, %p\n", font, font2);
1756  ITextFont_Release(font2);
1757  ITextFont_Release(font);
1758  ITextSelection_Release(selection);
1759 
1760  EXPECT_REF(reOle, 3);
1761  EXPECT_REF(doc, 3);
1762 
1763  hr = ITextDocument_Range(doc, 0, 4, &range);
1764  ok(hr == S_OK, "got 0x%08x\n", hr);
1765 
1766  EXPECT_REF(reOle, 3);
1767  EXPECT_REF(doc, 3);
1768  EXPECT_REF(range, 1);
1769 
1770  hr = ITextRange_GetFont(range, NULL);
1771  ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
1772 
1773  hr = ITextRange_GetFont(range, &font);
1774  ok(hr == S_OK, "got 0x%08x\n", hr);
1775 
1776  EXPECT_REF(reOle, 3);
1777  EXPECT_REF(doc, 3);
1778  EXPECT_REF(range, 2);
1779  EXPECT_REF(font, 1);
1780 
1781  hr = ITextRange_GetFont(range, &font2);
1782  ok(hr == S_OK, "got 0x%08x\n", hr);
1783  ok(font != font2, "got %p, %p\n", font, font2);
1784 
1785  EXPECT_REF(reOle, 3);
1786  EXPECT_REF(doc, 3);
1787  EXPECT_REF(range, 3);
1788  EXPECT_REF(font, 1);
1789  EXPECT_REF(font2, 1);
1790 
1791  ITextFont_Release(font2);
1792 
1793  /* set different font style within a range */
1794  hr = ITextFont_GetItalic(font, NULL);
1795  ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
1796 
1797  hr = ITextFont_GetSize(font, NULL);
1798  ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
1799 
1800  size = 0.0;
1801  hr = ITextFont_GetSize(font, &size);
1802  ok(hr == S_OK, "got 0x%08x\n", hr);
1803  ok(size > 0.0, "size %.2f\n", size);
1804 
1805  value = 0;
1806  hr = ITextFont_GetLanguageID(font, &value);
1807  ok(hr == S_OK, "got 0x%08x\n", hr);
1808  ok(value == GetSystemDefaultLCID(), "got lcid %x, user lcid %x\n", value,
1810 
1811  /* range is non-italic */
1812  value = tomTrue;
1813  hr = ITextFont_GetItalic(font, &value);
1814  ok(hr == S_OK, "got 0x%08x\n", hr);
1815  ok(value == tomFalse, "got %d\n", value);
1816 
1817  cf.cbSize = sizeof(CHARFORMAT2A);
1818  cf.dwMask = CFM_ITALIC|CFM_SIZE;
1819  cf.dwEffects = CFE_ITALIC;
1820  cf.yHeight = 24.0;
1821 
1822  SendMessageA(hwnd, EM_SETSEL, 2, 3);
1824  ok(ret, "got %d\n", ret);
1825 
1826  /* now range is partially italicized */
1827  value = tomFalse;
1828  hr = ITextFont_GetItalic(font, &value);
1829  ok(hr == S_OK, "got 0x%08x\n", hr);
1830  ok(value == tomUndefined, "got %d\n", value);
1831 
1832  size = 0.0;
1833  hr = ITextFont_GetSize(font, &size);
1834  ok(hr == S_OK, "got 0x%08x\n", hr);
1835  ok(size == tomUndefined, "size %.2f\n", size);
1836 
1837  ITextFont_Release(font);
1838  release_interfaces(&hwnd, &reOle, &doc, NULL);
1839 
1840  hr = ITextRange_GetFont(range, NULL);
1841  ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
1842 
1843  hr = ITextRange_GetFont(range, &font2);
1844  ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
1845 
1846  ITextRange_Release(range);
1847 }
Definition: tom.idl:28
static IClassFactory * cf
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
Definition: pdh_main.c:93
HRESULT hr
Definition: shlfolder.c:183
Definition: mk_font.cpp:20
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define CO_E_RELEASED
Definition: winerror.h:2818
char CHAR
Definition: xmlstorage.h:175
#define CFM_ITALIC
Definition: richedit.h:333
static void create_interfaces(HWND *w, IRichEditOle **reOle, ITextDocument **txtDoc, ITextSelection **txtSel)
Definition: richole.c:90
int selection
Definition: ctm.c:92
struct _charformat2a CHARFORMAT2A
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
#define EM_SETCHARFORMAT
Definition: richedit.h:101
#define E_INVALIDARG
Definition: ddrawi.h:101
LONG_PTR LPARAM
Definition: windef.h:208
LCID WINAPI GetSystemDefaultLCID(void)
Definition: lang.c:787
#define WM_SETTEXT
Definition: winuser.h:1599
GLsizeiptr size
Definition: glext.h:5919
LONG HRESULT
Definition: typedefs.h:79
#define EM_SETSEL
Definition: winuser.h:2000
#define CFM_SIZE
Definition: richedit.h:362
int ret
#define CFE_ITALIC
Definition: richedit.h:407
GLsizei const GLfloat * value
Definition: glext.h:6069
static void release_interfaces(HWND *w, IRichEditOle **reOle, ITextDocument **txtDoc, ITextSelection **txtSel)
Definition: richole.c:100
GLenum GLint * range
Definition: glext.h:7539
#define S_OK
Definition: intsafe.h:52
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define EXPECT_REF(obj, ref)
Definition: richole.c:42
#define SCF_SELECTION
Definition: richedit.h:235
Definition: tom.idl:29

Referenced by START_TEST().

◆ test_GetPara()

static void test_GetPara ( void  )
static

Definition at line 1849 of file richole.c.

1850 {
1851  static const CHAR test_text1[] = "TestSomeText";
1852  IRichEditOle *reOle = NULL;
1853  ITextDocument *doc = NULL;
1855  ITextRange *range = NULL;
1856  ITextPara *para, *para2;
1857  HRESULT hr;
1858  HWND hwnd;
1859 
1860  create_interfaces(&hwnd, &reOle, &doc, &selection);
1861  SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1);
1862 
1863  EXPECT_REF(reOle, 3);
1864  EXPECT_REF(doc, 3);
1865 
1866  hr = ITextDocument_Range(doc, 0, 4, &range);
1867  ok(hr == S_OK, "got 0x%08x\n", hr);
1868 
1869  EXPECT_REF(reOle, 3);
1870  EXPECT_REF(doc, 3);
1871  EXPECT_REF(range, 1);
1872 
1873  hr = ITextRange_GetPara(range, NULL);
1874  ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
1875 
1876  hr = ITextRange_GetPara(range, &para);
1877  ok(hr == S_OK, "got 0x%08x\n", hr);
1878 
1879  EXPECT_REF(reOle, 3);
1880  EXPECT_REF(doc, 3);
1881  EXPECT_REF(range, 2);
1882  EXPECT_REF(para, 1);
1883 
1884  hr = ITextRange_GetPara(range, &para2);
1885  ok(hr == S_OK, "got 0x%08x\n", hr);
1886  ok(para != para2, "got %p, %p\n", para, para2);
1887 
1888  EXPECT_REF(reOle, 3);
1889  EXPECT_REF(doc, 3);
1890  EXPECT_REF(range, 3);
1891  EXPECT_REF(para, 1);
1892  EXPECT_REF(para2, 1);
1893 
1894  ITextPara_Release(para);
1895  ITextPara_Release(para2);
1896 
1897  EXPECT_REF(reOle, 3);
1898  EXPECT_REF(doc, 3);
1899  EXPECT_REF(selection, 2);
1900 
1901  hr = ITextSelection_GetPara(selection, &para);
1902  ok(hr == S_OK, "got 0x%08x\n", hr);
1903 
1904  EXPECT_REF(reOle, 3);
1905  EXPECT_REF(doc, 3);
1906  EXPECT_REF(selection, 3);
1907  EXPECT_REF(para, 1);
1908 
1909  hr = ITextSelection_GetPara(selection, &para2);
1910  ok(hr == S_OK, "got 0x%08x\n", hr);
1911  ok(para != para2, "got %p, %p\n", para, para2);
1912 
1913  ITextPara_Release(para);
1914  ITextPara_Release(para2);
1915  release_interfaces(&hwnd, &reOle, &doc, NULL);
1916 
1917  hr = ITextRange_GetPara(range, NULL);
1918  ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
1919 
1920  hr = ITextRange_GetPara(range, &para);
1921  ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
1922 
1923  hr = ITextSelection_GetPara(selection, NULL);
1924  ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
1925 
1926  hr = ITextSelection_GetPara(selection, &para);
1927  ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
1928 
1929  ITextSelection_Release(selection);
1930  ITextRange_Release(range);
1931 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
HRESULT hr
Definition: shlfolder.c:183
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define CO_E_RELEASED
Definition: winerror.h:2818
char CHAR
Definition: xmlstorage.h:175
static void create_interfaces(HWND *w, IRichEditOle **reOle, ITextDocument **txtDoc, ITextSelection **txtSel)
Definition: richole.c:90
int selection
Definition: ctm.c:92
#define E_INVALIDARG
Definition: ddrawi.h:101
LONG_PTR LPARAM
Definition: windef.h:208
#define WM_SETTEXT
Definition: winuser.h:1599
LONG HRESULT
Definition: typedefs.h:79
static void release_interfaces(HWND *w, IRichEditOle **reOle, ITextDocument **txtDoc, ITextSelection **txtSel)
Definition: richole.c:100
GLenum GLint * range
Definition: glext.h:7539
#define S_OK
Definition: intsafe.h:52
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define EXPECT_REF(obj, ref)
Definition: richole.c:42

Referenced by START_TEST().

◆ test_GetStoryLength()

static void test_GetStoryLength ( void  )
static

Definition at line 3403 of file richole.c.

3404 {
3405  static const CHAR test_text1[] = "TestSomeText";
3406  IRichEditOle *reOle = NULL;
3407  ITextDocument *doc = NULL;
3409  ITextRange *range;
3410  LONG value;
3411  HRESULT hr;
3412  HWND hwnd;
3413 
3414  create_interfaces(&hwnd, &reOle, &doc, &selection);
3415  SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1);
3416  SendMessageA(hwnd, EM_SETSEL, 1, 2);
3417 
3418  hr = ITextDocument_Range(doc, 0, 4, &range);
3419  ok(hr == S_OK, "got 0x%08x\n", hr);
3420 
3421  hr = ITextRange_GetStoryLength(range, NULL);
3422  ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
3423 
3424  value = 0;
3425  hr = ITextRange_GetStoryLength(range, &value);
3426  ok(hr == S_OK, "got 0x%08x\n", hr);
3427  ok(value == 13, "got %d\n", value);
3428 
3429  hr = ITextSelection_GetStoryLength(selection, NULL);
3430  ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
3431 
3432  value = 0;
3433  hr = ITextSelection_GetStoryLength(selection, &value);
3434  ok(hr == S_OK, "got 0x%08x\n", hr);
3435  ok(value == 13, "got %d\n", value);
3436 
3437  SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)"");
3438 
3439  value = 0;
3440  hr = ITextRange_GetStoryLength(range, &value);
3441  ok(hr == S_OK, "got 0x%08x\n", hr);
3442  ok(value == 1, "got %d\n", value);
3443 
3444  value = 0;
3445  hr = ITextSelection_GetStoryLength(selection, &value);
3446  ok(hr == S_OK, "got 0x%08x\n", hr);
3447  ok(value == 1, "got %d\n", value);
3448 
3449  release_interfaces(&hwnd, &reOle, &doc, NULL);
3450 
3451  hr = ITextRange_GetStoryLength(range, NULL);
3452  ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
3453 
3454  value = 100;
3455  hr = ITextRange_GetStoryLength(range, &value);
3456  ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
3457  ok(value == 100, "got %d\n", value);
3458 
3459  hr = ITextSelection_GetStoryLength(selection, NULL);
3460  ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
3461 
3462  value = 100;
3463  hr = ITextSelection_GetStoryLength(selection, &value);
3464  ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
3465  ok(value == 100, "got %d\n", value);
3466 
3467  ITextSelection_Release(selection);
3468  ITextRange_Release(range);
3469 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
Definition: pdh_main.c:93
HRESULT hr
Definition: shlfolder.c:183
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define CO_E_RELEASED
Definition: winerror.h:2818
char CHAR
Definition: xmlstorage.h:175
static void create_interfaces(HWND *w, IRichEditOle **reOle, ITextDocument **txtDoc, ITextSelection **txtSel)
Definition: richole.c:90
int selection
Definition: ctm.c:92
long LONG
Definition: pedump.c:60
#define E_INVALIDARG
Definition: ddrawi.h:101
LONG_PTR LPARAM
Definition: windef.h:208
#define WM_SETTEXT
Definition: winuser.h:1599
LONG HRESULT
Definition: typedefs.h:79
#define EM_SETSEL
Definition: winuser.h:2000
GLsizei const GLfloat * value
Definition: glext.h:6069
static void release_interfaces(HWND *w, IRichEditOle **reOle, ITextDocument **txtDoc, ITextSelection **txtSel)
Definition: richole.c:100
GLenum GLint * range
Definition: glext.h:7539
#define S_OK
Definition: intsafe.h:52
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112

Referenced by START_TEST().

◆ test_GetStoryType()

static void test_GetStoryType ( void  )
static

Definition at line 3056 of file richole.c.

3057 {
3058  static const CHAR test_text1[] = "TestSomeText";
3059  IRichEditOle *reOle = NULL;
3060  ITextDocument *doc = NULL;
3062  ITextRange *range;
3063  LONG value;
3064  HRESULT hr;
3065  HWND hwnd;
3066 
3067  create_interfaces(&hwnd, &reOle, &doc, &selection);
3068  SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1);
3069  SendMessageA(hwnd, EM_SETSEL, 1, 2);
3070 
3071  hr = ITextDocument_Range(doc, 0, 4, &range);
3072  ok(hr == S_OK, "got 0x%08x\n", hr);
3073 
3074  hr = ITextRange_GetStoryType(range, NULL);
3075  ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
3076 
3078  hr = ITextRange_GetStoryType(range, &value);
3079  ok(hr == S_OK, "got 0x%08x\n", hr);
3080  ok(value == tomUnknownStory, "got %d\n", value);
3081 
3082  hr = ITextSelection_GetStoryType(selection, NULL);
3083  ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
3084 
3086  hr = ITextSelection_GetStoryType(selection, &value);
3087  ok(hr == S_OK, "got 0x%08x\n", hr);
3088  ok(value == tomUnknownStory, "got %d\n", value);
3089 
3090  release_interfaces(&hwnd, &reOle, &doc, NULL);
3091 
3092  hr = ITextRange_GetStoryType(range, NULL);
3093  ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
3094 
3095  value = 123;
3096  hr = ITextRange_GetStoryType(range, &value);
3097  ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
3098  ok(value == 123, "got %d\n", value);
3099 
3100  hr = ITextSelection_GetStoryType(selection, NULL);
3101  ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
3102 
3103  value = 123;
3104  hr = ITextSelection_GetStoryType(selection, &value);
3105  ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
3106  ok(value == 123, "got %d\n", value);
3107 
3108  ITextRange_Release(range);
3109  ITextSelection_Release(selection);
3110 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
Definition: pdh_main.c:93
HRESULT hr
Definition: shlfolder.c:183
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define CO_E_RELEASED
Definition: winerror.h:2818
char CHAR
Definition: xmlstorage.h:175
static void create_interfaces(HWND *w, IRichEditOle **reOle, ITextDocument **txtDoc, ITextSelection **txtSel)
Definition: richole.c:90
int selection
Definition: ctm.c:92
long LONG
Definition: pedump.c:60
#define E_INVALIDARG
Definition: ddrawi.h:101
LONG_PTR LPARAM
Definition: windef.h:208
#define WM_SETTEXT
Definition: winuser.h:1599
LONG HRESULT
Definition: typedefs.h:79
#define EM_SETSEL
Definition: winuser.h:2000
GLsizei const GLfloat * value
Definition: glext.h:6069
static void release_interfaces(HWND *w, IRichEditOle **reOle, ITextDocument **txtDoc, ITextSelection **txtSel)
Definition: richole.c:100
GLenum GLint * range
Definition: glext.h:7539
#define S_OK
Definition: intsafe.h:52
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112

Referenced by START_TEST().

◆ test_GetText()

static void test_GetText ( void  )
static

Definition at line 520 of file richole.c.

521 {
522  HWND w;
523  IRichEditOle *reOle = NULL;
524  ITextDocument *txtDoc = NULL;
525  ITextSelection *txtSel = NULL;
526  HRESULT hres;
527  BSTR bstr = NULL;
528  int first, lim;
529  static const CHAR test_text1[] = "TestSomeText";
530  static const WCHAR bufW1[] = {'T', 'e', 's', 't', 0};
531  static const WCHAR bufW2[] = {'T', 'e', 'x', 't', '\r', 0};
532  static const WCHAR bufW3[] = {'T', 'e', 'x', 't', 0};
533  static const WCHAR bufW4[] = {'T', 'e', 's', 't', 'S', 'o', 'm',
534  'e', 'T', 'e', 'x', 't', '\r', 0};
535  static const WCHAR bufW5[] = {'\r', 0};
536  static const WCHAR bufW6[] = {'T','e','s','t','S','o','m','e','T',0};
537  BOOL is64bit = sizeof(void *) > sizeof(int);
538  ITextRange *range;
539 
540  create_interfaces(&w, &reOle, &txtDoc, &txtSel);
541  SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
542 
543  /* ITextSelection */
544  first = 0; lim = 4;
545  SendMessageA(w, EM_SETSEL, first, lim);
546  hres = ITextSelection_GetText(txtSel, &bstr);
547  ok(hres == S_OK, "ITextSelection_GetText\n");
548  ok(!lstrcmpW(bstr, bufW1), "got wrong text: %s\n", wine_dbgstr_w(bstr));
549  SysFreeString(bstr);
550 
551  first = 4; lim = 0;
552  SendMessageA(w, EM_SETSEL, first, lim);
553  hres = ITextSelection_GetText(txtSel, &bstr);
554  ok(hres == S_OK, "ITextSelection_GetText\n");
555  ok(!lstrcmpW(bstr, bufW1), "got wrong text: %s\n", wine_dbgstr_w(bstr));
556  SysFreeString(bstr);
557 
558  first = 1; lim = 1;
559  SendMessageA(w, EM_SETSEL, first, lim);
560  hres = ITextSelection_GetText(txtSel, &bstr);
561  ok(hres == S_OK, "ITextSelection_GetText\n");
562  ok(!bstr, "got wrong text: %s\n", wine_dbgstr_w(bstr));
563 
564  if (!is64bit)
565  {
566  hres = ITextSelection_GetText(txtSel, NULL);
567  ok(hres == E_INVALIDARG, "ITextSelection_GetText\n");
568  }
569 
570  first = 8; lim = 12;
571  SendMessageA(w, EM_SETSEL, first, lim);
572  hres = ITextSelection_GetText(txtSel, &bstr);
573  ok(hres == S_OK, "ITextSelection_GetText\n");
574  ok(!lstrcmpW(bstr, bufW3), "got wrong text: %s\n", wine_dbgstr_w(bstr));
575  SysFreeString(bstr);
576 
577  first = 8; lim = 13;
578  SendMessageA(w, EM_SETSEL, first, lim);
579  hres = ITextSelection_GetText(txtSel, &bstr);
580  ok(hres == S_OK, "ITextSelection_GetText\n");
581  ok(!lstrcmpW(bstr, bufW2), "got wrong text: %s\n", wine_dbgstr_w(bstr));
582  SysFreeString(bstr);
583 
584  first = 12; lim = 13;
585  SendMessageA(w, EM_SETSEL, first, lim);
586  hres = ITextSelection_GetText(txtSel, &bstr);
587  ok(hres == S_OK, "ITextSelection_GetText\n");
588  ok(!lstrcmpW(bstr, bufW5), "got wrong text: %s\n", wine_dbgstr_w(bstr));
589  SysFreeString(bstr);
590 
591  first = 0; lim = -1;
592  SendMessageA(w, EM_SETSEL, first, lim);
593  hres = ITextSelection_GetText(txtSel, &bstr);
594  ok(hres == S_OK, "ITextSelection_GetText\n");
595  ok(!lstrcmpW(bstr, bufW4), "got wrong text: %s\n", wine_dbgstr_w(bstr));
596  SysFreeString(bstr);
597 
598  first = -1; lim = 9;
599  SendMessageA(w, EM_SETSEL, first, lim);
600  hres = ITextSelection_GetText(txtSel, &bstr);
601  ok(hres == S_OK, "ITextSelection_GetText\n");
602  ok(!bstr, "got wrong text: %s\n", wine_dbgstr_w(bstr));
603 
604  /* ITextRange */
605  hres = ITextDocument_Range(txtDoc, 0, 4, &range);
606  ok(hres == S_OK, "got 0x%08x\n", hres);
607  hres = ITextRange_GetText(range, &bstr);
608  ok(hres == S_OK, "got 0x%08x\n", hres);
609  ok(!lstrcmpW(bstr, bufW1), "got wrong text: %s\n", wine_dbgstr_w(bstr));
610 
611  SysFreeString(bstr);
612  ITextRange_Release(range);
613 
614  hres = ITextDocument_Range(txtDoc, 4, 0, &range);
615  ok(hres == S_OK, "got 0x%08x\n", hres);
616  hres = ITextRange_GetText(range, &bstr);
617  ok(hres == S_OK, "got 0x%08x\n", hres);
618  ok(!lstrcmpW(bstr, bufW1), "got wrong text: %s\n", wine_dbgstr_w(bstr));
619 
620  SysFreeString(bstr);
621  ITextRange_Release(range);
622 
623  hres = ITextDocument_Range(txtDoc, 1, 1, &range);
624  ok(hres == S_OK, "got 0x%08x\n", hres);
625  hres = ITextRange_GetText(range, &bstr);
626  ok(hres == S_OK, "got 0x%08x\n", hres);
627  ok(!bstr, "got wrong text: %s\n", wine_dbgstr_w(bstr));
628  if (!is64bit)
629  {
630  hres = ITextRange_GetText(range, NULL);
631  ok(hres == E_INVALIDARG, "got 0x%08x\n", hres);
632  }
633  ITextRange_Release(range);
634 
635  hres = ITextDocument_Range(txtDoc, 8, 12, &range);
636  ok(hres == S_OK, "got 0x%08x\n", hres);
637  hres = ITextRange_GetText(range, &bstr);
638  ok(hres == S_OK, "got 0x%08x\n", hres);
639  ok(!lstrcmpW(bstr, bufW3), "got wrong text: %s\n", wine_dbgstr_w(bstr));
640 
641  SysFreeString(bstr);
642  ITextRange_Release(range);
643 
644  hres = ITextDocument_Range(txtDoc, 8, 13, &range);
645  ok(hres == S_OK, "got 0x%08x\n", hres);
646  hres = ITextRange_GetText(range, &bstr);
647  ok(hres == S_OK, "got 0x%08x\n", hres);
648  ok(!lstrcmpW(bstr, bufW2), "got wrong text: %s\n", wine_dbgstr_w(bstr));
649 
650  SysFreeString(bstr);
651  ITextRange_Release(range);
652 
653  hres = ITextDocument_Range(txtDoc, 12, 13, &range);
654  ok(hres == S_OK, "got 0x%08x\n", hres);
655  hres = ITextRange_GetText(range, &bstr);
656  ok(hres == S_OK, "got 0x%08x\n", hres);
657  ok(!lstrcmpW(bstr, bufW5), "got wrong text: %s\n", wine_dbgstr_w(bstr));
658 
659  SysFreeString(bstr);
660  ITextRange_Release(range);
661 
662  hres = ITextDocument_Range(txtDoc, 0, -1, &range);
663  ok(hres == S_OK, "got 0x%08x\n", hres);
664  hres = ITextRange_GetText(range, &bstr);
665  ok(hres == S_OK, "got 0x%08x\n", hres);
666  ok(!bstr, "got wrong text: %s\n", wine_dbgstr_w(bstr));
667  ITextRange_Release(range);
668 
669  hres = ITextDocument_Range(txtDoc, -1, 9, &range);
670  ok(hres == S_OK, "got 0x%08x\n", hres);
671  hres = ITextRange_GetText(range, &bstr);
672  ok(hres == S_OK, "got 0x%08x\n", hres);
673  ok(!lstrcmpW(bstr, bufW6), "got wrong text: %s\n", wine_dbgstr_w(bstr));
674 
675  SysFreeString(bstr);
676 
677  release_interfaces(&w, &reOle, &txtDoc, NULL);
678 
679  /* detached selection/range */
680  if (is64bit) {
681  bstr = (void*)0xdeadbeef;
682  hres = ITextSelection_GetText(txtSel, &bstr);
683  ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres);
684 todo_wine
685  ok(bstr == NULL, "got %p\n", bstr);
686 
687  bstr = (void*)0xdeadbeef;
688  hres = ITextRange_GetText(range, &bstr);
689  ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres);
690 todo_wine
691  ok(bstr == NULL, "got %p\n", bstr);
692  }
693  else {
694  hres = ITextSelection_GetText(txtSel, NULL);
695  ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres);
696 
697  hres = ITextRange_GetText(range, NULL);
698  ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres);
699  }
700 
701  ITextRange_Release(range);
702  ITextSelection_Release(txtSel);
703 }
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: atltest.h:87
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
#define CO_E_RELEASED
Definition: winerror.h:2818
char CHAR
Definition: xmlstorage.h:175
const GLint * first
Definition: glext.h:5794
OLECHAR * BSTR
Definition: compat.h:2152
static void create_interfaces(HWND *w, IRichEditOle **reOle, ITextDocument **txtDoc, ITextSelection **txtSel)
Definition: richole.c:90
unsigned int BOOL
Definition: ntddk_ex.h:94
#define E_INVALIDARG
Definition: ddrawi.h:101
LONG_PTR LPARAM
Definition: windef.h:208
#define WM_SETTEXT
Definition: winuser.h:1599
HRESULT hres
Definition: protocol.c:465
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
#define EM_SETSEL
Definition: winuser.h:2000
#define todo_wine
Definition: test.h:164
static void release_interfaces(HWND *w, IRichEditOle **reOle, ITextDocument **txtDoc, ITextSelection **txtSel)
Definition: richole.c:100
GLenum GLint * range
Definition: glext.h:7539
#define S_OK
Definition: intsafe.h:52
#define ok(value,...)
Definition: atltest.h:57
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:271
#define NULL
Definition: types.h:112

Referenced by START_TEST().

◆ test_InRange()

static void test_InRange ( void  )
static

Definition at line 2787 of file richole.c.

2788 {
2789  static const CHAR test_text1[] = "TestSomeText";
2790  ITextRange *range, *range2, *range3;
2791  IRichEditOle *reOle = NULL;
2792  ITextDocument *doc = NULL;
2794  LONG value;
2795  HRESULT hr;
2796  HWND hwnd;
2797 
2798  create_interfaces(&hwnd, &reOle, &doc, &selection);
2799  SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1);
2800  SendMessageA(hwnd, EM_SETSEL, 1, 2);
2801 
2802  hr = ITextDocument_Range(doc, 0, 4, &range);
2803  ok(hr == S_OK, "got 0x%08x\n", hr);
2804 
2805  hr = ITextDocument_Range(doc, 0, 4, &range2);
2806  ok(hr == S_OK, "got 0x%08x\n", hr);
2807 
2808  /* matches selection */
2809  hr = ITextDocument_Range(doc, 1, 2, &range3);
2810  ok(hr == S_OK, "got 0x%08x\n", hr);
2811 
2812  hr = ITextRange_InRange(range, NULL, NULL);
2813  ok(hr == S_FALSE, "got 0x%08x\n", hr);
2814 
2815  value = tomTrue;
2816  hr = ITextRange_InRange(range, NULL, &value);
2817  ok(hr == S_FALSE, "got 0x%08x\n", hr);
2818  ok(value == tomFalse, "got %d\n", value);
2819 
2820  hr = ITextRange_InRange(range, range2, NULL);
2821  ok(hr == S_OK, "got 0x%08x\n", hr);
2822 
2823  value = tomFalse;
2824  hr = ITextRange_InRange(range, range2, &value);
2825  ok(hr == S_OK, "got 0x%08x\n", hr);
2826  ok(value == tomTrue, "got %d\n", value);
2827 
2828  /* selection */
2829  hr = ITextSelection_InRange(selection, NULL, NULL);
2830  ok(hr == S_FALSE, "got 0x%08x\n", hr);
2831 
2832  value = tomTrue;
2833  hr = ITextSelection_InRange(selection, NULL, &value);
2834  ok(hr == S_FALSE, "got 0x%08x\n", hr);
2835  ok(value == tomFalse, "got %d\n", value);
2836 
2837  hr = ITextSelection_InRange(selection, range2, NULL);
2838  ok(hr == S_FALSE, "got 0x%08x\n", hr);
2839 
2840  value = tomTrue;
2841  hr = ITextSelection_InRange(selection, range2, &value);
2842  ok(hr == S_FALSE, "got 0x%08x\n", hr);
2843  ok(value == tomFalse, "got %d\n", value);
2844 
2845  value = tomTrue;
2846  hr = ITextSelection_InRange(selection, range3, &value);
2847  ok(hr == S_FALSE, "got 0x%08x\n", hr);
2848  ok(value == tomFalse, "got %d\n", value);
2849 
2850  /* seems to work on ITextSelection ranges only */
2851  value = tomFalse;
2852  hr = ITextSelection_InRange(selection, (ITextRange*)selection, &value);
2853  ok(hr == S_OK, "got 0x%08x\n", hr);
2854  ok(value == tomTrue, "got %d\n", value);
2855 
2856  release_interfaces(&hwnd, &reOle, &doc, NULL);
2857 
2858  hr = ITextRange_InRange(range, NULL, NULL);
2859  ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
2860 
2861  value = tomTrue;
2862  hr = ITextRange_InRange(range, NULL, &value);
2863  ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
2864  ok(value == tomFalse, "got %d\n", value);
2865 
2866  hr = ITextRange_InRange(range, range2, NULL);
2867  ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
2868 
2869  value = tomTrue;
2870  hr = ITextRange_InRange(range, range2, &value);
2871  ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
2872  ok(value == tomFalse, "got %d\n", value);
2873 
2874  /* selection */
2875  hr = ITextSelection_InRange(selection, NULL, NULL);
2876  ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
2877 
2878  value = tomTrue;
2879  hr = ITextSelection_InRange(selection, NULL, &value);
2880  ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
2881  ok(value == tomFalse, "got %d\n", value);
2882 
2883  hr = ITextSelection_InRange(selection, range2, NULL);
2884  ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
2885 
2886  value = tomTrue;
2887  hr = ITextSelection_InRange(selection, range2, &value);
2888  ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
2889  ok(value == tomFalse, "got %d\n", value);
2890 
2891  ITextRange_Release(range);
2892  ITextRange_Release(range2);
2893  ITextRange_Release(range3);
2894  ITextSelection_Release(selection);
2895 }
Definition: tom.idl:28
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
Definition: pdh_main.c:93
HRESULT hr
Definition: shlfolder.c:183
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define CO_E_RELEASED
Definition: winerror.h:2818
char CHAR
Definition: xmlstorage.h:175
static void create_interfaces(HWND *w, IRichEditOle **reOle, ITextDocument **txtDoc, ITextSelection **txtSel)
Definition: richole.c:90
int selection
Definition: ctm.c:92
long LONG
Definition: pedump.c:60
#define S_FALSE
Definition: winerror.h:2357
LONG_PTR LPARAM
Definition: windef.h:208
#define WM_SETTEXT
Definition: winuser.h:1599
LONG HRESULT
Definition: typedefs.h:79
#define EM_SETSEL
Definition: winuser.h:2000
GLsizei const GLfloat * value
Definition: glext.h:6069
static void release_interfaces(HWND *w, IRichEditOle **reOle, ITextDocument **txtDoc, ITextSelection **txtSel)
Definition: richole.c:100
GLenum GLint * range
Definition: glext.h:7539
#define S_OK
Definition: intsafe.h:52
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
Definition: tom.idl:29

Referenced by START_TEST().

◆ test_InsertObject()

static void test_InsertObject ( void  )
static

Definition at line 3227 of file richole.c.

3228 {
3229  static CHAR test_text1[] = "abcdefg";
3230  IRichEditOle *reole = NULL;
3231  ITextDocument *doc = NULL;
3232  IOleClientSite *clientsite;
3233  REOBJECT reo1, reo2, reo3, received_reo1, received_reo2, received_reo3, received_reo4;
3234  HRESULT hr;
3235  HWND hwnd;
3236  LONG count;
3237 
3238  create_interfaces(&hwnd, &reole, &doc, NULL);
3239  SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1);
3240 
3241  hr = IRichEditOle_InsertObject(reole, NULL);
3242  ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
3243 
3244  /* insert object1 in (0, 1)*/
3245  SendMessageA(hwnd, EM_SETSEL, 0, 1);
3246  hr = IRichEditOle_GetClientSite(reole, &clientsite);
3247  ok(hr == S_OK, "IRichEditOle_GetClientSite failed: 0x%08x\n", hr);
3248  fill_reobject_struct(&reo1, REO_CP_SELECTION, NULL, NULL, clientsite, 10, 10, DVASPECT_CONTENT, 0, 1);
3249  hr = IRichEditOle_InsertObject(reole, &reo1);
3250  ok(hr == S_OK, "IRichEditOle_InsertObject failed: 0x%08x\n", hr);
3251  count = IRichEditOle_GetObjectCount(reole);
3252  ok(count == 1, "got wrong object count: %d\n", count);
3253  IOleClientSite_Release(clientsite);
3254 
3255  /* insert object2 in (2, 3)*/
3256  SendMessageA(hwnd, EM_SETSEL, 2, 3);
3257  hr = IRichEditOle_GetClientSite(reole, &clientsite);
3258  ok(hr == S_OK, "IRichEditOle_GetClientSite failed: 0x%08x\n", hr);
3259  fill_reobject_struct(&reo2, REO_CP_SELECTION, NULL, NULL, clientsite, 10, 10, DVASPECT_CONTENT, 0, 2);
3260  hr = IRichEditOle_InsertObject(reole, &reo2);
3261  ok(hr == S_OK, "IRichEditOle_InsertObject failed: 0x%08x\n", hr);
3262  count = IRichEditOle_GetObjectCount(reole);
3263  ok(count == 2, "got wrong object count: %d\n", count);
3264  IOleClientSite_Release(clientsite);
3265 
3266  /* insert object3 in (1, 2)*/
3267  SendMessageA(hwnd, EM_SETSEL, 1, 2);
3268  hr = IRichEditOle_GetClientSite(reole, &clientsite);
3269  ok(hr == S_OK, "IRichEditOle_GetClientSite failed: 0x%08x\n", hr);
3270  fill_reobject_struct(&reo3, REO_CP_SELECTION, NULL, NULL, clientsite, 10, 10, DVASPECT_CONTENT, 0, 3);
3271  hr = IRichEditOle_InsertObject(reole, &reo3);
3272  ok(hr == S_OK, "IRichEditOle_InsertObject failed: 0x%08x\n", hr);
3273  count = IRichEditOle_GetObjectCount(reole);
3274  ok(count == 3, "got wrong object count: %d\n", count);
3275  IOleClientSite_Release(clientsite);
3276 
3277  /* tests below show that order of rebject (from 0 to 2) is: reo1,reo3,reo2 */
3278  received_reo1.cbStruct = sizeof(received_reo1);
3279  hr = IRichEditOle_GetObject(reole, 0, &received_reo1, REO_GETOBJ_ALL_INTERFACES);
3280  ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr);
3281  CHECK_REOBJECT_STRUCT(received_reo1, NULL, NULL, reo1.polesite, 1);
3282 
3283  received_reo2.cbStruct = sizeof(received_reo2);
3284  hr = IRichEditOle_GetObject(reole, 1, &received_reo2, REO_GETOBJ_ALL_INTERFACES);
3285  ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr);
3286  CHECK_REOBJECT_STRUCT(received_reo2, NULL, NULL, reo3.polesite, 3);
3287 
3288  received_reo3.cbStruct = sizeof(received_reo3);
3289  hr = IRichEditOle_GetObject(reole, 2, &received_reo3, REO_GETOBJ_ALL_INTERFACES);
3290  ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr);
3291  CHECK_REOBJECT_STRUCT(received_reo3, NULL, NULL, reo2.polesite, 2);
3292 
3293  hr = IRichEditOle_GetObject(reole, 2, NULL, REO_GETOBJ_ALL_INTERFACES);
3294  ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08x\n", hr);
3295 
3296  received_reo4.cbStruct = 0;
3297  hr = IRichEditOle_GetObject(reole, 2, &received_reo4, REO_GETOBJ_ALL_INTERFACES);
3298  ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08x\n", hr);
3299 
3300  received_reo4.cbStruct = sizeof(received_reo4);
3301  hr = IRichEditOle_GetObject(reole, 2, &received_reo4, REO_GETOBJ_PSTG);
3302  ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr);
3303  CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, NULL, 2);
3304 
3305  hr = IRichEditOle_GetObject(reole, 2, &received_reo4, REO_GETOBJ_POLESITE);
3306  ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr);
3307  CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, reo2.polesite, 2);
3308 
3309  hr = IRichEditOle_GetObject(reole, 4, &received_reo4, REO_GETOBJ_POLESITE);
3310  ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08x\n", hr);
3311 
3312  hr = IRichEditOle_GetObject(reole, 1024, &received_reo4, REO_GETOBJ_POLESITE);
3313  ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08x\n", hr);
3314 
3315  /* received_reo4 will be zeroed before be used */
3316  hr = IRichEditOle_GetObject(reole, 2, &received_reo4, REO_GETOBJ_NO_INTERFACES);
3317  ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr);
3318  CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, NULL, 2);
3319 
3320  received_reo4.cbStruct = sizeof(received_reo4);
3321  received_reo4.cp = 0;
3322  hr = IRichEditOle_GetObject(reole, REO_IOB_USE_CP, &received_reo4, REO_GETOBJ_ALL_INTERFACES);
3323  ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr);
3324  CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, reo1.polesite, 1);
3325 
3326  received_reo4.cbStruct = sizeof(received_reo4);
3327  received_reo4.cp = 1;
3328  hr = IRichEditOle_GetObject(reole, REO_IOB_USE_CP, &received_reo4, REO_GETOBJ_ALL_INTERFACES);
3329  ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr);
3330  CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, reo3.polesite, 3);
3331 
3332  received_reo4.cbStruct = sizeof(received_reo4);
3333  received_reo4.cp = 2;
3334  hr = IRichEditOle_GetObject(reole, REO_IOB_USE_CP, &received_reo4, REO_GETOBJ_ALL_INTERFACES);
3335  ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr);
3336  CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, reo2.polesite, 2);
3337 
3338  received_reo4.cbStruct = sizeof(received_reo4);
3339  received_reo4.cp = 4;
3340  hr = IRichEditOle_GetObject(reole, REO_IOB_USE_CP, &received_reo4, REO_GETOBJ_ALL_INTERFACES);
3341  ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08x\n", hr);
3342  /* received_reo4 didn't be zeroed in E_INVALIDARG case */
3343  CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, reo2.polesite, 2);
3344 
3345  SendMessageA(hwnd, EM_SETSEL, 0, 1);
3346  received_reo4.cbStruct = sizeof(received_reo4);
3347  received_reo4.cp = 1;
3348  hr = IRichEditOle_GetObject(reole, REO_IOB_SELECTION, &received_reo4, REO_GETOBJ_ALL_INTERFACES);
3349  ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr);
3350  CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, reo1.polesite, 1);
3351 
3352  SendMessageA(hwnd, EM_SETSEL, 1, 2);
3353  received_reo4.cbStruct = sizeof(received_reo4);
3354  received_reo4.cp = 0;
3355  hr = IRichEditOle_GetObject(reole, REO_IOB_SELECTION, &received_reo4, REO_GETOBJ_ALL_INTERFACES);
3356  ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr);
3357  CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, reo3.polesite, 3);
3358 
3359  SendMessageA(hwnd, EM_SETSEL, 2, 3);
3360  received_reo4.cbStruct = sizeof(received_reo4);
3361  received_reo4.cp = 0;
3362  hr = IRichEditOle_GetObject(reole, REO_IOB_SELECTION, &received_reo4, REO_GETOBJ_ALL_INTERFACES);
3363  ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr);
3364  CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, reo2.polesite, 2);
3365 
3366  SendMessageA(hwnd, EM_SETSEL, 0, 2);
3367  received_reo4.cbStruct = sizeof(received_reo4);
3368  received_reo4.cp = 0;
3369  hr = IRichEditOle_GetObject(reole, REO_IOB_SELECTION, &received_reo4, REO_GETOBJ_ALL_INTERFACES);
3370  ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr);
3371  CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, reo1.polesite, 1);
3372 
3373  SendMessageA(hwnd, EM_SETSEL, 1, 3);
3374  received_reo4.cbStruct = sizeof(received_reo4);
3375  received_reo4.cp = 0;
3376  hr = IRichEditOle_GetObject(reole, REO_IOB_SELECTION, &received_reo4, REO_GETOBJ_ALL_INTERFACES);
3377  ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr);
3378  CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, reo3.polesite, 3);
3379 
3380  SendMessageA(hwnd, EM_SETSEL, 2, 0);
3381  received_reo4.cbStruct = sizeof(received_reo4);
3382  received_reo4.cp = 0;
3383  hr = IRichEditOle_GetObject(reole, REO_IOB_SELECTION, &received_reo4, REO_GETOBJ_ALL_INTERFACES);
3384  ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr);
3385  CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, reo1.polesite, 1);
3386 
3387  SendMessageA(hwnd, EM_SETSEL, 0, 6);
3388  received_reo4.cbStruct = sizeof(received_reo4);
3389  received_reo4.cp = 0;
3390  hr = IRichEditOle_GetObject(reole, REO_IOB_SELECTION, &received_reo4, REO_GETOBJ_ALL_INTERFACES);
3391  ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr);
3392  CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, reo1.polesite, 1);
3393 
3394  SendMessageA(hwnd, EM_SETSEL, 4, 5);
3395  received_reo4.cbStruct = sizeof(received_reo4);
3396  received_reo4.cp = 0;
3397  hr = IRichEditOle_GetObject(reole, REO_IOB_SELECTION, &received_reo4, REO_GETOBJ_ALL_INTERFACES);
3398  ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08x\n", hr);
3399 
3400  release_interfaces(&hwnd, &reole, &doc, NULL);
3401 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
HRESULT hr
Definition: shlfolder.c:183
RECO_DRAG struct _reobject REOBJECT
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
GLuint GLuint GLsizei count
Definition: gl.h:1545
char CHAR
Definition: xmlstorage.h:175
static void create_interfaces(HWND *w, IRichEditOle **reOle, ITextDocument **txtDoc, ITextSelection **txtSel)
Definition: richole.c:90
long LONG
Definition: pedump.c:60
#define E_INVALIDARG
Definition: ddrawi.h:101
LONG_PTR LPARAM
Definition: windef.h:208
#define WM_SETTEXT
Definition: winuser.h:1599
LONG HRESULT
Definition: typedefs.h:79
#define EM_SETSEL
Definition: winuser.h:2000
static void release_interfaces(HWND *w, IRichEditOle **reOle, ITextDocument **txtDoc, ITextSelection **txtSel)
Definition: richole.c:100
#define S_OK
Definition: intsafe.h:52
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
static void fill_reobject_struct(REOBJECT *reobj, LONG cp, LPOLEOBJECT poleobj, LPSTORAGE pstg, LPOLECLIENTSITE polesite, LONG sizel_cx, LONG sizel_cy, DWORD aspect, DWORD flags, DWORD user)
Definition: richole.c:3199
#define CHECK_REOBJECT_STRUCT(reobj, poleobj, pstg, polesite, user)
Definition: richole.c:3216

Referenced by START_TEST().

◆ test_Interfaces()

static void test_Interfaces ( void  )
static

Definition at line 143 of file richole.c.

144 {
145  IRichEditOle *reOle = NULL, *reOle1 = NULL;
146  ITextDocument *txtDoc = NULL;
147 #if 0 /*avoid CORE-16799*/
148  ITextDocument2Old *txtDoc2Old = NULL;
149 #endif
150  ITextSelection *txtSel = NULL, *txtSel2;
151  IUnknown *punk;
152  HRESULT hres;
153  LRESULT res;
154  HWND w;
155  ULONG refcount;
156 
157  w = new_richedit(NULL);
158  if (!w) {
159  skip("Couldn't create window\n");
160  return;
161  }
162 
163  res = SendMessageA(w, EM_GETOLEINTERFACE, 0, (LPARAM)&reOle);
164  ok(res, "SendMessage\n");
165  ok(reOle != NULL, "EM_GETOLEINTERFACE\n");
166  EXPECT_REF(reOle, 2);
167 
168  res = SendMessageA(w, EM_GETOLEINTERFACE, 0, (LPARAM)&reOle1);
169  ok(res == 1, "SendMessage\n");
170  ok(reOle1 == reOle, "Should not return a new IRichEditOle interface\n");
171  EXPECT_REF(reOle, 3);
172 
173  hres = IRichEditOle_QueryInterface(reOle, &IID_ITextDocument,
174  (void **) &txtDoc);
175  ok(hres == S_OK, "IRichEditOle_QueryInterface\n");
176  ok(txtDoc != NULL, "IRichEditOle_QueryInterface\n");
177 #if 0 /*avoid CORE-16799*/
178  CHECK_TYPEINFO(txtDoc, &IID_ITextDocument);
179 #endif
180 
181  hres = ITextDocument_GetSelection(txtDoc, NULL);
182  ok(hres == E_INVALIDARG, "ITextDocument_GetSelection: 0x%x\n", hres);
183 
184  EXPECT_REF(txtDoc, 4);
185 
186  hres = ITextDocument_GetSelection(txtDoc, &txtSel);
187  ok(hres == S_OK, "got 0x%08x\n", hres);
188 
189  EXPECT_REF(txtDoc, 4);
190  EXPECT_REF(txtSel, 2);
191 
192  hres = ITextDocument_GetSelection(txtDoc, &txtSel2);
193  ok(hres == S_OK, "got 0x%08x\n", hres);
194  ok(txtSel2 == txtSel, "got %p, %p\n", txtSel, txtSel2);
195 
196  EXPECT_REF(txtDoc, 4);
197  EXPECT_REF(txtSel, 3);
198 
199  ITextSelection_Release(txtSel2);
200 
201  punk = NULL;
202  hres = ITextSelection_QueryInterface(txtSel, &IID_ITextSelection, (void **) &punk);
203  ok(hres == S_OK, "ITextSelection_QueryInterface\n");
204  ok(punk != NULL, "ITextSelection_QueryInterface\n");
205  IUnknown_Release(punk);
206 
207  punk = NULL;
208  hres = ITextSelection_QueryInterface(txtSel, &IID_ITextRange, (void **) &punk);
209  ok(hres == S_OK, "ITextSelection_QueryInterface\n");
210  ok(punk != NULL, "ITextSelection_QueryInterface\n");
211  IUnknown_Release(punk);
212 
213  punk = NULL;
214  hres = ITextSelection_QueryInterface(txtSel, &IID_IDispatch, (void **) &punk);
215  ok(hres == S_OK, "ITextSelection_QueryInterface\n");
216  ok(punk != NULL, "ITextSelection_QueryInterface\n");
217  IUnknown_Release(punk);
218 
219  punk = NULL;
220  hres = IRichEditOle_QueryInterface(reOle, &IID_IOleClientSite, (void **) &punk);
221  ok(hres == E_NOINTERFACE, "IRichEditOle_QueryInterface\n");
222 
223  punk = NULL;
224  hres = IRichEditOle_QueryInterface(reOle, &IID_IOleWindow, (void **) &punk);
225  ok(hres == E_NOINTERFACE, "IRichEditOle_QueryInterface\n");
226 
227  punk = NULL;
228  hres = IRichEditOle_QueryInterface(reOle, &IID_IOleInPlaceSite, (void **) &punk);
229  ok(hres == E_NOINTERFACE, "IRichEditOle_QueryInterface\n");
230 
231 #if 0 /*avoid CORE-16799*/
232  hres = IRichEditOle_QueryInterface(reOle, &IID_ITextDocument2Old, (void **)&txtDoc2Old);
233  ok(hres == S_OK, "IRichEditOle_QueryInterface\n");
234  ok(txtDoc2Old != NULL, "IRichEditOle_QueryInterface\n");
235  ok((ITextDocument *)txtDoc2Old == txtDoc, "interface pointer isn't equal.\n");
236  EXPECT_REF(txtDoc2Old, 5);
237  EXPECT_REF(reOle, 5);
238  CHECK_TYPEINFO(txtDoc2Old, &IID_ITextDocument);
239 
240  ITextDocument2Old_Release(txtDoc2Old);
241 #endif
242 
243  ITextDocument_Release(txtDoc);
244  IRichEditOle_Release(reOle);
245  refcount = IRichEditOle_Release(reOle);
246  ok(refcount == 1, "got wrong ref count: %d\n", refcount);
247  DestroyWindow(w);
248 
249  /* Methods should return CO_E_RELEASED if the backing document has
250  been released. One test should suffice. */
251  hres = ITextSelection_CanEdit(txtSel, NULL);
252  ok(hres == CO_E_RELEASED, "ITextSelection after ITextDocument destroyed\n");
253 
254  ITextSelection_Release(txtSel);
255 
256 #if 0 /*avoid CORE-16799*/
257  w = new_richedit(NULL);
258  res = SendMessageA(w, EM_GETOLEINTERFACE, 0, (LPARAM)&reOle);
259  ok(res, "SendMessage\n");
260  ok(reOle != NULL, "EM_GETOLEINTERFACE\n");
261 
262  hres = IRichEditOle_QueryInterface(reOle, &IID_ITextDocument2Old, (void **)&txtDoc2Old);
263  ok(hres == S_OK, "IRichEditOle_QueryInterface failed: 0x%08x.\n", hres);
264  ok(txtDoc2Old != NULL, "IRichEditOle_QueryInterface\n");
265  CHECK_TYPEINFO(txtDoc2Old, &IID_ITextDocument);
266  ITextDocument2Old_Release(txtDoc2Old);
267  IRichEditOle_Release(reOle);
268  DestroyWindow(w);
269 #endif
270 }
#define E_NOINTERFACE
Definition: winerror.h:2364
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
const GUID IID_IOleInPlaceSite
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
const GUID IID_IOleClientSite
#define CO_E_RELEASED
Definition: winerror.h:2818
#define EM_GETOLEINTERFACE
Definition: richedit.h:93
BOOL WINAPI DestroyWindow(_In_ HWND)
static HWND new_richedit(HWND parent)
Definition: richole.c:60
#define E_INVALIDARG
Definition: ddrawi.h:101
LONG_PTR LPARAM
Definition: windef.h:208
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:79
const GUID IID_IDispatch
#define S_OK
Definition: intsafe.h:52
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define skip(...)
Definition: atltest.h:64
GLuint res
Definition: glext.h:9613
#define EXPECT_REF(obj, ref)
Definition: richole.c:42
const GUID IID_IOleWindow
unsigned int ULONG
Definition: retypes.h:1
LONG_PTR LRESULT
Definition: windef.h:209

Referenced by START_TEST().

◆ test_IOleInPlaceSite_GetWindow()

static void test_IOleInPlaceSite_GetWindow ( void  )
static

Definition at line 1703 of file richole.c.

1704 {
1705  HWND w;
1706  IRichEditOle *reOle = NULL;
1707  ITextDocument *txtDoc = NULL;
1708  IOleClientSite *clientSite = NULL;
1709  IOleInPlaceSite *olePlace = NULL;
1710  HRESULT hres;
1711  HWND hwnd;
1712 
1713  create_interfaces(&w, &reOle, &txtDoc, NULL);
1714  hres = IRichEditOle_GetClientSite(reOle, &clientSite);
1715  ok(hres == S_OK, "IRichEditOle_QueryInterface: 0x%08x\n", hres);
1716 
1717  hres = IOleClientSite_QueryInterface(clientSite, &IID_IOleInPlaceSite, (void **)&olePlace);
1718  ok(hres == S_OK, "IOleClientSite_QueryInterface: 0x%08x\n", hres);
1719  hres = IOleInPlaceSite_GetWindow(olePlace, &hwnd);
1720  ok(hres == S_OK, "IOleInPlaceSite_GetWindow: 0x%08x\n", hres);
1721  ok(w == hwnd, "got wrong pointer.\n");
1722 
1723  hres = IOleInPlaceSite_GetWindow(olePlace, NULL);
1724  ok(hres == E_INVALIDARG, "IOleInPlaceSite_GetWindow: 0x%08x\n", hres);
1725 
1726  IOleInPlaceSite_Release(olePlace);
1727  IOleClientSite_Release(clientSite);
1728  release_interfaces(&w, &reOle, &txtDoc, NULL);
1729 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
const GUID IID_IOleInPlaceSite
static void create_interfaces(HWND *w, IRichEditOle **reOle, ITextDocument **txtDoc, ITextSelection **txtSel)
Definition: richole.c:90
#define E_INVALIDARG
Definition: ddrawi.h:101
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:79
static void release_interfaces(HWND *w, IRichEditOle **reOle, ITextDocument **txtDoc, ITextSelection **txtSel)
Definition: richole.c:100
#define S_OK
Definition: intsafe.h:52
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112

Referenced by START_TEST().

◆ test_IOleWindow_GetWindow()

static void test_IOleWindow_GetWindow ( void  )
static

Definition at line 1675 of file richole.c.

1676 {
1677  HWND w;
1678  IRichEditOle *reOle = NULL;
1679  ITextDocument *txtDoc = NULL;
1680  IOleClientSite *clientSite = NULL;
1681  IOleWindow *oleWin = NULL;
1682  HRESULT hres;
1683  HWND hwnd;
1684 
1685  create_interfaces(&w, &reOle, &txtDoc, NULL);
1686  hres = IRichEditOle_GetClientSite(reOle, &clientSite);
1687  ok(hres == S_OK, "IRichEditOle_QueryInterface: 0x%08x\n", hres);
1688 
1689  hres = IOleClientSite_QueryInterface(clientSite, &IID_IOleWindow, (void **)&oleWin);
1690  ok(hres == S_OK, "IOleClientSite_QueryInterface: 0x%08x\n", hres);
1691  hres = IOleWindow_GetWindow(oleWin, &hwnd);
1692  ok(hres == S_OK, "IOleClientSite_GetWindow: 0x%08x\n", hres);
1693  ok(w == hwnd, "got wrong pointer\n");
1694 
1695  hres = IOleWindow_GetWindow(oleWin, NULL);
1696  ok(hres == E_INVALIDARG, "IOleClientSite_GetWindow: 0x%08x\n", hres);
1697 
1698  IOleWindow_Release(oleWin);
1699  IOleClientSite_Release(clientSite);
1700  release_interfaces(&w, &reOle, &txtDoc, NULL);
1701 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
static void create_interfaces(HWND *w, IRichEditOle **reOle, ITextDocument **txtDoc, ITextSelection **txtSel)
Definition: richole.c:90
#define E_INVALIDARG
Definition: ddrawi.h:101
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:79
static void release_interfaces(HWND *w, IRichEditOle **reOle, ITextDocument **txtDoc, ITextSelection **txtSel)
Definition: richole.c:100
#define S_OK
Definition: intsafe.h:52
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
const GUID IID_IOleWindow

Referenced by START_TEST().

◆ test_ITextDocument_Open()

static void test_ITextDocument_Open ( void  )
static

Definition at line 272 of file richole.c.

273 {
274  IRichEditOle *reOle = NULL;
275  ITextDocument *txtDoc = NULL;
276  ITextSelection *txtSel = NULL;
277  HRESULT hres;
278  HWND w;
279  HANDLE hFile;
280  VARIANT testfile;
281  WCHAR filename[] = {'t', 'e', 's', 't','.','t','x','t', 0};
282  int result;
283  DWORD dw;
284  static const CHAR chACP[] = "TestSomeText";
285  static const CHAR chUTF8[] = "\xef\xbb\xbfTextWithUTF8BOM";
286  static const WCHAR chUTF16[] = {0xfeff, 'T', 'e', 's', 't', 'S', 'o', 'm',
287  'e', 'T', 'e', 'x', 't', 0};
288 
289 #define MAX_BUF_LEN 1024
290  CHAR bufACP[MAX_BUF_LEN];
291  WCHAR bufUnicode[MAX_BUF_LEN];
292 
293  static const int tomConstantsSingle[] =
294  {
298  };
299 
300  static const int tomConstantsMulti[] =
301  {
308  };
309 
310  int tomNumSingle = ARRAY_SIZE(tomConstantsSingle);
311  int tomNumMulti = ARRAY_SIZE(tomConstantsMulti);
312  int i;
313 
314  V_VT(&testfile) = VT_BSTR;
315  V_BSTR(&testfile) = SysAllocString(filename);
316 
317  for(i=0; i < tomNumSingle; i++)
318  {
320  create_interfaces(&w, &reOle, &txtDoc, &txtSel);
321  hres = ITextDocument_Open(txtDoc, &testfile, tomConstantsSingle[i], CP_ACP);
322  todo_wine ok(hres == S_OK, "ITextDocument_Open: Filename:test.txt Flags:0x%x Codepage:CP_ACP hres:0x%x\n",
323  tomConstantsSingle[i], hres);
324  release_interfaces(&w, &reOle, &txtDoc, &txtSel);
326 
328  create_interfaces(&w, &reOle, &txtDoc, &txtSel);
329  hres = ITextDocument_Open(txtDoc, &testfile, tomConstantsSingle[i], CP_UTF8);
330  todo_wine ok(hres == S_OK, "ITextDocument_Open: Filename:test.txt Flags:0x%x Codepage:CP_UTF8 hres:0x%x\n",
331  tomConstantsSingle[i], hres);
332  release_interfaces(&w, &reOle, &txtDoc, &txtSel);
334  }
335 
336  for(i=0; i < tomNumMulti; i++)
337  {
339  create_interfaces(&w, &reOle, &txtDoc, &txtSel);
340  hres = ITextDocument_Open(txtDoc, &testfile, tomConstantsMulti[i], CP_ACP);
341  todo_wine ok(hres == S_OK, "ITextDocument_Open: Filename:test.txt Flags:0x%x Codepage:CP_ACP hres:0x%x\n",
342  tomConstantsMulti[i], hres);
343  release_interfaces(&w, &reOle, &txtDoc, &txtSel);
345 
347  create_interfaces(&w, &reOle, &txtDoc, &txtSel);
348  hres = ITextDocument_Open(txtDoc, &testfile, tomConstantsMulti[i], CP_UTF8);
349  todo_wine ok(hres == S_OK, "ITextDocument_Open: Filename:test.txt Flags:0x%x Codepage:CP_UTF8 hres:0x%x\n",
350  tomConstantsMulti[i], hres);
351  release_interfaces(&w, &reOle, &txtDoc, &txtSel);
353  }
354 
355  create_interfaces(&w, &reOle, &txtDoc, &txtSel);
356  hres = ITextDocument_Open(txtDoc, &testfile, tomCreateAlways, CP_ACP);
357  todo_wine ok(hres == S_OK, "ITextDocument_Open should success Codepage:CP_ACP\n");
358  todo_wine ok(is_existing_file(filename), "ITextDocument_Open should create a file\n");
359  release_interfaces(&w, &reOle, &txtDoc, &txtSel);
361 
362  create_interfaces(&w, &reOle, &txtDoc, &txtSel);
363  hres = ITextDocument_Open(txtDoc, &testfile, tomCreateAlways, CP_UTF8);
364  todo_wine ok(hres == S_OK, "ITextDocument_Open should success Codepage:CP_UTF8\n");
365  todo_wine ok(is_existing_file(filename), "ITextDocument_Open should create a file\n");
366  release_interfaces(&w, &reOle, &txtDoc, &txtSel);
368 
369  create_interfaces(&w, &reOle, &txtDoc, &txtSel);
370  hres = ITextDocument_Open(txtDoc, &testfile, tomOpenAlways, CP_ACP);
371  todo_wine ok(hres == S_OK, "ITextDocument_Open should success Codepage:CP_ACP\n");
372  todo_wine ok(is_existing_file(filename), "ITextDocument_Open should create a file\n");
373  release_interfaces(&w, &reOle, &txtDoc, &txtSel);
375 
376  create_interfaces(&w, &reOle, &txtDoc, &txtSel);
377  hres = ITextDocument_Open(txtDoc, &testfile, tomOpenAlways, CP_UTF8);
378  todo_wine ok(hres == S_OK, "ITextDocument_Open should success Codepage:CP_UTF8\n");
379  todo_wine ok(is_existing_file(filename), "ITextDocument_Open should create a file\n");
380  release_interfaces(&w, &reOle, &txtDoc, &txtSel);
382 
383  create_interfaces(&w, &reOle, &txtDoc, &txtSel);
384  hres = ITextDocument_Open(txtDoc, &testfile, tomCreateNew, CP_ACP);
385  todo_wine ok(hres == S_OK, "ITextDocument_Open should success Codepage:CP_ACP\n");
386  todo_wine ok(is_existing_file(filename), "ITextDocument_Open should create a file\n");
387  release_interfaces(&w, &reOle, &txtDoc, &txtSel);
389 
390  create_interfaces(&w, &reOle, &txtDoc, &txtSel);
391  hres = ITextDocument_Open(txtDoc, &testfile, tomCreateNew, CP_UTF8);
392  todo_wine ok(hres == S_OK, "ITextDocument_Open should success Codepage:CP_UTF8\n");
393  todo_wine ok(is_existing_file(filename), "ITextDocument_Open should create a file\n");
394  release_interfaces(&w, &reOle, &txtDoc, &txtSel);
396 
397  create_interfaces(&w, &reOle, &txtDoc, &txtSel);
399  hres = ITextDocument_Open(txtDoc, &testfile, tomCreateNew, CP_ACP);
400  todo_wine ok(hres == HRESULT_FROM_WIN32(ERROR_FILE_EXISTS), "ITextDocument_Open should fail Codepage:CP_ACP\n");
401  release_interfaces(&w, &reOle, &txtDoc, &txtSel);
403 
404  create_interfaces(&w, &reOle, &txtDoc, &txtSel);
406  hres = ITextDocument_Open(txtDoc, &testfile, tomCreateNew, CP_UTF8);
407  todo_wine ok(hres == HRESULT_FROM_WIN32(ERROR_FILE_EXISTS), "ITextDocument_Open should fail Codepage:CP_UTF8\n");
408  release_interfaces(&w, &reOle, &txtDoc, &txtSel);
410 
411  create_interfaces(&w, &reOle, &txtDoc, &txtSel);
412  hres = ITextDocument_Open(txtDoc, &testfile, tomOpenExisting, CP_ACP);
413  todo_wine ok(hres == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "ITextDocument_Open should fail Codepage:CP_ACP\n");
414  release_interfaces(&w, &reOle, &txtDoc, &txtSel);
415 
416  create_interfaces(&w, &reOle, &txtDoc, &txtSel);
417  hres = ITextDocument_Open(txtDoc, &testfile, tomOpenExisting, CP_UTF8);
418  todo_wine ok(hres == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "ITextDocument_Open should fail Codepage:CP_UTF8\n");
419  release_interfaces(&w, &reOle, &txtDoc, &txtSel);
420 
421  create_interfaces(&w, &reOle, &txtDoc, &txtSel);
423  hres = ITextDocument_Open(txtDoc, &testfile, tomText, CP_ACP);
424 todo_wine {
425  ok(hres == S_OK, "got 0x%08x\n", hres);
426  ok(is_existing_file(filename) == TRUE, "a file should be created default\n");
427 }
428  release_interfaces(&w, &reOle, &txtDoc, &txtSel);
430 
431  /* test of share mode */
433  create_interfaces(&w, &reOle, &txtDoc, &txtSel);
434  hres = ITextDocument_Open(txtDoc, &testfile, tomShareDenyRead, CP_ACP);
435 todo_wine
436  ok(hres == S_OK, "got 0x%08x\n", hres);
437  SetLastError(0xdeadbeef);
440  todo_wine ok(GetLastError() == ERROR_SHARING_VIOLATION, "ITextDocument_Open should fail\n");
442  release_interfaces(&w, &reOle, &txtDoc, &txtSel);
444 
446  create_interfaces(&w, &reOle, &txtDoc, &txtSel);
447  hres = ITextDocument_Open(txtDoc, &testfile, tomShareDenyWrite, CP_ACP);
448 todo_wine
449  ok(hres == S_OK, "got 0x%08x\n", hres);
450  SetLastError(0xdeadbeef);
453  todo_wine ok(GetLastError() == ERROR_SHARING_VIOLATION, "ITextDocument_Open should fail\n");
455  release_interfaces(&w, &reOle, &txtDoc, &txtSel);
457 
459  create_interfaces(&w, &reOle, &txtDoc, &txtSel);
460  SetLastError(0xdeadbeef);
461  hres = ITextDocument_Open(txtDoc, &testfile, tomShareDenyWrite|tomShareDenyRead, CP_ACP);
462 todo_wine
463  ok(hres == S_OK, "got 0x%08x\n", hres);
466  todo_wine ok(GetLastError() == ERROR_SHARING_VIOLATION, "ITextDocument_Open should fail\n");
468  release_interfaces(&w, &reOle, &txtDoc, &txtSel);
470 
471  /* tests to check the content */
474  WriteFile(hFile, chACP, sizeof(chACP)-sizeof(CHAR), &dw, NULL);
476  create_interfaces(&w, &reOle, &txtDoc, &txtSel);
477  hres = ITextDocument_Open(txtDoc, &testfile, tomReadOnly, CP_ACP);
478 todo_wine
479  ok(hres == S_OK, "got 0x%08x\n", hres);
480  result = SendMessageA(w, WM_GETTEXT, 1024, (LPARAM)bufACP);
481  todo_wine ok(result == 12, "ITextDocument_Open: Test ASCII returned %d, expected 12\n", result);
482  result = strcmp(bufACP, chACP);
483  todo_wine ok(result == 0, "ITextDocument_Open: Test ASCII set wrong text: Result: %s\n", bufACP);
484  release_interfaces(&w, &reOle, &txtDoc, &txtSel);
486 
489  WriteFile(hFile, chUTF8, sizeof(chUTF8)-sizeof(CHAR), &dw, NULL);
491  create_interfaces(&w, &reOle, &txtDoc, &txtSel);
492  hres = ITextDocument_Open(txtDoc, &testfile, tomReadOnly, CP_UTF8);
493 todo_wine
494  ok(hres == S_OK, "got 0x%08x\n", hres);
495  result = SendMessageA(w, WM_GETTEXT, 1024, (LPARAM)bufACP);
496  todo_wine ok(result == 15, "ITextDocument_Open: Test UTF-8 returned %d, expected 15\n", result);
497  result = strcmp(bufACP, &chUTF8[3]);
498  todo_wine ok(result == 0, "ITextDocument_Open: Test UTF-8 set wrong text: Result: %s\n", bufACP);
499  release_interfaces(&w, &reOle, &txtDoc, &txtSel);
501 
504  WriteFile(hFile, chUTF16, sizeof(chUTF16)-sizeof(WCHAR), &dw, NULL);
506  create_interfaces(&w, &reOle, &txtDoc, &txtSel);
507  hres = ITextDocument_Open(txtDoc, &testfile, tomReadOnly, 1200);
508 todo_wine
509  ok(hres == S_OK, "got 0x%08x\n", hres);
510  result = SendMessageW(w, WM_GETTEXT, 1024, (LPARAM)bufUnicode);
511  todo_wine ok(result == 12, "ITextDocument_Open: Test UTF-16 returned %d, expected 12\n", result);
512  result = lstrcmpW(bufUnicode, &chUTF16[1]);
513  todo_wine ok(result == 0, "ITextDocument_Open: Test UTF-16 set wrong text: Result: %s\n", wine_dbgstr_w(bufUnicode));
514  release_interfaces(&w, &reOle, &txtDoc, &txtSel);
516 
517  VariantClear(&testfile);
518 }
#define MAX_BUF_LEN
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define ERROR_FILE_EXISTS
Definition: winerror.h:165
#define CloseHandle
Definition: compat.h:598
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
GLuint64EXT * result
Definition: glext.h:11304
#define TRUE
Definition: types.h:120
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: atltest.h:87
#define CP_ACP
Definition: compat.h:109
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
char CHAR
Definition: xmlstorage.h:175
#define WM_GETTEXT
Definition: winuser.h:1600
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
Definition: tom.idl:178
static void create_interfaces(HWND *w, IRichEditOle **reOle, ITextDocument **txtDoc, ITextSelection **txtSel)
Definition: richole.c:90
Definition: tom.idl:179
const char * filename
Definition: ioapi.h:135
#define FILE_SHARE_READ
Definition: compat.h:136
#define CP_UTF8
Definition: nls.h:20
#define GENERIC_WRITE
Definition: nt_native.h:90
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
REFIID LPVOID DWORD_PTR dw
Definition: atlbase.h:40
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:238
LONG_PTR LPARAM
Definition: windef.h:208
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define OPEN_EXISTING
Definition: compat.h:634
HRESULT hres
Definition: protocol.c:465
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG *pVarg)
Definition: variant.c:648
#define todo_wine
Definition: test.h:164
#define V_VT(A)
Definition: oleauto.h:211
#define GENERIC_READ
Definition: compat.h:135
#define ERROR_SHARING_VIOLATION
Definition: winerror.h:135
_In_ HANDLE hFile
Definition: mswsock.h:90
#define V_BSTR(A)
Definition: oleauto.h:226
static void release_interfaces(HWND *w, IRichEditOle **reOle, ITextDocument **txtDoc, ITextSelection **txtSel)
Definition: richole.c:100
#define S_OK
Definition: intsafe.h:52
#define CREATE_ALWAYS
Definition: disk.h:72
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define ARRAY_SIZE(a)
Definition: main.h:24
static BOOL is_existing_file(LPCWSTR filename)
Definition: richole.c:78
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define CreateFileW
Definition: compat.h:600
static BOOL touch_file(LPCWSTR filename)
Definition: richole.c:65
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469

Referenced by START_TEST().

◆ test_ITextDocument_Range()

static void test_ITextDocument_Range ( void  )
static

Definition at line 705 of file richole.c.

706 {
707  static const CHAR test_text1[] = "TestSomeText";
708  HWND w;
709  IRichEditOle *reOle = NULL;
710  ITextDocument *txtDoc = NULL;
711  ITextRange *txtRge, *range2;
712  HRESULT hres;
713  LONG value;
714 
715  create_interfaces(&w, &reOle, &txtDoc, NULL);
716  hres = ITextDocument_Range(txtDoc, 0, 0, &txtRge);
717  ok(hres == S_OK, "ITextDocument_Range fails 0x%x.\n", hres);
718  EXPECT_REF(txtRge, 1);
719 
720  hres = ITextDocument_Range(txtDoc, 0, 0, &range2);
721  ok(hres == S_OK, "ITextDocument_Range fails 0x%x.\n", hres);
722  ok(range2 != txtRge, "A new pointer should be returned\n");
723  ITextRange_Release(range2);
724 
725  hres = ITextDocument_Range(txtDoc, 0, 0, NULL);
726  ok(hres == E_INVALIDARG, "ITextDocument_Range should fail 0x%x.\n", hres);
727 
728  SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
729 
730  hres = ITextDocument_Range(txtDoc, 8, 30, &range2);
731  ok(hres == S_OK, "ITextDocument_Range fails 0x%x.\n", hres);
732  hres = ITextRange_GetStart(range2, &value);
733  ok(hres == S_OK, "got 0x%08x\n", hres);
734  ok(value == 8, "got %d\n", value);
735 
736  hres = ITextRange_GetEnd(range2, &value);
737  ok(hres == S_OK, "got 0x%08x\n", hres);
738  ok(value == 13, "got %d\n", value);
739  ITextRange_Release(range2);
740 
741  release_interfaces(&w, &reOle, &txtDoc, NULL);
742  hres = ITextRange_CanEdit(txtRge, NULL);
743  ok(hres == CO_E_RELEASED, "ITextRange after ITextDocument destroyed\n");
744  ITextRange_Release(txtRge);
745 }
Definition: pdh_main.c:93
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define CO_E_RELEASED
Definition: winerror.h:2818
char CHAR
Definition: xmlstorage.h:175
static void create_interfaces(HWND *w, IRichEditOle **reOle, ITextDocument **txtDoc, ITextSelection **txtSel)
Definition: richole.c:90
long LONG
Definition: pedump.c:60
#define E_INVALIDARG
Definition: ddrawi.h:101
LONG_PTR LPARAM
Definition: windef.h:208
#define WM_SETTEXT
Definition: winuser.h:1599
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:79
GLsizei const GLfloat * value
Definition: glext.h:6069
static void release_interfaces(HWND *w, IRichEditOle **reOle, ITextDocument **txtDoc, ITextSelection **txtSel)
Definition: richole.c:100
#define S_OK
Definition: intsafe.h:52
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define EXPECT_REF(obj, ref)
Definition: richole.c:42

Referenced by START_TEST().

◆ test_ITextFont()

static void test_ITextFont ( void  )
static

Definition at line 2304 of file richole.c.

2305 {
2306  static const WCHAR arialW[] = {'A','r','i','a','l',0};
2307  static const CHAR test_text1[] = "TestSomeText";
2308  ITextFont *font, *font2, *font3;
2309  FLOAT size, position, kerning;
2310  IRichEditOle *reOle = NULL;
2311  ITextDocument *doc = NULL;
2312  ITextRange *range = NULL;
2313  CHARFORMAT2A cf;
2314  LONG value;
2315  HRESULT hr;
2316  HWND hwnd;
2317  BOOL ret;
2318  BSTR str;
2319 
2320  create_interfaces(&hwnd, &reOle, &doc, NULL);
2321  SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1);
2322 
2323  hr = ITextDocument_Range(doc, 0, 10, &range);
2324  ok(hr == S_OK, "got 0x%08x\n", hr);
2325 
2326  hr = ITextRange_GetFont(range, &font);
2327  ok(hr == S_OK, "got 0x%08x\n", hr);
2328 
2329  hr = ITextFont_Reset(font, tomUseTwips);
2330  ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2331 
2332  hr = ITextFont_Reset(font, tomUsePoints);
2333  ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2334 
2335  hr = ITextFont_GetName(font, NULL);
2336  ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2337 
2338  /* default font size unit is point */
2339  size = 0.0;
2340  hr = ITextFont_GetSize(font, &size);
2341  ok(hr == S_OK, "got 0x%08x\n", hr);
2342 
2343  /* set to some non-zero values */
2344  hr = ITextFont_SetPosition(font, 20.0);
2345  ok(hr == S_OK, "got 0x%08x\n", hr);
2346 
2347  hr = ITextFont_SetKerning(font, 10.0);
2348  ok(hr == S_OK, "got 0x%08x\n", hr);
2349 
2350  position = 0.0;
2351  hr = ITextFont_GetPosition(font, &position);
2352  ok(hr == S_OK, "got 0x%08x\n", hr);
2353 
2354  kerning = 0.0;
2355  hr = ITextFont_GetKerning(font, &kerning);
2356  ok(hr == S_OK, "got 0x%08x\n", hr);
2357 
2358  memset(&cf, 0, sizeof(cf));
2359  cf.cbSize = sizeof(cf);
2360  cf.dwMask = CFM_SIZE|CFM_OFFSET|CFM_KERNING;
2361 
2362  /* CHARFORMAT members are in twips */
2363  SendMessageA(hwnd, EM_SETSEL, 0, 10);
2365  ok(ret, "got %d\n", ret);
2366  ok(size == twips_to_points(cf.yHeight), "got yHeight %d, size %.2f\n", cf.yHeight, size);
2367  ok(position == twips_to_points(cf.yOffset), "got yOffset %d, position %.2f\n", cf.yOffset, position);
2368  ok(kerning == twips_to_points(cf.wKerning), "got wKerning %d, kerning %.2f\n", cf.wKerning, kerning);
2369 
2370  hr = ITextFont_Reset(font, tomUseTwips);
2371  ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2372 
2373  hr = ITextFont_Reset(font, tomUsePoints);
2374  ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2375 
2376  hr = ITextFont_GetDuplicate(font, &font2);
2377  ok(hr == S_OK, "got 0x%08x\n", hr);
2378 
2379  hr = ITextFont_Reset(font2, tomUseTwips);
2380  ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2381 
2382  hr = ITextFont_Reset(font2, tomUsePoints);
2383  ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2384 
2385  ITextFont_Release(font2);
2386 
2387  /* default font name */
2388  str = NULL;
2389  hr = ITextFont_GetName(font, &str);
2390  ok(hr == S_OK, "got 0x%08x\n", hr);
2391  ok(!lstrcmpW(str, sysW), "got %s\n", wine_dbgstr_w(str));
2392  SysFreeString(str);
2393 
2394  /* change font name for an inner subrange */
2395  memset(&cf, 0, sizeof(cf));
2396  cf.cbSize = sizeof(cf);
2397  cf.dwMask = CFM_FACE;
2398  strcpy(cf.szFaceName, "Arial");
2399 
2400  SendMessageA(hwnd, EM_SETSEL, 3, 4);
2402  ok(ret, "got %d\n", ret);
2403 
2404  /* still original name */
2405  str = NULL;
2406  hr = ITextFont_GetName(font, &str);
2407  ok(hr == S_OK, "got 0x%08x\n", hr);
2408  ok(!lstrcmpW(str, sysW), "got %s\n", wine_dbgstr_w(str));
2409  SysFreeString(str);
2410 
2411  SendMessageA(hwnd, EM_SETSEL, 1, 2);
2413  ok(ret, "got %d\n", ret);
2414 
2415  str = NULL;
2416  hr = ITextFont_GetName(font, &str);
2417  ok(hr == S_OK, "got 0x%08x\n", hr);
2418  ok(!lstrcmpW(str, sysW), "got %s\n", wine_dbgstr_w(str));
2419  SysFreeString(str);
2420 
2421  /* name is returned for first position within a range */
2422  SendMessageA(hwnd, EM_SETSEL, 0, 1);
2424  ok(ret, "got %d\n", ret);
2425 
2426  str = NULL;
2427  hr = ITextFont_GetName(font, &str);
2428  ok(hr == S_OK, "got 0x%08x\n", hr);
2429  ok(!lstrcmpW(str, arialW), "got %s\n", wine_dbgstr_w(str));
2430  SysFreeString(str);
2431 
2432  /* GetDuplicate() */
2433  hr = ITextFont_GetDuplicate(font, NULL);
2434  ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2435 
2436  EXPECT_REF(range, 2);
2437  font2 = NULL;
2438  hr = ITextFont_GetDuplicate(font, &font2);
2439  ok(hr == S_OK, "got 0x%08x\n", hr);
2440  EXPECT_REF(range, 2);
2441 
2442  /* set whole range to italic */
2443  cf.cbSize = sizeof(CHARFORMAT2A);
2444  cf.dwMask = CFM_ITALIC;
2445  cf.dwEffects = CFE_ITALIC;
2446 
2447  SendMessageA(hwnd, EM_SETSEL, 0, 10);
2449  ok(ret, "got %d\n", ret);
2450 
2451  value = tomFalse;
2452  hr = ITextFont_GetItalic(font, &value);
2453  ok(hr == S_OK, "got 0x%08x\n", hr);
2454  ok(value == tomTrue, "got %d\n", value);
2455 
2456  /* duplicate retains original value */
2457  value = tomTrue;
2458  hr = ITextFont_GetItalic(font2, &value);
2459  ok(hr == S_OK, "got 0x%08x\n", hr);
2460  ok(value == tomFalse, "got %d\n", value);
2461 
2462  /* get a duplicate from a cloned font */
2463  hr = ITextFont_GetDuplicate(font2, &font3);
2464  ok(hr == S_OK, "got 0x%08x\n", hr);
2465  ITextFont_Release(font3);
2466 
2467  ITextRange_Release(range);
2468  release_interfaces(&hwnd, &reOle, &doc, NULL);
2469 
2470  hr = ITextFont_GetDuplicate(font, NULL);
2471  ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2472 
2475 
2476  /* get a duplicate of detached font */
2477  hr = ITextFont_GetDuplicate(font2, &font3);
2478  ok(hr == S_OK, "got 0x%08x\n", hr);
2479  ITextFont_Release(font3);
2480 
2481  /* reset detached font to undefined */
2482  value = tomUndefined;
2483  hr = ITextFont_GetBold(font2, &value);
2484  ok(hr == S_OK, "got 0x%08x\n", hr);
2485  ok(value != tomUndefined, "got %d\n", value);
2486 
2487  /* reset to undefined for detached font */
2488  hr = ITextFont_Reset(font2, tomUndefined);
2489  ok(hr == S_OK, "got 0x%08x\n", hr);
2490  test_textfont_undefined(font2);
2491 
2492  /* font is detached, default means global TOM defaults */
2493  hr = ITextFont_Reset(font2, tomDefault);
2494  ok(hr == S_OK, "got 0x%08x\n", hr);
2496 
2497  hr = ITextFont_GetDuplicate(font2, &font3);
2498  ok(hr == S_OK, "got 0x%08x\n", hr);
2500 
2501  hr = ITextFont_Reset(font2, tomApplyNow);
2502  ok(hr == S_OK, "got 0x%08x\n", hr);
2504 
2505  hr = ITextFont_Reset(font2, tomApplyLater);
2506  ok(hr == S_OK, "got 0x%08x\n", hr);
2508 
2509  hr = ITextFont_Reset(font2, tomTrackParms);
2510  ok(hr == S_OK, "got 0x%08x\n", hr);
2512 
2513  hr = ITextFont_SetItalic(font2, tomUndefined);
2514  ok(hr == S_OK, "got 0x%08x\n", hr);
2515 
2516  hr = ITextFont_GetItalic(font2, &value);
2517  ok(hr == S_OK, "got 0x%08x\n", hr);
2518  ok(value == tomFalse, "got %d\n", value);
2519 
2520  hr = ITextFont_Reset(font2, tomCacheParms);
2521  ok(hr == S_OK, "got 0x%08x\n", hr);
2523 
2524  ITextFont_Release(font3);
2525  ITextFont_Release(font2);
2526 
2527  font2 = (void*)0xdeadbeef;
2528  hr = ITextFont_GetDuplicate(font, &font2);
2529  ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
2530  ok(font2 == NULL, "got %p\n", font2);
2531 
2532  hr = ITextFont_Reset(font, tomDefault);
2533  ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
2534 
2535  ITextFont_Release(font);
2536 
2537  /* Reset() */
2538  create_interfaces(&hwnd, &reOle, &doc, NULL);
2539  SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1);
2540 
2541  hr = ITextDocument_Range(doc, 0, 10, &range);
2542  ok(hr == S_OK, "got 0x%08x\n", hr);
2543 
2544  hr = ITextRange_GetFont(range, &font);
2545  ok(hr == S_OK, "got 0x%08x\n", hr);
2546 
2547  value = tomUndefined;
2548  hr = ITextFont_GetBold(font, &value);
2549  ok(hr == S_OK, "got 0x%08x\n", hr);
2550  ok(value != tomUndefined, "got %d\n", value);
2551 
2552  /* reset to undefined for attached font */
2553  hr = ITextFont_Reset(font, tomUndefined);
2554  ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2555 
2556  value = tomUndefined;
2557  hr = ITextFont_GetBold(font, &value);
2558  ok(hr == S_OK, "got 0x%08x\n", hr);
2559  ok(value != tomUndefined, "got %d\n", value);
2560 
2561  /* tomCacheParms/tomTrackParms */
2562  hr = ITextFont_Reset(font, tomCacheParms);
2563  ok(hr == S_OK, "got 0x%08x\n", hr);
2564 
2565  hr = ITextFont_GetItalic(font, &value);
2566  ok(hr == S_OK, "got 0x%08x\n", hr);
2567  ok(value == tomFalse, "got %d\n", value);
2568 
2569  memset(&cf, 0, sizeof(cf));
2570  cf.cbSize = sizeof(CHARFORMAT2A);
2571  cf.dwMask = CFM_ITALIC;
2572 
2573  cf.dwEffects = CFE_ITALIC;
2574  SendMessageA(hwnd, EM_SETSEL, 0, 10);
2576  ok(ret, "got %d\n", ret);
2577 
2578  /* still cached value */
2579  hr = ITextFont_GetItalic(font, &value);
2580  ok(hr == S_OK, "got 0x%08x\n", hr);
2581  ok(value == tomFalse, "got %d\n", value);
2582 
2583  hr = ITextFont_Reset(font, tomTrackParms);
2584  ok(hr == S_OK, "got 0x%08x\n", hr);
2585 
2586  hr = ITextFont_GetItalic(font, &value);
2587  ok(hr == S_OK, "got 0x%08x\n", hr);
2588  ok(value == tomTrue, "got %d\n", value);
2589 
2590  /* switch back to cache - value retained */
2591  hr = ITextFont_Reset(font, tomCacheParms);
2592  ok(hr == S_OK, "got 0x%08x\n", hr);
2593 
2594  hr = ITextFont_GetItalic(font, &value);
2595  ok(hr == S_OK, "got 0x%08x\n", hr);
2596  ok(value == tomTrue, "got %d\n", value);
2597 
2598  /* tomApplyLater */
2599  hr = ITextFont_Reset(font, tomApplyLater);
2600  ok(hr == S_OK, "got 0x%08x\n", hr);
2601 
2602  hr = ITextFont_SetItalic(font, tomFalse);
2603  ok(hr == S_OK, "got 0x%08x\n", hr);
2604 
2605  hr = ITextFont_GetItalic(font, &value);
2606  ok(hr == S_OK, "got 0x%08x\n", hr);
2607  ok(value == tomFalse, "got %d\n", value);
2608 
2609  cf.dwEffects = 0;
2610  SendMessageA(hwnd, EM_SETSEL, 0, 10);
2612  ok(ret, "got %d\n", ret);
2613  ok((cf.dwEffects & CFE_ITALIC) == CFE_ITALIC, "got 0x%08x\n", cf.dwEffects);
2614 
2615  hr = ITextFont_Reset(font, tomApplyNow);
2616  ok(hr == S_OK, "got 0x%08x\n", hr);
2617 
2618  cf.dwEffects = 0;
2619  SendMessageA(hwnd, EM_SETSEL, 0, 10);
2621  ok(ret, "got %d\n", ret);
2622  ok((cf.dwEffects & CFE_ITALIC) == 0, "got 0x%08x\n", cf.dwEffects);
2623 
2624  hr = ITextFont_SetItalic(font, tomUndefined);
2625  ok(hr == S_OK, "got 0x%08x\n", hr);
2626 
2627  hr = ITextFont_GetItalic(font, &value);
2628  ok(hr == S_OK, "got 0x%08x\n", hr);
2629  ok(value == tomFalse, "got %d\n", value);
2630 
2631  hr = ITextFont_SetItalic(font, tomAutoColor);
2632  ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2633 
2634  cf.dwEffects = 0;
2635  SendMessageA(hwnd, EM_SETSEL, 0, 10);
2637  ok(ret, "got %d\n", ret);
2638  ok((cf.dwEffects & CFE_ITALIC) == 0, "got 0x%08x\n", cf.dwEffects);
2639 
2640  ITextRange_Release(range);
2641  ITextFont_Release(font);
2642  release_interfaces(&hwnd, &reOle, &doc, NULL);
2643 }
Definition: tom.idl:28
static IClassFactory * cf
#define CFM_KERNING
Definition: richedit.h:352
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
static void test_textfont_global_defaults(ITextFont *font)
Definition: richole.c:2048
Definition: pdh_main.c:93
HRESULT hr
Definition: shlfolder.c:183
Definition: mk_font.cpp:20
#define TRUE
Definition: types.h:120
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: atltest.h:87
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
#define CO_E_RELEASED
Definition: winerror.h:2818
char CHAR
Definition: xmlstorage.h:175
static FLOAT twips_to_points(LONG value)
Definition: richole.c:2299
#define CFM_FACE
Definition: richedit.h:360
static void test_detached_font_getters(ITextFont *font, BOOL duplicate)
Definition: richole.c:1980
#define CFM_ITALIC
Definition: richedit.h:333
OLECHAR * BSTR
Definition: compat.h:2152
static void create_interfaces(HWND *w, IRichEditOle **reOle, ITextDocument **txtDoc, ITextSelection **txtSel)
Definition: richole.c:90
struct _charformat2a CHARFORMAT2A
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
#define EM_SETCHARFORMAT
Definition: richedit.h:101
#define E_INVALIDARG
Definition: ddrawi.h:101
const WCHAR * str
LONG_PTR LPARAM
Definition: windef.h:208
#define WM_SETTEXT
Definition: winuser.h:1599
static const WCHAR sysW[]
Definition: richole.c:40
static void test_textfont_undefined(ITextFont *font)
Definition: richole.c:2177
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
#define EM_SETSEL
Definition: winuser.h:2000
#define CFM_SIZE
Definition: richedit.h:362
#define CFM_OFFSET
Definition: richedit.h:359
int ret
#define CFE_ITALIC
Definition: richedit.h:407
GLsizei const GLfloat * value
Definition: glext.h:6069
static void release_interfaces(HWND *w, IRichEditOle **reOle, ITextDocument **txtDoc, ITextSelection **txtSel)
Definition: richole.c:100
GLenum GLint * range
Definition: glext.h:7539
#define S_OK
Definition: intsafe.h:52
#define EM_GETCHARFORMAT
Definition: richedit.h:91
#define ok(value,...)
Definition: atltest.h:57
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:271
#define NULL
Definition: types.h:112
#define EXPECT_REF(obj, ref)
Definition: richole.c:42
float FLOAT
Definition: typedefs.h:69
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define SCF_SELECTION
Definition: richedit.h:235
Definition: tom.idl:29
#define memset(x, y, z)
Definition: