1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: Mozilla-sample-code 1.0
5 * Copyright (c) 2002 Netscape Communications Corporation and
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this Mozilla sample software and associated documentation files
10 * (the "Software"), to deal in the Software without restriction, including
11 * without limitation the rights to use, copy, modify, merge, publish,
12 * distribute, sublicense, and/or sell copies of the Software, and to permit
13 * persons to whom the Software is furnished to do so, subject to the
14 * following conditions:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 * DEALINGS IN THE SOFTWARE.
28 * Adam Lock <adamlock@netscape.com>
30 * ***** END LICENSE BLOCK ***** */
35 #include "nsEmbedAPI.h"
37 int main(int argc
, char *argv
[])
39 _CrtSetReportMode( _CRT_WARN
, _CRTDBG_MODE_FILE
);
40 _CrtSetReportFile( _CRT_WARN
, _CRTDBG_FILE_STDOUT
);
43 _CrtMemState sBefore
, sMiddle
, sAfter
;
45 // Store a memory checkpoint in the s1 memory-state structure
46 _CrtMemCheckpoint(&sBefore
);
48 char *pszBinDirPath
= nsnull
;
51 pszBinDirPath
= argv
[1];
53 printf("apitest running...\n");
55 nsCOMPtr
<nsILocalFile
> binDir
;
56 NS_NewLocalFile(pszBinDirPath
, PR_TRUE
, getter_AddRefs(binDir
));
58 nsresult rv
= NS_InitEmbedding(binDir
, nsnull
);
61 printf("NS_InitEmbedding FAILED (rv = 0x%08x)\n", rv
);
62 // DROP THROUGH - NS_TermEmbedding should cope
66 printf("NS_InitEmbedding SUCCEEDED (rv = 0x%08x)\n", rv
);
69 // TODO put lot's of interesting diagnostic stuff here such as time taken
71 // Memory used up etc.
72 _CrtMemCheckpoint(&sMiddle
);
75 rv
= NS_TermEmbedding();
78 printf("NS_TermEmbedding FAILED (rv = 0x%08x)\n", rv
);
83 printf("NS_TermEmbedding SUCCEEDED (rv = 0x%08x)\n", rv
);
86 // TODO more interesting stuff. Time to shutdown
88 // Dump the leaked memory
89 printf("FINAL LEAKAGE:\n");
90 _CrtMemCheckpoint(&sAfter
);
91 _CrtMemState sDifference
;
92 if ( _CrtMemDifference(&sDifference
, &sBefore
, &sAfter
))
94 _CrtMemDumpStatistics(&sDifference
);
97 _CrtDumpMemoryLeaks( );
99 printf("apitest complete\n");