From 1d8f1eb68d63371066377b7ecaa81380322bef0a Mon Sep 17 00:00:00 2001 From: "depstein%netscape.com" Date: Tue, 5 Nov 2002 04:19:33 +0000 Subject: [PATCH] Some additional error checking for observer service. Direct rv results to screen dialog for nsIEditingSession tests. Not part of the build. --- embedding/qa/testembed/nsIEditSession.cpp | 62 ++++++++++++++--------- embedding/qa/testembed/nsIEditSession.h | 12 ++--- embedding/qa/testembed/nsIObserServ.cpp | 11 ++++ 3 files changed, 54 insertions(+), 31 deletions(-) diff --git a/embedding/qa/testembed/nsIEditSession.cpp b/embedding/qa/testembed/nsIEditSession.cpp index 5c79e10b2d2..6eebfbfc472 100644 --- a/embedding/qa/testembed/nsIEditSession.cpp +++ b/embedding/qa/testembed/nsIEditSession.cpp @@ -81,45 +81,51 @@ nsIEditingSession * CnsIEditSession::GetEditSessionObject() return (editingSession); } -void CnsIEditSession::InitTest() +void CnsIEditSession::InitTest(PRInt16 displayMode) { editingSession = GetEditSessionObject(); domWindow = GetTheDOMWindow(qaWebBrowser); if (domWindow && editingSession) { rv = editingSession->Init(domWindow); - RvTestResult(rv, "Init() test", 2); + RvTestResult(rv, "Init() test", displayMode); + if (displayMode == 1) + RvTestResultDlg(rv, "Init() test", true); } else QAOutput("Didn't get object(s) for InitTest() test. Test failed.", 1); } -void CnsIEditSession::MakeWinEditTest(PRBool afterUriLoad) +void CnsIEditSession::MakeWinEditTest(PRBool afterUriLoad, PRInt16 displayMode) { editingSession = GetEditSessionObject(); domWindow = GetTheDOMWindow(qaWebBrowser); if (domWindow && editingSession) { // aEditorType (2nd param) is crashing with null entry. bug 174151 rv= editingSession->MakeWindowEditable(domWindow, "text", afterUriLoad); - RvTestResult(rv, "MakeWindowEditable() test", 2); + RvTestResult(rv, "MakeWindowEditable() test", displayMode); + if (displayMode == 1) + RvTestResultDlg(rv, "MakeWindowEditable() test"); } else QAOutput("Didn't get object(s) for MakeWindowEditable() test. Test failed.", 1); } -void CnsIEditSession::WinIsEditTest(PRBool outIsEditable) +void CnsIEditSession::WinIsEditTest(PRBool outIsEditable, PRInt16 displayMode) { editingSession = GetEditSessionObject(); domWindow = GetTheDOMWindow(qaWebBrowser); if (domWindow && editingSession) { rv = editingSession->WindowIsEditable(domWindow, &outIsEditable); - RvTestResult(rv, "WindowIsEditable() test", 2); - FormatAndPrintOutput("the outIsEditable boolean = ", outIsEditable, 2); + RvTestResult(rv, "WindowIsEditable() test", displayMode); + if (displayMode == 1) + RvTestResultDlg(rv, "WindowIsEditable() test"); + FormatAndPrintOutput("the outIsEditable boolean = ", outIsEditable, displayMode); } else QAOutput("Didn't get object(s) for WinIsEditTest() test. Test failed.", 1); } -void CnsIEditSession::GetEditorWinTest() +void CnsIEditSession::GetEditorWinTest(PRInt16 displayMode) { nsCOMPtr theEditor; // nsIEditor *theEditor = nsnull; @@ -127,7 +133,9 @@ void CnsIEditSession::GetEditorWinTest() domWindow = GetTheDOMWindow(qaWebBrowser); if (domWindow && editingSession) { rv = editingSession->GetEditorForWindow(domWindow, getter_AddRefs(theEditor)); - RvTestResult(rv, "GetEditorForWindow() test", 2); + RvTestResult(rv, "GetEditorForWindow() test", displayMode); + if (displayMode == 1) + RvTestResultDlg(rv, "GetEditorForWindow() test"); if (!theEditor) QAOutput("Didn't get the Editor object."); } @@ -135,25 +143,29 @@ void CnsIEditSession::GetEditorWinTest() QAOutput("Didn't get object(s) for WinIsEditTest() test. Test failed.", 1); } -void CnsIEditSession::SetEditorWinTest() +void CnsIEditSession::SetEditorWinTest(PRInt16 displayMode) { editingSession = GetEditSessionObject(); domWindow = GetTheDOMWindow(qaWebBrowser); if (domWindow && editingSession) { rv = editingSession->SetupEditorOnWindow(domWindow); - RvTestResult(rv, "SetupEditorOnWindow() test", 2); + RvTestResult(rv, "SetupEditorOnWindow() test", displayMode); + if (displayMode == 1) + RvTestResultDlg(rv, "SetupEditorOnWindow() test"); } else QAOutput("Didn't get object(s) for SetEditorWinTest() test. Test failed.", 1); } -void CnsIEditSession::TearEditorWinTest() +void CnsIEditSession::TearEditorWinTest(PRInt16 displayMode) { editingSession = GetEditSessionObject(); domWindow = GetTheDOMWindow(qaWebBrowser); if (domWindow && editingSession) { rv = editingSession->TearDownEditorOnWindow(domWindow); - RvTestResult(rv, "TearDownEditorOnWindow() test", 2); + RvTestResult(rv, "TearDownEditorOnWindow() test", displayMode); + if (displayMode == 1) + RvTestResultDlg(rv, "TearDownEditorOnWindow() test"); } else QAOutput("Didn't get object(s) for TearEditorWinTest() test. Test failed.", 1); @@ -167,34 +179,34 @@ void CnsIEditSession::OnStartTests(UINT nMenuID) RunAllTests(); break; case ID_INTERFACES_NSIEDITINGSESSION_INIT : - InitTest(); + InitTest(2); break; case ID_INTERFACES_NSIEDITINGSESSION_MAKEWINDOWEDITABLE : - MakeWinEditTest(PR_FALSE); + MakeWinEditTest(PR_FALSE, 2); break; case ID_INTERFACES_NSIEDITINGSESSION_WINDOWISEDITABLE : - WinIsEditTest(PR_TRUE); + WinIsEditTest(PR_TRUE, 2); break; case ID_INTERFACES_NSIEDITINGSESSION_GETEDITORFORWINDOW : - GetEditorWinTest(); + GetEditorWinTest(2); break; case ID_INTERFACES_NSIEDITINGSESSION_SETUPEDITORONWINDOW : - SetEditorWinTest(); + SetEditorWinTest(2); break; case ID_INTERFACES_NSIEDITINGSESSION_TEARDOWNEDITORONWINDOW : - TearEditorWinTest(); + TearEditorWinTest(2); break; } } void CnsIEditSession::RunAllTests() { - InitTest(); - MakeWinEditTest(PR_FALSE); - WinIsEditTest(PR_TRUE); - GetEditorWinTest(); -// SetEditorWinTest(); - TearEditorWinTest(); + InitTest(1); + MakeWinEditTest(PR_FALSE, 1); + WinIsEditTest(PR_TRUE, 1); + GetEditorWinTest(1); +// SetEditorWinTest(1); + TearEditorWinTest(1); } ///////////////////////////////////////////////////////////////////////////// diff --git a/embedding/qa/testembed/nsIEditSession.h b/embedding/qa/testembed/nsIEditSession.h index 1f7c2ff274b..2ec1d412b81 100644 --- a/embedding/qa/testembed/nsIEditSession.h +++ b/embedding/qa/testembed/nsIEditSession.h @@ -83,12 +83,12 @@ public: // local methods for nsIEditingSession tests nsIEditingSession * GetEditSessionObject(); - void InitTest(void); - void MakeWinEditTest(PRBool); - void WinIsEditTest(PRBool); - void SetEditorWinTest(void); - void GetEditorWinTest(void); - void TearEditorWinTest(void); + void InitTest(PRInt16); + void MakeWinEditTest(PRBool, PRInt16); + void WinIsEditTest(PRBool, PRInt16); + void SetEditorWinTest(PRInt16); + void GetEditorWinTest(PRInt16); + void TearEditorWinTest(PRInt16); void OnStartTests(UINT nMenuID); void RunAllTests(void); diff --git a/embedding/qa/testembed/nsIObserServ.cpp b/embedding/qa/testembed/nsIObserServ.cpp index 43a4229e5b4..fdbccfeffca 100644 --- a/embedding/qa/testembed/nsIObserServ.cpp +++ b/embedding/qa/testembed/nsIObserServ.cpp @@ -177,6 +177,12 @@ void CnsIObserServ::NotifyObserversTest(int displayType) QAOutput("\n nsIObserverService::NotifyObserversTest()."); + if (!observerService) + { + QAOutput("Can't get nsIObserverService object. Tests fail."); + return; + } + for (i=0; i<10; i++) { FormatAndPrintOutput("The notified observer = ", ObserverTable[i].theTopic, 1); @@ -223,6 +229,11 @@ void CnsIObserServ::EnumerateObserversTest(int displayType) { simpleEnum->GetNext(getter_AddRefs(observer)); + if (!observer) + { + QAOutput("Didn't get the observer object. Tests fail."); + return; + } rv = observer->Observe(observer, ObserverTable[i].theTopic, 0); RvTestResult(rv, "nsIObserver() test", 1); RvTestResultDlg(rv, "nsIObserver() test");