quartz: Free two assert calls from having side effects.
[wine/testsucceed.git] / dlls / riched20 / tests / richole.c
blobee89086416f5c1dc20b4c678bf64306506013eb0
1 /*
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
21 #define COBJMACROS
23 #include <stdarg.h>
25 #include <windef.h>
26 #include <winbase.h>
27 #include <wingdi.h>
28 #include <winuser.h>
29 #include <initguid.h>
30 #include <ole2.h>
31 #include <richedit.h>
32 #include <richole.h>
33 #include <tom.h>
34 #include <wine/test.h>
36 static HMODULE hmoduleRichEdit;
38 static HWND new_window(LPCTSTR lpClassName, DWORD dwStyle, HWND parent)
40 HWND hwnd
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());
45 return hwnd;
48 static HWND new_richedit(HWND parent)
50 return new_window(RICHEDIT_CLASS, ES_MULTILINE, parent);
54 START_TEST(richole)
56 IRichEditOle *reOle = NULL;
57 ITextDocument *txtDoc = NULL;
58 ITextSelection *txtSel = NULL;
59 IUnknown *punk;
60 HRESULT hres;
61 LRESULT res;
62 HWND w;
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);
70 if (!w) {
71 skip("Couldn't create window\n");
72 return;
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,
80 (void **) &txtDoc);
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");
88 punk = NULL;
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);
94 punk = NULL;
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);
100 punk = NULL;
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);
108 DestroyWindow(w);
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);