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
34 #include <wine/test.h>
36 static HMODULE hmoduleRichEdit
;
38 static HWND
new_window(LPCTSTR lpClassName
, DWORD dwStyle
, HWND parent
)
41 = CreateWindow(lpClassName
, NULL
,
42 dwStyle
| WS_POPUP
| WS_HSCROLL
| WS_VSCROLL
| WS_VISIBLE
,
43 0, 0, 200, 60, parent
, NULL
, hmoduleRichEdit
, NULL
);
44 ok(hwnd
!= NULL
, "class: %s, error: %d\n", lpClassName
, (int) GetLastError());
48 static HWND
new_richedit(HWND parent
)
50 return new_window(RICHEDIT_CLASS
, ES_MULTILINE
, parent
);
56 IRichEditOle
*reOle
= NULL
;
57 ITextDocument
*txtDoc
= NULL
;
58 ITextSelection
*txtSel
= NULL
;
64 /* Must explicitly LoadLibrary(). The test has no references to functions in
65 * RICHED20.DLL, so the linker doesn't actually link to it. */
66 hmoduleRichEdit
= LoadLibrary("RICHED20.DLL");
67 ok(hmoduleRichEdit
!= NULL
, "error: %d\n", (int) GetLastError());
69 w
= new_richedit(NULL
);
71 skip("Couldn't create window\n");
75 res
= SendMessage(w
, EM_GETOLEINTERFACE
, 0, (LPARAM
) &reOle
);
76 ok(res
, "SendMessage\n");
77 ok(reOle
!= NULL
, "EM_GETOLEINTERFACE\n");
79 hres
= IUnknown_QueryInterface(reOle
, &IID_ITextDocument
,
81 ok(hres
== S_OK
, "IRichEditOle_QueryInterface\n");
82 ok(txtDoc
!= NULL
, "IRichEditOle_QueryInterface\n");
84 hres
= ITextDocument_GetSelection(txtDoc
, &txtSel
);
85 ok(hres
== S_OK
, "ITextDocument_GetSelection\n");
86 ok(txtSel
!= NULL
, "ITextDocument_GetSelection\n");
89 hres
= ITextSelection_QueryInterface(txtSel
, &IID_ITextSelection
, (void **) &punk
);
90 ok(hres
== S_OK
, "ITextSelection_QueryInterface\n");
91 ok(punk
!= NULL
, "ITextSelection_QueryInterface\n");
92 IUnknown_Release(punk
);
95 hres
= ITextSelection_QueryInterface(txtSel
, &IID_ITextRange
, (void **) &punk
);
96 ok(hres
== S_OK
, "ITextSelection_QueryInterface\n");
97 ok(punk
!= NULL
, "ITextSelection_QueryInterface\n");
98 IUnknown_Release(punk
);
101 hres
= ITextSelection_QueryInterface(txtSel
, &IID_IDispatch
, (void **) &punk
);
102 ok(hres
== S_OK
, "ITextSelection_QueryInterface\n");
103 ok(punk
!= NULL
, "ITextSelection_QueryInterface\n");
104 IUnknown_Release(punk
);
106 ITextDocument_Release(txtDoc
);
107 IUnknown_Release(reOle
);
110 /* Methods should return CO_E_RELEASED if the backing document has
111 been released. One test should suffice. */
112 hres
= ITextSelection_CanEdit(txtSel
, NULL
);
113 ok(hres
== CO_E_RELEASED
, "ITextSelection after ITextDocument destroyed\n");
115 ITextSelection_Release(txtSel
);