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 * Dharma Sirnapalli <dsirnapalli@netscape.com>
24 * Ashish Bhatt <ashishbhatt@netscape.com>
26 * Alternatively, the contents of this file may be used under the terms of
27 * either the GNU General Public License Version 2 or later (the "GPL"), or
28 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
38 * ***** END LICENSE BLOCK ***** */
42 // Test cases for the nsIClipBoardCommand Interface
47 #include "nsIClipboardCmd.h"
49 CNsIClipBoardCmd::CNsIClipBoardCmd(nsIWebBrowser
* mWebBrowser
)
51 qaWebBrowser
= mWebBrowser
;
55 CNsIClipBoardCmd::~CNsIClipBoardCmd()
60 void CNsIClipBoardCmd::OnStartTests(UINT nMenuID
)
62 // Calls all or indivdual test cases on the basis of the
63 // option selected from menu.
67 case ID_INTERFACES_NSICLIPBOARDCOMMANDS_PASTE
:
70 case ID_INTERFACES_NSICLIPBOARDCOMMANDS_COPYSELECTION
:
73 case ID_INTERFACES_NSICLIPBOARDCOMMANDS_SELECTALL
:
76 case ID_INTERFACES_NSICLIPBOARDCOMMANDS_SELECTNONE
:
79 case ID_INTERFACES_NSICLIPBOARDCOMMANDS_CUTSELECTION
:
82 case ID_INTERFACES_NSICLIPBOARDCOMMANDS_COPYLINKLOCATION
:
83 copyLinkLocationTest();
85 case ID_INTERFACES_NSICLIPBOARDCOMMANDS_CANCOPYSELECTION
:
86 canCopySelectionTest();
88 case ID_INTERFACES_NSICLIPBOARDCOMMANDS_CANCUTSELECTION
:
89 canCutSelectionTest();
91 case ID_INTERFACES_NSICLIPBOARDCOMMANDS_CANPASTE
:
98 // ***********************************************************************
99 //DHARMA - nsIClipboardCommands
100 // Checking the paste() method.
101 void CNsIClipBoardCmd::OnPasteTest()
103 QAOutput("testing paste command", 1);
104 nsCOMPtr
<nsIClipboardCommands
> clipCmds
= do_GetInterface(qaWebBrowser
);
107 rv
= clipCmds
->Paste();
108 RvTestResult(rv
, "nsIClipboardCommands::Paste()' rv test", 1);
112 QAOutput("We didn't get the clipboard object.", 1);
115 // Checking the copySelection() method.
116 void CNsIClipBoardCmd::OnCopyTest()
118 QAOutput("testing copyselection command");
119 nsCOMPtr
<nsIClipboardCommands
> clipCmds
= do_GetInterface(qaWebBrowser
);
122 rv
= clipCmds
->CopySelection();
123 RvTestResult(rv
, "nsIClipboardCommands::CopySelection()' rv test", 1);
126 QAOutput("We didn't get the clipboard object.", 1);
129 // Checking the selectAll() method.
130 void CNsIClipBoardCmd::OnSelectAllTest()
132 QAOutput("testing selectall method");
133 nsCOMPtr
<nsIClipboardCommands
> clipCmds
= do_GetInterface(qaWebBrowser
);
136 rv
= clipCmds
->SelectAll();
137 RvTestResult(rv
, "nsIClipboardCommands::SelectAll()' rv test", 1);
140 QAOutput("We didn't get the clipboard object.", 1);
143 // Checking the selectNone() method.
144 void CNsIClipBoardCmd::OnSelectNoneTest()
146 QAOutput("testing selectnone method");
147 nsCOMPtr
<nsIClipboardCommands
> clipCmds
= do_GetInterface(qaWebBrowser
);
150 rv
= clipCmds
->SelectNone();
151 RvTestResult(rv
, "nsIClipboardCommands::SelectNone()' rv test", 1);
154 QAOutput("We didn't get the clipboard object.", 1);
157 // Checking the cutSelection() method.
158 void CNsIClipBoardCmd::OnCutSelectionTest()
160 QAOutput("testing cutselection method");
161 nsCOMPtr
<nsIClipboardCommands
> clipCmds
= do_GetInterface(qaWebBrowser
);
164 rv
= clipCmds
->CutSelection();
165 RvTestResult(rv
, "nsIClipboardCommands::CutSelection()' rv test", 1);
168 QAOutput("We didn't get the clipboard object.", 1);
171 // Checking the copyLinkLocation() method.
172 void CNsIClipBoardCmd::copyLinkLocationTest()
174 QAOutput("testing CopyLinkLocation method", 2);
175 nsCOMPtr
<nsIClipboardCommands
> clipCmds
= do_GetInterface(qaWebBrowser
);
178 rv
= clipCmds
->CopyLinkLocation();
179 RvTestResult(rv
, "nsIClipboardCommands::CopyLinkLocation()' rv test", 1);
182 QAOutput("We didn't get the clipboard object.", 1);
185 // Checking the canCopySelection() method.
186 void CNsIClipBoardCmd::canCopySelectionTest()
188 PRBool canCopySelection
= PR_FALSE
;
189 nsCOMPtr
<nsIClipboardCommands
> clipCmds
= do_GetInterface(qaWebBrowser
);
192 rv
= clipCmds
->CanCopySelection(&canCopySelection
);
193 RvTestResult(rv
, "nsIClipboardCommands::CanCopySelection()' rv test", 1);
196 QAOutput("The selection you made Can be copied", 2);
198 QAOutput("Either you did not make a selection or The selection you made Cannot be copied", 2);
201 QAOutput("We didn't get the clipboard object.", 1);
204 // Checking the canCutSelection() method.
205 void CNsIClipBoardCmd::canCutSelectionTest()
207 PRBool canCutSelection
= PR_FALSE
;
208 nsCOMPtr
<nsIClipboardCommands
> clipCmds
= do_GetInterface(qaWebBrowser
);
211 rv
= clipCmds
->CanCutSelection(&canCutSelection
);
212 RvTestResult(rv
, "nsIClipboardCommands::CanCutSelection()' rv test", 1);
215 QAOutput("The selection you made Can be cut", 2);
217 QAOutput("Either you did not make a selection or The selection you made Cannot be cut", 2);
220 QAOutput("We didn't get the clipboard object.", 1);
223 // Checking the canPaste() method.
224 void CNsIClipBoardCmd::canPasteTest()
226 PRBool canPaste
= PR_FALSE
;
227 nsCOMPtr
<nsIClipboardCommands
> clipCmds
= do_GetInterface(qaWebBrowser
);
230 rv
= clipCmds
->CanPaste(&canPaste
);
231 RvTestResult(rv
, "nsIClipboardCommands::CanPaste()' rv test", 1);
234 QAOutput("The clipboard contents can be pasted here", 2);
236 QAOutput("The clipboard contents cannot be pasted here", 2);
239 QAOutput("We didn't get the clipboard object.", 1);