Added VisitRequestHeaders and VisitResponseHeaders for nsiHttpChannel tests.

Added in support for Tooltip Listener. not part of the build.
This commit is contained in:
depstein%netscape.com 2003-01-24 03:56:31 +00:00
Родитель 867179e41d
Коммит 3ad37f6995
15 изменённых файлов: 320 добавлений и 4 удалений

Просмотреть файл

@ -411,3 +411,17 @@ HWND CBrowserFrame::BrowserFrameGlueObj::GetBrowserFrameNativeWnd()
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
return pThis->m_hWnd;
}
void CBrowserFrame::BrowserFrameGlueObj::ShowTooltip(PRInt32 aXCoords, PRInt32 aYCoords, const PRUnichar *aTipText)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
pThis->m_wndTooltip.SetTipText(CString(aTipText));
pThis->m_wndTooltip.Show(&pThis->m_wndBrowserView, aXCoords, aYCoords);
}
void CBrowserFrame::BrowserFrameGlueObj::HideTooltip()
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
pThis->m_wndTooltip.Hide();
}

Просмотреть файл

@ -215,6 +215,11 @@ int CBrowserFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
return -1; // fail to create
}
// The third pane(i.e. at index 2) of the status bar will have
// the security lock icon displayed in it. Set up it's size(16)
// and style(no border)so that the padlock icons can be properly drawn
// m_wndStatusBar.SetPaneInfo(2, -1, SBPS_NORMAL|SBPS_NOBORDERS, 16);
// Based on the "chromeMask" we were supplied during construction
// hide any requested UI elements - statusbar, menubar etc...
// Note that the window styles (WM_RESIZE etc) are set inside

Просмотреть файл

@ -49,6 +49,7 @@
#endif // _MSC_VER > 1000
#include "BrowserView.h"
#include "BrowserToolTip.h"
#include "IBrowserFrameGlue.h"
#include "MostRecentUrls.h"
@ -138,6 +139,7 @@ public:
CReBar m_wndReBar;
// The view inside which the embedded browser will
// be displayed in
CBrowserToolTip m_wndTooltip;
CBrowserView m_wndBrowserView;
// Wrapper functions for UrlBar clipboard operations

Просмотреть файл

@ -597,6 +597,11 @@ NS_IMETHODIMP CBrowserImpl::OnStopRequest(nsIRequest *request,
NS_IMETHODIMP CBrowserImpl::OnShowTooltip(PRInt32 aXCoords, PRInt32 aYCoords,
const PRUnichar *aTipText)
{
if(! m_pBrowserFrameGlue)
return NS_ERROR_FAILURE;
m_pBrowserFrameGlue->ShowTooltip(aXCoords, aYCoords, aTipText);
QAOutput("nsITooltipListener->OnShowTooltip()",1);
FormatAndPrintOutput("OnShowTooltip() aXCoords = ", aXCoords, 1);
FormatAndPrintOutput("OnShowTooltip() aYCoords = ", aYCoords, 1);
@ -606,6 +611,10 @@ NS_IMETHODIMP CBrowserImpl::OnShowTooltip(PRInt32 aXCoords, PRInt32 aYCoords,
NS_IMETHODIMP CBrowserImpl::OnHideTooltip()
{
if(! m_pBrowserFrameGlue)
return NS_ERROR_FAILURE;
m_pBrowserFrameGlue->HideTooltip();
QAOutput("nsITooltipListener->OnHideTooltip()",1);
return NS_OK;
}

Просмотреть файл

@ -0,0 +1,145 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: Mozilla-sample-code 1.0
*
* Copyright (c) 2002 Netscape Communications Corporation and
* other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this Mozilla sample software and associated documentation files
* (the "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to permit
* persons to whom the Software is furnished to do so, subject to the
* following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* Contributor(s):
* Adam Lock <adamlock@netscape.com>
*
* ***** END LICENSE BLOCK ***** */
#include "stdafx.h"
#include "BrowserToolTip.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CBrowserToolTip
CBrowserToolTip::CBrowserToolTip()
{
}
CBrowserToolTip::~CBrowserToolTip()
{
}
BEGIN_MESSAGE_MAP(CBrowserToolTip, CWnd)
//{{AFX_MSG_MAP(CBrowserToolTip)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
BOOL CBrowserToolTip::Create(CWnd *pParentWnd)
{
return CWnd::CreateEx(WS_EX_TOOLWINDOW,
AfxRegisterWndClass(CS_SAVEBITS, NULL, GetSysColorBrush(COLOR_INFOBK), NULL),
_T("ToolTip"), WS_POPUP | WS_BORDER, 0, 0, 1, 1, pParentWnd->GetSafeHwnd(), NULL);
}
/////////////////////////////////////////////////////////////////////////////
// CBrowserToolTip message handlers
void CBrowserToolTip::OnPaint()
{
CPaintDC dc(this); // device context for painting
CRect rcClient;
GetClientRect(&rcClient);
// Draw tip text
int oldBkMode = dc.SetBkMode(TRANSPARENT);
COLORREF oldTextColor = dc.SetTextColor(GetSysColor(COLOR_INFOTEXT));
HGDIOBJ oldFont = dc.SelectObject(GetStockObject(DEFAULT_GUI_FONT));
dc.DrawText(m_szTipText, -1, rcClient, DT_SINGLELINE | DT_VCENTER | DT_CENTER);
dc.SetBkMode(oldBkMode);
dc.SetTextColor(oldTextColor);
dc.SelectObject(oldFont);
}
BOOL CBrowserToolTip::PreCreateWindow(CREATESTRUCT& cs)
{
return CWnd::PreCreateWindow(cs);
}
void CBrowserToolTip::SetTipText(const CString &szTipText)
{
m_szTipText = szTipText;
}
void CBrowserToolTip::Show(CWnd *pOverWnd, long left, long top)
{
// Calculate the client window size
CRect rcNewClient(0,0,0,0);
CDC *pdc = GetDC();
HGDIOBJ oldFont = pdc->SelectObject(GetStockObject(DEFAULT_GUI_FONT));
rcNewClient.bottom = pdc->DrawText(m_szTipText, -1, rcNewClient,
DT_SINGLELINE | DT_VCENTER | DT_CENTER | DT_CALCRECT);
pdc->SelectObject(oldFont);
ReleaseDC(pdc);
rcNewClient.right += 8;
rcNewClient.bottom += 8;
// Adjust the tooltip to new size
AdjustWindowRectEx(rcNewClient, GetWindowLong(m_hWnd, GWL_STYLE), FALSE, GetWindowLong(m_hWnd, GWL_EXSTYLE));
// Adjust the left, top position of the tooltip
CPoint ptTip(left, top);
pOverWnd->ClientToScreen(&ptTip);
// Make sure tip is below cursor
POINT ptCursor;
GetCursorPos(&ptCursor);
long cyCursor = GetSystemMetrics(SM_CYCURSOR);
if (ptTip.y < ptCursor.y + cyCursor)
ptTip.y = ptCursor.y + cyCursor;
// Make sure tip is fully visible
RECT rcScreen;
GetDesktopWindow()->GetClientRect(&rcScreen);
if (ptTip.x < 0)
ptTip.x = 0;
else if (ptTip.x + rcNewClient.Width() > rcScreen.right)
ptTip.x = rcScreen.right - rcNewClient.Width();
if (ptTip.y < 0)
ptTip.y = 0;
else if (ptTip.y + rcNewClient.Height() > rcScreen.bottom)
ptTip.y = rcScreen.bottom - rcNewClient.Height();
// Position and show the tip
SetWindowPos(&CWnd::wndTop, ptTip.x, ptTip.y, rcNewClient.Width(), rcNewClient.Height(),
SWP_NOACTIVATE | SWP_SHOWWINDOW);
}
void CBrowserToolTip::Hide()
{
ShowWindow(SW_HIDE);
}

Просмотреть файл

@ -0,0 +1,86 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: Mozilla-sample-code 1.0
*
* Copyright (c) 2002 Netscape Communications Corporation and
* other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this Mozilla sample software and associated documentation files
* (the "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to permit
* persons to whom the Software is furnished to do so, subject to the
* following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* Contributor(s):
* Adam Lock <adamlock@netscape.com>
*
* ***** END LICENSE BLOCK ***** */
#if !defined(AFX_BROWSERTOOLTIP_H__13240069_1816_403C_A79D_306FD710B75A__INCLUDED_)
#define AFX_BROWSERTOOLTIP_H__13240069_1816_403C_A79D_306FD710B75A__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// BrowserToolTip.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CBrowserToolTip window
class CBrowserToolTip : public CWnd
{
// Construction
public:
CBrowserToolTip();
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CBrowserToolTip)
protected:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
//}}AFX_VIRTUAL
CString m_szTipText;
// Implementation
public:
virtual ~CBrowserToolTip();
BOOL Create(CWnd *pParentWnd);
void SetTipText(const CString &szTipText);
void Show(CWnd *pOverWnd, long left, long top);
void Hide();
// Generated message map functions
protected:
//{{AFX_MSG(CBrowserToolTip)
afx_msg void OnPaint();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_BROWSERTOOLTIP_H__13240069_1816_403C_A79D_306FD710B75A__INCLUDED_)

Просмотреть файл

@ -81,6 +81,10 @@ struct IBrowserFrameGlue {
// ContextMenu Related Methods
virtual void ShowContextMenu(PRUint32 aContextFlags, nsIDOMNode *aNode) = 0;
// Tooltip methods
virtual void ShowTooltip(PRInt32 aXCoords, PRInt32 aYCoords, const PRUnichar *aTipText) = 0;
virtual void HideTooltip() = 0;
virtual HWND GetBrowserFrameNativeWnd() = 0;
};
@ -105,8 +109,9 @@ struct IBrowserFrameGlue {
virtual void FocusAvailable(PRBool *aFocusAvail); \
virtual void GetBrowserFrameVisibility(PRBool *aVisible); \
virtual void ShowContextMenu(PRUint32 aContextFlags, nsIDOMNode *aNode); \
virtual HWND GetBrowserFrameNativeWnd();
virtual void ShowTooltip(PRInt32 aXCoords, PRInt32 aYCoords, const PRUnichar *aTipText); \
virtual void HideTooltip(); \
virtual HWND GetBrowserFrameNativeWnd();
typedef IBrowserFrameGlue *PBROWSERFRAMEGLUE;
#endif //_IBROWSERFRAMEGLUE_H

Просмотреть файл

@ -76,6 +76,7 @@ CPPSRCS = \
TestEmbed.cpp \
BrowserFrm.cpp \
BrowserFrameGlue.cpp \
BrowserToolTip.cpp \
BrowserView.cpp \
BrowserImpl.cpp \
BrowserImplWebPrgrsLstnr.cpp \

Просмотреть файл

@ -93,6 +93,7 @@ BEGIN_MESSAGE_MAP(CTests, CWnd)
ON_COMMAND(ID_TESTS_GLOBALHISTORY, OnTestsGlobalHistory)
ON_COMMAND(ID_TESTS_CREATEFILE, OnTestsCreateFile)
ON_COMMAND(ID_TESTS_CREATEPROFILE, OnTestsCreateprofile)
ON_COMMAND(ID_TESTS_ADDTOOLTIPLISTENER, OnTestsAddTooltipListener)
ON_COMMAND(ID_TESTS_ADDWEBPROGLISTENER, OnTestsAddWebProgListener)
ON_COMMAND(ID_TESTS_ADDHISTORYLISTENER, OnTestsAddHistoryListener)
ON_COMMAND(ID_TESTS_REMOVEHISTORYLISTENER, OnTestsRemovehistorylistener)
@ -481,6 +482,17 @@ void CTests::OnTestsCreateprofile()
// *********************************************************
void CTests::OnTestsAddTooltipListener()
{
nsWeakPtr weakling(
dont_AddRef(NS_GetWeakReference(NS_STATIC_CAST(nsITooltipListener*, qaBrowserImpl))));
rv = qaWebBrowser->AddWebBrowserListener(weakling, NS_GET_IID(nsITooltipListener));
RvTestResult(rv, "AddWebBrowserListener(). Add Tooltip Listener test", 2);
}
// *********************************************************
void CTests::OnTestsAddWebProgListener()
{
nsWeakPtr weakling(

Просмотреть файл

@ -108,6 +108,7 @@ protected:
afx_msg void OnTestsGlobalHistory();
afx_msg void OnTestsCreateFile();
afx_msg void OnTestsCreateprofile();
afx_msg void OnTestsAddTooltipListener();
afx_msg void OnTestsAddWebProgListener();
afx_msg void OnTestsAddHistoryListener();
afx_msg void OnTestsRemovehistorylistener();

Просмотреть файл

@ -12,6 +12,7 @@
#include "QaUtils.h"
#include "Tests.h"
#include "nsichanneltests.h"
#include "nsIHttpHeaderVisitor.h"
#ifdef _DEBUG
#define new DEBUG_NEW
@ -33,6 +34,25 @@ CnsIHttpChannelTests::~CnsIHttpChannelTests()
{
}
class HeaderVisitor : public nsIHttpHeaderVisitor
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIHTTPHEADERVISITOR
HeaderVisitor() { }
virtual ~HeaderVisitor() {}
};
NS_IMPL_ISUPPORTS1(HeaderVisitor, nsIHttpHeaderVisitor)
NS_IMETHODIMP
HeaderVisitor::VisitHeader(const nsACString &header, const nsACString &value)
{
FormatAndPrintOutput("VisitHeader header = ", PromiseFlatCString(header).get(), 1);
FormatAndPrintOutput("VisitHeader value = ", PromiseFlatCString(value).get(), 1);
return NS_OK;
}
/////////////////////////////////////////////////////////////////////////////
// CnsIHttpChannelTests message handlers
@ -237,7 +257,7 @@ void CnsIHttpChannelTests::VisitRequestHeadersTest(nsIHttpChannel *theHttpChann
PRInt16 displayMode)
{
// visitRequestHeaders()
nsCOMPtr<nsIHttpHeaderVisitor> theVisitor;
HeaderVisitor *theVisitor = new HeaderVisitor();
if (!theVisitor)
QAOutput("Didn't get nsIHttpHeaderVisitor object. Test failed.", displayMode);
@ -306,6 +326,7 @@ void CnsIHttpChannelTests::CallResponseTests(nsIHttpChannel *theHttpChannel,
GetResponseHeaderTest(theHttpChannel, "Set-Cookie", displayMode);
SetResponseHeaderTest(theHttpChannel, "Cache-control", "no-cache", PR_FALSE, displayMode);
GetResponseHeaderTest(theHttpChannel, "Cache-control", displayMode);
VisitResponseHeaderTest(theHttpChannel, displayMode);
IsNoStoreResponseTest(theHttpChannel, displayMode);
IsNoCacheResponseTest(theHttpChannel, displayMode);
}
@ -365,6 +386,18 @@ void CnsIHttpChannelTests::SetResponseHeaderTest(nsIHttpChannel *theHttpChannel,
FormatAndPrintOutput("SetResponseHeader response type = ", responseType, displayMode);
}
void CnsIHttpChannelTests::VisitResponseHeaderTest(nsIHttpChannel *theHttpChannel,
PRInt16 displayMode)
{
// visitResponseHeaders()
HeaderVisitor *theVisitor = new HeaderVisitor();
if (!theVisitor)
QAOutput("Didn't get nsIHttpHeaderVisitor object. Test failed.", displayMode);
rv = theHttpChannel->VisitResponseHeaders(theVisitor);
RvTestResult(rv, "VisitResponseHeaders()", displayMode);
}
void CnsIHttpChannelTests::IsNoStoreResponseTest(nsIHttpChannel *theHttpChannel,
PRInt16 displayMode)
{

Просмотреть файл

@ -42,6 +42,7 @@ public:
void GetRequestSucceededTest(nsIHttpChannel *, PRInt16);
void GetResponseHeaderTest(nsIHttpChannel *, const char *, PRInt16);
void SetResponseHeaderTest(nsIHttpChannel *, const char *, const char *, PRBool, PRInt16);
void VisitResponseHeaderTest(nsIHttpChannel *, PRInt16);
void IsNoStoreResponseTest(nsIHttpChannel *, PRInt16);
void IsNoCacheResponseTest(nsIHttpChannel *, PRInt16);
public:

Просмотреть файл

@ -306,6 +306,7 @@
#define ID_INTERFACES_NSIHTTPCHANNEL_GETREDIRECTIONLIMIT 33043
#define ID_INTERFACES_NSIHTTPCHANNEL_GETRESPONSESTATUS 33044
#define ID_INTERFACES_NSIHTTPCHANNEL_GETRESPONSESTATUSTEXT 33045
#define ID_TESTS_ADDTOOLTIPLISTENER 33046
#define ID_CLIPBOARDCMD_PASTE 42789
#define ID_CLIPBOARDCMD_COPYSELECTION 42790
#define ID_CLIPBOARDCMD_SELECTALL 42791
@ -322,7 +323,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_3D_CONTROLS 1
#define _APS_NEXT_RESOURCE_VALUE 153
#define _APS_NEXT_COMMAND_VALUE 33046
#define _APS_NEXT_COMMAND_VALUE 33047
#define _APS_NEXT_CONTROL_VALUE 1033
#define _APS_NEXT_SYMED_VALUE 101
#endif

Двоичные данные
embedding/qa/testembed/testembed.aps

Двоичный файл не отображается.

Просмотреть файл

@ -151,6 +151,7 @@ BEGIN
MENUITEM "&Global &History", ID_TESTS_GLOBALHISTORY
MENUITEM "Create &File", ID_TESTS_CREATEFILE
MENUITEM "Create/Switch &Profile", ID_TESTS_CREATEPROFILE
MENUITEM "Add Tooltip Listener", ID_TESTS_ADDTOOLTIPLISTENER
MENUITEM "&Add Web Prog Listener", ID_TESTS_ADDWEBPROGLISTENER
MENUITEM SEPARATOR
MENUITEM "Add History &Listener", ID_TESTS_ADDHISTORYLISTENER