mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 854921 - Pass firefox path to metrotestharness so tests.ini can be written to a location that works with test zips / test slaves. Also add metro tests to mochitest tests.jar. r=mbrubeck, bbondy
This commit is contained in:
parent
e4e5257f3d
commit
7239b54c6f
@ -28,6 +28,13 @@ static const WCHAR* kFirefoxExe = L"firefox.exe";
|
||||
static const WCHAR* kDefaultMetroBrowserIDPathKey = L"FirefoxURL";
|
||||
static const WCHAR* kDemoMetroBrowserIDPathKey = L"Mozilla.Firefox.URL";
|
||||
|
||||
CString sAppParams;
|
||||
CString sFirefoxPath;
|
||||
|
||||
// The tests file we write out for firefox.exe which contains test
|
||||
// startup command line paramters.
|
||||
#define kMetroTestFile "tests.ini"
|
||||
|
||||
static void Log(const wchar_t *fmt, ...)
|
||||
{
|
||||
va_list a = NULL;
|
||||
@ -134,7 +141,20 @@ static bool GetDefaultBrowserAppModelID(WCHAR* aIDBuffer,
|
||||
return true;
|
||||
}
|
||||
|
||||
CString sAppParams;
|
||||
// Tests.ini file cleanup helper
|
||||
class DeleteTestFileHelper
|
||||
{
|
||||
CStringA mTestFile;
|
||||
public:
|
||||
DeleteTestFileHelper(CStringA& aTestFile) :
|
||||
mTestFile(aTestFile) {}
|
||||
~DeleteTestFileHelper() {
|
||||
if (mTestFile.GetLength()) {
|
||||
Log(L"Deleting %s", CStringW(mTestFile));
|
||||
DeleteFileA(mTestFile);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
static bool Launch()
|
||||
{
|
||||
@ -143,7 +163,7 @@ static bool Launch()
|
||||
DWORD processID;
|
||||
|
||||
// The interface that allows us to activate the browser
|
||||
IApplicationActivationManager* activateMgr = NULL;
|
||||
CComPtr<IApplicationActivationManager> activateMgr;
|
||||
if (FAILED(CoCreateInstance(CLSID_ApplicationActivationManager, NULL,
|
||||
CLSCTX_LOCAL_SERVER,
|
||||
IID_IApplicationActivationManager,
|
||||
@ -157,7 +177,6 @@ static bool Launch()
|
||||
// Activation is based on the browser's registered app model id
|
||||
if (!GetDefaultBrowserAppModelID(appModelID, (sizeof(appModelID)/sizeof(WCHAR)))) {
|
||||
Fail(L"GetDefaultBrowserAppModelID failed.");
|
||||
activateMgr->Release();
|
||||
return false;
|
||||
}
|
||||
Log(L"App model id='%s'", appModelID);
|
||||
@ -167,7 +186,6 @@ static bool Launch()
|
||||
hr = CoAllowSetForegroundWindow(activateMgr, NULL);
|
||||
if (FAILED(hr)) {
|
||||
Fail(L"CoAllowSetForegroundWindow result %X", hr);
|
||||
activateMgr->Release();
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -175,34 +193,49 @@ static bool Launch()
|
||||
|
||||
// Because we can't pass command line args, we store params in a
|
||||
// tests.ini file in dist/bin which the browser picks up on launch.
|
||||
char path[MAX_PATH];
|
||||
if (!GetModuleFileNameA(NULL, path, MAX_PATH)) {
|
||||
Fail(L"GetModuleFileNameA errorno=%d", GetLastError());
|
||||
activateMgr->Release();
|
||||
return false;
|
||||
CStringA testFilePath;
|
||||
if (sFirefoxPath.GetLength()) {
|
||||
// Use the firefoxpath passed to us by the test harness
|
||||
int index = sFirefoxPath.ReverseFind('\\');
|
||||
if (index == -1) {
|
||||
Fail(L"Bad firefoxpath path");
|
||||
return false;
|
||||
}
|
||||
testFilePath = sFirefoxPath.Mid(0, index);
|
||||
testFilePath += "\\";
|
||||
testFilePath += kMetroTestFile;
|
||||
} else {
|
||||
// Use the module path
|
||||
char path[MAX_PATH];
|
||||
if (!GetModuleFileNameA(NULL, path, MAX_PATH)) {
|
||||
Fail(L"GetModuleFileNameA errorno=%d", GetLastError());
|
||||
return false;
|
||||
}
|
||||
char* slash = strrchr(path, '\\');
|
||||
if (!slash)
|
||||
return false;
|
||||
*slash = '\0'; // no trailing slash
|
||||
testFilePath = path;
|
||||
testFilePath += "\\";
|
||||
testFilePath += kMetroTestFile;
|
||||
}
|
||||
char* slash = strrchr(path, '\\');
|
||||
if (!slash)
|
||||
return false;
|
||||
*slash = '\0'; // no trailing slash
|
||||
CStringA testFilePath = path;
|
||||
testFilePath += "\\tests.ini";
|
||||
|
||||
Log(L"Writing out tests.ini to: '%s'", CStringW(testFilePath));
|
||||
HANDLE hTestFile = CreateFileA(testFilePath, GENERIC_WRITE,
|
||||
0, NULL, CREATE_ALWAYS,
|
||||
FILE_ATTRIBUTE_NORMAL,
|
||||
NULL);
|
||||
if (hTestFile == INVALID_HANDLE_VALUE) {
|
||||
Fail(L"CreateFileA errorno=%d", GetLastError());
|
||||
activateMgr->Release();
|
||||
return false;
|
||||
}
|
||||
|
||||
DeleteTestFileHelper dtf(testFilePath);
|
||||
|
||||
CStringA asciiParams = sAppParams;
|
||||
if (!WriteFile(hTestFile, asciiParams, asciiParams.GetLength(), NULL, 0)) {
|
||||
CloseHandle(hTestFile);
|
||||
Fail(L"WriteFile errorno=%d", GetLastError());
|
||||
activateMgr->Release();
|
||||
return false;
|
||||
}
|
||||
FlushFileBuffers(hTestFile);
|
||||
@ -212,7 +245,6 @@ static bool Launch()
|
||||
hr = activateMgr->ActivateApplication(appModelID, L"", AO_NOERRORUI, &processID);
|
||||
if (FAILED(hr)) {
|
||||
Fail(L"ActivateApplication result %X", hr);
|
||||
activateMgr->Release();
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -221,7 +253,6 @@ static bool Launch()
|
||||
HANDLE child = OpenProcess(SYNCHRONIZE, FALSE, processID);
|
||||
if (!child) {
|
||||
Fail(L"Couldn't find child process. (%d)", GetLastError());
|
||||
activateMgr->Release();
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -237,8 +268,6 @@ static bool Launch()
|
||||
}
|
||||
|
||||
Log(L"Exiting.");
|
||||
activateMgr->Release();
|
||||
DeleteFileA(testFilePath);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -247,11 +276,29 @@ int wmain(int argc, WCHAR* argv[])
|
||||
CoInitialize(NULL);
|
||||
|
||||
int idx;
|
||||
bool firefoxParam = false;
|
||||
for (idx = 1; idx < argc; idx++) {
|
||||
CString param = argv[idx];
|
||||
param.Trim();
|
||||
|
||||
// Pickup the firefox path param and store it, we'll need this
|
||||
// when we create the tests.ini file.
|
||||
if (param == "-firefoxpath") {
|
||||
firefoxParam = true;
|
||||
continue;
|
||||
} else if (firefoxParam) {
|
||||
firefoxParam = false;
|
||||
sFirefoxPath = param;
|
||||
continue;
|
||||
}
|
||||
|
||||
sAppParams.Append(argv[idx]);
|
||||
sAppParams.Append(L" ");
|
||||
}
|
||||
sAppParams.Trim();
|
||||
if (sFirefoxPath.GetLength()) {
|
||||
Log(L"firefoxpath: '%s'", sFirefoxPath);
|
||||
}
|
||||
Log(L"args: '%s'", sAppParams);
|
||||
Launch();
|
||||
|
||||
|
@ -180,6 +180,9 @@ stage-chromejar:
|
||||
$(NSINSTALL) -D $(PKG_CHROMEJAR)
|
||||
cp -RL $(DEPTH)/_tests/testing/mochitest/browser $(PKG_CHROMEJAR)
|
||||
cp -RL $(DEPTH)/_tests/testing/mochitest/chrome $(PKG_CHROMEJAR)
|
||||
ifdef MOZ_METRO
|
||||
cp -RL $(DEPTH)/_tests/testing/mochitest/metro $(PKG_CHROMEJAR)
|
||||
endif
|
||||
ifdef ACCESSIBILITY
|
||||
cp -RL $(DEPTH)/_tests/testing/mochitest/a11y $(PKG_CHROMEJAR)
|
||||
endif
|
||||
|
@ -735,6 +735,7 @@ class Mochitest(object):
|
||||
testURL = None
|
||||
|
||||
if options.immersiveMode:
|
||||
options.browserArgs.extend(('-firefoxpath', options.app))
|
||||
options.app = self.immersiveHelperPath
|
||||
|
||||
# Remove the leak detection file so it can't "leak" to the tests run.
|
||||
|
Loading…
Reference in New Issue
Block a user