зеркало из https://github.com/mozilla/pjs.git
Added code to scan for external scripts and present them in the test tree
This commit is contained in:
Родитель
ff5cc7cd3a
Коммит
23ad32bc5b
|
@ -303,6 +303,7 @@ TestResult CBrowseDlg::RunTest(Test *pTest)
|
|||
{
|
||||
BrowserInfo cInfo;
|
||||
|
||||
cInfo.pTest = pTest;
|
||||
cInfo.clsid = m_clsid;
|
||||
cInfo.pControlSite = m_pControlSite;
|
||||
cInfo.pIUnknown = NULL;
|
||||
|
|
|
@ -5,18 +5,30 @@
|
|||
// produce the type library (Cbrowse.tlb) and marshalling code.
|
||||
import "oaidl.idl";
|
||||
import "ocidl.idl";
|
||||
[
|
||||
object,
|
||||
uuid(95AF1AB1-FA66-11D2-A284-000000000000),
|
||||
dual,
|
||||
helpstring("DITestScriptHelper Interface"),
|
||||
pointer_default(unique)
|
||||
]
|
||||
interface DITestScriptHelper : IDispatch
|
||||
{
|
||||
[id(1), helpstring("method OutputString")] HRESULT OutputString(BSTR bstrMessage);
|
||||
[propget, id(2), helpstring("property WebBrowser")] HRESULT WebBrowser([out, retval] LPDISPATCH *pVal);
|
||||
};
|
||||
|
||||
typedef enum
|
||||
{
|
||||
trNotRun,
|
||||
trFailed,
|
||||
trPassed,
|
||||
trPartial
|
||||
} TestResult;
|
||||
|
||||
[
|
||||
object,
|
||||
uuid(95AF1AB1-FA66-11D2-A284-000000000000),
|
||||
dual,
|
||||
helpstring("DITestScriptHelper Interface"),
|
||||
pointer_default(unique)
|
||||
]
|
||||
interface DITestScriptHelper : IDispatch
|
||||
{
|
||||
[id(1), helpstring("method OutputString")] HRESULT OutputString(BSTR bstrMessage);
|
||||
[propget, id(2), helpstring("property WebBrowser")] HRESULT WebBrowser([out, retval] LPDISPATCH *pVal);
|
||||
[propput, id(3), helpstring("property Result")] HRESULT Result([in] TestResult newVal);
|
||||
};
|
||||
|
||||
|
||||
[
|
||||
uuid(5B209213-F756-11D2-A27F-000000000000),
|
||||
version(1.0),
|
||||
|
|
|
@ -44,3 +44,17 @@ STDMETHODIMP CTestScriptHelper::get_WebBrowser(LPDISPATCH *pVal)
|
|||
m_pBrowserInfo->GetWebBrowser(&spWebBrowserApp);
|
||||
return spWebBrowserApp->QueryInterface(IID_IDispatch, (void **) pVal);
|
||||
}
|
||||
|
||||
STDMETHODIMP CTestScriptHelper::put_Result(TestResult newVal)
|
||||
{
|
||||
AFX_MANAGE_STATE(AfxGetStaticModuleState())
|
||||
|
||||
if (m_pBrowserInfo == NULL)
|
||||
{
|
||||
return E_UNEXPECTED;
|
||||
}
|
||||
|
||||
m_pBrowserInfo->nResult = newVal;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ END_COM_MAP()
|
|||
|
||||
// DITestScriptHelper
|
||||
public:
|
||||
STDMETHOD(put_Result)(/*[in]*/ TestResult newVal);
|
||||
STDMETHOD(get_WebBrowser)(/*[out, retval]*/ LPDISPATCH *pVal);
|
||||
STDMETHOD(OutputString)(BSTR bstrMessage);
|
||||
};
|
||||
|
|
|
@ -323,27 +323,32 @@ TestResult __cdecl tstNavigate2(BrowserInfo &cInfo)
|
|||
|
||||
TestResult __cdecl tstScriptTest(BrowserInfo &cInfo)
|
||||
{
|
||||
cInfo.nResult = trFailed;
|
||||
|
||||
CTestScriptHelperInstance *pHelper = NULL;
|
||||
CTestScriptHelperInstance::CreateInstance(&pHelper);
|
||||
if (pHelper)
|
||||
{
|
||||
pHelper->m_pBrowserInfo = &cInfo;
|
||||
|
||||
CActiveScriptSiteInstance *pSite = NULL;
|
||||
CActiveScriptSiteInstance::CreateInstance(&pSite);
|
||||
if (pSite)
|
||||
{
|
||||
// TODO read from registry
|
||||
CString szScript;
|
||||
szScript.Format(_T("Scripts\\%s"), cInfo.pTest->szName);
|
||||
|
||||
pHelper->m_pBrowserInfo = &cInfo;
|
||||
pSite->AddRef();
|
||||
pSite->AttachVBScript();
|
||||
pSite->AddNamedObject(_T("BrowserInfo"), pHelper, TRUE);
|
||||
pSite->ParseScriptFile(szScript);
|
||||
pSite->PlayScript();
|
||||
pSite->Release();
|
||||
}
|
||||
}
|
||||
|
||||
CActiveScriptSiteInstance *pSite = NULL;
|
||||
CActiveScriptSiteInstance::CreateInstance(&pSite);
|
||||
|
||||
TCHAR *szTestScript = _T("OutputString \"Navigation test\"\n"
|
||||
"WebBrowser.Navigate \"http://www.yahoo.com\"\n");
|
||||
|
||||
|
||||
pSite->AddRef();
|
||||
pSite->AttachVBScript();
|
||||
pSite->AddNamedObject(_T("BrowserInfo"), pHelper, TRUE);
|
||||
pSite->ParseScriptText(szTestScript);
|
||||
pSite->PlayScript();
|
||||
pSite->Release();
|
||||
|
||||
return trPassed;
|
||||
return cInfo.nResult;
|
||||
}
|
||||
|
||||
Test aScripts[] =
|
||||
|
@ -354,8 +359,42 @@ Test aScripts[] =
|
|||
|
||||
void __cdecl ScriptSetPopulator(TestSet *pTestSet)
|
||||
{
|
||||
pTestSet->nTests = 1;
|
||||
pTestSet->aTests = aScripts;
|
||||
// TODO read from registry
|
||||
CString szTestDir(_T("Scripts"));
|
||||
|
||||
CStringList cStringList;
|
||||
CFileFind cFinder;
|
||||
CString szPattern;
|
||||
|
||||
|
||||
szPattern.Format(_T("%s\\*.vbs"), szTestDir);
|
||||
BOOL bWorking = cFinder.FindFile(szPattern);
|
||||
while (bWorking)
|
||||
{
|
||||
bWorking = cFinder.FindNextFile();
|
||||
cStringList.AddTail(cFinder.GetFileName());
|
||||
}
|
||||
|
||||
szPattern.Format(_T("%s\\*.js"), szTestDir);
|
||||
bWorking = cFinder.FindFile(szPattern);
|
||||
while (bWorking)
|
||||
{
|
||||
bWorking = cFinder.FindNextFile();
|
||||
cStringList.AddTail(cFinder.GetFileName());
|
||||
}
|
||||
|
||||
// Create a set of tests from the scripts found
|
||||
Test *pTests = (Test *) malloc(sizeof(Test) * cStringList.GetCount());
|
||||
for (int i = 0; i < cStringList.GetCount(); i++)
|
||||
{
|
||||
CString szScript = cStringList.GetAt(cStringList.FindIndex(i));
|
||||
_tcscpy(pTests[i].szName, szScript);
|
||||
_tcscpy(pTests[i].szDesc, _T("Run the specified script"));
|
||||
pTests[i].pfn = tstScriptTest;
|
||||
}
|
||||
|
||||
pTestSet->nTests = cStringList.GetCount();
|
||||
pTestSet->aTests = pTests;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -21,19 +21,15 @@
|
|||
#define CIPtr(iface) \
|
||||
CComQIPtr< iface, &IID_ ## iface >
|
||||
|
||||
enum TestResult
|
||||
{
|
||||
trNotRun,
|
||||
trFailed,
|
||||
trPassed,
|
||||
trPartial
|
||||
};
|
||||
|
||||
class CBrowseDlg;
|
||||
struct Test;
|
||||
|
||||
class BrowserInfo
|
||||
{
|
||||
public:
|
||||
Test *pTest;
|
||||
TestResult nResult;
|
||||
CControlSiteInstance *pControlSite;
|
||||
IUnknown *pIUnknown;
|
||||
CLSID clsid;
|
||||
|
@ -50,8 +46,8 @@ typedef TestResult (__cdecl *TestProc)(BrowserInfo &cInfo);
|
|||
|
||||
struct Test
|
||||
{
|
||||
TCHAR *szName;
|
||||
TCHAR *szDesc;
|
||||
TCHAR szName[256];
|
||||
TCHAR szDesc[256];
|
||||
TestProc pfn;
|
||||
TestResult nLastResult;
|
||||
};
|
||||
|
|
|
@ -223,6 +223,14 @@ SOURCE=.\res\testfailed.ico
|
|||
SOURCE=.\res\testpassed.ico
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Scripts"
|
||||
|
||||
# PROP Default_Filter "js;vbs"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Scripts\Basic.vbs
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Cbrowse.rgs
|
||||
|
|
Загрузка…
Ссылка в новой задаче