From 3f92f3951e51dd5be503b1e4eb15d692df986556 Mon Sep 17 00:00:00 2001 From: "sspitzer%netscape.com" Date: Tue, 4 May 1999 03:03:29 +0000 Subject: [PATCH] extend the parser test to add two headers to a public newsgroup --- .../news/tests/newsParser/newsParserTest.cpp | 70 ++++++++++++------- 1 file changed, 44 insertions(+), 26 deletions(-) diff --git a/mailnews/news/tests/newsParser/newsParserTest.cpp b/mailnews/news/tests/newsParser/newsParserTest.cpp index e3674c4569d9..875703b88fda 100644 --- a/mailnews/news/tests/newsParser/newsParserTest.cpp +++ b/mailnews/news/tests/newsParser/newsParserTest.cpp @@ -57,7 +57,7 @@ #define NETLIB_DLL "libnetlib.so" #define XPCOM_DLL "libxpcom.so" #define PREF_DLL "libpref.so" -#define APPCORES_DLL "libappcores.so" +//#define APPCORES_DLL "libappcores.so" #define APPSHELL_DLL "libnsappshell.so" #endif #endif @@ -74,6 +74,7 @@ public: nsresult RunDriver(); nsresult GetDatabase(); nsresult GetPath(const char *uri, nsFileSpec& aPathName); + nsresult AddNewHeader(const char *subject, const char *author, const char *id, PRUint32 key); protected: nsIMsgDatabase *m_newsDB; @@ -101,38 +102,23 @@ nsresult newsTestDriver::RunDriver() rv = GetDatabase(); if (NS_SUCCEEDED(rv) && m_newsDB) { - nsIMsgDBHdr *newMsgHdr = nsnull; - - m_newsDB->CreateNewHdr(1, &newMsgHdr); + rv = AddNewHeader("praising with faint damnation","David McCusker ","372A0615.F03C44C2@netscape.com", 0); if (NS_FAILED(rv)) { -#ifdef DEBUG - printf("m_newsDB->CreateNewHdr() failed\n"); -#endif return rv; } - newMsgHdr->SetSubject("RedHat 6.0 available"); - newMsgHdr->SetFlags(MSG_FLAG_READ); - newMsgHdr->SetAuthor("ramiro@netscape.com (Ramiro Estrugo)"); - newMsgHdr->SetMessageId("<37295058.FED53E36@netscape.com>"); + rv = AddNewHeader("help running M5", "Steve Clark ", "372A8676.59838C76@netscape.com", 1); - rv = m_newsDB->AddNewHdrToDB(newMsgHdr, PR_TRUE); if (NS_FAILED(rv)) { -#ifdef DEBUG - printf("m_newsDB->AddNewHdrToDB() failed\n"); -#endif - return rv; + return rv; } - newMsgHdr->Release(); - newMsgHdr = nsnull; - - /* closing the newsDB isn't enough. something still has - * reference to it. (need to look into this, bienvenu - * suggests nsMsgFolderInfo?) - * for now, we need to Commit() to force the changes - * to the disk - */ + /* closing the newsDB isn't enough. something still has + * reference to it. (need to look into this, bienvenu + * suggests nsMsgFolderInfo?) + * for now, we need to Commit() to force the changes + * to the disk + */ m_newsDB->Commit(kSessionCommit); m_newsDB->Close(PR_TRUE); } @@ -140,6 +126,38 @@ nsresult newsTestDriver::RunDriver() return rv; } +nsresult newsTestDriver::AddNewHeader(const char *subject, const char *author, const char *id, PRUint32 key) +{ + nsresult rv = NS_OK; + + nsIMsgDBHdr *newMsgHdr = nsnull; + + m_newsDB->CreateNewHdr(key, &newMsgHdr); + if (NS_FAILED(rv)) { +#ifdef DEBUG + printf("m_newsDB->CreateNewHdr() failed\n"); +#endif + return rv; + } + + newMsgHdr->SetSubject(subject); + newMsgHdr->SetFlags(MSG_FLAG_READ); + newMsgHdr->SetAuthor(author); + newMsgHdr->SetMessageId(id); + + rv = m_newsDB->AddNewHdrToDB(newMsgHdr, PR_TRUE); + if (NS_FAILED(rv)) { +#ifdef DEBUG + printf("m_newsDB->AddNewHdrToDB() failed\n"); +#endif + return rv; + } + + NS_IF_RELEASE(newMsgHdr); + newMsgHdr = nsnull; + return NS_OK; +} + nsresult newsTestDriver::GetPath(const char *uri, nsFileSpec& aPathName) { nsresult rv = NS_OK; @@ -157,7 +175,7 @@ nsresult newsTestDriver::GetDatabase() { if (m_newsDB == nsnull) { nsNativeFileSpec path; - nsresult rv = GetPath("news://news.mcom.com/mcom.linux", path); + nsresult rv = GetPath("news://news.mozilla.org/netscape.public.mozilla.mail-news", path); if (NS_FAILED(rv)) return rv; nsresult newsDBOpen = NS_OK;