Follow-on fix for bug 457825. Use sheet principal for agent and user sheets. r=dbaron...
[wine-gecko.git] / embedding / qa / testembed / nsIclipboardcmd.cpp
blob84cd871ab7fdb040156135c58fc6a6e95d63d801
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 * 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 ***** */
40 // File Overview....
42 // Test cases for the nsIClipBoardCommand Interface
44 #include "stdafx.h"
45 #include "QaUtils.h"
46 #include <stdio.h>
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.
65 switch(nMenuID)
67 case ID_INTERFACES_NSICLIPBOARDCOMMANDS_PASTE :
68 OnPasteTest();
69 break ;
70 case ID_INTERFACES_NSICLIPBOARDCOMMANDS_COPYSELECTION :
71 OnCopyTest();
72 break ;
73 case ID_INTERFACES_NSICLIPBOARDCOMMANDS_SELECTALL :
74 OnSelectAllTest();
75 break ;
76 case ID_INTERFACES_NSICLIPBOARDCOMMANDS_SELECTNONE :
77 OnSelectNoneTest();
78 break ;
79 case ID_INTERFACES_NSICLIPBOARDCOMMANDS_CUTSELECTION :
80 OnCutSelectionTest();
81 break ;
82 case ID_INTERFACES_NSICLIPBOARDCOMMANDS_COPYLINKLOCATION :
83 copyLinkLocationTest();
84 break ;
85 case ID_INTERFACES_NSICLIPBOARDCOMMANDS_CANCOPYSELECTION :
86 canCopySelectionTest();
87 break ;
88 case ID_INTERFACES_NSICLIPBOARDCOMMANDS_CANCUTSELECTION :
89 canCutSelectionTest();
90 break ;
91 case ID_INTERFACES_NSICLIPBOARDCOMMANDS_CANPASTE :
92 canPasteTest();
93 break ;
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);
105 if (clipCmds)
107 rv = clipCmds->Paste();
108 RvTestResult(rv, "nsIClipboardCommands::Paste()' rv test", 1);
111 else
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);
120 if (clipCmds)
122 rv = clipCmds->CopySelection();
123 RvTestResult(rv, "nsIClipboardCommands::CopySelection()' rv test", 1);
125 else
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);
134 if (clipCmds)
136 rv = clipCmds->SelectAll();
137 RvTestResult(rv, "nsIClipboardCommands::SelectAll()' rv test", 1);
139 else
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);
148 if (clipCmds)
150 rv = clipCmds->SelectNone();
151 RvTestResult(rv, "nsIClipboardCommands::SelectNone()' rv test", 1);
153 else
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);
162 if (clipCmds)
164 rv = clipCmds->CutSelection();
165 RvTestResult(rv, "nsIClipboardCommands::CutSelection()' rv test", 1);
167 else
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);
176 if (clipCmds)
178 rv = clipCmds->CopyLinkLocation();
179 RvTestResult(rv, "nsIClipboardCommands::CopyLinkLocation()' rv test", 1);
181 else
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);
190 if (clipCmds)
192 rv = clipCmds->CanCopySelection(&canCopySelection);
193 RvTestResult(rv, "nsIClipboardCommands::CanCopySelection()' rv test", 1);
195 if(canCopySelection)
196 QAOutput("The selection you made Can be copied", 2);
197 else
198 QAOutput("Either you did not make a selection or The selection you made Cannot be copied", 2);
200 else
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);
209 if (clipCmds)
211 rv = clipCmds->CanCutSelection(&canCutSelection);
212 RvTestResult(rv, "nsIClipboardCommands::CanCutSelection()' rv test", 1);
214 if(canCutSelection)
215 QAOutput("The selection you made Can be cut", 2);
216 else
217 QAOutput("Either you did not make a selection or The selection you made Cannot be cut", 2);
219 else
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);
228 if (clipCmds)
230 rv = clipCmds->CanPaste(&canPaste);
231 RvTestResult(rv, "nsIClipboardCommands::CanPaste()' rv test", 1);
233 if(canPaste)
234 QAOutput("The clipboard contents can be pasted here", 2);
235 else
236 QAOutput("The clipboard contents cannot be pasted here", 2);
238 else
239 QAOutput("We didn't get the clipboard object.", 1);
242 //DHARMA