Bug 770772 - Implement WebappRT test framework on Linux. r=adw

This commit is contained in:
Marco Castelluccio 2012-07-14 19:16:58 -04:00
parent 3326c2985e
commit 50e2e1387f
2 changed files with 39 additions and 13 deletions

View File

@ -135,6 +135,9 @@ endif
ifeq ($(OS_ARCH),WINNT)
webapprt_stub_path = $(TARGET_DIST)/bin/webapprt-stub$(BIN_SUFFIX)
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2)
webapprt_stub_path = $(TARGET_DIST)/bin/webapprt-stub$(BIN_SUFFIX)
endif
ifdef webapprt_stub_path
webapprt-test-content:

View File

@ -28,6 +28,8 @@ const char kAPP_RT[] = "webapprt-stub";
int* pargc;
char*** pargv;
char profile[MAXPATHLEN];
bool isProfileOverridden = false;
XRE_GetFileFromPathType XRE_GetFileFromPath;
XRE_CreateAppDataType XRE_CreateAppData;
@ -120,7 +122,7 @@ bool CopyFile(const char* inputFile, const char* outputFile)
return (bytesRead >= 0);
}
bool GRELoadAndLaunch(const char* firefoxDir, const char* profile)
bool GRELoadAndLaunch(const char* firefoxDir)
{
char xpcomDllPath[MAXPATHLEN];
snprintf(xpcomDllPath, MAXPATHLEN, "%s/%s", firefoxDir, XPCOM_DLL);
@ -135,11 +137,13 @@ bool GRELoadAndLaunch(const char* firefoxDir, const char* profile)
return false;
}
// Override the class name part of the WM_CLASS property, so that the
// DE can match our window to the correct launcher
char programClass[MAXPATHLEN];
snprintf(programClass, MAXPATHLEN, "owa-%s", profile);
g_set_prgname(programClass);
if (!isProfileOverridden) {
// Override the class name part of the WM_CLASS property, so that the
// DE can match our window to the correct launcher
char programClass[MAXPATHLEN];
snprintf(programClass, MAXPATHLEN, "owa-%s", profile);
g_set_prgname(programClass);
}
// NOTE: The GRE has successfully loaded, so we can use XPCOM now
{ // Scope for any XPCOM stuff we create
@ -173,8 +177,10 @@ bool GRELoadAndLaunch(const char* firefoxDir, const char* profile)
return false;
}
SetAllocatedString(webShellAppData->profile, profile);
SetAllocatedString(webShellAppData->name, profile);
if (!isProfileOverridden) {
SetAllocatedString(webShellAppData->profile, profile);
SetAllocatedString(webShellAppData->name, profile);
}
nsCOMPtr<nsIFile> directory;
if (NS_FAILED(XRE_GetFileFromPath(rtPath, getter_AddRefs(directory)))) {
@ -231,10 +237,29 @@ int main(int argc, char *argv[])
ErrorDialog("Couldn't read current executable path");
return 255;
}
// Set up webAppIniPath with path to webapp.ini
char curExeDir[MAXPATHLEN];
GetDirFromPath(curExeDir, curExePath);
for (int i = 1; i < argc; i++) {
if (!strcmp(argv[i], "-profile")) {
isProfileOverridden = true;
break;
}
}
char firefoxDir[MAXPATHLEN];
// Check if Firefox is in the ../../dist/bin directory (relative to the webapp runtime)
// This is the case for webapprt chrome and content tests.
snprintf(firefoxDir, MAXPATHLEN, "%s/../../dist/bin", curExeDir);
if (access(firefoxDir, F_OK) != -1) {
if (GRELoadAndLaunch(firefoxDir))
return 0;
return 255;
}
// Set up webAppIniPath with path to webapp.ini
char webAppIniPath[MAXPATHLEN];
snprintf(webAppIniPath, MAXPATHLEN, "%s/%s", curExeDir, kWEBAPP_INI);
@ -252,14 +277,12 @@ int main(int argc, char *argv[])
}
// Get profile dir from webapp.ini
char profile[MAXPATHLEN];
if (NS_FAILED(parser.GetString("Webapp", "Profile", profile, MAXPATHLEN))) {
ErrorDialog("Couldn't retrieve profile from web app INI file");
return 255;
}
// Get the location of Firefox from our webapp.ini
char firefoxDir[MAXPATHLEN];
if (NS_FAILED(parser.GetString("WebappRT", "InstallDir", firefoxDir, MAXPATHLEN))) {
ErrorDialog("Couldn't find your Firefox install directory.");
return 255;
@ -285,7 +308,7 @@ int main(int argc, char *argv[])
// If WebAppRT version == Firefox version, load XUL and execute the application
if (!strcmp(buildid, NS_STRINGIFY(GRE_BUILDID))) {
if (GRELoadAndLaunch(firefoxDir, profile))
if (GRELoadAndLaunch(firefoxDir))
return 0;
}
// Else, copy WebAppRT from Firefox installation and re-execute the process