History

Merge pull request #13046 from NissimHadar/commandLineParametersForAutotester

Command line parameters for autotester

Sam Gateau committed 8 years ago

Commit 17350a72 parents a42491d 175fa9114 files · +255 −150Browse files

Showing the changes to interface/src/Application.cpp (1 of 14 files). Show all

Unified · Split

interface/src/Application.cpp+54−7
@@ -743,6 +743,11 @@ extern DisplayPluginList getDisplayPlugins(); · 742 unmodified lines
743743 extern InputPluginList getInputPlugins();
744744 extern void saveInputPluginSettings(const InputPluginList& plugins);
745745
746+// Parameters used for running tests from teh command line
747+const QString TEST_SCRIPT_COMMAND { "--testScript" };
748+const QString TEST_QUIT_WHEN_FINISHED_OPTION { "quitWhenFinished" };
749+const QString TEST_SNAPSHOT_LOCATION_COMMAND { "--testSnapshotLocation" };
750+
746751 bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) {
747752 const char** constArgv = const_cast<const char**>(argv);
748753
@@ -777,7 +782,22 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { · 28 unmodified lines
777782
778783 static const auto SUPPRESS_SETTINGS_RESET = "--suppress-settings-reset";
779784 bool suppressPrompt = cmdOptionExists(argc, const_cast<const char**>(argv), SUPPRESS_SETTINGS_RESET);
780− bool previousSessionCrashed = CrashHandler::checkForResetSettings(runningMarkerExisted, suppressPrompt);
785+
786+ // Ignore any previous crashes if running from command line with a test script.
787+ bool inTestMode { false };
788+ for (int i = 0; i < argc; ++i) {
789+ QString parameter(argv[i]);
790+ if (parameter == TEST_SCRIPT_COMMAND) {
791+ inTestMode = true;
792+ break;
793+ }
794+ }
795+
796+ bool previousSessionCrashed { false };
797+ if (!inTestMode) {
798+ previousSessionCrashed = CrashHandler::checkForResetSettings(runningMarkerExisted, suppressPrompt);
799+ }
800+
781801 // get dir to use for cache
782802 static const auto CACHE_SWITCH = "--cache";
783803 QString cacheDir = getCmdOption(argc, const_cast<const char**>(argv), CACHE_SWITCH);
@@ -996,13 +1016,30 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 212 unmodified lines
9961016 setProperty(hifi::properties::STEAM, (steamClient && steamClient->isRunning()));
9971017 setProperty(hifi::properties::CRASHED, _previousSessionCrashed);
9981018 {
999− const QString TEST_SCRIPT = "--testScript";
10001019 const QStringList args = arguments();
1020+
10011021 for (int i = 0; i < args.size() - 1; ++i) {
1002− if (args.at(i) == TEST_SCRIPT) {
1022+ if (args.at(i) == TEST_SCRIPT_COMMAND && (i + 1) < args.size()) {
10031023 QString testScriptPath = args.at(i + 1);
1004− if (QFileInfo(testScriptPath).exists()) {
1024+
1025+ // If the URL scheme is http(s) or ftp, then use as is, else - treat it as a local file
1026+ // This is done so as not break previous command line scripts
1027+ if (testScriptPath.left(URL_SCHEME_HTTP.length()) == URL_SCHEME_HTTP || testScriptPath.left(URL_SCHEME_FTP.length()) == URL_SCHEME_FTP) {
1028+ setProperty(hifi::properties::TEST, QUrl::fromUserInput(testScriptPath));
1029+ } else if (QFileInfo(testScriptPath).exists()) {
10051030 setProperty(hifi::properties::TEST, QUrl::fromLocalFile(testScriptPath));
1031+ }
1032+
1033+ // quite when finished parameter must directly follow the test script
1034+ if ((i + 2) < args.size() && args.at(i + 2) == TEST_QUIT_WHEN_FINISHED_OPTION) {
1035+ quitWhenFinished = true;
1036+ }
1037+ } else if (args.at(i) == TEST_SNAPSHOT_LOCATION_COMMAND) {
1038+ // Set test snapshot location only if it is a writeable directory
1039+ QString pathname(args.at(i + 1));
1040+ QFileInfo fileInfo(pathname);
1041+ if (fileInfo.isDir() && fileInfo.isWritable()) {
1042+ testSnapshotLocation = pathname;
10061043 }
10071044 }
10081045 }
@@ -2135,7 +2172,17 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 1126 unmodified lines
21352172 if (testProperty.isValid()) {
21362173 auto scriptEngines = DependencyManager::get<ScriptEngines>();
21372174 const auto testScript = property(hifi::properties::TEST).toUrl();
2138− scriptEngines->loadScript(testScript, false);
2175+
2176+ // Set last parameter to exit interface when the test script finishes, if so requested
2177+ scriptEngines->loadScript(testScript, false, false, false, false, quitWhenFinished);
2178+
2179+ // This is done so we don't get a "connection time-out" message when we haven't passed in a URL.
2180+ if (arguments().contains("--url")) {
2181+ auto reply = SandboxUtils::getStatus();
2182+ connect(reply, &QNetworkReply::finished, this, [=] {
2183+ handleSandboxStatus(reply);
2184+ });
2185+ }
21392186 } else {
21402187 PROFILE_RANGE(render, "GetSandboxStatus");
21412188 auto reply = SandboxUtils::getStatus();
@@ -7465,7 +7512,7 @@ void Application::loadAvatarBrowser() const { · 5323 unmodified lines
74657512 void Application::takeSnapshot(bool notify, bool includeAnimated, float aspectRatio, const QString& filename) {
74667513 postLambdaEvent([notify, includeAnimated, aspectRatio, filename, this] {
74677514 // Get a screenshot and save it
7468− QString path = Snapshot::saveSnapshot(getActiveDisplayPlugin()->getScreenshot(aspectRatio), filename);
7515+ QString path = Snapshot::saveSnapshot(getActiveDisplayPlugin()->getScreenshot(aspectRatio), filename, testSnapshotLocation);
74697516 // If we're not doing an animated snapshot as well...
74707517 if (!includeAnimated) {
74717518 // Tell the dependency manager that the capture of the still snapshot has taken place.
@@ -7479,7 +7526,7 @@ void Application::takeSnapshot(bool notify, bool includeAnimated, float aspectRa · 7 unmodified lines
74797526
74807527 void Application::takeSecondaryCameraSnapshot(const QString& filename) {
74817528 postLambdaEvent([filename, this] {
7482− QString snapshotPath = Snapshot::saveSnapshot(getActiveDisplayPlugin()->getSecondaryCameraScreenshot(), filename);
7529+ QString snapshotPath = Snapshot::saveSnapshot(getActiveDisplayPlugin()->getSecondaryCameraScreenshot(), filename, testSnapshotLocation);
74837530 emit DependencyManager::get<WindowScriptingInterface>()->stillSnapshotTaken(snapshotPath, true);
74847531 });
74857532 }