diff --git a/mozilla/embedding/qa/testembed/Tests.cpp b/mozilla/embedding/qa/testembed/Tests.cpp index 347ca81b222..7c1825eb27d 100644 --- a/mozilla/embedding/qa/testembed/Tests.cpp +++ b/mozilla/embedding/qa/testembed/Tests.cpp @@ -531,7 +531,10 @@ void CTests::OnTestsAddUriContentListenerByOpenUri() if (myDialog.DoModal() == IDOK) { - rv = NS_NewURI(getter_AddRefs(theURI), myDialog.m_urlfield); + nsCAutoString theStr; + + theStr = myDialog.m_urlfield; + rv = NS_NewURI(getter_AddRefs(theURI), theStr); RvTestResult(rv, "For OpenURI(): NS_NewURI() test", 1); GetTheUri(theURI, 1); rv = NS_NewChannel(getter_AddRefs(theChannel), theURI, nsnull, nsnull); diff --git a/mozilla/embedding/qa/testembed/nsICmdParams.cpp b/mozilla/embedding/qa/testembed/nsICmdParams.cpp index d42e6538c68..df53600d018 100644 --- a/mozilla/embedding/qa/testembed/nsICmdParams.cpp +++ b/mozilla/embedding/qa/testembed/nsICmdParams.cpp @@ -20,6 +20,61 @@ static char THIS_FILE[] = __FILE__; ///////////////////////////////////////////////////////////////////////////// // nsICmdParams +// note: this table is temporary. will customize later. +// 1st column: command; 2nd column: DoCommand state, 3rd column: CmdParam state; +CommandTest CommandTable2[] = { + {"cmd_bold", "", "state_all", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_italic", "", "state_all", PR_TRUE, 10000000, 2.27, "This is a complete sentence", "This isn't!"}, + {"cmd_underline", "", "state_all", PR_TRUE, 17, 7839.3480, "A longer string than the previous one.", "Shorter string, but still pretty long."}, + {"cmd_indent", "", "state_enabled", PR_TRUE, 7480, -1.487, "Another string input for testing ...", "How about them Giants?!"}, + {"cmd_outdent", "", "state_enabled", PR_FALSE, 0, 24987.2465, "A few numbers: 1 2 3, A few letters: C A B, A few characters: Mickey Goofy $%*&@", "nothing here"}, + {"cmd_increaseFont", "", "state_enabled", PR_TRUE, 500000000, 16, "hi", "HI"}, + {"cmd_undo", "", "state_enabled", PR_TRUE, 987352487, 36.489, "x ", "x"}, + {"cmd_redo", "", "state_enabled", PR_FALSE, 90, -24, "", " "}, + {"cmd_decreaseFont", "", "", PR_TRUE, 0.0, 0.0, "hello", "HELLO"}, + {"cmd_fontColor", "state_attribute", "state_attribute", PR_TRUE, 25, 100, "#FF0000", "#000000"}, + {"cmd_backgroundColor", "state_attribute", "state_attribute", PR_TRUE, -35871678, 15.345363645, "#FF1234", "#001234"}, + {"cmd_fontFace", "state_attribute", "state_attribute", PR_TRUE, 50000, 5.798, "Times New Roman, Times, serif", "Courier New, Courier, monospace"}, + {"cmd_align", "state_attribute", "state_attribute", PR_TRUE, 10000, 5.798, "right", "center"}, + {"cmd_charSet", "state_attribute", "state_attribute", PR_TRUE, 20000, 5.798, "hello", "HELLO"}, + {"cmd_copy", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_delete", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_deleteCharBackward", "", "state_enabled", PR_TRUE, 30000, 245.2323, "hello", "HELLO"}, + {"cmd_deleteCharForward", "", "state_enabled", PR_TRUE, 50000, -24235.2346, "a very very very very very very very very looooooooooooooooooooong stringgggggggggggggggggggggggggggggggggggggggggggg!!!", "HELLO"}, + {"cmd_deleteWordForward", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_deleteWordBackward", "", "state_enabled", PR_TRUE, 6034600, 5.798, "hello", "HELLO"}, + {"cmd_deleteToBeginningOfLine", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_deleteToEndOfLine", "", "state_enabled", PR_TRUE, -5434, 5.798, "hello", "HELLO"}, + {"cmd_scrollTop", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_scrollBottom", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_scrollPageUp", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_scrollPageDown", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_movePageUp", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_movePageDown", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_moveTop", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_moveBottom", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_selectTop", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_selectBottom", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_lineNext", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_linePrevious", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_selectLineNext", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_selectLinePrevious", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_charPrevious", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_charNext", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_selectCharPrevious", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_selectCharNext", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_beginLine", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_endLine", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_selectBeginLine", "", "state_enabled", PR_FALSE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_selectEndLine", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_wordPrevious", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_wordNext", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_selectWordPrevious", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_selectWordNext", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_cut", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_cutOrDelete", "", "state_enabled", PR_FALSE, 50000, 5.798, "hello", "HELLO"}, +}; + CnsICmdParams::CnsICmdParams(nsIWebBrowser *mWebBrowser) { qaWebBrowser = mWebBrowser; @@ -42,124 +97,124 @@ nsICommandParams * CnsICmdParams::GetCommandParamObject() return retVal; } -void CnsICmdParams::GetValueTypeTest(const char *aCommand, const char *stateType) +void CnsICmdParams::GetValueTypeTest(const char *aCommand, const char *stateType, int displayMode) { PRInt16 retval; cmdParamObj = GetCommandParamObject(); if (cmdParamObj) { - FormatAndPrintOutput("The input command name = ", aCommand, 2); - FormatAndPrintOutput("The input state type = ", stateType, 2); + FormatAndPrintOutput("The input command name = ", aCommand, displayMode); + FormatAndPrintOutput("The input state type = ", stateType, displayMode); cmdMgrObj = CnsICommandMgr::GetCommandMgrObject(qaWebBrowser); if (!cmdMgrObj) { - QAOutput("We didn't get nsICommandMgr object. Test fails.", 2); + QAOutput("We didn't get nsICommandMgr object. Test fails.", displayMode); return; } else { rv = cmdMgrObj->GetCommandState(aCommand,cmdParamObj); - RvTestResult(rv, "cmdMgrObj->GetCommandState test", 2); + RvTestResult(rv, "cmdMgrObj->GetCommandState test", displayMode); } rv = cmdParamObj->GetValueType(stateType, &retval); - RvTestResult(rv, "GetValueType test", 2); - FormatAndPrintOutput("GetValueType return int = ", retval, 2); + RvTestResult(rv, "GetValueType test", displayMode); + FormatAndPrintOutput("GetValueType return int = ", retval, displayMode); } else QAOutput("GetValueTypeTest(): We didn't get nsICommandParams object.", 1); } -void CnsICmdParams::GetBooleanValueTest(const char *aCommand, const char *stateType) +void CnsICmdParams::GetBooleanValueTest(const char *aCommand, const char *stateType, int displayMode) { PRBool retval; cmdParamObj = GetCommandParamObject(); if (cmdParamObj) { - FormatAndPrintOutput("The input command name = ", aCommand, 2); - FormatAndPrintOutput("The input state type = ", stateType, 2); + FormatAndPrintOutput("The input command name = ", aCommand, displayMode); + FormatAndPrintOutput("The input state type = ", stateType, displayMode); cmdMgrObj = CnsICommandMgr::GetCommandMgrObject(qaWebBrowser); if (!cmdMgrObj) { - QAOutput("We didn't get nsICommandMgr object. Test fails.", 2); + QAOutput("We didn't get nsICommandMgr object. Test fails.", displayMode); return; } else cmdMgrObj->GetCommandState(aCommand, cmdParamObj); rv = cmdParamObj->GetBooleanValue(stateType, &retval); - RvTestResult(rv, "GetBooleanValue test", 2); - FormatAndPrintOutput("GetBooleanValue() return boolean = ", retval, 2); + RvTestResult(rv, "GetBooleanValue test", displayMode); + FormatAndPrintOutput("GetBooleanValue() return boolean = ", retval, displayMode); } else QAOutput("GetBooleanValueTest(): We didn't get nsICommandParams object.", 1); } -void CnsICmdParams::GetLongValueTest(PRInt32 value, const char *stateType) +void CnsICmdParams::GetLongValueTest(PRInt32 value, const char *stateType, int displayMode) { PRInt32 retval; cmdParamObj = GetCommandParamObject(); if (cmdParamObj) { - FormatAndPrintOutput("The input Set value = ", value, 2); - FormatAndPrintOutput("The input state type = ", stateType, 2); + FormatAndPrintOutput("The input Set value = ", value, displayMode); + FormatAndPrintOutput("The input state type = ", stateType, displayMode); cmdParamObj->SetLongValue(stateType, value); rv = cmdParamObj->GetLongValue(stateType, &retval); - RvTestResult(rv, "GetLongValue test", 2); - FormatAndPrintOutput("GetLongValue() return long = ", retval, 2); + RvTestResult(rv, "GetLongValue test", displayMode); + FormatAndPrintOutput("GetLongValue() return long = ", retval, displayMode); } else QAOutput("GetLongValueTest: We didn't get nsICommandParams object.", 1); } -void CnsICmdParams::GetDoubleValueTest(double value, const char *stateType) +void CnsICmdParams::GetDoubleValueTest(double value, const char *stateType, int displayMode) { double retval; cmdParamObj = GetCommandParamObject(); if (cmdParamObj) { - FormatAndPrintOutput("The input Set value = ", value, 2); - FormatAndPrintOutput("The input state type = ", stateType, 2); + FormatAndPrintOutput("The input Set value = ", value, displayMode); + FormatAndPrintOutput("The input state type = ", stateType, displayMode); cmdParamObj->SetDoubleValue(stateType, value); rv = cmdParamObj->GetDoubleValue(stateType, &retval); - RvTestResult(rv, "GetDoubleValue test", 2); - FormatAndPrintOutput("GetLongValue() return double = ", retval, 2); + RvTestResult(rv, "GetDoubleValue test", displayMode); + FormatAndPrintOutput("GetLongValue() return double = ", retval, displayMode); } else QAOutput("GetDoubleValueTest: We didn't get nsICommandParams object.", 1); } -void CnsICmdParams::GetStringValueTest(char *stringVal, const char *stateType) +void CnsICmdParams::GetStringValueTest(char *stringVal, const char *stateType, int displayMode) { nsAutoString retval; cmdParamObj = GetCommandParamObject(); if (cmdParamObj) { - FormatAndPrintOutput("The input string = ", stringVal, 2); - FormatAndPrintOutput("The input state type = ", stateType, 2); + FormatAndPrintOutput("The input string = ", stringVal, displayMode); + FormatAndPrintOutput("The input state type = ", stateType, displayMode); rv = cmdParamObj->SetStringValue(stateType, NS_ConvertASCIItoUCS2(stringVal)); rv = cmdParamObj->GetStringValue(stateType, retval); - RvTestResult(rv, "GetStringValue test", 2); -// FormatAndPrintOutput("GetStringValue() return string = ", retval, 2); + RvTestResult(rv, "GetStringValue test", displayMode); +// FormatAndPrintOutput("GetStringValue() return string = ", retval, displayMode); } else QAOutput("GetStringValueTest: We didn't get nsICommandParams object.", 1); } -void CnsICmdParams::GetCStringValueTest(const char *aCommand, const char *stateType) +void CnsICmdParams::GetCStringValueTest(const char *aCommand, const char *stateType, int displayMode) { cmdParamObj = GetCommandParamObject(); if (cmdParamObj) { - FormatAndPrintOutput("The input command name = ", aCommand, 2); - FormatAndPrintOutput("The input state type = ", stateType, 2); + FormatAndPrintOutput("The input command name = ", aCommand, displayMode); + FormatAndPrintOutput("The input state type = ", stateType, displayMode); cmdMgrObj = CnsICommandMgr::GetCommandMgrObject(qaWebBrowser); if (!cmdMgrObj) { - QAOutput("We didn't get nsICommandMgr object. Test fails.", 2); + QAOutput("We didn't get nsICommandMgr object. Test fails.", displayMode); return; } else cmdMgrObj->GetCommandState(aCommand, cmdParamObj); char *tCstringValue = nsnull; rv = cmdParamObj->GetCStringValue(stateType, &tCstringValue); - RvTestResult(rv, "GetCStringValue test", 2); - FormatAndPrintOutput("the CString value = ", tCstringValue, 2); + RvTestResult(rv, "GetCStringValue test", displayMode); + FormatAndPrintOutput("the CString value = ", tCstringValue, displayMode); if (tCstringValue) nsCRT::free(tCstringValue); } @@ -169,66 +224,66 @@ void CnsICmdParams::GetCStringValueTest(const char *aCommand, const char *stateT // NS_ConvertASCIItoUCS2 -void CnsICmdParams::SetBooleanValueTest(PRBool value, const char *stateType) +void CnsICmdParams::SetBooleanValueTest(PRBool value, const char *stateType, int displayMode) { cmdParamObj = GetCommandParamObject(); if (cmdParamObj) { - FormatAndPrintOutput("The input state type = ", stateType, 2); - FormatAndPrintOutput("The input value = ", value, 2); + FormatAndPrintOutput("The input state type = ", stateType, displayMode); + FormatAndPrintOutput("The input value = ", value, displayMode); rv = cmdParamObj->SetBooleanValue(stateType, value); - RvTestResult(rv, "SetBooleanValue() test", 2); + RvTestResult(rv, "SetBooleanValue() test", displayMode); } else QAOutput("SetBooleanValueTest(): We didn't get nsICommandParams object.", 1); } -void CnsICmdParams::SetLongValueTest(PRInt32 value, const char *stateType) +void CnsICmdParams::SetLongValueTest(PRInt32 value, const char *stateType, int displayMode) { cmdParamObj = GetCommandParamObject(); if (cmdParamObj) { - FormatAndPrintOutput("The input state type = ", stateType, 2); - FormatAndPrintOutput("The input value = ", value, 2); + FormatAndPrintOutput("The input state type = ", stateType, displayMode); + FormatAndPrintOutput("The input value = ", value, displayMode); rv = cmdParamObj->SetLongValue(stateType, value); - RvTestResult(rv, "SetLongValue() test", 2); + RvTestResult(rv, "SetLongValue() test", displayMode); } else QAOutput("SetLongValueTest(): We didn't get nsICommandParams object.", 1); } -void CnsICmdParams::SetDoubleValueTest(double value, const char *stateType) +void CnsICmdParams::SetDoubleValueTest(double value, const char *stateType, int displayMode) { cmdParamObj = GetCommandParamObject(); if (cmdParamObj) { - FormatAndPrintOutput("The input state type = ", stateType, 2); - FormatAndPrintOutput("The input value = ", value, 2); + FormatAndPrintOutput("The input state type = ", stateType, displayMode); + FormatAndPrintOutput("The input value = ", value, displayMode); rv = cmdParamObj->SetDoubleValue(stateType, value); - RvTestResult(rv, "SetDoubleValue() test", 2); + RvTestResult(rv, "SetDoubleValue() test", displayMode); } else QAOutput("SetDoubleValueTest(): We didn't get nsICommandParams object.", 1); } -void CnsICmdParams::SetStringValueTest(char *value, const char *stateType) +void CnsICmdParams::SetStringValueTest(char *value, const char *stateType, int displayMode) { cmdParamObj = GetCommandParamObject(); if (cmdParamObj) { - FormatAndPrintOutput("The input state type = ", stateType, 2); - FormatAndPrintOutput("The input value = ", value, 2); + FormatAndPrintOutput("The input state type = ", stateType, displayMode); + FormatAndPrintOutput("The input value = ", value, displayMode); rv = cmdParamObj->SetStringValue(stateType, NS_ConvertASCIItoUCS2(value)); - RvTestResult(rv, "SetStringValue() test", 2); + RvTestResult(rv, "SetStringValue() test", displayMode); } else QAOutput("SetStringValueTest(): We didn't get nsICommandParams object.", 1); } -void CnsICmdParams::SetCStringValueTest(char *value, const char *stateType) +void CnsICmdParams::SetCStringValueTest(char *value, const char *stateType, int displayMode) { cmdParamObj = GetCommandParamObject(); if (cmdParamObj) { - FormatAndPrintOutput("The input state type = ", stateType, 2); - FormatAndPrintOutput("The input value = ", value, 2); + FormatAndPrintOutput("The input state type = ", stateType, displayMode); + FormatAndPrintOutput("The input value = ", value, displayMode); rv = cmdParamObj->SetCStringValue(stateType, value); - RvTestResult(rv, "SetCStringValue() test", 2); + RvTestResult(rv, "SetCStringValue() test", displayMode); } else QAOutput("SetCStringValueTest(): We didn't get nsICommandParams object.", 1); @@ -242,40 +297,40 @@ void CnsICmdParams::OnStartTests(UINT nMenuID) RunAllTests(); break; case ID_INTERFACES_NSICOMMANDPARAMS_GETVALUETYPE : - GetValueTypeTest( "cmd_bold", "state_all"); + GetValueTypeTest( "cmd_bold", "state_all", 2); break; case ID_INTERFACES_NSICOMMANDPARAMS_GETBOOLEANVALUE : - GetBooleanValueTest("cmd_bold", "state_mixed"); + GetBooleanValueTest("cmd_bold", "state_mixed", 2); break; case ID_INTERFACES_NSICOMMANDPARAMS_GETLONGVALUE : - GetLongValueTest(57000000, "state_attribute"); + GetLongValueTest(57000000, "state_attribute", 2); break; case ID_INTERFACES_NSICOMMANDPARAMS_GETDOUBLEVALUE : - GetDoubleValueTest(5.25, "state_attribute"); + GetDoubleValueTest(5.25, "state_attribute", 2); break; case ID_INTERFACES_NSICOMMANDPARAMS_GETSTRINGVALUE : - GetStringValueTest("MyString!!", "state_attribute"); + GetStringValueTest("MyString!!", "state_attribute", 2); break; case ID_INTERFACES_NSICOMMANDPARAMS_GETCSTRINGVALUE: - GetCStringValueTest("cmd_fontColor", "state_attribute"); + GetCStringValueTest("cmd_fontColor", "state_attribute", 2); break; case ID_INTERFACES_NSICOMMANDPARAMS_GETISUPPORTSVALUE : QAOutput("Not implemented yet.", 2); break; case ID_INTERFACES_NSICOMMANDPARAMS_SETBOOLEANVALUE : - SetBooleanValueTest(PR_TRUE, "state_attribute"); + SetBooleanValueTest(PR_TRUE, "state_attribute", 2); break; case ID_INTERFACES_NSICOMMANDPARAMS_SETLONGVALUE : - SetLongValueTest(25000000, "state_attribute"); + SetLongValueTest(25000000, "state_attribute", 2); break; case ID_INTERFACES_NSICOMMANDPARAMS_SETDOUBLEVALUE : - SetDoubleValueTest(-3.05, "state_attribute"); + SetDoubleValueTest(-3.05, "state_attribute", 2); break; case ID_INTERFACES_NSICOMMANDPARAMS_SETSTRINGVALUE : - SetStringValueTest("HELLO!", "state_attribute"); + SetStringValueTest("HELLO!", "state_attribute", 2); break; case ID_INTERFACES_NSICOMMANDPARAMS_SETCSTRINGVALUE: - SetCStringValueTest("#FF0000", "state_attribute"); + SetCStringValueTest("#FF0000", "state_attribute", 2); break; case ID_INTERFACES_NSICOMMANDPARAMS_SETISUPPORTSVALUE : QAOutput("Not implemented yet.", 2); @@ -299,18 +354,31 @@ void CnsICmdParams::RunAllTests() { cmdParamObj = GetCommandParamObject(); if (cmdParamObj) - QAOutput("We got nsICommandParams object.", 2); + QAOutput("We got nsICommandParams object.", 1); else - QAOutput("We didn't get nsICommandParams object.", 2); + QAOutput("We didn't get nsICommandParams object.", 1); - SetBooleanValueTest(PR_FALSE, "state_attribute"); - SetBooleanValueTest(PR_TRUE, "state_attribute"); - SetLongValueTest(15000000, "state_attribute"); - SetDoubleValueTest(100.295375, "state_attribute"); - SetStringValueTest("Hello world!", "state_attribute"); + PRInt16 i; + + QAOutput("Run All nsICommandParam Set and Get tests. Check C:/Temp/TestOutput.txt for test results.", 2); + for (i=0; i < 50; i++) + { + FormatAndPrintOutput("loop cnt = ", i, 1); + SetBooleanValueTest(CommandTable2[i].mBooleanValue, CommandTable2[i].mCmdParamState, 1); + SetLongValueTest(CommandTable2[i].mLongValue, CommandTable2[i].mCmdParamState, 1); + SetDoubleValueTest(CommandTable2[i].mDoubleValue, CommandTable2[i].mCmdParamState, 1); + SetStringValueTest(CommandTable2[i].mStringValue, CommandTable2[i].mCmdParamState, 1); + SetCStringValueTest(CommandTable2[i].mCStringValue, CommandTable2[i].mCmdParamState, 1); + + GetValueTypeTest(CommandTable2[i].mCmdName, CommandTable2[i].mCmdParamState, 1); + GetBooleanValueTest(CommandTable2[i].mCmdName, CommandTable2[i].mCmdParamState, 1); + GetLongValueTest(CommandTable2[i].mLongValue, CommandTable2[i].mCmdParamState, 1); + GetDoubleValueTest(CommandTable2[i].mDoubleValue, CommandTable2[i].mCmdParamState, 1); + GetStringValueTest(CommandTable2[i].mStringValue, CommandTable2[i].mCmdParamState, 1); + GetCStringValueTest(CommandTable2[i].mCmdName, CommandTable2[i].mCmdParamState, 1); + } QAOutput("Other tests Not implemented yet.", 2); } - ///////////////////////////////////////////////////////////////////////////// // nsICmdParams message handlers diff --git a/mozilla/embedding/qa/testembed/nsICmdParams.h b/mozilla/embedding/qa/testembed/nsICmdParams.h index 617d618a36a..dc040e17f12 100644 --- a/mozilla/embedding/qa/testembed/nsICmdParams.h +++ b/mozilla/embedding/qa/testembed/nsICmdParams.h @@ -41,18 +41,18 @@ public: // Implementation static nsICommandParams * GetCommandParamObject(); - void GetValueTypeTest(const char *, const char *); - void GetBooleanValueTest(const char *, const char *); - void GetLongValueTest(PRInt32, const char *); - void GetDoubleValueTest(double, const char *); - void GetStringValueTest(char *, const char *); - void GetCStringValueTest(const char *, const char *); + void GetValueTypeTest(const char *, const char *, int); + void GetBooleanValueTest(const char *, const char *, int); + void GetLongValueTest(PRInt32, const char *, int); + void GetDoubleValueTest(double, const char *, int); + void GetStringValueTest(char *, const char *, int); + void GetCStringValueTest(const char *, const char *, int); - void SetBooleanValueTest(PRBool, const char *); - void SetLongValueTest(PRInt32, const char *); - void SetDoubleValueTest(double, const char *); - void SetStringValueTest(char *, const char *); - void SetCStringValueTest(char *, const char *); + void SetBooleanValueTest(PRBool, const char *, int); + void SetLongValueTest(PRInt32, const char *, int); + void SetDoubleValueTest(double, const char *, int); + void SetStringValueTest(char *, const char *, int); + void SetCStringValueTest(char *, const char *, int); void OnStartTests(UINT nMenuID); void RunAllTests(); diff --git a/mozilla/embedding/qa/testembed/nsICommandMgr.cpp b/mozilla/embedding/qa/testembed/nsICommandMgr.cpp index c4a81838a06..701d375815e 100644 --- a/mozilla/embedding/qa/testembed/nsICommandMgr.cpp +++ b/mozilla/embedding/qa/testembed/nsICommandMgr.cpp @@ -71,58 +71,58 @@ CnsICommandMgr::~CnsICommandMgr() { } -// 1st column: command; 2nd column: DoCommand state; +// 1st column: command; 2nd column: DoCommand state, 3rd column: CmdParam state; CommandTest CommandTable[] = { - {"cmd_bold", "", "state_all", "state_begin", "state_end", "state_mixed", 1}, - {"cmd_italic", "", "state_all", "state_begin", "state_end", "state_mixed", 1}, - {"cmd_underline", "", "state_all", "state_begin", "state_end", "state_mixed", 1}, - {"cmd_indent", "", "state_enabled", "", "", "", 1}, - {"cmd_outdent", "", "state_enabled", "", "", "", 1}, - {"cmd_increaseFont", "", "state_enabled", "", "", "", 1}, - {"cmd_undo", "", "state_enabled", "", "", "", 1}, - {"cmd_redo", "", "state_enabled", "", "", "", 1}, - {"cmd_decreaseFont", "", "", "", "", "", 1}, - {"cmd_fontColor", "state_attribute", "state_attribute", "", "", "", 1}, - {"cmd_backgroundColor", "state_attribute", "state_attribute", "", "", "", 1}, - {"cmd_fontFace", "state_attribute", "state_attribute", "", "", "", 1}, - {"cmd_align", "state_attribute", "state_attribute", "", "", "", 1}, - {"cmd_charSet", "state_attribute", "state_attribute", "", "", "", 1}, - {"cmd_copy", "", "state_enabled", "", "", "", 1}, - {"cmd_delete", "", "state_enabled", "", "", "", 1}, - {"cmd_deleteCharBackward", "", "state_enabled", "", "", "", 1}, - {"cmd_deleteCharForward", "", "state_enabled", "", "", "", 1}, - {"cmd_deleteWordForward", "", "state_enabled", "", "", "", 1}, - {"cmd_deleteWordBackward", "", "state_enabled", "", "", "", 1}, - {"cmd_deleteToBeginningOfLine", "", "state_enabled", "", "", "", 1}, - {"cmd_deleteToEndOfLine", "", "state_enabled", "", "", "", 1}, - {"cmd_scrollTop", "", "state_enabled", "", "", "", 1}, - {"cmd_scrollBottom", "", "state_enabled", "", "", "", 1}, - {"cmd_scrollPageUp", "", "state_enabled", "", "", "", 1}, - {"cmd_scrollPageDown", "", "state_enabled", "", "", "", 1}, - {"cmd_movePageUp", "", "state_enabled", "", "", "", 1}, - {"cmd_movePageDown", "", "state_enabled", "", "", "", 1}, - {"cmd_moveTop", "", "state_enabled", "", "", "", 1}, - {"cmd_moveBottom", "", "state_enabled", "", "", "", 1}, - {"cmd_selectTop", "", "state_enabled", "", "", "", 1}, - {"cmd_selectBottom", "", "state_enabled", "", "", "", 1}, - {"cmd_lineNext", "", "state_enabled", "", "", "", 1}, - {"cmd_linePrevious", "", "state_enabled", "", "", "", 1}, - {"cmd_selectLineNext", "", "state_enabled", "", "", "", 1}, - {"cmd_selectLinePrevious", "", "state_enabled", "", "", "", 1}, - {"cmd_charPrevious", "", "state_enabled", "", "", "", 1}, - {"cmd_charNext", "", "state_enabled", "", "", "", 1}, - {"cmd_selectCharPrevious", "", "state_enabled", "", "", "", 1}, - {"cmd_selectCharNext", "", "state_enabled", "", "", "", 1}, - {"cmd_beginLine", "", "state_enabled", "", "", "", 1}, - {"cmd_endLine", "", "state_enabled", "", "", "", 1}, - {"cmd_selectBeginLine", "", "state_enabled", "", "", "", 1}, - {"cmd_selectEndLine", "", "state_enabled", "", "", "", 1}, - {"cmd_wordPrevious", "", "state_enabled", "", "", "", 1}, - {"cmd_wordNext", "", "state_enabled", "", "", "", 1}, - {"cmd_selectWordPrevious", "", "state_enabled", "", "", "", 1}, - {"cmd_selectWordNext", "", "state_enabled", "", "", "", 1}, - {"cmd_cut", "", "state_enabled", "", "", "", 1}, - {"cmd_cutOrDelete", "", "state_enabled", "", "", "", 1}, + {"cmd_bold", "", "state_all", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_italic", "", "state_all", PR_TRUE, 10000000, 2.27, "This is a complete sentence", "This isn't!"}, + {"cmd_underline", "", "state_all", PR_TRUE, 17, 7839.3480, "A longer string than the previous one.", "Shorter string, but still pretty long."}, + {"cmd_indent", "", "state_enabled", PR_TRUE, 7480, -1.487, "Another string input for testing ...", "How about them Giants?!"}, + {"cmd_outdent", "", "state_enabled", PR_FALSE, 0, 24987.2465, "A few numbers: 1 2 3, A few letters: C A B, A few characters: Mickey Goofy $%*&@", "nothing here"}, + {"cmd_increaseFont", "", "state_enabled", PR_TRUE, 500000000, 16, "hi", "HI"}, + {"cmd_undo", "", "state_enabled", PR_TRUE, 987352487, 36.489, "x ", "x"}, + {"cmd_redo", "", "state_enabled", PR_FALSE, 90, -24, "", " "}, + {"cmd_decreaseFont", "", "", PR_TRUE, 0.0, 0.0, "hello", "HELLO"}, + {"cmd_fontColor", "state_attribute", "state_attribute", PR_TRUE, 25, 100, "#FF0000", "#000000"}, + {"cmd_backgroundColor", "state_attribute", "state_attribute", PR_TRUE, -35871678, 15.345363645, "#FF1234", "#001234"}, + {"cmd_fontFace", "state_attribute", "state_attribute", PR_TRUE, 50000, 5.798, "Times New Roman, Times, serif", "Courier New, Courier, monospace"}, + {"cmd_align", "state_attribute", "state_attribute", PR_TRUE, 10000, 5.798, "right", "center"}, + {"cmd_charSet", "state_attribute", "state_attribute", PR_TRUE, 20000, 5.798, "hello", "HELLO"}, + {"cmd_copy", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_delete", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_deleteCharBackward", "", "state_enabled", PR_TRUE, 30000, 245.2323, "hello", "HELLO"}, + {"cmd_deleteCharForward", "", "state_enabled", PR_TRUE, 50000, -24235.2346, "a very very very very very very very very looooooooooooooooooooong stringgggggggggggggggggggggggggggggggggggggggggggg!!!", "HELLO"}, + {"cmd_deleteWordForward", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_deleteWordBackward", "", "state_enabled", PR_TRUE, 6034600, 5.798, "hello", "HELLO"}, + {"cmd_deleteToBeginningOfLine", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_deleteToEndOfLine", "", "state_enabled", PR_TRUE, -5434, 5.798, "hello", "HELLO"}, + {"cmd_scrollTop", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_scrollBottom", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_scrollPageUp", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_scrollPageDown", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_movePageUp", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_movePageDown", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_moveTop", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_moveBottom", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_selectTop", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_selectBottom", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_lineNext", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_linePrevious", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_selectLineNext", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_selectLinePrevious", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_charPrevious", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_charNext", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_selectCharPrevious", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_selectCharNext", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_beginLine", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_endLine", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_selectBeginLine", "", "state_enabled", PR_FALSE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_selectEndLine", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_wordPrevious", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_wordNext", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_selectWordPrevious", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_selectWordNext", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_cut", "", "state_enabled", PR_TRUE, 50000, 5.798, "hello", "HELLO"}, + {"cmd_cutOrDelete", "", "state_enabled", PR_FALSE, 50000, 5.798, "hello", "HELLO"}, }; nsICommandManager * CnsICommandMgr::GetCommandMgrObject(nsIWebBrowser *aWebBrowser) @@ -148,41 +148,41 @@ nsICommandManager * CnsICommandMgr::GetCommandMgrWithContractIDObject() return cmdMgrObj; } -void CnsICommandMgr::IsCommandSupportedTest(const char *aCommandName) +void CnsICommandMgr::IsCommandSupportedTest(const char *aCommandName, int displayMethod) { PRBool isSupported; - FormatAndPrintOutput("the Command input = ", aCommandName, 2); + FormatAndPrintOutput("the Command input = ", aCommandName, displayMethod); if (!cmdMgrObj) { QAOutput("Didn't get nsICommandManager object."); return; } cmdMgrObj = GetCommandMgrObject(qaWebBrowser); rv = cmdMgrObj->IsCommandSupported(aCommandName, &isSupported); - RvTestResult(rv, "IsCommandSupported() test", 2); - FormatAndPrintOutput("isSupported boolean = ", isSupported, 2); + RvTestResult(rv, "IsCommandSupported() test", displayMethod); + FormatAndPrintOutput("isSupported boolean = ", isSupported, displayMethod); } -void CnsICommandMgr::IsCommandEnabledTest(const char *aCommandName) +void CnsICommandMgr::IsCommandEnabledTest(const char *aCommandName, int displayMethod) { PRBool isEnabled; - FormatAndPrintOutput("the Command input = ", aCommandName, 2); + FormatAndPrintOutput("the Command input = ", aCommandName, displayMethod); cmdMgrObj = GetCommandMgrObject(qaWebBrowser); if (!cmdMgrObj) { QAOutput("Didn't get nsICommandManager object."); return; } rv = cmdMgrObj->IsCommandEnabled(aCommandName, &isEnabled); - RvTestResult(rv, "IsCommandEnabled() test", 2); - FormatAndPrintOutput("isEnabled boolean = ", isEnabled, 2); + RvTestResult(rv, "IsCommandEnabled() test", displayMethod); + FormatAndPrintOutput("isEnabled boolean = ", isEnabled, displayMethod); } -void CnsICommandMgr::GetCommandStateTest(const char *aCommandName) +void CnsICommandMgr::GetCommandStateTest(const char *aCommandName, int displayMethod) { PRBool enabled = PR_FALSE; - FormatAndPrintOutput("the Command input = ", aCommandName, 2); + FormatAndPrintOutput("the Command input = ", aCommandName, displayMethod); cmdMgrObj = GetCommandMgrObject(qaWebBrowser); cmdParamObj = CnsICmdParams::GetCommandParamObject(); if (!cmdMgrObj) { @@ -195,16 +195,17 @@ void CnsICommandMgr::GetCommandStateTest(const char *aCommandName) } else { rv = cmdMgrObj->GetCommandState(aCommandName, cmdParamObj); - RvTestResult(rv, "GetCommandState() test", 2); + RvTestResult(rv, "GetCommandState() test", displayMethod); } } void CnsICommandMgr::DoCommandTest(const char *aCommandName, - const char *doCommandState) + const char *doCommandState, + int displayMethod) { nsCAutoString value; - FormatAndPrintOutput("the Command input = ", aCommandName, 2); + FormatAndPrintOutput("the Command input = ", aCommandName, displayMethod); cmdMgrObj = GetCommandMgrObject(qaWebBrowser); cmdParamObj = CnsICmdParams::GetCommandParamObject(); if (!cmdMgrObj) { @@ -228,7 +229,7 @@ void CnsICommandMgr::DoCommandTest(const char *aCommandName, cmdParamObj->SetCStringValue("state_attribute", value.get()); } rv = cmdMgrObj->DoCommand(aCommandName, cmdParamObj); - RvTestResult(rv, "DoCommand() test", 2); + RvTestResult(rv, "DoCommand() test", displayMethod); } @@ -246,16 +247,16 @@ void CnsICommandMgr::OnStartTests(UINT nMenuID) QAOutput("Not implemented yet.", 2); break; case ID_INTERFACES_NSICOMMANDMANAGER_ISCOMMANDESUPPORTED : - IsCommandSupportedTest("cmd_bold"); + IsCommandSupportedTest("cmd_bold", 2); break; case ID_INTERFACES_NSICOMMANDMANAGER_ISCOMMANDENABLED : - IsCommandEnabledTest("cmd_bold"); + IsCommandEnabledTest("cmd_bold", 2); break; case ID_INTERFACES_NSICOMMANDMANAGER_GETCOMMANDSTATE : - GetCommandStateTest("cmd_charSet"); + GetCommandStateTest("cmd_charSet", 2); break; case ID_INTERFACES_NSICOMMANDMANAGER_DOCOMMAND : - DoCommandTest("cmd_fontColor", "state_attribute"); + DoCommandTest("cmd_fontColor", "state_attribute", 2); break; } } @@ -264,15 +265,17 @@ void CnsICommandMgr::RunAllTests() { PRInt16 i; + QAOutput("Run All nsICommandManager tests. Check C:/Temp/TestOutput.txt for test results.", 2); for (i=0; i < 50; i++) { - FormatAndPrintOutput("loop cnt = ", i, 2); - IsCommandSupportedTest(CommandTable[i].mCmdName); - IsCommandEnabledTest(CommandTable[i].mCmdName); - GetCommandStateTest(CommandTable[i].mCmdName); + FormatAndPrintOutput("loop cnt = ", i, 1); + IsCommandSupportedTest(CommandTable[i].mCmdName, 1); + IsCommandEnabledTest(CommandTable[i].mCmdName, 1); + GetCommandStateTest(CommandTable[i].mCmdName, 1); DoCommandTest(CommandTable[i].mCmdName, - CommandTable[i].mDoCmdParam); + CommandTable[i].mDoCmdState, 1); } + QAOutput("Tests completed.", 2); } diff --git a/mozilla/embedding/qa/testembed/nsICommandMgr.h b/mozilla/embedding/qa/testembed/nsICommandMgr.h index 3ea40d90c71..ab9b7efca98 100644 --- a/mozilla/embedding/qa/testembed/nsICommandMgr.h +++ b/mozilla/embedding/qa/testembed/nsICommandMgr.h @@ -71,10 +71,10 @@ public: public: static nsICommandManager * GetCommandMgrObject(nsIWebBrowser *aWebBrowser); static nsICommandManager * GetCommandMgrWithContractIDObject(); - void IsCommandSupportedTest(const char *); - void IsCommandEnabledTest(const char *); - void GetCommandStateTest(const char *); - void DoCommandTest(const char *, const char *); + void IsCommandSupportedTest(const char *, int); + void IsCommandEnabledTest(const char *, int); + void GetCommandStateTest(const char *, int); + void DoCommandTest(const char *, const char *, int); void OnStartTests(UINT nMenuID); void RunAllTests(); // Operations @@ -97,12 +97,13 @@ protected: struct CommandTest { const char *mCmdName; - const char *mDoCmdParam; - const char *mGetCmdStateParam1; - const char *mGetCmdStateParam2; - const char *mGetCmdStateParam3; - const char *mGetCmdStateParam4; - PRBool mGetCmdParamValue; + const char *mDoCmdState; + const char *mCmdParamState; + PRBool mBooleanValue; + PRInt32 mLongValue; + double mDoubleValue; + char *mStringValue; + char *mCStringValue; }; /////////////////////////////////////////////////////////////////////////////