Follow-on fix for bug 457825. Use sheet principal for agent and user sheets. r=dbaron...
[wine-gecko.git] / embedding / qa / testembed / nsiDirServ.cpp
blob299f7919a05a13884ee0c6271c9a2bc111c6b523
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
13 * License.
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.
22 * Contributor(s):
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 ***** */
39 // File Overview....
41 // Test cases for the nsiDirectoryService Interface
43 #include "stdafx.h"
44 #include "TestEmbed.h"
45 #include "BrowserImpl.h"
46 #include "BrowserFrm.h"
47 #include "UrlDialog.h"
48 #include "ProfileMgr.h"
49 #include "ProfilesDlg.h"
50 #include "QaUtils.h"
51 #include "nsiDirServ.h"
52 #include "nsIDirectoryService.h"
53 #include "winEmbedFileLocProvider.h"
54 #include <stdio.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)
81 //}}AFX_MSG_MAP
82 END_MESSAGE_MAP()
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.
101 switch(nMenuID)
103 case ID_INTERFACES_NSIDIRECTORYSERVICE_RUNALLTESTS :
104 Init();
105 RegisterProvider();
106 UnRegisterProvider();
107 break ;
108 case ID_INTERFACES_NSIDIRECTORYSERVICE_INIT :
109 Init();
110 break ;
111 case ID_INTERFACES_NSIDIRECTORYSERVICE_REGISTERPROVIDER :
112 RegisterProvider();
113 break ;
114 case ID_INTERFACES_NSIDIRECTORYSERVICE_UNREGISTERPROVIDER :
115 UnRegisterProvider();
116 break ;
117 default :
118 AfxMessageBox("Menu handler not added for this menu item");
119 break ;
123 void CNsIDirectoryService::Init()
125 nsCOMPtr<nsIDirectoryService> theDirService(do_CreateInstance(NS_DIRECTORY_SERVICE_CONTRACTID));
127 if (!theDirService)
129 QAOutput("Directory Service object doesn't exist.", 0);
130 return;
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");
141 if (!theDirService)
143 QAOutput("Directory Service object doesn't exist.", 0);
144 return;
146 if (!provider)
148 QAOutput("Directory Service Provider object doesn't exist.", 0);
149 return;
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");
159 if (!theDirService)
161 QAOutput("Directory Service object doesn't exist.", 0);
162 return;
164 if (!provider)
166 QAOutput("Directory Service Provider object doesn't exist.", 0);
167 return;
169 rv= theDirService->RegisterProvider(provider);
170 rv= theDirService->UnregisterProvider(provider);
171 RvTestResult(rv, "rv UnRegisterProvider() test", 1);
172 RvTestResultDlg(rv, "rv UnRegisterProvider() test");