aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/sfx/tests
diff options
context:
space:
mode:
authorJordi Vilalta Prat2009-02-15 06:10:59 +0000
committerJordi Vilalta Prat2009-02-15 06:10:59 +0000
commitfa6e10e9cec163845aa29e7940c86e9c9ab8a2bc (patch)
treece87338830cc8c149e1de545246bcefe4f45da00 /engines/sci/sfx/tests
parent7c148ddf021c990fa866b7600f979aac9a5b26c9 (diff)
downloadscummvm-rg350-fa6e10e9cec163845aa29e7940c86e9c9ab8a2bc.tar.gz
scummvm-rg350-fa6e10e9cec163845aa29e7940c86e9c9ab8a2bc.tar.bz2
scummvm-rg350-fa6e10e9cec163845aa29e7940c86e9c9ab8a2bc.zip
Import the SCI engine sources from the FreeSCI Glutton branch (it doesn't compile yet)
svn-id: r38192
Diffstat (limited to 'engines/sci/sfx/tests')
-rw-r--r--engines/sci/sfx/tests/stubs.c9
-rw-r--r--engines/sci/sfx/tests/tests.cpp172
-rw-r--r--engines/sci/sfx/tests/tests.vcproj158
3 files changed, 339 insertions, 0 deletions
diff --git a/engines/sci/sfx/tests/stubs.c b/engines/sci/sfx/tests/stubs.c
new file mode 100644
index 0000000000..06da6f9419
--- /dev/null
+++ b/engines/sci/sfx/tests/stubs.c
@@ -0,0 +1,9 @@
+int sciprintf(char *fmt,...)
+{
+ return 0;
+}
+
+int sfx_pcm_available()
+{
+ return 1;
+} \ No newline at end of file
diff --git a/engines/sci/sfx/tests/tests.cpp b/engines/sci/sfx/tests/tests.cpp
new file mode 100644
index 0000000000..10eacc0de2
--- /dev/null
+++ b/engines/sci/sfx/tests/tests.cpp
@@ -0,0 +1,172 @@
+#include <stdio.h>
+#include <sfx_iterator.h>
+
+#define TESTEQUAL(x, y) if(x != y) printf("test failure: expected %04x, got %04x @ file %s line %d \n", x, y, __FILE__, __LINE__);
+
+static char calledDeathListenerCallback;
+
+static unsigned char song[] = {
+// PCM not present
+0,
+// channel defs
+0, 0x20, 0, 0x21, 0, 0, 0, 0,
+0, 0, 0, 0, 0, 0, 0, 0,
+0, 0, 0, 0, 0, 0, 0, 0,
+0, 0, 0, 0, 0, 0, 0, 0,
+// note on, wait, note off
+0xAA,
+0x90, 0xAA, 0xAA,
+0xAA,
+0x80, 0xAA, 0xAA,
+0xAA,
+0x91, 0xAA, 0xAA,
+0xAA,
+0x81, 0xAA, 0xAA,
+0xAA,
+// end track
+0xFC};
+
+#define SONG_CMD_COUNT 10
+
+#define TEST_SETUP() \
+ unsigned char cmds[4] = {0}; \
+ int result = 0; \
+ int message; \
+ int i; \
+\
+ song_iterator_t *it = songit_new(song, sizeof(song), 0, 0); \
+ it->init(it); \
+ SIMSG_SEND(it, SIMSG_SET_PLAYMASK(0x20));\
+ calledDeathListenerCallback = 0;
+
+#define TEST_TEARDOWN() \
+ songit_free(it);
+
+
+void testFinishSong()
+{
+ TEST_SETUP();
+ message = songit_next(&it, &cmds, &result, IT_READER_MASK_ALL);
+ TESTEQUAL(0xAA, message);
+
+ message = songit_next(&it, &cmds, &result, IT_READER_MASK_ALL);
+ TESTEQUAL(0, message);
+ TESTEQUAL(3, result);
+
+ for (i=0; i < SONG_CMD_COUNT - 2; i++)
+ {
+ message = songit_next(&it, &cmds, &result, IT_READER_MASK_ALL);
+ }
+
+ TESTEQUAL(SI_FINISHED, message);
+
+ TEST_TEARDOWN();
+}
+
+
+void DeathListenerCallback(void *v1, void *v2)
+{
+ calledDeathListenerCallback++;
+ return;
+}
+
+void testDeathListener()
+{
+ TEST_SETUP();
+
+ song_iterator_add_death_listener(
+ it,
+ it,
+ (void (*)(void *, void*))DeathListenerCallback);
+
+ for (i=0; i < SONG_CMD_COUNT; i++)
+ {
+ message = songit_next(&it, &cmds, &result, IT_READER_MASK_ALL);
+ }
+
+ TESTEQUAL(SI_FINISHED, message);
+
+ TEST_TEARDOWN();
+
+ TESTEQUAL(1, calledDeathListenerCallback);
+}
+
+void testMultipleDeathListeners()
+{
+ TEST_SETUP();
+
+ song_iterator_add_death_listener(
+ it,
+ it,
+ (void (*)(void *, void*))DeathListenerCallback);
+
+ song_iterator_add_death_listener(
+ it,
+ it,
+ (void (*)(void *, void*))DeathListenerCallback);
+
+ for (i=0; i < SONG_CMD_COUNT; i++)
+ {
+ message = songit_next(&it, &cmds, &result, IT_READER_MASK_ALL);
+ }
+
+ TESTEQUAL(SI_FINISHED, message);
+
+ TEST_TEARDOWN();
+
+ TESTEQUAL(2, calledDeathListenerCallback);
+}
+
+void testStopSong()
+{
+ TEST_SETUP();
+ SIMSG_SEND(it, SIMSG_STOP);
+
+ message = songit_next(&it, &cmds, &result, IT_READER_MASK_ALL);
+ TESTEQUAL(SI_FINISHED, message);
+
+ TEST_TEARDOWN();
+}
+
+void testStopLoopedSong()
+{
+ TEST_SETUP();
+
+ SIMSG_SEND(it, SIMSG_SET_LOOPS(3));
+ message = songit_next(&it, &cmds, &result, IT_READER_MASK_ALL);
+ TESTEQUAL(0xAA, message);
+
+ SIMSG_SEND(it, SIMSG_STOP);
+ message = songit_next(&it, &cmds, &result, IT_READER_MASK_ALL);
+ TESTEQUAL(SI_FINISHED, message);
+
+ TEST_TEARDOWN();
+}
+
+void testChangeSongMask()
+{
+ TEST_SETUP();
+
+ message = songit_next(&it, &cmds, &result, IT_READER_MASK_ALL);
+ TESTEQUAL(0xAA, message);
+
+ SIMSG_SEND(it, SIMSG_SET_PLAYMASK(0x40));
+ message = songit_next(&it, &cmds, &result, IT_READER_MASK_ALL);
+ TESTEQUAL(0, message);
+ TESTEQUAL(0, result);
+
+ TEST_TEARDOWN();
+}
+
+
+int main(int argc, char* argv[])
+{
+ testFinishSong();
+ testDeathListener();
+ testMultipleDeathListeners();
+ testStopSong();
+ testStopLoopedSong();
+ testChangeSongMask();
+ return 0;
+}
+
diff --git a/engines/sci/sfx/tests/tests.vcproj b/engines/sci/sfx/tests/tests.vcproj
new file mode 100644
index 0000000000..a50c794bce
--- /dev/null
+++ b/engines/sci/sfx/tests/tests.vcproj
@@ -0,0 +1,158 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="tests"
+ ProjectGUID="{3C6F6B16-D092-495C-B611-03FFDBFF27FC}"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="Debug"
+ IntermediateDirectory="Debug"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="..\..\include;..\..\include\win32"
+ PreprocessorDefinitions="PACKAGE=\&quot;freesci\&quot;;HAVE_GETOPT_H;HAVE_LIBPNG;VERSION=__TIMESTAMP__;_DEBUG;WIN32;_CONSOLE;HAVE_STRING_H;HAVE_MEMCHR"
+ MinimalRebuild="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="5"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="4"
+ CompileAs="1"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="winmm.lib"
+ OutputFile="$(OutDir)/tests.exe"
+ LinkIncremental="2"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/tests.pdb"
+ SubSystem="1"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="Release"
+ IntermediateDirectory="Release"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\include"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="4"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="winmm.lib"
+ OutputFile="$(OutDir)/tests.exe"
+ LinkIncremental="1"
+ GenerateDebugInformation="TRUE"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+ <File
+ RelativePath="..\..\sfx\iterator.c">
+ </File>
+ <File
+ RelativePath="..\..\sfx\pcm-iterator.c">
+ </File>
+ <File
+ RelativePath="..\..\scicore\sci_memory.c">
+ </File>
+ <File
+ RelativePath=".\stubs.c">
+ </File>
+ <File
+ RelativePath=".\tests.cpp">
+ </File>
+ <File
+ RelativePath="..\..\scicore\tools.c">
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
+ <File
+ RelativePath="..\..\include\win32\sci_win32.h">
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
+ </Filter>
+ <File
+ RelativePath=".\ReadMe.txt">
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>