[Scummvm-git-logs] scummvm master -> e1e3ff09a54e915219012f743861751a5463dbf4

bluegr noreply at scummvm.org
Sun May 25 11:28:54 UTC 2025


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .

Summary:
e1e3ff09a5 TESTBED: Small Improvements & Bugfixes


Commit: e1e3ff09a54e915219012f743861751a5463dbf4
    https://github.com/scummvm/scummvm/commit/e1e3ff09a54e915219012f743861751a5463dbf4
Author: Christian Kündig (christian at kuendig.info)
Date: 2025-05-25T14:28:52+03:00

Commit Message:
TESTBED: Small Improvements & Bugfixes

* Make Interactive Mode configurable in GUI
* Fix file writing if game data directory is read-only
* Don't block main thread when playing midi
* Add option to open logfile via TextViewerDialog

Changed paths:
  A engines/testbed/detection.h
    engines/testbed/config-params.cpp
    engines/testbed/config.cpp
    engines/testbed/detection.cpp
    engines/testbed/fs.cpp
    engines/testbed/metaengine.cpp
    engines/testbed/midi.cpp
    engines/testbed/testbed.cpp
    engines/testbed/testbed.h
    gui/textviewer.h


diff --git a/engines/testbed/config-params.cpp b/engines/testbed/config-params.cpp
index f5de4817e23..7a549b81837 100644
--- a/engines/testbed/config-params.cpp
+++ b/engines/testbed/config-params.cpp
@@ -53,8 +53,15 @@ void ConfigParams::initLogging(const Common::Path &dirname, const char *filename
 }
 
 void ConfigParams::initLogging(bool enable) {
-	// Default Log Directory is game-data directory and filename is 'testbed.log'.
-	initLogging(ConfMan.getPath("path"), "testbed.log", enable);
+	Common::Path logPath = ConfMan.getPath("path");
+	Common::FSNode logDir(logPath);
+	if (logDir.isWritable()) {
+		// Default Log Directory is game-data directory and filename is 'testbed.log'.
+		initLogging(ConfMan.getPath("path"), "testbed.log", enable);
+	} else {
+		// redirect to savepath if game-data directory is not writable.
+		initLogging(ConfMan.getPath("savepath"), "testbed.log", enable);
+	}
 }
 
 bool ConfigParams::isRerunRequired() {
diff --git a/engines/testbed/config.cpp b/engines/testbed/config.cpp
index 26421a4fd6a..ff81d57a6c9 100644
--- a/engines/testbed/config.cpp
+++ b/engines/testbed/config.cpp
@@ -208,7 +208,8 @@ void TestbedInteractionDialog::handleCommand(GUI::CommandSender *sender, uint32
 void TestbedConfigManager::initDefaultConfiguration() {
 	// Default Configuration
 	// Add Global configuration Parameters here.
-	_configFileInterface.setKey("isSessionInteractive", "Global", "true");
+	ConfParams.setSessionAsInteractive(ConfMan.getBool("interactive-mode"));
+	_configFileInterface.setKey("isSessionInteractive", "Global", ConfParams.isSessionInteractive() ? "true" : "false");
 }
 
 void TestbedConfigManager::writeTestbedConfigToStream(Common::WriteStream *ws) {
diff --git a/engines/testbed/detection.cpp b/engines/testbed/detection.cpp
index bb360ae212f..7431309233c 100644
--- a/engines/testbed/detection.cpp
+++ b/engines/testbed/detection.cpp
@@ -23,6 +23,7 @@
 
 #include "base/plugins.h"
 #include "testbed/testbed.h"
+#include "testbed/detection.h"
 
 static const PlainGameDescriptor testbed_setting[] = {
 	{ "testbed", "Testbed: The Backend Testing Framework" },
@@ -52,6 +53,7 @@ class TestbedMetaEngineDetection : public AdvancedMetaEngineDetection<ADGameDesc
 public:
 	TestbedMetaEngineDetection() : AdvancedMetaEngineDetection(testbedDescriptions, testbed_setting) {
 		_md5Bytes = 512;
+		_guiOptions = GUIO1(GAMEOPTION_INTERACTIVE_MODE);
 	}
 
 	const char *getName() const override {
diff --git a/engines/testbed/detection.h b/engines/testbed/detection.h
new file mode 100644
index 00000000000..93822cff6c4
--- /dev/null
+++ b/engines/testbed/detection.h
@@ -0,0 +1,28 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+ #ifndef TESTBED_DETECTION_H
+ #define TESTBED_DETECTION_H
+ 
+ #define GAMEOPTION_INTERACTIVE_MODE GUIO_GAMEOPTIONS1
+ 
+ #endif
+ 
\ No newline at end of file
diff --git a/engines/testbed/fs.cpp b/engines/testbed/fs.cpp
index 8edf98f68dd..4ff99d3d2f4 100644
--- a/engines/testbed/fs.cpp
+++ b/engines/testbed/fs.cpp
@@ -67,10 +67,10 @@ TestExitStatus FStests::testReadFile() {
 
 	if (!gameRoot.getFSNode().exists() || !gameRoot.getFSNode().isDirectory()) {
 		Testsuite::logDetailedPrintf("game Path should be an existing directory");
-		 return kTestFailed;
+		return kTestFailed;
 	}
 
-	const char *dirList[] = {"test1" ,"Test2", "TEST3" , "tEST4", "test5"};
+	const char *dirList[] = {"test1", "Test2", "TEST3", "tEST4", "test5"};
 	const char *file[] = {"file.txt", "File.txt", "FILE.txt", "fILe.txt", "file"};
 
 	for (unsigned int i = 0; i < ARRAYSIZE(dirList); i++) {
@@ -80,7 +80,7 @@ TestExitStatus FStests::testReadFile() {
 
 		if (!directory) {
 			Testsuite::logDetailedPrintf("Failed to open directory %s during FS tests\n", dirName.c_str());
-			 return kTestFailed;
+			return kTestFailed;
 		}
 
 		if (!readDataFromFile(directory, fileName.c_str())) {
@@ -95,7 +95,7 @@ TestExitStatus FStests::testReadFile() {
 
 		if (!directory) {
 			Testsuite::logDetailedPrintf("Failed to open directory %s during FS tests\n", dirName.c_str());
-			 return kTestFailed;
+			return kTestFailed;
 		}
 
 		if (!readDataFromFile(directory, fileName.c_str())) {
@@ -110,7 +110,7 @@ TestExitStatus FStests::testReadFile() {
 
 		if (!directory) {
 			Testsuite::logDetailedPrintf("Failed to open directory %s during FS tests\n", dirName.c_str());
-			 return kTestFailed;
+			return kTestFailed;
 		}
 
 		if (!readDataFromFile(directory, fileName.c_str())) {
@@ -133,21 +133,24 @@ TestExitStatus FStests::testReadFile() {
  * it is same by reading the file again.
  */
 TestExitStatus FStests::testWriteFile() {
-	const Common::Path &path = ConfMan.getPath("path");
-	Common::FSNode gameRoot(path);
-	if (!gameRoot.exists()) {
+	Common::FSNode testDirectory(ConfMan.getPath("path"));
+	if (!testDirectory.isWritable()) {
+		// redirect to savepath if game-data directory is not writable.
+		testDirectory = Common::FSNode(ConfMan.getPath("savepath"));
+	}
+	if (!testDirectory.exists()) {
 		Testsuite::logPrintf("Couldn't open the game data directory %s",
-				path.toString(Common::Path::kNativeSeparator).c_str());
+				testDirectory.getPath().toString(Common::Path::kNativeSeparator).c_str());
 		 return kTestFailed;
 	}
 
-	Common::FSNode fileToWrite = gameRoot.getChild("testbed.out");
+	Common::FSNode fileToWrite = testDirectory.getChild("testbed.out");
 
 	Common::WriteStream *ws = fileToWrite.createWriteStream();
 
 	if (!ws) {
 		Testsuite::logDetailedPrintf("Can't open writable file in game data dir\n");
-		 return kTestFailed;
+		return kTestFailed;
 	}
 
 	ws->writeString("ScummVM Rocks!");
@@ -157,7 +160,7 @@ TestExitStatus FStests::testWriteFile() {
 	Common::SeekableReadStream *rs = fileToWrite.createReadStream();
 	if (!rs) {
 		Testsuite::logDetailedPrintf("Can't open recently written file testbed.out in game data dir\n");
-		 return kTestFailed;
+		return kTestFailed;
 	}
 	Common::String readFromFile = rs->readLine();
 	delete rs;
@@ -165,26 +168,28 @@ TestExitStatus FStests::testWriteFile() {
 	if (readFromFile.equals("ScummVM Rocks!")) {
 		// All good
 		Testsuite::logDetailedPrintf("Data written and read correctly\n");
-		 return kTestPassed;
+		return kTestPassed;
 	}
 
 	return kTestFailed;
 }
 
-
 /**
  * This test creates a directory testbed.dir, and confirms if the directory is created successfully
  */
 TestExitStatus FStests::testCreateDir() {
-	const Common::Path &path = ConfMan.getPath("path");
-	Common::FSNode gameRoot(path);
-	if (!gameRoot.exists()) {
+	Common::FSNode testDirectory(ConfMan.getPath("path"));
+	if (!testDirectory.isWritable()) {
+		// redirect to savepath if game-data directory is not writable.
+		testDirectory = Common::FSNode(ConfMan.getPath("savepath"));
+	}
+	if (!testDirectory.exists()) {
 		Testsuite::logPrintf("Couldn't open the game data directory %s",
-				path.toString(Common::Path::kNativeSeparator).c_str());
+				testDirectory.getPath().toString(Common::Path::kNativeSeparator).c_str());
 		 return kTestFailed;
 	}
 
-	Common::FSNode dirToCreate = gameRoot.getChild("testbed.dir");
+	Common::FSNode dirToCreate = testDirectory.getChild("testbed.dir");
 
 	// TODO: Delete the directory after creating it
 	if (dirToCreate.exists()) {
@@ -201,8 +206,6 @@ TestExitStatus FStests::testCreateDir() {
 	return kTestPassed;
 }
 
-
-
 FSTestSuite::FSTestSuite() {
 	// FS tests depend on Game Data files.
 	// If those are not found. Disable this testsuite.
diff --git a/engines/testbed/metaengine.cpp b/engines/testbed/metaengine.cpp
index a1f81a4cb97..93fb881d2f3 100644
--- a/engines/testbed/metaengine.cpp
+++ b/engines/testbed/metaengine.cpp
@@ -25,7 +25,26 @@
 
 #include "engines/advancedDetector.h"
 
+#include "common/translation.h"
 #include "testbed/testbed.h"
+#include "testbed/detection.h"
+
+
+static const ADExtraGuiOptionsMap optionsList[] = {
+
+	{
+		GAMEOPTION_INTERACTIVE_MODE,
+		{
+			_s("Run in interactive mode"),
+			_s("Run in interactive mode"),
+			"interactive-mode",
+			true,
+			0,
+			0
+		}
+	},
+	AD_EXTRA_GUI_OPTIONS_TERMINATOR
+};
 
 class TestbedMetaEngine : public AdvancedMetaEngine<ADGameDescription> {
 public:
@@ -33,6 +52,10 @@ public:
 		return "testbed";
 	}
 
+	const ADExtraGuiOptionsMap *getAdvancedExtraGuiOptions() const override {
+		return optionsList;
+	}
+
 	Common::Error createInstance(OSystem *syst, Engine **engine, const ADGameDescription * /* desc */) const override {
 		*engine = new Testbed::TestbedEngine(syst);
 		return Common::kNoError;
diff --git a/engines/testbed/midi.cpp b/engines/testbed/midi.cpp
index a78d8cc4b65..26f9db51dfb 100644
--- a/engines/testbed/midi.cpp
+++ b/engines/testbed/midi.cpp
@@ -54,6 +54,7 @@ void MidiTests::waitForMusicToPlay(MidiParser *parser) {
 
 	CursorMan.showMouse(true);
 	while (!quitLoop) {
+		g_system->delayMillis(10);
 		while (eventMan->pollEvent(event)) {
 			// Quit if explicitly requested!
 			if (Engine::shouldQuit()) {
diff --git a/engines/testbed/testbed.cpp b/engines/testbed/testbed.cpp
index 08b2a55fd9c..b137d52f2a2 100644
--- a/engines/testbed/testbed.cpp
+++ b/engines/testbed/testbed.cpp
@@ -31,6 +31,9 @@
 #include "engines/achievements.h"
 #include "engines/util.h"
 
+#include "gui/textviewer.h"
+#include "gui/gui-manager.h"
+
 #include "testbed/events.h"
 #include "testbed/fs.h"
 #include "testbed/graphics.h"
@@ -90,6 +93,7 @@ void TestbedExitDialog::init() {
 	_yOffset += 5;
 	addButtonXY(_xOffset + 80, _yOffset, 120, 24, "Rerun test suite", kCmdRerunTestbed);
 	addButtonXY(_xOffset + 240, _yOffset, 60, 24, "Close", GUI::kCloseCmd);
+	addButtonXY(_xOffset + 340, _yOffset, 60, 24, "Open Log", kViewLogCmd);
 }
 
 void TestbedExitDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) {
@@ -97,10 +101,16 @@ void TestbedExitDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, ui
 	default:
 		break;
 
-	case kCmdRerunTestbed :
+	case kCmdRerunTestbed:
 		ConfParams.setRerunFlag(true);
 		cmd = GUI::kCloseCmd;
 		break;
+	case kViewLogCmd: 
+		Common::Path logPath = Common::Path(ConfParams.getLogDirectory());
+		GUI::TextViewerDialog viewer(logPath.appendComponent(ConfParams.getLogFilename()));
+		viewer.runModal();
+		g_gui.scheduleTopDialogRedraw();
+		break;
 	}
 
 	GUI::Dialog::handleCommand(sender, cmd, data);
@@ -111,7 +121,7 @@ bool TestbedEngine::hasFeature(EngineFeature f) const {
 }
 
 TestbedEngine::TestbedEngine(OSystem *syst)
- : Engine(syst) {
+	: Engine(syst) {
 	// Put your engine in a sane state, but do nothing big yet;
 	// in particular, do not load data from files; rather, if you
 	// need to do such things, do them from init().
@@ -160,9 +170,9 @@ void TestbedEngine::pushTestsuites(Common::Array<Testsuite *> &testsuiteList) {
 	ts = new NetworkingTestSuite();
 	testsuiteList.push_back(ts);
 #ifdef USE_TTS
-	 // TextToSpeech
-	 ts = new SpeechTestSuite();
-	 testsuiteList.push_back(ts);
+	// TextToSpeech
+	ts = new SpeechTestSuite();
+	testsuiteList.push_back(ts);
 #endif
 #if defined(USE_CLOUD) && defined(USE_LIBCURL)
 	// Cloud
diff --git a/engines/testbed/testbed.h b/engines/testbed/testbed.h
index ee098791e1d..22fcb060aa5 100644
--- a/engines/testbed/testbed.h
+++ b/engines/testbed/testbed.h
@@ -36,7 +36,7 @@ class TestbedConfigManager;
 enum {
 	kTestbedLogOutput = 1,
 	kTestbedEngineDebug,
-
+	kViewLogCmd = 'vwlg',
 	kCmdRerunTestbed = 'crtb'
 };
 
diff --git a/gui/textviewer.h b/gui/textviewer.h
index a50400a0faa..15fa3455623 100644
--- a/gui/textviewer.h
+++ b/gui/textviewer.h
@@ -33,6 +33,7 @@ class Font;
 
 namespace GUI {
 
+class ButtonWidget;
 class ScrollBarWidget;
 
 class TextViewerDialog : public Dialog {




More information about the Scummvm-git-logs mailing list