~ubuntu-branches/ubuntu/precise/kompozer/precise

« back to all changes in this revision

Viewing changes to mozilla/embedding/qa/testembed/nsihttpchanneltests.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Yarusso
  • Date: 2007-08-27 01:11:03 UTC
  • Revision ID: james.westby@ubuntu.com-20070827011103-2jgf4s6532gqu2ka
Tags: upstream-0.7.10
ImportĀ upstreamĀ versionĀ 0.7.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// nsIHttpChannelTests.cpp : implementation file
 
2
//
 
3
 
 
4
#include "stdafx.h"
 
5
#include "testembed.h"
 
6
#include "nsIHttpChannelTests.h"
 
7
#include "BrowserImpl.h"
 
8
#include "BrowserFrm.h"
 
9
#include "UrlDialog.h"
 
10
#include "ProfileMgr.h"
 
11
#include "ProfilesDlg.h"
 
12
#include "QaUtils.h"
 
13
#include "Tests.h"
 
14
#include "nsichanneltests.h"
 
15
#include "nsIHttpHeaderVisitor.h"
 
16
 
 
17
#ifdef _DEBUG
 
18
#define new DEBUG_NEW
 
19
#undef THIS_FILE
 
20
static char THIS_FILE[] = __FILE__;
 
21
#endif
 
22
 
 
23
/////////////////////////////////////////////////////////////////////////////
 
24
// nsIHttpChannelTests
 
25
 
 
26
CnsIHttpChannelTests::CnsIHttpChannelTests(nsIWebBrowser *mWebBrowser,
 
27
                                                                   CBrowserImpl *mpBrowserImpl)
 
28
{
 
29
        qaWebBrowser = mWebBrowser;
 
30
        qaBrowserImpl = mpBrowserImpl;
 
31
}
 
32
 
 
33
CnsIHttpChannelTests::~CnsIHttpChannelTests()
 
34
{
 
35
}
 
36
 
 
37
class HeaderVisitor : public nsIHttpHeaderVisitor
 
38
{
 
39
public:
 
40
   NS_DECL_ISUPPORTS
 
41
   NS_DECL_NSIHTTPHEADERVISITOR
 
42
 
 
43
   HeaderVisitor() { }
 
44
   virtual ~HeaderVisitor() {}
 
45
 };
 
46
 
 
47
NS_IMPL_ISUPPORTS1(HeaderVisitor, nsIHttpHeaderVisitor)
 
48
 
 
49
NS_IMETHODIMP
 
50
HeaderVisitor::VisitHeader(const nsACString &header, const nsACString &value)
 
51
{
 
52
   FormatAndPrintOutput("VisitHeader header = ", PromiseFlatCString(header).get(), 1);
 
53
   FormatAndPrintOutput("VisitHeader value = ", PromiseFlatCString(value).get(), 1);
 
54
return NS_OK;
 
55
}
 
56
 
 
57
/////////////////////////////////////////////////////////////////////////////
 
58
// CnsIHttpChannelTests message handlers
 
59
 
 
60
nsIHttpChannel * CnsIHttpChannelTests::GetHttpChannelObject(nsCAutoString theSpec)
 
61
{
 
62
        NS_NewURI(getter_AddRefs(theURI), theSpec);
 
63
        if (!theURI)    
 
64
           QAOutput("Didn't get URI object. Test failed.", 2);
 
65
        NS_NewChannel(getter_AddRefs(theChannel), theURI, nsnull, nsnull);
 
66
        if (!theChannel)
 
67
           QAOutput("Didn't get Channel object. GetChannelObject Test failed.", 2);
 
68
 
 
69
        theHttpChannel = do_QueryInterface(theChannel);
 
70
        if (!theHttpChannel)
 
71
           QAOutput("Didn't get httpChannel object. Test failed.", 2);
 
72
 
 
73
        return theHttpChannel;
 
74
}
 
75
 
 
76
void CnsIHttpChannelTests::OnStartTests(UINT nMenuID)
 
77
{
 
78
        theSpec = "http://www.netscape.com";
 
79
        theHttpChannel = GetHttpChannelObject(theSpec);
 
80
        if (!theHttpChannel)
 
81
        {
 
82
           QAOutput("Didn't get nsIHttpChannel object. Test not run.", 1);
 
83
           return;
 
84
        }
 
85
        switch(nMenuID)
 
86
        {
 
87
                case ID_INTERFACES_NSIHTTPCHANNEL_RUNALLTESTS :
 
88
                        RunAllTests();
 
89
                        break ;
 
90
                case ID_INTERFACES_NSIHTTPCHANNEL_SETREQUESTMETHOD :
 
91
                        SetRequestMethodTest(theHttpChannel, "PUT", 2);
 
92
                        break ;
 
93
                case ID_INTERFACES_NSIHTTPCHANNEL_GETREQUESTMETHOD :
 
94
                        GetRequestMethodTest(theHttpChannel, 2);
 
95
                        break ;
 
96
                case ID_INTERFACES_NSIHTTPCHANNEL_SETREFERRER :
 
97
                        SetReferrerTest(theHttpChannel, "https://www.sun.com", 2);
 
98
                        break ;
 
99
                case ID_INTERFACES_NSIHTTPCHANNEL_GETREFERRER :
 
100
                        GetReferrerTest(theHttpChannel, 2);
 
101
                        break ;
 
102
                case ID_INTERFACES_NSIHTTPCHANNEL_SETREQUESTHEADER :
 
103
                        SetRequestHeaderTest(theHttpChannel, "Content-Type", "text/html", 2);
 
104
                        break ;
 
105
                case ID_INTERFACES_NSIHTTPCHANNEL_GETREQUESTHEADER :
 
106
                        GetRequestHeaderTest(theHttpChannel, "Content-Type", 2);
 
107
                        break ;
 
108
                case ID_INTERFACES_NSIHTTPCHANNEL_VISITREQUESTHEADERS :
 
109
                        VisitRequestHeadersTest(theHttpChannel, 2);
 
110
                        break;
 
111
                case ID_INTERFACES_NSIHTTPCHANNEL_SETALLOWPIPELINING :
 
112
                        SetAllowPipeliningTest(theHttpChannel, PR_FALSE, 2);
 
113
                        break;
 
114
                case ID_INTERFACES_NSIHTTPCHANNEL_GETALLOWPIPELINING :
 
115
                        GetAllowPipeliningTest(theHttpChannel, 2);
 
116
                        break;
 
117
                case ID_INTERFACES_NSIHTTPCHANNEL_SETREDIRECTIONLIMIT :
 
118
                        SetRedirectionLimitTest(theHttpChannel, 100, 2);
 
119
                        break;
 
120
                case ID_INTERFACES_NSIHTTPCHANNEL_GETREDIRECTIONLIMIT :
 
121
                        GetRedirectionLimitTest(theHttpChannel, 2);
 
122
                        break;
 
123
 
 
124
                        // response methods
 
125
 
 
126
                case ID_INTERFACES_NSIHTTPCHANNEL_GETRESPONSESTATUS :
 
127
                        GetResponseStatusTest(theHttpChannel, 2);
 
128
                        break;
 
129
                case ID_INTERFACES_NSIHTTPCHANNEL_GETRESPONSESTATUSTEXT :
 
130
                        GetResponseStatusTextTest(theHttpChannel, 2);
 
131
                        break;
 
132
        }
 
133
}
 
134
 
 
135
void CnsIHttpChannelTests::RunAllTests()
 
136
{
 
137
        theSpec = "http://www.netscape.com";
 
138
        theHttpChannel = GetHttpChannelObject(theSpec);
 
139
        if (!theHttpChannel)
 
140
        {
 
141
           QAOutput("Didn't get nsIHttpChannel object. RunAllTests not run.", 1);
 
142
           return;
 
143
        }
 
144
        QAOutput("   nsIHttpChannel request tests:");
 
145
        SetRequestMethodTest(theHttpChannel, "POST", 1);
 
146
        GetRequestMethodTest(theHttpChannel, 1);
 
147
        SetRequestMethodTest(theHttpChannel, "HEAD", 1);
 
148
        GetRequestMethodTest(theHttpChannel, 1);
 
149
        SetReferrerTest(theHttpChannel, "http://www.cisco.com", 1);
 
150
        GetReferrerTest(theHttpChannel, 1);
 
151
        SetRequestHeaderTest(theHttpChannel, "Cookie", "TheCookie", 1);
 
152
        GetRequestHeaderTest(theHttpChannel, "Cookie", 1);
 
153
        SetRequestHeaderTest(theHttpChannel, "Content-Type", "text/xml", 1);
 
154
        GetRequestHeaderTest(theHttpChannel, "Content-Type", 1);
 
155
        SetRequestHeaderTest(theHttpChannel, "Content-Length", "10000", 1);
 
156
        GetRequestHeaderTest(theHttpChannel, "Content-Length", 1);
 
157
        VisitRequestHeadersTest(theHttpChannel, 1);
 
158
        SetAllowPipeliningTest(theHttpChannel, PR_FALSE, 1);
 
159
        SetAllowPipeliningTest(theHttpChannel, PR_TRUE, 1);
 
160
        GetAllowPipeliningTest(theHttpChannel, 1);
 
161
        SetRedirectionLimitTest(theHttpChannel, 0, 1);
 
162
        SetRedirectionLimitTest(theHttpChannel, 5, 1);
 
163
        GetRedirectionLimitTest(theHttpChannel, 1);
 
164
 
 
165
        // see nsIRequestObserver->OnStartRequest for Successful response tests
 
166
        CnsIChannelTests *channelObj = new CnsIChannelTests(qaWebBrowser, qaBrowserImpl);
 
167
        if (!channelObj)
 
168
        {
 
169
           QAOutput("Didn't get nsIHttpChannel object. GetChannelObject not run.", 1);
 
170
           return;
 
171
        }
 
172
        theChannel = channelObj->GetChannelObject(theSpec);
 
173
        if (!theChannel)
 
174
        {
 
175
           QAOutput("Didn't get nsIChannel object. AsyncOpenTest not run.", 1);
 
176
           return;
 
177
        }
 
178
        channelObj->AsyncOpenTest(theChannel, 1);
 
179
        QAOutput("\n");
 
180
}
 
181
 
 
182
void  CnsIHttpChannelTests::SetRequestMethodTest(nsIHttpChannel *theHttpChannel,
 
183
                                                                                                 const char * requestType,
 
184
                                                                                                 PRInt16 displayMode)
 
185
 
186
        // SetRequestMethod
 
187
        // try "GET", "PUT", "HEAD", or "POST"
 
188
        if (!theHttpChannel)
 
189
        {
 
190
           QAOutput("Didn't get nsIHttpChannel object. SetRequestMethodTest failed.", displayMode);
 
191
           return;
 
192
        }
 
193
        rv = theHttpChannel->SetRequestMethod(nsDependentCString(requestType));
 
194
        RvTestResult(rv, "SetRequestMethod()", displayMode);
 
195
        RvTestResultDlg(rv, "SetRequestMethod() test", true);
 
196
}
 
197
 
 
198
void  CnsIHttpChannelTests::GetRequestMethodTest(nsIHttpChannel *theHttpChannel,
 
199
                                                                                                 PRInt16 displayMode)
 
200
{
 
201
        // GetRequestMethod
 
202
        nsCAutoString method;
 
203
 
 
204
        if (!theHttpChannel)
 
205
        {
 
206
           QAOutput("Didn't get nsIHttpChannel object. GetRequestMethodTest failed.", displayMode);
 
207
           return;
 
208
        }
 
209
        rv = theHttpChannel->GetRequestMethod(method);
 
210
        RvTestResult(rv, "GetRequestMethod()", displayMode);
 
211
        RvTestResultDlg(rv, "GetRequestMethod() test");
 
212
        // if (method.Equals("POST")
 
213
        FormatAndPrintOutput("GetRequestMethod method = ", method, displayMode);
 
214
}
 
215
 
 
216
void CnsIHttpChannelTests::SetReferrerTest(nsIHttpChannel *theHttpChannel,
 
217
                                                                                                 const char *theUrl,
 
218
                                                                                                 PRInt16 displayMode)
 
219
{
 
220
        // SetReferrer
 
221
        nsCAutoString theSpec;
 
222
        theSpec = theUrl;
 
223
 
 
224
        if (!theHttpChannel)
 
225
        {
 
226
           QAOutput("Didn't get nsIHttpChannel object. SetReferrerTest failed.", displayMode);
 
227
           return;
 
228
        }
 
229
        NS_NewURI(getter_AddRefs(theURI), theSpec);
 
230
        if (!theURI)    
 
231
           QAOutput("Didn't get URI object. Test failed.", 2);
 
232
        rv = theHttpChannel->SetReferrer(theURI);
 
233
        RvTestResult(rv, "SetReferrer()", displayMode);
 
234
        RvTestResultDlg(rv, "SetReferrer() test");
 
235
}
 
236
 
 
237
void CnsIHttpChannelTests::GetReferrerTest(nsIHttpChannel *theHttpChannel,
 
238
                                                                                                 PRInt16 displayMode)
 
239
{
 
240
        // GetReferrer
 
241
        nsCAutoString theSpec;
 
242
 
 
243
        if (!theHttpChannel)
 
244
        {
 
245
           QAOutput("Didn't get nsIHttpChannel object. GetReferrerTest failed.", displayMode);
 
246
           return;
 
247
        }
 
248
        rv = theHttpChannel->GetReferrer(getter_AddRefs(theURI));
 
249
        RvTestResult(rv, "GetReferrer()", displayMode);
 
250
        RvTestResultDlg(rv, "GetReferrer() test");
 
251
        if (!theURI)
 
252
           QAOutput("Didn't get nsIURI object. Test failed.", displayMode);
 
253
        else {
 
254
           theURI->GetSpec(theSpec);
 
255
           FormatAndPrintOutput("GetReferrerTest uri = ", theSpec, displayMode);           
 
256
        }
 
257
}
 
258
 
 
259
void  CnsIHttpChannelTests::SetRequestHeaderTest(nsIHttpChannel *theHttpChannel,
 
260
                                                                                                 const char *requestType,
 
261
                                                                                                 const char *headerVal,
 
262
                                                                                                 PRInt16 displayMode)
 
263
{
 
264
        // SetRequestHeader
 
265
        // try {"Content-Type","text/xml"}, {"Content-Length", 10000}, and
 
266
        //     {"Accept"), NS_LITERAL_CSTRING("text/xml,application/xml,application/xhtml+xml,*/*;q=0.1"),
 
267
        if (!theHttpChannel)
 
268
        {
 
269
           QAOutput("Didn't get nsIHttpChannel object. SetRequestHeaderTest failed.", displayMode);
 
270
           return;
 
271
        }
 
272
    rv = theHttpChannel->SetRequestHeader(nsDependentCString(requestType),
 
273
                                         nsDependentCString(headerVal),
 
274
                                         PR_FALSE);
 
275
        RvTestResult(rv, "SetRequestHeader()", displayMode);
 
276
        RvTestResultDlg(rv, "SetRequestHeader() test");
 
277
}
 
278
 
 
279
void  CnsIHttpChannelTests::GetRequestHeaderTest(nsIHttpChannel *theHttpChannel,
 
280
                                                                                                 const char *requestType,
 
281
                                                                                                 PRInt16 displayMode)
 
282
{
 
283
        // GetRequestHeader
 
284
        nsCAutoString header;
 
285
        // could be set to "referrer"
 
286
 
 
287
        if (!theHttpChannel)
 
288
        {
 
289
           QAOutput("Didn't get nsIHttpChannel object. GetRequestHeaderTest failed.", displayMode);
 
290
           return;
 
291
        }
 
292
        rv = theHttpChannel->GetRequestHeader(nsDependentCString(requestType), header);
 
293
        RvTestResult(rv, "GetRequestHeader()", displayMode);
 
294
        RvTestResultDlg(rv, "GetRequestHeader() test");
 
295
        FormatAndPrintOutput("GetRequestHeader type = ", header, displayMode);
 
296
}
 
297
 
 
298
void  CnsIHttpChannelTests::VisitRequestHeadersTest(nsIHttpChannel *theHttpChannel,
 
299
                                                                                                    PRInt16 displayMode)
 
300
{
 
301
        // visitRequestHeaders()
 
302
        if (!theHttpChannel)
 
303
        {
 
304
           QAOutput("Didn't get nsIHttpChannel object. VisitRequestHeadersTest failed.", displayMode);
 
305
           return;
 
306
        }
 
307
        HeaderVisitor *theVisitor = new HeaderVisitor();
 
308
        if (!theVisitor)
 
309
           QAOutput("Didn't get nsIHttpHeaderVisitor object. Test failed.", displayMode);
 
310
 
 
311
        rv = theHttpChannel->VisitRequestHeaders(theVisitor);
 
312
        RvTestResult(rv, "VisitRequestHeaders()", displayMode);
 
313
        RvTestResultDlg(rv, "VisitRequestHeaders() test");
 
314
}
 
315
 
 
316
void  CnsIHttpChannelTests::SetAllowPipeliningTest(nsIHttpChannel *theHttpChannel,
 
317
                                                                                           PRBool mAllowPipelining,
 
318
                                                                                           PRInt16 displayMode)
 
319
{
 
320
        if (!theHttpChannel)
 
321
        {
 
322
           QAOutput("Didn't get nsIHttpChannel object. SetAllowPipeliningTest failed.", displayMode);
 
323
           return;
 
324
        }
 
325
        rv = theHttpChannel->SetAllowPipelining(mAllowPipelining);
 
326
        RvTestResult(rv, "SetAllowPipelining()", displayMode);
 
327
        RvTestResultDlg(rv, "SetAllowPipelining() test");
 
328
        FormatAndPrintOutput("SetAllowPipelining value = ", mAllowPipelining, displayMode);
 
329
 
 
330
        rv = theHttpChannel->GetAllowPipelining(&mAllowPipelining);
 
331
        FormatAndPrintOutput("GetAllowPipelining value = ", mAllowPipelining, displayMode);
 
332
}
 
333
 
 
334
void  CnsIHttpChannelTests::GetAllowPipeliningTest(nsIHttpChannel *theHttpChannel,
 
335
                                                                                                   PRInt16 displayMode)
 
336
{
 
337
        PRBool mAllowPipelining;
 
338
 
 
339
        if (!theHttpChannel)
 
340
        {
 
341
           QAOutput("Didn't get nsIHttpChannel object. GetAllowPipeliningTest failed.", displayMode);
 
342
           return;
 
343
        }
 
344
        rv = theHttpChannel->GetAllowPipelining(&mAllowPipelining);
 
345
        RvTestResult(rv, "GetAllowPipelining()", displayMode);
 
346
        RvTestResultDlg(rv, "GetAllowPipelining() test");
 
347
        FormatAndPrintOutput("GetAllowPipelining value = ", mAllowPipelining, displayMode);
 
348
}
 
349
 
 
350
void  CnsIHttpChannelTests::SetRedirectionLimitTest(nsIHttpChannel *theHttpChannel,
 
351
                                                                                                   PRUint32 mRedirectionLimit,
 
352
                                                                                                   PRInt16 displayMode)
 
353
{
 
354
        if (!theHttpChannel)
 
355
        {
 
356
           QAOutput("Didn't get nsIHttpChannel object. SetRedirectionLimitTest failed.", displayMode);
 
357
           return;
 
358
        }
 
359
        rv = theHttpChannel->SetRedirectionLimit(mRedirectionLimit);
 
360
        RvTestResult(rv, "SetRedirectionLimit()", displayMode);
 
361
        RvTestResultDlg(rv, "SetRedirectionLimit() test");
 
362
}
 
363
 
 
364
void  CnsIHttpChannelTests::GetRedirectionLimitTest(nsIHttpChannel *theHttpChannel,
 
365
                                                                                                    PRInt16 displayMode)
 
366
{
 
367
        PRUint32 mRedirectionLimit;
 
368
 
 
369
        if (!theHttpChannel)
 
370
        {
 
371
           QAOutput("Didn't get nsIHttpChannel object. GetRedirectionLimitTest failed.", displayMode);
 
372
           return;
 
373
        }
 
374
        rv = theHttpChannel->GetRedirectionLimit(&mRedirectionLimit);
 
375
        RvTestResult(rv, "GetRedirectionLimit()", displayMode);
 
376
        RvTestResultDlg(rv, "GetRedirectionLimit() test");
 
377
        FormatAndPrintOutput("GetRedirectionLimit value = ", mRedirectionLimit, displayMode);
 
378
}
 
379
 
 
380
// Response tests
 
381
// called from OnStartRequest
 
382
 
 
383
void CnsIHttpChannelTests::CallResponseTests(nsIHttpChannel *theHttpChannel,
 
384
                                                                                                 PRInt16 displayMode)
 
385
{
 
386
        GetResponseStatusTest(theHttpChannel, displayMode);
 
387
        GetResponseStatusTextTest(theHttpChannel, displayMode);
 
388
        GetRequestSucceededTest(theHttpChannel, displayMode);
 
389
        GetResponseHeaderTest(theHttpChannel, "Set-Cookie", displayMode);
 
390
        SetResponseHeaderTest(theHttpChannel, "Refresh", "1001", PR_TRUE, displayMode);
 
391
        GetResponseHeaderTest(theHttpChannel, "Refresh", displayMode);
 
392
        SetResponseHeaderTest(theHttpChannel, "Set-Cookie", "MyCookie", PR_TRUE, displayMode);
 
393
        GetResponseHeaderTest(theHttpChannel, "Set-Cookie", displayMode);
 
394
        SetResponseHeaderTest(theHttpChannel, "Cache-control", "no-cache", PR_FALSE, displayMode);
 
395
        GetResponseHeaderTest(theHttpChannel, "Cache-control", displayMode);
 
396
        VisitResponseHeaderTest(theHttpChannel, displayMode);
 
397
        IsNoStoreResponseTest(theHttpChannel, displayMode);
 
398
        IsNoCacheResponseTest(theHttpChannel, displayMode);
 
399
}
 
400
 
 
401
void CnsIHttpChannelTests::GetResponseStatusTest(nsIHttpChannel *theHttpChannel,
 
402
                                                                                                 PRInt16 displayMode)
 
403
{
 
404
        PRUint32 mResponseStatus;
 
405
 
 
406
        if (!theHttpChannel)
 
407
        {
 
408
           QAOutput("Didn't get nsIHttpChannel object. GetResponseStatusTest failed.", displayMode);
 
409
           return;
 
410
        }
 
411
        rv = theHttpChannel->GetResponseStatus(&mResponseStatus);
 
412
        RvTestResult(rv, "GetResponseStatus()", displayMode);
 
413
        FormatAndPrintOutput("GetResponseStatus value = ", mResponseStatus, displayMode);
 
414
}
 
415
 
 
416
void CnsIHttpChannelTests::GetResponseStatusTextTest(nsIHttpChannel *theHttpChannel,
 
417
                                                                                                 PRInt16 displayMode)
 
418
{
 
419
        nsCAutoString mText;
 
420
 
 
421
        if (!theHttpChannel)
 
422
        {
 
423
           QAOutput("Didn't get nsIHttpChannel object. GetResponseStatusTextTest failed.", displayMode);
 
424
           return;
 
425
        }
 
426
        rv = theHttpChannel->GetResponseStatusText(mText);
 
427
        RvTestResult(rv, "GetResponseStatusText()", displayMode);
 
428
        FormatAndPrintOutput("GetResponseStatusText = ", mText, displayMode);
 
429
}
 
430
 
 
431
 
 
432
void CnsIHttpChannelTests::GetRequestSucceededTest(nsIHttpChannel *theHttpChannel,
 
433
                                                                                                 PRInt16 displayMode)
 
434
{
 
435
        PRBool mRequest;
 
436
 
 
437
        if (!theHttpChannel)
 
438
        {
 
439
           QAOutput("Didn't get nsIHttpChannel object. GetRequestSucceededTest failed.", displayMode);
 
440
           return;
 
441
        }
 
442
        rv = theHttpChannel->GetRequestSucceeded(&mRequest);
 
443
        RvTestResult(rv, "GetRequestSucceeded()", displayMode);
 
444
        FormatAndPrintOutput("GetRequestSucceeded = ", mRequest, displayMode);
 
445
}
 
446
 
 
447
void CnsIHttpChannelTests::GetResponseHeaderTest(nsIHttpChannel *theHttpChannel,
 
448
                                                                                                 const char * responseType,
 
449
                                                                                                 PRInt16 displayMode)
 
450
{
 
451
        nsCAutoString mResponse;
 
452
 
 
453
        if (!theHttpChannel)
 
454
        {
 
455
           QAOutput("Didn't get nsIHttpChannel object. GetResponseHeaderTest failed.", displayMode);
 
456
           return;
 
457
        }
 
458
        rv = theHttpChannel->GetResponseHeader(nsDependentCString(responseType), mResponse);
 
459
        RvTestResult(rv, "GetResponseHeader()", displayMode);
 
460
        FormatAndPrintOutput("GetResponseHeader = ", mResponse, displayMode);
 
461
        FormatAndPrintOutput("GetResponseHeader response type = ", responseType, displayMode);
 
462
}
 
463
 
 
464
void CnsIHttpChannelTests::SetResponseHeaderTest(nsIHttpChannel *theHttpChannel,
 
465
                                                                                                 const char * responseType,
 
466
                                                                                                 const char * value,
 
467
                                                                                                 PRBool merge, PRInt16 displayMode)
 
468
{
 
469
        if (!theHttpChannel)
 
470
        {
 
471
           QAOutput("Didn't get nsIHttpChannel object. SetResponseHeaderTest failed.", displayMode);
 
472
           return;
 
473
        }
 
474
        rv = theHttpChannel->SetResponseHeader(nsDependentCString(responseType),
 
475
                                           nsDependentCString(value), merge);
 
476
        RvTestResult(rv, "SetResponseHeader()", displayMode);
 
477
        FormatAndPrintOutput("SetResponseHeader value = ", value, displayMode);
 
478
        FormatAndPrintOutput("SetResponseHeader response type = ", responseType, displayMode);
 
479
}
 
480
 
 
481
void CnsIHttpChannelTests::VisitResponseHeaderTest(nsIHttpChannel *theHttpChannel,
 
482
                                                                                                   PRInt16 displayMode)
 
483
{
 
484
        if (!theHttpChannel)
 
485
        {
 
486
           QAOutput("Didn't get nsIHttpChannel object. VisitResponseHeaderTest failed.", displayMode);
 
487
           return;
 
488
        }
 
489
        // visitResponseHeaders()
 
490
        HeaderVisitor *theVisitor = new HeaderVisitor();
 
491
        if (!theVisitor)
 
492
           QAOutput("Didn't get nsIHttpHeaderVisitor object. Test failed.", displayMode);
 
493
 
 
494
        rv = theHttpChannel->VisitResponseHeaders(theVisitor);
 
495
        RvTestResult(rv, "VisitResponseHeaders()", displayMode);
 
496
}
 
497
 
 
498
void CnsIHttpChannelTests::IsNoStoreResponseTest(nsIHttpChannel *theHttpChannel,
 
499
                                                                                                 PRInt16 displayMode)
 
500
{
 
501
        PRBool mNoResponse;
 
502
 
 
503
        if (!theHttpChannel)
 
504
        {
 
505
           QAOutput("Didn't get nsIHttpChannel object. IsNoStoreResponseTest failed.", displayMode);
 
506
           return;
 
507
        }
 
508
        rv = theHttpChannel->IsNoStoreResponse(&mNoResponse);
 
509
        RvTestResult(rv, "IsNoStoreResponse()", displayMode);
 
510
        FormatAndPrintOutput("IsNoStoreResponse = ", mNoResponse, displayMode);
 
511
}
 
512
 
 
513
void CnsIHttpChannelTests::IsNoCacheResponseTest(nsIHttpChannel *theHttpChannel,
 
514
                                                                                                 PRInt16 displayMode)
 
515
{
 
516
        PRBool mNoResponse;
 
517
 
 
518
        if (!theHttpChannel)
 
519
        {
 
520
           QAOutput("Didn't get nsIHttpChannel object. IsNoCacheResponseTest failed.", displayMode);
 
521
           return;
 
522
        }
 
523
        rv = theHttpChannel->IsNoCacheResponse(&mNoResponse);
 
524
        RvTestResult(rv, "IsNoCacheResponse()", displayMode);
 
525
        FormatAndPrintOutput("IsNoCacheResponse = ", mNoResponse, displayMode);
 
526
}
 
 
b'\\ No newline at end of file'