2 * Tests for IRichEditOle and friends.
4 * Copyright 2008 Google (Dan Hipschman)
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
33 #include <wine/test.h>
36 DEFINE_GUID(IID_ITextDocument
, 0x8cc497c0, 0xa1df, 0x11ce, 0x80, 0x98, 0x00, 0xaa, 0x00, 0x47, 0xbe, 0x5d);
37 DEFINE_GUID(IID_ITextRange
, 0x8cc497c2, 0xa1df, 0x11ce, 0x80, 0x98, 0x00, 0xaa, 0x00, 0x47, 0xbe, 0x5d);
38 DEFINE_GUID(IID_ITextSelection
, 0x8cc497c1, 0xa1df, 0x11ce, 0x80, 0x98, 0x00, 0xaa, 0x00, 0x47, 0xbe, 0x5d);
40 static HMODULE hmoduleRichEdit
;
42 static HWND
new_window(LPCTSTR lpClassName
, DWORD dwStyle
, HWND parent
)
45 = CreateWindow(lpClassName
, NULL
,
46 dwStyle
| WS_POPUP
| WS_HSCROLL
| WS_VSCROLL
| WS_VISIBLE
,
47 0, 0, 200, 60, parent
, NULL
, hmoduleRichEdit
, NULL
);
48 ok(hwnd
!= NULL
, "class: %s, error: %d\n", lpClassName
, (int) GetLastError());
52 static HWND
new_richedit(HWND parent
)
54 return new_window(RICHEDIT_CLASS
, ES_MULTILINE
, parent
);
60 IRichEditOle
*reOle
= NULL
;
61 ITextDocument
*txtDoc
= NULL
;
62 ITextSelection
*txtSel
= NULL
;
68 /* Must explicitly LoadLibrary(). The test has no references to functions in
69 * RICHED20.DLL, so the linker doesn't actually link to it. */
70 hmoduleRichEdit
= LoadLibrary("RICHED20.DLL");
71 ok(hmoduleRichEdit
!= NULL
, "error: %d\n", (int) GetLastError());
73 w
= new_richedit(NULL
);
75 skip("Couldn't create window\n");
79 res
= SendMessage(w
, EM_GETOLEINTERFACE
, 0, (LPARAM
) &reOle
);
80 ok(res
, "SendMessage\n");
81 ok(reOle
!= NULL
, "EM_GETOLEINTERFACE\n");
83 hres
= IUnknown_QueryInterface(reOle
, &IID_ITextDocument
,
85 ok(hres
== S_OK
, "IRichEditOle_QueryInterface\n");
86 ok(txtDoc
!= NULL
, "IRichEditOle_QueryInterface\n");
88 hres
= ITextDocument_GetSelection(txtDoc
, &txtSel
);
89 ok(hres
== S_OK
, "ITextDocument_GetSelection\n");
90 ok(txtSel
!= NULL
, "ITextDocument_GetSelection\n");
93 hres
= ITextSelection_QueryInterface(txtSel
, &IID_ITextSelection
, (void **) &punk
);
94 ok(hres
== S_OK
, "ITextSelection_QueryInterface\n");
95 ok(punk
!= NULL
, "ITextSelection_QueryInterface\n");
96 IUnknown_Release(punk
);
99 hres
= ITextSelection_QueryInterface(txtSel
, &IID_ITextRange
, (void **) &punk
);
100 ok(hres
== S_OK
, "ITextSelection_QueryInterface\n");
101 ok(punk
!= NULL
, "ITextSelection_QueryInterface\n");
102 IUnknown_Release(punk
);
105 hres
= ITextSelection_QueryInterface(txtSel
, &IID_IDispatch
, (void **) &punk
);
106 ok(hres
== S_OK
, "ITextSelection_QueryInterface\n");
107 ok(punk
!= NULL
, "ITextSelection_QueryInterface\n");
108 IUnknown_Release(punk
);
110 ITextDocument_Release(txtDoc
);
111 IUnknown_Release(reOle
);
114 /* Methods should return CO_E_RELEASED if the backing document has
115 been released. One test should suffice. */
116 hres
= ITextSelection_CanEdit(txtSel
, NULL
);
117 ok(hres
== CO_E_RELEASED
, "ITextSelection after ITextDocument destroyed\n");
119 ITextSelection_Release(txtSel
);