1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
23 * Ashish Bhatt <ashishbhatt@netscape.com>
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
41 // Test cases for the nsiDirectoryService Interface
44 #include "TestEmbed.h"
45 #include "BrowserImpl.h"
46 #include "BrowserFrm.h"
47 #include "UrlDialog.h"
48 #include "ProfileMgr.h"
49 #include "ProfilesDlg.h"
51 #include "nsiDirServ.h"
52 #include "nsIDirectoryService.h"
53 #include "winEmbedFileLocProvider.h"
57 /////////////////////////////////////////////////////////////////////////////
58 // CNsIDirectoryService
60 CNsIDirectoryService::CNsIDirectoryService()
65 /*CNsIDirectoryService::CNsIDirectoryService(nsIWebBrowser* mWebBrowser,
66 nsIBaseWindow* mBaseWindow,
67 nsIWebNavigation* mWebNav,
68 CBrowserImpl *mpBrowserImpl):CTests(mWebBrowser,mBaseWindow,mWebNav,mpBrowserImpl)
74 CNsIDirectoryService::~CNsIDirectoryService()
79 BEGIN_MESSAGE_MAP(CNsIDirectoryService, CTests)
80 //{{AFX_MSG_MAP(CNsIDirectoryService)
85 /////////////////////////////////////////////////////////////////////////////
86 // CNsIDirectoryService message handlers
87 // ***********************************************************************
88 // ***********************************************************************
89 // NsIDirectoryService iface
92 void CNsIDirectoryService::StartTests(UINT nMenuID
)
95 QAOutput("------------------------------------------------",1);
96 QAOutput("Start DirectoryService Test",1);
98 // Calls all or indivdual test cases on the basis of the
99 // option selected from menu.
103 case ID_INTERFACES_NSIDIRECTORYSERVICE_RUNALLTESTS
:
106 UnRegisterProvider();
108 case ID_INTERFACES_NSIDIRECTORYSERVICE_INIT
:
111 case ID_INTERFACES_NSIDIRECTORYSERVICE_REGISTERPROVIDER
:
114 case ID_INTERFACES_NSIDIRECTORYSERVICE_UNREGISTERPROVIDER
:
115 UnRegisterProvider();
118 AfxMessageBox("Menu handler not added for this menu item");
123 void CNsIDirectoryService::Init()
125 nsCOMPtr
<nsIDirectoryService
> theDirService(do_CreateInstance(NS_DIRECTORY_SERVICE_CONTRACTID
));
129 QAOutput("Directory Service object doesn't exist.", 0);
133 rv
= theDirService
->Init();
134 RvTestResult(rv
, "rv Init() test", 1);
135 RvTestResultDlg(rv
, "rv Init() test", true);
137 void CNsIDirectoryService::RegisterProvider()
139 nsCOMPtr
<nsIDirectoryService
> theDirService(do_CreateInstance(NS_DIRECTORY_SERVICE_CONTRACTID
));
140 winEmbedFileLocProvider
*provider
= new winEmbedFileLocProvider("TestEmbed");
143 QAOutput("Directory Service object doesn't exist.", 0);
148 QAOutput("Directory Service Provider object doesn't exist.", 0);
151 rv
= theDirService
->RegisterProvider(provider
);
152 RvTestResult(rv
, "rv RegisterProvider() test", 1);
153 RvTestResultDlg(rv
, "rv RegisterProvider() test");
155 void CNsIDirectoryService::UnRegisterProvider()
157 nsCOMPtr
<nsIDirectoryService
> theDirService(do_CreateInstance(NS_DIRECTORY_SERVICE_CONTRACTID
));
158 winEmbedFileLocProvider
*provider
= new winEmbedFileLocProvider("TestEmbed");
161 QAOutput("Directory Service object doesn't exist.", 0);
166 QAOutput("Directory Service Provider object doesn't exist.", 0);
169 rv
= theDirService
->RegisterProvider(provider
);
170 rv
= theDirService
->UnregisterProvider(provider
);
171 RvTestResult(rv
, "rv UnRegisterProvider() test", 1);
172 RvTestResultDlg(rv
, "rv UnRegisterProvider() test");