summaryrefslogtreecommitdiffstats
path: root/private/oleutest/simpdnd/tests.cpp
blob: 7119442de72e09d05b96f8d0ada612f8fdc221f7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
//+-------------------------------------------------------------------------
//
//  Microsoft Windows
//  Copyright (C) Microsoft Corporation, 1992 - 1993.
//
//  File:   	tests.cpp
//
//  Contents:	Implementations of the Upper Layer unit tests
//
//  Classes:
//
//  Functions: 	StartTest1
//
//  History:    dd-mmm-yy Author    Comment
//		07-Feb-94 alexgo    author
//
//--------------------------------------------------------------------------

#include "pre.h"
#include "iocs.h"
#include "ias.h"
#include "app.h"
#include "site.h"
#include "doc.h"
#include <testmess.h>

const CLSID CLSID_SimpleServer = {0xbcf6d4a0, 0xbe8c, 0x1068, { 0xb6, 0xd4,
	0x00, 0xdd, 0x01, 0x0c, 0x05, 0x09 }};

const CLSID CLSID_Paintbrush = {0x0003000a, 0, 0, { 0xc0, 0,0,0,0,0,0,0x46 }};

//+-------------------------------------------------------------------------
//
//  Function:	StartTest1
//
//  Synopsis:	Starts unit test1, inserting a simple server object into
//		this (simpdnd) container.
//
//  Effects:
//
//  Arguments:	pApp	-- a pointer to the CSimpleApp that we're a part of
//
//  Requires:
//
//  Returns:
//
//  Signals:    			
//
//  Modifies:
//			
//  Algorithm:
//
//  History:    dd-mmm-yy Author    Comment
//     		07-Feb-94 alexgo    author
//
//  Notes:
//
//--------------------------------------------------------------------------

void StartTest1( CSimpleApp *pApp )
{
	HRESULT hresult;
	static FORMATETC formatetc;

	//insert the simple server object

	formatetc.dwAspect = DVASPECT_CONTENT;
	formatetc.cfFormat = NULL;
	formatetc.lindex = -1;

	//need to create the client site

	pApp->m_lpDoc->m_lpSite = CSimpleSite::Create(pApp->m_lpDoc);

	hresult = OleCreate(CLSID_SimpleServer, IID_IOleObject,
		OLERENDER_DRAW, &formatetc,
		&pApp->m_lpDoc->m_lpSite->m_OleClientSite,
		pApp->m_lpDoc->m_lpSite->m_lpObjStorage,
		(void **)&(pApp->m_lpDoc->m_lpSite->m_lpOleObject));

	if( hresult != NOERROR )
	{
		goto errRtn;
	}

	//initialize the object
							
	hresult = pApp->m_lpDoc->m_lpSite->InitObject(TRUE);

	if( hresult == NOERROR )
	{
		//tell it to paint itself, then we'll quit
		PostMessage(pApp->m_lpDoc->m_hDocWnd, WM_PAINT, 0L, 0L);
		PostMessage(pApp->m_hDriverWnd, WM_TESTEND, TEST_SUCCESS,
		(LPARAM)hresult);
		PostMessage(pApp->m_hAppWnd, WM_SYSCOMMAND, SC_CLOSE, 0L);
		return;
	}

errRtn:
	PostMessage(pApp->m_hDriverWnd, WM_TESTEND, TEST_FAILURE,
		(LPARAM)hresult);
	PostMessage(pApp->m_hAppWnd, WM_SYSCOMMAND, SC_CLOSE, 0L);
	return;
}


//+-------------------------------------------------------------------------
//
//  Function:	StartTest2
//
//  Synopsis:	Starts unit Test2, inserting a paintbrush object into
//		this (simpdnd) container.
//
//  Effects:
//
//  Arguments:	pApp	-- a pointer to the CSimpleApp that we're a part of
//
//  Requires:
//
//  Returns:
//
//  Signals:    			
//
//  Modifies:
//			
//  Algorithm:
//
//  History:    dd-mmm-yy Author    Comment
//     		24-May-94 kevinro & alexgo    author
//
//  Notes:
//
//--------------------------------------------------------------------------

void StartTest2( CSimpleApp *pApp )
{
	HRESULT hresult;
	static FORMATETC formatetc;

	//insert the simple server object

	formatetc.dwAspect = DVASPECT_CONTENT;
	formatetc.cfFormat = NULL;
	formatetc.lindex = -1;

	//need to create the client site

	pApp->m_lpDoc->m_lpSite = CSimpleSite::Create(pApp->m_lpDoc);

	hresult = OleCreate(CLSID_Paintbrush, IID_IOleObject,
		OLERENDER_DRAW, &formatetc,
		&pApp->m_lpDoc->m_lpSite->m_OleClientSite,
		pApp->m_lpDoc->m_lpSite->m_lpObjStorage,
		(void **)&(pApp->m_lpDoc->m_lpSite->m_lpOleObject));

	if( hresult != NOERROR )
	{
		goto errRtn;
	}

	//initialize the object
							
	hresult = pApp->m_lpDoc->m_lpSite->InitObject(TRUE);

	//
	// The DDE layer is going to ignore all of the parameters except
	// the verb index. The parameters here are mostly dummies.
	//
	if (hresult == NOERROR)
	{
		hresult = pApp->m_lpDoc->m_lpSite->m_lpOleObject->DoVerb(0,
				NULL,
				&(pApp->m_lpDoc->m_lpSite->m_OleClientSite),
				-1,
				NULL,
				NULL);
	}

	if( hresult == NOERROR )
	{
		//tell it to paint itself, then we'll quit
		PostMessage(pApp->m_lpDoc->m_hDocWnd, WM_PAINT, 0L, 0L);
		PostMessage(pApp->m_hDriverWnd, WM_TESTEND, TEST_SUCCESS,
		(LPARAM)hresult);
		PostMessage(pApp->m_hAppWnd, WM_SYSCOMMAND, SC_CLOSE, 0L);
		return;
	}

errRtn:
	PostMessage(pApp->m_hDriverWnd, WM_TESTEND, TEST_FAILURE,
		(LPARAM)hresult);
	PostMessage(pApp->m_hAppWnd, WM_SYSCOMMAND, SC_CLOSE, 0L);
	return;
}