[Scummvm-cvs-logs] SF.net SVN: scummvm:[50400] scummvm/branches/gsoc2010-testbed/engines/ testbed

sud03r at users.sourceforge.net sud03r at users.sourceforge.net
Sun Jun 27 23:09:57 CEST 2010


Revision: 50400
          http://scummvm.svn.sourceforge.net/scummvm/?rev=50400&view=rev
Author:   sud03r
Date:     2010-06-27 21:09:57 +0000 (Sun, 27 Jun 2010)

Log Message:
-----------
added files for misc tests, implemented the datetime test

Modified Paths:
--------------
    scummvm/branches/gsoc2010-testbed/engines/testbed/module.mk
    scummvm/branches/gsoc2010-testbed/engines/testbed/testbed.cpp

Added Paths:
-----------
    scummvm/branches/gsoc2010-testbed/engines/testbed/misc.cpp
    scummvm/branches/gsoc2010-testbed/engines/testbed/misc.h

Added: scummvm/branches/gsoc2010-testbed/engines/testbed/misc.cpp
===================================================================
--- scummvm/branches/gsoc2010-testbed/engines/testbed/misc.cpp	                        (rev 0)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/misc.cpp	2010-06-27 21:09:57 UTC (rev 50400)
@@ -0,0 +1,89 @@
+/* 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 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ */
+
+#include "testbed/misc.h"
+
+namespace Testbed {
+
+void MiscTests::getHumanReadableFormat(TimeDate &td, Common::String &date) {
+	// XXX: can use snprintf?
+	char strDate[100];
+	snprintf(strDate, 100, "%d:%d:%d on %d/%d/%d (dd/mm/yy)", td.tm_hour, td.tm_min, td.tm_sec, td.tm_mday, td.tm_mon, td.tm_year);
+	date = strDate;
+	return;
+}
+
+bool MiscTests::testDateTime() {
+	TimeDate t1, t2;
+	g_system->getTimeAndDate(t1);
+	printf("LOG: Current Time and Date: ");
+	Common::String dateTimeNow;
+	getHumanReadableFormat(t1, dateTimeNow);
+	printf("%s\n", dateTimeNow.c_str());
+
+	if (Testsuite::isInteractive) {
+		// Directly verify date
+		dateTimeNow = "We expect the current date time to be " + dateTimeNow;
+		Testsuite::clearScreen();
+		if (Testsuite::handleInteractiveInput(dateTimeNow, "Correct!", "Wrong", kOptionRight)) {
+			return false;
+		}
+	}
+
+	// Now, Put some delay
+	g_system->delayMillis(2000);
+	g_system->getTimeAndDate(t2);
+	printf("LOG: Time and Date 2s later: ");
+	getHumanReadableFormat(t2, dateTimeNow);
+	printf("%s\n", dateTimeNow.c_str());
+	
+	if (t1.tm_year == t2.tm_year && t1.tm_mon == t2.tm_mon && t1.tm_mday == t2.tm_mday) {
+		if (t1.tm_mon == t2.tm_mon && t1.tm_year == t2.tm_year){
+			// Ignore lag due to processing time
+			if (t1.tm_sec + 2 == t2.tm_sec) {
+				return true;
+			}
+		}
+	}
+	return false;
+}
+
+bool MiscTests::testTimers() {
+	return true;
+}
+
+bool MiscTests::testMutexes() {
+	return true;
+}
+
+MiscTestSuite::MiscTestSuite() {
+	addTest("Date/time", &MiscTests::testDateTime);	
+	addTest("Timers", &MiscTests::testTimers);	
+	addTest("Mutexes", &MiscTests::testMutexes);	
+}
+const char *MiscTestSuite::getName() const {
+	return "Misc. Tests: Datetime/Timer/Mutextes";
+}
+
+} // End of namespace Testbed


Property changes on: scummvm/branches/gsoc2010-testbed/engines/testbed/misc.cpp
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:keywords
   + Date Rev Author URL Id
Added: svn:eol-style
   + native

Added: scummvm/branches/gsoc2010-testbed/engines/testbed/misc.h
===================================================================
--- scummvm/branches/gsoc2010-testbed/engines/testbed/misc.h	                        (rev 0)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/misc.h	2010-06-27 21:09:57 UTC (rev 50400)
@@ -0,0 +1,65 @@
+/* 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 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ */
+
+#ifndef TESTBED_MISC_H
+#define TESTBED_MISC_H
+
+#include "testbed/testsuite.h"
+
+
+namespace Testbed {
+
+namespace MiscTests {
+
+// Miscellaneous tests include testing datetime, timers and mutexes
+
+// Helper functions for Misc tests
+void getHumanReadableFormat(TimeDate &td, Common::String &date);
+
+// will contain function declarations for Misc tests
+bool testDateTime();
+bool testTimers();
+bool testMutexes();
+// add more here
+}
+
+class MiscTestSuite : public Testsuite {
+public:
+	/**
+	 * The constructor for the MiscTestSuite
+	 * 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()
+	 */
+	MiscTestSuite();
+	~MiscTestSuite(){}
+	const char *getName() const;
+
+};
+
+}	// End of namespace Testbed
+
+#endif


Property changes on: scummvm/branches/gsoc2010-testbed/engines/testbed/misc.h
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:keywords
   + Date Rev Author URL Id
Added: svn:eol-style
   + native

Modified: scummvm/branches/gsoc2010-testbed/engines/testbed/module.mk
===================================================================
--- scummvm/branches/gsoc2010-testbed/engines/testbed/module.mk	2010-06-27 21:04:47 UTC (rev 50399)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/module.mk	2010-06-27 21:09:57 UTC (rev 50400)
@@ -4,6 +4,7 @@
 	detection.o \
 	fs.o \
 	graphics.o \
+	misc.o \
 	savegame.o \
 	testbed.o \
 	testsuite.o

Modified: scummvm/branches/gsoc2010-testbed/engines/testbed/testbed.cpp
===================================================================
--- scummvm/branches/gsoc2010-testbed/engines/testbed/testbed.cpp	2010-06-27 21:04:47 UTC (rev 50399)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/testbed.cpp	2010-06-27 21:09:57 UTC (rev 50400)
@@ -29,6 +29,7 @@
  
 #include "testbed/fs.h"
 #include "testbed/graphics.h"
+#include "testbed/misc.h"
 #include "testbed/savegame.h"
 #include "testbed/testbed.h"
  
@@ -103,6 +104,9 @@
 	SaveGameTestSuite sts;
 	sts.execute();
 	
+	MiscTestSuite mts;
+	mts.execute();
+	
 	return Common::kNoError;
 }
  


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list