Back to index

lightning-sunbird  0.9+nobinonly
nsiDirServ.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   Ashish Bhatt <ashishbhatt@netscape.com>
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either the GNU General Public License Version 2 or later (the "GPL"), or
00027  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 
00039 // File Overview....
00040 //
00041 // Test cases for the nsiDirectoryService Interface
00042 
00043 #include "stdafx.h"
00044 #include "TestEmbed.h"
00045 #include "BrowserImpl.h"
00046 #include "BrowserFrm.h"
00047 #include "UrlDialog.h"
00048 #include "ProfileMgr.h"
00049 #include "ProfilesDlg.h"
00050 #include "QaUtils.h"
00051 #include "nsiDirServ.h"
00052 #include "nsIDirectoryService.h"
00053 #include "winEmbedFileLocProvider.h"
00054 #include <stdio.h>
00055 
00056 
00058 // CNsIDirectoryService
00059 
00060 CNsIDirectoryService::CNsIDirectoryService()
00061 {
00062 
00063 }
00064 
00065 /*CNsIDirectoryService::CNsIDirectoryService(nsIWebBrowser* mWebBrowser,
00066                         nsIBaseWindow* mBaseWindow,
00067                         nsIWebNavigation* mWebNav,
00068                         CBrowserImpl *mpBrowserImpl):CTests(mWebBrowser,mBaseWindow,mWebNav,mpBrowserImpl)
00069 {
00070 
00071 }
00072 */
00073 
00074 CNsIDirectoryService::~CNsIDirectoryService()
00075 {
00076 }
00077 
00078 /*
00079 BEGIN_MESSAGE_MAP(CNsIDirectoryService, CTests)
00080        //{{AFX_MSG_MAP(CNsIDirectoryService)
00081        //}}AFX_MSG_MAP
00082 END_MESSAGE_MAP()
00083 */
00084 
00086 // CNsIDirectoryService message handlers
00087 // ***********************************************************************
00088 // ***********************************************************************
00089 //  NsIDirectoryService iface
00090 
00091 
00092 void CNsIDirectoryService::StartTests(UINT nMenuID)
00093 {
00094 
00095     QAOutput("------------------------------------------------",1);
00096     QAOutput("Start DirectoryService Test",1);
00097        
00098        // Calls  all or indivdual test cases on the basis of the 
00099        // option selected from menu.
00100 
00101        switch(nMenuID)
00102        {
00103        case ID_INTERFACES_NSIDIRECTORYSERVICE_RUNALLTESTS :
00104                        Init(); 
00105                        RegisterProvider();       
00106                        UnRegisterProvider();     
00107                        break ;
00108        case ID_INTERFACES_NSIDIRECTORYSERVICE_INIT :
00109                        Init(); 
00110                        break ;
00111        case ID_INTERFACES_NSIDIRECTORYSERVICE_REGISTERPROVIDER :
00112                        RegisterProvider();       
00113                        break ;
00114        case ID_INTERFACES_NSIDIRECTORYSERVICE_UNREGISTERPROVIDER :
00115                        UnRegisterProvider();     
00116                        break ;
00117        default :  
00118                      AfxMessageBox("Menu handler not added for this menu item");
00119                      break ;
00120        }      
00121 }
00122 
00123 void CNsIDirectoryService::Init()
00124 {
00125    nsCOMPtr<nsIDirectoryService> theDirService(do_CreateInstance(NS_DIRECTORY_SERVICE_CONTRACTID));
00126 
00127     if (!theDirService)
00128        {
00129               QAOutput("Directory Service object doesn't exist.", 0);
00130               return;
00131        }
00132 
00133        rv = theDirService->Init();
00134        RvTestResult(rv, "rv Init() test", 1);
00135        RvTestResultDlg(rv, "rv Init() test", true);
00136 }
00137 void CNsIDirectoryService::RegisterProvider()
00138 {
00139    nsCOMPtr<nsIDirectoryService> theDirService(do_CreateInstance(NS_DIRECTORY_SERVICE_CONTRACTID));
00140    winEmbedFileLocProvider *provider = new winEmbedFileLocProvider("TestEmbed");
00141     if (!theDirService)
00142        {
00143               QAOutput("Directory Service object doesn't exist.", 0);
00144               return;
00145        }
00146     if (!provider)
00147        {
00148               QAOutput("Directory Service Provider object doesn't exist.", 0);
00149               return;
00150        }
00151        rv= theDirService->RegisterProvider(provider);
00152        RvTestResult(rv, "rv RegisterProvider() test", 1);
00153        RvTestResultDlg(rv, "rv RegisterProvider() test");
00154 }
00155 void CNsIDirectoryService::UnRegisterProvider()
00156 {
00157    nsCOMPtr<nsIDirectoryService> theDirService(do_CreateInstance(NS_DIRECTORY_SERVICE_CONTRACTID));
00158    winEmbedFileLocProvider *provider = new winEmbedFileLocProvider("TestEmbed");
00159     if (!theDirService)
00160        {
00161               QAOutput("Directory Service object doesn't exist.", 0);
00162               return;
00163        }
00164     if (!provider)
00165        {
00166               QAOutput("Directory Service Provider object doesn't exist.", 0);
00167               return;
00168        }
00169        rv= theDirService->RegisterProvider(provider);
00170        rv= theDirService->UnregisterProvider(provider);
00171        RvTestResult(rv, "rv UnRegisterProvider() test", 1);
00172        RvTestResultDlg(rv, "rv UnRegisterProvider() test");
00173 }
00174 
00175