//------------------------------------------------------------------------------
// Lamp : Open source game middleware
// Copyright (C) 2004  Junpei Ohtani ( Email : junpee@users.sourceforge.jp )
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library 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
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//------------------------------------------------------------------------------

/** @file
 * Lamp for Maya Test 実装
 * @author Junpee
 */

#include "System/stdafx.h"
#include "Test/LampForMayaTest.h"
#include "Test/LampForMayaAllTests.h"
#include <Core/Utility/Timer.h>

namespace LampForMaya{

//------------------------------------------------------------------------------
// 実行
MStatus LampForMayaTest::doIt(const MArgList& args){
	//--------------------------------------------------------------------------
	// タイマ初期化
	Timer::initialize();
	Timer::Tick startTime = Timer::getTick();

	//--------------------------------------------------------------------------
	// テスト初期化
	TestStringListener listener;
	TestResult result;
	result.addListener(&listener);
	LampForMayaAllTests allTest;
	listener.print("------------------------------"
		"-------------------------------------------------\n");
	listener.printFormat(
		"テスト開始  テスト数 %d\n", allTest.getCountTestCases());
	allTest.run(&result);
//	MGlobal::executeCommand("file -new", true, true);

	//--------------------------------------------------------------------------
	// 時間表示
	float time = Timer::getInterval(startTime);
	listener.printFormat("\nテスト終了 %.3fms  %d / %d (失敗 / 実行数)\n",
		time, result.getFailureCount(), result.getRunCount());
	MStatus mayaResult;
	if(result.wasSuccessful()){
		listener.print("テストは無事終了しました。\n");
		mayaResult = MStatus(MStatus::kSuccess);
	}else{
		listener.print("##############################"
			"#################################################\n");
		listener.print("テストは失敗しました。\n");
		mayaResult = MStatus(MStatus::kFailure);
	}
	listener.print("------------------------------"
		"-------------------------------------------------\n");

	//--------------------------------------------------------------------------
	return mayaResult;
}
//------------------------------------------------------------------------------
} // End of namespace LampForMaya
//------------------------------------------------------------------------------
