1 // This is a Win32-only test for verifying that the ACE dll
2 // initializes itself without having a nonstatic object manager
3 // present by way of a console app's main function. It's a MFC dialog
4 // app - it pops up a dialog and spawns a thread - the thread will
5 // wait 2 seconds and programatically dismiss the dialog box. The
6 // main thread waits for the other one to exit, and that's the test.
7 // If the ACE DLL doesn't initialize correctly, it will go boom!
9 // This test program was initially generated from MSVC AppWizard, then
10 // some files were renamed and moved around to fit in with the ACE
11 // test directory structure.
13 // ACE_Init_Test.cpp : Defines the class behaviors for the application.
15 #if !defined(ACE_HAS_MFC)
17 #include "test_config.h"
19 // If this is not a WIN32 platform do not even try to compile the
20 // test, many of the #includes make little sense.
22 run_main (int, ACE_TCHAR
*[])
24 ACE_START_TEST (ACE_TEXT ("ACE_Init_Test"));
26 ACE_TEXT ("This is not a Win32 platform with MFC support, test skipped\n")));
33 #include "ACE_Init_Test_StdAfx.h"
34 #include "ACE_Init_Test.h"
35 #include "ACE_Init_TestDlg.h"
36 #include "test_config.h"
38 #include "ace/Init_ACE.h"
39 #include "ace/OS_NS_unistd.h"
40 #include "ace/Thread_Manager.h"
46 static char THIS_FILE
[] = __FILE__
;
49 static ACE_THR_FUNC_RETURN
wait_and_kill_dialog (void *pBox
);
51 /////////////////////////////////////////////////////////////////////////////
54 BEGIN_MESSAGE_MAP(CACE_Init_TestApp
, CWinApp
)
55 //{{AFX_MSG_MAP(CACE_Init_TestApp)
56 // NOTE - the ClassWizard will add and remove mapping macros here.
57 // DO NOT EDIT what you see in these blocks of generated code!
59 ON_COMMAND(ID_HELP
, CWinApp::OnHelp
)
62 /////////////////////////////////////////////////////////////////////////////
63 // CACE_Init_TestApp construction
65 CACE_Init_TestApp::CACE_Init_TestApp()
67 // TODO: add construction code here,
68 // Place all significant initialization in InitInstance
71 /////////////////////////////////////////////////////////////////////////////
72 // The one and only CACE_Init_TestApp object
74 CACE_Init_TestApp theApp
;
76 /////////////////////////////////////////////////////////////////////////////
77 // CACE_Init_TestApp initialization
79 BOOL
CACE_Init_TestApp::InitInstance()
81 // This is needed because there's no overridden main(int, char *[])
82 // which would normally handle the initialization. Also see the
83 // corresponding ACE::fini, below.
86 ACE_START_TEST (ACE_TEXT ("ACE_Init_Test"));
88 CACE_Init_TestDlg dlg
;
90 ACE_Thread_Manager::instance()->spawn (wait_and_kill_dialog
,
92 int nResponse
= dlg
.DoModal();
93 if (nResponse
== IDOK
)
95 // TODO: Place code here to handle when the dialog is
98 else if (nResponse
== IDCANCEL
)
100 // TODO: Place code here to handle when the dialog is
101 // dismissed with Cancel
104 ACE_Thread_Manager::instance()->wait();
108 // Since the dialog has been closed, return FALSE so that we exit the
109 // application, rather than start the application's message pump.
115 // This function runs in a separate thread - it will wait a couple of
116 // seconds and then programatically dismiss the dialog box. If ACE is
117 // not properly initialized, we will have crashed before getting here.
118 static ACE_THR_FUNC_RETURN
119 wait_and_kill_dialog (void *pBox
)
121 CACE_Init_TestDlg
*pDialog
= reinterpret_cast<CACE_Init_TestDlg
*> (pBox
);
123 pDialog
->EndModalLoop (IDOK
);
127 #endif /* ACE_HAS_MFC */