Back to index

lightning-sunbird  0.9+nobinonly
nsIclipboardcmd.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  *   Dharma Sirnapalli <dsirnapalli@netscape.com>
00024  *   Ashish Bhatt <ashishbhatt@netscape.com>
00025  *
00026  * Alternatively, the contents of this file may be used under the terms of
00027  * either the GNU General Public License Version 2 or later (the "GPL"), or
00028  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00029  * in which case the provisions of the GPL or the LGPL are applicable instead
00030  * of those above. If you wish to allow use of your version of this file only
00031  * under the terms of either the GPL or the LGPL, and not to allow others to
00032  * use your version of this file under the terms of the MPL, indicate your
00033  * decision by deleting the provisions above and replace them with the notice
00034  * and other provisions required by the GPL or the LGPL. If you do not delete
00035  * the provisions above, a recipient may use your version of this file under
00036  * the terms of any one of the MPL, the GPL or the LGPL.
00037  *
00038  * ***** END LICENSE BLOCK ***** */
00039 
00040 // File Overview....
00041 //
00042 // Test cases for the nsIClipBoardCommand Interface
00043 
00044 #include "stdafx.h"
00045 #include "QaUtils.h"
00046 #include <stdio.h>
00047 #include "nsIClipboardCmd.h"
00048 
00049 CNsIClipBoardCmd::CNsIClipBoardCmd(nsIWebBrowser* mWebBrowser)
00050 {
00051        qaWebBrowser = mWebBrowser;
00052 }
00053 
00054 
00055 CNsIClipBoardCmd::~CNsIClipBoardCmd()
00056 {
00057 }
00058 
00059 
00060 void CNsIClipBoardCmd::OnStartTests(UINT nMenuID)
00061 {
00062        // Calls  all or indivdual test cases on the basis of the 
00063        // option selected from menu.
00064 
00065        switch(nMenuID)
00066        {
00067               case ID_INTERFACES_NSICLIPBOARDCOMMANDS_PASTE    :
00068                      OnPasteTest();
00069                      break ;
00070               case ID_INTERFACES_NSICLIPBOARDCOMMANDS_COPYSELECTION :
00071                      OnCopyTest();
00072                      break ;
00073               case ID_INTERFACES_NSICLIPBOARDCOMMANDS_SELECTALL :
00074                      OnSelectAllTest();
00075                      break ;
00076               case ID_INTERFACES_NSICLIPBOARDCOMMANDS_SELECTNONE :
00077                      OnSelectNoneTest();
00078                      break ;
00079               case ID_INTERFACES_NSICLIPBOARDCOMMANDS_CUTSELECTION :
00080                      OnCutSelectionTest();
00081                      break ;
00082               case ID_INTERFACES_NSICLIPBOARDCOMMANDS_COPYLINKLOCATION :
00083                      copyLinkLocationTest();
00084                      break ;
00085               case ID_INTERFACES_NSICLIPBOARDCOMMANDS_CANCOPYSELECTION :
00086                      canCopySelectionTest();
00087                      break ;
00088               case ID_INTERFACES_NSICLIPBOARDCOMMANDS_CANCUTSELECTION :
00089                      canCutSelectionTest();
00090                      break ;
00091               case ID_INTERFACES_NSICLIPBOARDCOMMANDS_CANPASTE :
00092                      canPasteTest();
00093                      break ;
00094        }
00095 
00096 }
00097 
00098 // ***********************************************************************
00099 //DHARMA      - nsIClipboardCommands
00100 // Checking the paste() method.
00101 void CNsIClipBoardCmd::OnPasteTest()
00102 {
00103     QAOutput("testing paste command", 1);
00104     nsCOMPtr<nsIClipboardCommands> clipCmds = do_GetInterface(qaWebBrowser);
00105     if (clipCmds)
00106        {
00107         rv = clipCmds->Paste();
00108               RvTestResult(rv, "nsIClipboardCommands::Paste()' rv test", 1);
00109 
00110        }
00111        else
00112               QAOutput("We didn't get the clipboard object.", 1);
00113 }
00114 
00115 // Checking the copySelection() method.
00116 void CNsIClipBoardCmd::OnCopyTest()
00117 {
00118     QAOutput("testing copyselection command");
00119     nsCOMPtr<nsIClipboardCommands> clipCmds = do_GetInterface(qaWebBrowser);
00120     if (clipCmds)
00121        {
00122         rv = clipCmds->CopySelection();
00123               RvTestResult(rv, "nsIClipboardCommands::CopySelection()' rv test", 1);
00124        }
00125        else
00126               QAOutput("We didn't get the clipboard object.", 1);
00127 }
00128 
00129 // Checking the selectAll() method.
00130 void CNsIClipBoardCmd::OnSelectAllTest()
00131 {
00132     QAOutput("testing selectall method");
00133     nsCOMPtr<nsIClipboardCommands> clipCmds = do_GetInterface(qaWebBrowser);
00134     if (clipCmds)
00135        {
00136         rv = clipCmds->SelectAll();
00137               RvTestResult(rv, "nsIClipboardCommands::SelectAll()' rv test", 1);
00138        }
00139        else
00140               QAOutput("We didn't get the clipboard object.", 1);
00141 }
00142 
00143 // Checking the selectNone() method.
00144 void CNsIClipBoardCmd::OnSelectNoneTest()
00145 {
00146     QAOutput("testing selectnone method");
00147     nsCOMPtr<nsIClipboardCommands> clipCmds = do_GetInterface(qaWebBrowser);
00148     if (clipCmds)
00149        {
00150         rv = clipCmds->SelectNone();
00151               RvTestResult(rv, "nsIClipboardCommands::SelectNone()' rv test", 1);
00152        }
00153        else
00154               QAOutput("We didn't get the clipboard object.", 1);
00155 }
00156 
00157 // Checking the cutSelection() method.
00158 void CNsIClipBoardCmd::OnCutSelectionTest()
00159 {
00160     QAOutput("testing cutselection method");
00161     nsCOMPtr<nsIClipboardCommands> clipCmds = do_GetInterface(qaWebBrowser);
00162     if (clipCmds)
00163        {
00164         rv = clipCmds->CutSelection();
00165               RvTestResult(rv, "nsIClipboardCommands::CutSelection()' rv test", 1);
00166        }
00167        else
00168               QAOutput("We didn't get the clipboard object.", 1);
00169 }
00170 
00171 // Checking the copyLinkLocation() method.
00172 void CNsIClipBoardCmd::copyLinkLocationTest()
00173 {
00174     QAOutput("testing CopyLinkLocation method", 2);
00175     nsCOMPtr<nsIClipboardCommands> clipCmds = do_GetInterface(qaWebBrowser);
00176     if (clipCmds)
00177        {
00178         rv = clipCmds->CopyLinkLocation();
00179               RvTestResult(rv, "nsIClipboardCommands::CopyLinkLocation()' rv test", 1);
00180        }
00181        else
00182               QAOutput("We didn't get the clipboard object.", 1);
00183 }
00184 
00185 // Checking the canCopySelection() method.
00186 void CNsIClipBoardCmd::canCopySelectionTest()
00187 {
00188     PRBool canCopySelection = PR_FALSE;
00189     nsCOMPtr<nsIClipboardCommands> clipCmds = do_GetInterface(qaWebBrowser);
00190     if (clipCmds)
00191        {
00192        rv = clipCmds->CanCopySelection(&canCopySelection);
00193           RvTestResult(rv, "nsIClipboardCommands::CanCopySelection()' rv test", 1);
00194 
00195        if(canCopySelection)
00196           QAOutput("The selection you made Can be copied", 2);
00197        else
00198           QAOutput("Either you did not make a selection or The selection you made Cannot be copied", 2);
00199        }
00200        else
00201               QAOutput("We didn't get the clipboard object.", 1);
00202 }
00203 
00204 // Checking the canCutSelection() method.
00205 void CNsIClipBoardCmd::canCutSelectionTest()
00206 {
00207     PRBool canCutSelection = PR_FALSE;
00208     nsCOMPtr<nsIClipboardCommands> clipCmds = do_GetInterface(qaWebBrowser);
00209     if (clipCmds)
00210        {
00211        rv = clipCmds->CanCutSelection(&canCutSelection);
00212           RvTestResult(rv, "nsIClipboardCommands::CanCutSelection()' rv test", 1);
00213 
00214           if(canCutSelection)
00215           QAOutput("The selection you made Can be cut", 2);
00216        else
00217           QAOutput("Either you did not make a selection or The selection you made Cannot be cut", 2);
00218        }
00219        else
00220               QAOutput("We didn't get the clipboard object.", 1);
00221 }
00222 
00223 // Checking the canPaste() method.
00224 void CNsIClipBoardCmd::canPasteTest()
00225 {
00226     PRBool canPaste = PR_FALSE;
00227     nsCOMPtr<nsIClipboardCommands> clipCmds = do_GetInterface(qaWebBrowser);
00228     if (clipCmds)
00229        {
00230         rv = clipCmds->CanPaste(&canPaste);
00231            RvTestResult(rv, "nsIClipboardCommands::CanPaste()' rv test", 1);
00232 
00233               if(canPaste)
00234                      QAOutput("The clipboard contents can be pasted here", 2);
00235               else
00236                      QAOutput("The clipboard contents cannot be pasted here", 2);
00237        }
00238        else
00239               QAOutput("We didn't get the clipboard object.", 1);
00240 }
00241 
00242 //DHARMA