[Scummvm-git-logs] scummvm master -> 0e71404535e0e3671fb4a7dd575951a4be39b9f4

sev- noreply at scummvm.org
Thu Feb 23 17:28:03 UTC 2023


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

Summary:
0e71404535 TESTBED: Add a test suite for the video player


Commit: 0e71404535e0e3671fb4a7dd575951a4be39b9f4
    https://github.com/scummvm/scummvm/commit/0e71404535e0e3671fb4a7dd575951a4be39b9f4
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2023-02-23T18:27:59+01:00

Commit Message:
TESTBED: Add a test suite for the video player

Changed paths:
  A engines/testbed/video.h
    engines/testbed/testbed.cpp
    engines/testbed/testbed.h
    engines/testbed/video.cpp


diff --git a/engines/testbed/testbed.cpp b/engines/testbed/testbed.cpp
index 890d7dd9e79..5223832bbe5 100644
--- a/engines/testbed/testbed.cpp
+++ b/engines/testbed/testbed.cpp
@@ -40,6 +40,7 @@
 #include "testbed/savegame.h"
 #include "testbed/sound.h"
 #include "testbed/testbed.h"
+#include "testbed/video.h"
 #ifdef USE_CLOUD
 #include "testbed/cloud.h"
 #endif
@@ -166,6 +167,9 @@ void TestbedEngine::pushTestsuites(Common::Array<Testsuite *> &testsuiteList) {
 	ts = new WebserverTestSuite();
 	testsuiteList.push_back(ts);
 #endif
+	// Video decoder
+	ts = new VideoDecoderTestSuite();
+	testsuiteList.push_back(ts);
 }
 
 TestbedEngine::~TestbedEngine() {
@@ -213,8 +217,7 @@ void TestbedEngine::checkForAllAchievements() {
 
 Common::Error TestbedEngine::run() {
 	if (ConfMan.hasKey("start_movie")) {
-		videoTest();
-		return Common::kNoError;
+		return Videotests::videoTest(ConfMan.get("start_movie"));
 	}
 
 	// Initialize graphics using following:
diff --git a/engines/testbed/testbed.h b/engines/testbed/testbed.h
index 90300c39b07..1289b1e3acc 100644
--- a/engines/testbed/testbed.h
+++ b/engines/testbed/testbed.h
@@ -60,7 +60,6 @@ public:
 
 private:
 	void checkForAllAchievements();
-	void videoTest();
 
 	Common::Array<Testsuite *> _testsuiteList;
 };
diff --git a/engines/testbed/video.cpp b/engines/testbed/video.cpp
index 9d19c332f15..f0c43447edd 100644
--- a/engines/testbed/video.cpp
+++ b/engines/testbed/video.cpp
@@ -20,26 +20,47 @@
  */
 
 #include "common/events.h"
+#include "common/file.h"
 #include "engines/util.h"
 #include "video/qt_decoder.h"
 #include "video/qt_data.h"
 
 #include "testbed/testbed.h"
+#include "testbed/video.h"
 #include "graphics/palette.h"
+#include "gui/browser.h"
 
 namespace Testbed {
 
-void TestbedEngine::videoTest() {
+Common::Error Videotests::videoTest(const Common::Path &path) {
+	Common::File *file = new Common::File();
+	if (!file->open(path)) {
+		warning("Cannot open file %s", path.toString().c_str());
+		return Common::kNoGameDataFoundError;
+	}
+	return videoTest(file, path.toString());
+}
+
+Common::Error Videotests::videoTest(const Common::FSNode &node) {
+	Common::SeekableReadStream *stream = node.createReadStream();
+	if (!stream) {
+		warning("Cannot open file %s", node.getName().c_str());
+		return Common::kNoGameDataFoundError;
+	}
+
+	return videoTest(stream, node.getName());
+}
+
+Common::Error Videotests::videoTest(Common::SeekableReadStream *stream, const Common::String &name) {
 	Graphics::PixelFormat pixelformat = Graphics::PixelFormat::createFormatCLUT8();
 	initGraphics(640, 480, &pixelformat);
 
-	Common::String path = ConfMan.get("start_movie");
-
 	Video::VideoDecoder *video = new Video::QuickTimeDecoder();
-
-	if (!video->loadFile(path)) {
-		warning("Cannot open video %s", path.c_str());
-		return;
+	if (!video->loadStream(stream)) {
+		warning("Cannot open video %s", name.c_str());
+		delete stream;
+		delete video;
+		return Common::kReadingFailed;
 	}
 
 	const byte *palette = video->getPalette();
@@ -54,7 +75,7 @@ void TestbedEngine::videoTest() {
 	while (!video->endOfVideo()) {
 		if (video->needsUpdate()) {
 			uint32 pos = video->getTime();
-			warning("video time: %d", pos);
+			debug(5, "video time: %d", pos);
 
 			const Graphics::Surface *frame = video->decodeNextFrame();
 			if (frame) {
@@ -78,7 +99,7 @@ void TestbedEngine::videoTest() {
 				if (Engine::shouldQuit()) {
 					video->close();
 					delete video;
-					return;
+					return Common::kNoError;
 				}
 			}
 			g_system->updateScreen();
@@ -87,6 +108,54 @@ void TestbedEngine::videoTest() {
 	}
 	video->close();
 	delete video;
+
+	return Common::kNoError;
+}
+
+TestExitStatus Videotests::testPlayback() {
+	Testsuite::clearScreen();
+	Common::String info = "Video playback test. A QuickTime video should be selected using the file browser, and it'll be played on the screen.";
+
+	Common::Point pt(0, 100);
+	Testsuite::writeOnScreen("Testing video playback", pt);
+
+	if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) {
+		Testsuite::logPrintf("Info! Skipping test : testPlayback\n");
+		return kTestSkipped;
+	}
+
+	GUI::BrowserDialog browser(Common::U32String("Select video file"), false);
+
+	if (browser.runModal() <= 0) {
+		Testsuite::logPrintf("Info! Skipping test : testPlayback\n");
+		return kTestSkipped;
+	}
+
+	byte palette[256 * 3];
+	g_system->getPaletteManager()->grabPalette(palette, 0, 256);
+
+	Common::Error error = videoTest(browser.getResult());
+
+	initGraphics(320, 200);
+	g_system->getPaletteManager()->setPalette(palette, 0, 256);
+
+	if (error.getCode() != Common::kNoError) {
+		Testsuite::logDetailedPrintf("Video playback failed: %s\n", error.getDesc().c_str());
+		return kTestFailed;
+	}
+
+	Common::String prompt = "Did the video display correctly?";
+	if (!Testsuite::handleInteractiveInput(prompt, "Yes", "No", kOptionLeft)) {
+		Testsuite::logDetailedPrintf("Video playback failed\n");
+		return kTestFailed;
+	}
+
+	return kTestPassed;
 }
 
+VideoDecoderTestSuite::VideoDecoderTestSuite() {
+	_isTsEnabled = false;
+	addTest("testPlayback", &Videotests::testPlayback, true);
 }
+
+} // End of namespace Testbed
diff --git a/engines/testbed/video.h b/engines/testbed/video.h
new file mode 100644
index 00000000000..f83b806abd6
--- /dev/null
+++ b/engines/testbed/video.h
@@ -0,0 +1,69 @@
+/* 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_VIDEO_H
+#define TESTBED_VIDEO_H
+
+#include "testbed/testsuite.h"
+
+namespace Testbed {
+
+namespace Videotests {
+
+// Helper functions for Video tests
+
+// will contain function declarations for Video tests
+// add more here
+
+TestExitStatus testPlayback();
+
+Common::Error videoTest(const Common::Path &path);
+Common::Error videoTest(const Common::FSNode &node);
+Common::Error videoTest(Common::SeekableReadStream *stream, const Common::String &name);
+
+} // End of namespace Videotests
+
+class VideoDecoderTestSuite : public Testsuite {
+public:
+	/**
+	 * The constructor for the XXXTestSuite
+	 * For every test to be executed one must:
+	 * 1) Create a function that would invoke the test
+	 * 2) Add that test to list by executing addTest()
+	 *
+	 * @see addTest()
+	 */
+	VideoDecoderTestSuite();
+	~VideoDecoderTestSuite() override {}
+	const char *getName() const override {
+		return "Video";
+	}
+
+	const char *getDescription() const override {
+		return "Video Decoder Subsystem";
+	}
+
+};
+
+
+} // End of namespace Testbed
+
+#endif // TESTBED_SPEECH_H




More information about the Scummvm-git-logs mailing list