예제 #1
0
void ExtendedTaskAccessor_testTimeReporting()
{
	TempDB tempdb;
	std::shared_ptr<ITimeAccessor> timeAccessor = tempdb.getTimeAccessor();
	std::shared_ptr<IExtendedTaskAccessor> taskAccessor = tempdb.getExtendedTaskAccessor();
	const int64_t parentId = taskAccessor->newTask("test", 0);
	const int64_t taskId = taskAccessor->newTask("test", parentId);
	timeAccessor->newTime(taskId, 4000, 5000);


	std::shared_ptr<std::vector<ExtendedTask>> tasks = taskAccessor->getExtendedTask(parentId,0,0);
	ExtendedTask task = tasks->at(0);
	int result=task.getTotalTime();
	ASSERT_EQUALM("Test1",1000, result);

	tasks = taskAccessor->getExtendedTask(taskId,0,0);
	task = tasks->at(0);
	result=task.getTotalTime();
	ASSERT_EQUALM("Test2",1000, result);

	tasks = taskAccessor->getExtendedTasks(0,0,0);
	task = tasks->at(0);
	result=task.getTotalTime();
	ASSERT_EQUALM("Test3",1000, result);

	tasks = taskAccessor->getExtendedTasks(parentId,0,0);
	task = tasks->at(0);
	result=task.getTotalTime();
	ASSERT_EQUALM("Test4",1000, result);

}
예제 #2
0
파일: test_db.cpp 프로젝트: Hoglet/TimeIT
void database_testUpgrade()
{
	const char* dbname="/tmp/dbtest.db";
	createVersion4db(dbname);
	Database db("/tmp/dbtest.db");
	shared_ptr<ITaskAccessor> taskAccessor=db.getTaskAccessor();
	ASSERT_EQUALM("Numbers of tasks in tasks", 2, taskAccessor->getTasksChangedSince()->size());
	shared_ptr<Task> task1 = taskAccessor->getTask(1);
	ASSERT_EQUALM("Task 1 name ", string("Test"),task1->getName());
	ASSERT_EQUALM("Task 1 parent ", 0, task1->getParentID());
	ASSERTM("Task 1 uuid is valid ", UUID::isValid(task1->getUUID()));

	shared_ptr<Task> task2 = taskAccessor->getTask(2);
	ASSERT_EQUALM("Task 2 name ", string("Sub task"),task2->getName());
	ASSERT_EQUALM("Task 2 parent ", 1, task2->getParentID());
	ASSERTM("Task 2 uuid is valid ", UUID::isValid(task2->getUUID()));

	shared_ptr<ITimeAccessor> timeAccessor=db.getTimeAccessor();
	shared_ptr<vector<TimeEntry>> times=timeAccessor->getTimesChangedSince();
	ASSERT_EQUALM("Number of times ",1, times->size());
	TimeEntry te = times->at(0);
	ASSERT_EQUALM("Time id ", 1, te.getID());
	ASSERTM("Time uuid is valid ", UUID::isValid(te.getUUID()));
	ASSERT_EQUALM("Time taskID ", 2, te.getTaskID());
	ASSERT_EQUALM("Time start ", 10, te.getStart());
	ASSERT_EQUALM("Time stop ", 100, te.getStop());

	OSAbstraction::unlink("/tmp/dbtest.db");
}
예제 #3
0
파일: test_db.cpp 프로젝트: Hoglet/TimeIT
void database_testTransactions_rollback()
{
	TempDB db;
	db.beginTransaction();
	std::shared_ptr<DB::ITaskAccessor> taskAccessor = db.getTaskAccessor();
	taskAccessor->newTask("Test",0);
	ASSERT_EQUALM("Checking number of tasks after adding one", 1, taskAccessor->getTasksChangedSince()->size());
	db.tryRollback();
	ASSERT_EQUALM("Checking number of tasks after rollback", 0, taskAccessor->getTasksChangedSince()->size());
}
예제 #4
0
void OSAbstraction_test_file_operations()
{
	std::string directory = "/tmp/osatest";
	std::string file = directory + "/test";
	OSAbstraction::mkDir(directory);
	ASSERT_EQUALM("File should not exist before created", false, OSAbstraction::fileExists(file));
	std::ofstream out(file);
	out << "test";
	out.close();
	ASSERT_EQUALM("File should exist", true, OSAbstraction::fileExists(file));
	OSAbstraction::unlink(file);
	ASSERT_EQUALM("File should not exist after deletion", false, OSAbstraction::fileExists(file));
}
예제 #5
0
void TimeAccessor_testGetByID()
{
    TempDB tempdb;
    std::shared_ptr<ITimeAccessor> timeAccessor = tempdb.getTimeAccessor();
    std::shared_ptr<IExtendedTaskAccessor> taskAccessor = tempdb.getExtendedTaskAccessor();
    const int64_t taskId = taskAccessor->newTask("test", 0);
    int64_t timeEntryID = timeAccessor->newTime(taskId, 10, 100);
    TimeEntry te = timeAccessor->getByID(timeEntryID);
    ASSERT_EQUALM("Check task ID", taskId, te.getTaskID());
    ASSERT_EQUALM("Check start", 10, te.getStart());
    ASSERT_EQUALM("Check stop", 100, te.getStop());

}
예제 #6
0
void TimeAccessor_newItem()
{
    TempDB db;
    std::shared_ptr<ITimeAccessor> timeAccessor = db.getTimeAccessor();
    std::shared_ptr<IExtendedTaskAccessor> taskAccessor = db.getExtendedTaskAccessor();
    const int64_t taskId = taskAccessor->newTask("test", 0);
    TimeEntry item1(0, UUID::randomUUID(), taskId, "", 100, 200, false, false, 200);

    int64_t timeEntryID = timeAccessor->newEntry(item1);
    TimeEntry item2 = timeAccessor->getByID(timeEntryID);

    ASSERT_EQUALM("UUID: ", item1.getUUID(), item2.getUUID());
    ASSERT_EQUALM("TaskID: ", item1.getTaskID(), item2.getTaskID());
    ASSERT_EQUALM("Start: ", item1.getStart(), item2.getStart());
    ASSERT_EQUALM("Stop: ", item1.getStop(), item2.getStop());
    ASSERT_EQUALM("Deleted: ", item1.getDeleted(), item2.getDeleted());
    ASSERT_EQUALM("Running: ", item1.getRunning(), item2.getRunning());
    ASSERT_EQUALM("Changed: ", item1.getLastChanged(), item2.getLastChanged());

    ASSERT_THROWSM("Adding existing", timeAccessor->newEntry(item1), dbexception);
//	ASSERT_EQUALM("Updating with identical item ", false, timeAccessor->update(item1));

//	TimeEntry(	int64_t id, std::string uuid, int64_t taskID, std::string taskUUID, time_t start, time_t stop, bool deleted, bool running, int64_t changed);

//	TimeEntry item2( item1.getID(), item1.getUUID(), item1.getTaskID(), item1.getTaskUUID(), item1.getStart(),   )

    //TimeEntry faultyItem1(0, uuidManager.randomUUID(), taskId + 1, "", 100, 200, false, false, 200);

}
예제 #7
0
		static void testConstructor() {
			float x=10.0,y=12.0,z=13.54;
			Z3D_Base::Vector3f temp(x,y,z);

			Z3D_Base::Vector3f temp2 = temp;

			ASSERT_EQUALM("Test failed for vector3f in constructor: x=x",x,temp.getX());
			ASSERT_EQUALM("Test failed for vector3f in constructor: y=y",y,temp.getY());
			ASSERT_EQUALM("Test failed for vector3f in constructor: z=z",z,temp.getZ());

			ASSERT_EQUALM("Test failed for vector3f in copy constructor: x=x",temp2.getX(),temp.getX());
			ASSERT_EQUALM("Test failed for vector3f in copy constructor: y=y",temp2.getY(),temp.getY());
			ASSERT_EQUALM("Test failed for vector3f in copy constructor: z=z",temp2.getZ(),temp.getZ());
		}
예제 #8
0
void Controller_startSequence()
{
	//Create a database object
	shared_ptr<DB::IDatabase> database = std::shared_ptr<DB::IDatabase>(new TempDB());
	shared_ptr<Timer> timer = std::shared_ptr<Timer>(new Timer());
	shared_ptr<ITimeKeeper> timekeeper = std::shared_ptr<ITimeKeeper>(new MockTimeKeeper());
	shared_ptr<MockGuiFactory> guiFactory= std::shared_ptr<MockGuiFactory>(new MockGuiFactory());
	MockStatusIcon& statusIcon = static_cast<MockStatusIcon&>(guiFactory->getStatusIcon());

	ASSERT_EQUALM("Checking status of status icon before start sequence ", false, statusIcon.visible);
	ASSERT_EQUALM("Checking status of widgetIdentifier before start sequence ", GUI::MAX_WIDGETS, guiFactory->widgetIdentifier);
	ASSERT_EQUALM("Checking status of mockWidget before start sequence ", false, guiFactory->widget->is_visible());

	shared_ptr<GUI::IGUIFactory> gfactory = std::static_pointer_cast<GUI::IGUIFactory>(guiFactory);
	Controller controller(gfactory, timekeeper, database);
	controller.start();
	ASSERT_EQUALM("Checking status of status icon after start sequence ", true, statusIcon.visible);
	ASSERT_EQUALM("Checking status of widgetIdentifier after start sequence ", GUI::MAIN_WINDOW, guiFactory->widgetIdentifier);
	ASSERT_EQUALM("Checking status of mockWidget after start sequence ", true, guiFactory->widget->is_visible());

}
void Assertion::ASSERT_ANY_EQUALM(std::string msg, const ROAnything &expected, const ROAnything &actual) {
	OStringStream oexp(&sexp), oact(&act);
	expected.Export(oexp, false);
	actual.Export(oact, false);
	ASSERT_EQUALM(msg, sexp, act);
}
void test_int_queue_of_capacity_thousand_has_size_zero() {
	BoundedQueue<int> const queue{1000};
	ASSERT_EQUALM("New queue should be empty", 0, queue.size());
}
예제 #11
0
		static void testArithematicOperators()
		{
			float x=10.1,y=23.5,z=13.54;
			float x1=12.5,y1=13.2,z1=13.154;

			Z3D_Base::Vector3f temp(x,y,z);
			Z3D_Base::Vector3f temp1(x1,y1,z1);
			Z3D_Base::Vector3f temp2;

			//Test vector addition://
			//temp2 = temp1.operator+(temp);
			temp2=temp1+temp;
			ASSERT_EQUALM("Test failed for vector3f in operator arithematic(vector): x=x1+x2",temp.getX()+temp1.getX(),temp2.getX());
			ASSERT_EQUALM("Test failed for vector3f in operator arithematic(vector): y=y1+y2",temp.getY()+temp1.getY(),temp2.getY());
			ASSERT_EQUALM("Test failed for vector3f in operator arithematic(vector): z=z1+z2",temp.getZ()+temp1.getZ(),temp2.getZ());

			//Test vector self addition://
			temp2 = temp;
			temp += temp1;
			ASSERT_EQUALM("Test failed for vector3f in operator arithematic(vector): y+=y2",temp2.getX()+temp1.getX(),temp.getX());
			ASSERT_EQUALM("Test failed for vector3f in operator arithematic(vector): x+=x2",temp2.getY()+temp1.getY(),temp.getY());
			ASSERT_EQUALM("Test failed for vector3f in operator arithematic(vector): z+=z2",temp2.getZ()+temp1.getZ(),temp.getZ());

			//Test float addition://
			temp1 = temp + x;
			ASSERT_EQUALM("Test failed for vector3f in operator arithematic: X1=X + x",temp.getX()+x,temp1.getX());
			ASSERT_EQUALM("Test failed for vector3f in operator arithematic: Y1=Y + x",temp.getY()+x,temp1.getY());
			ASSERT_EQUALM("Test failed for vector3f in operator arithematic: Z1=Z + x",temp.getZ()+x,temp1.getZ());

			//Test float self addition://
			temp2 = temp;
			temp += x;
			ASSERT_EQUALM("Test failed for vector3f in operator arithematic: X1+=x",temp2.getX()+x,temp.getX());
			ASSERT_EQUALM("Test failed for vector3f in operator arithematic: Y1+=x",temp2.getY()+x,temp.getY());
			ASSERT_EQUALM("Test failed for vector3f in operator arithematic: Z1+=x",temp2.getZ()+x,temp.getZ());

			//Test vector subtraction://
			temp2 = temp-temp1;
			ASSERT_EQUALM("Test failed for vector3f in operator arithematic(vector): x=x1-x2",temp.getX()-temp1.getX(),temp2.getX());
			ASSERT_EQUALM("Test failed for vector3f in operator arithematic(vector): y=y1-y2",temp.getY()-temp1.getY(),temp2.getY());
			ASSERT_EQUALM("Test failed for vector3f in operator arithematic(vector): z=z1-z2",temp.getZ()-temp1.getZ(),temp2.getZ());

			//Test vector self subtraction://
			temp2 = temp;
			temp -= temp1;
			ASSERT_EQUALM("Test failed for vector3f in operator arithematic(vector): y-=y2",temp2.getX()-temp1.getX(),temp.getX());
			ASSERT_EQUALM("Test failed for vector3f in operator arithematic(vector): x-=x2",temp2.getY()-temp1.getY(),temp.getY());
			ASSERT_EQUALM("Test failed for vector3f in operator arithematic(vector): z-=z2",temp2.getZ()-temp1.getZ(),temp.getZ());

			//Test float subtraction://
			temp1 = temp - x;
			ASSERT_EQUALM("Test failed for vector3f in operator arithematic: X1=X - x",temp.getX()-x,temp1.getX());
			ASSERT_EQUALM("Test failed for vector3f in operator arithematic: Y1=Y - x",temp.getY()-x,temp1.getY());
			ASSERT_EQUALM("Test failed for vector3f in operator arithematic: Z1=Z - z",temp.getZ()-x,temp1.getZ());

			//Test float self subtraction://
			temp2 = temp;
			temp -= x;
			ASSERT_EQUALM("Test failed for vector3f in operator arithematic: X1-=x",temp2.getX()-x,temp.getX());
			ASSERT_EQUALM("Test failed for vector3f in operator arithematic: Y1-=x",temp2.getY()-x,temp.getY());
			ASSERT_EQUALM("Test failed for vector3f in operator arithematic: Z1-=x",temp2.getZ()-x,temp.getZ());

			//Test float division://
			temp1 = temp / x;
			ASSERT_EQUALM("Test failed for vector3f in operator arithematic: X1=X / x",temp.getX()/x,temp1.getX());
			ASSERT_EQUALM("Test failed for vector3f in operator arithematic: Y1=Y / x",temp.getY()/x,temp1.getY());
			ASSERT_EQUALM("Test failed for vector3f in operator arithematic: Z1=Z / x",temp.getZ()/x,temp1.getZ());

			//Test float self division://
			temp2 = temp;
			temp /= x;
			ASSERT_EQUALM("Test failed for vector3f in operator arithematic: X1/=x",temp2.getX()/x,temp.getX());
			ASSERT_EQUALM("Test failed for vector3f in operator arithematic: Y1/=x",temp2.getY()/x,temp.getY());
			ASSERT_EQUALM("Test failed for vector3f in operator arithematic: Z1/=x",temp2.getZ()/x,temp.getZ());

			//Test float multiplication://
			temp1 = temp * x;
			ASSERT_EQUALM("Test failed for vector3f in operator arithematic: X1=X * x",temp.getX()*x,temp1.getX());
			ASSERT_EQUALM("Test failed for vector3f in operator arithematic: Y1=Y * x",temp.getY()*x,temp1.getY());
			ASSERT_EQUALM("Test failed for vector3f in operator arithematic: Z1=Z * x",temp.getZ()*x,temp1.getZ());

			//Test float self multiplication://
			temp2 = temp;
			temp *= x;
			ASSERT_EQUALM("Test failed for vector3f in operator arithematic: X1*=x",temp2.getX()*x,temp.getX());
			ASSERT_EQUALM("Test failed for vector3f in operator arithematic: Y1*=x",temp2.getY()*x,temp.getY());
			ASSERT_EQUALM("Test failed for vector3f in operator arithematic: Z1*=x",temp2.getZ()*x,temp.getZ());

			//Test Cross Product://
			temp.setXYZ(1.0f,0.0f,0.0f);
			temp1.setXYZ(0.0f,1.0f,0.0f);
			temp2.setXYZ(0.0f,0.0f,1.0f);

			ASSERTM("Test failed for vector3f in operator arithematic(vector): k=i*j",(Z3D_Base::Vector3f)temp2==(Z3D_Base::Vector3f)(temp*temp1));
			ASSERTM("Test failed for vector3f in operator arithematic(vector): i=j*k",(Z3D_Base::Vector3f)temp==(Z3D_Base::Vector3f)(temp1*temp2));
			ASSERTM("Test failed for vector3f in operator arithematic(vector): j=k*i",(Z3D_Base::Vector3f)temp1==(Z3D_Base::Vector3f)(temp2*temp));

		}
예제 #12
0
		static void testRotation() {
			Z3D_Base::Vector3f temp(1.0f,0.0f,0.0f), temp1(0.0f,1.0f,0.0f), temp2(0.0f,0.0f,1.0f);

			ASSERT_EQUALM("Test failed for vector3f in rotation-1(vector)",temp1,temp.rotate(90.0f,temp2));

		}
예제 #13
0
void Controller_testActions()
{
	//Create a database object
	shared_ptr<DB::IDatabase> database = std::shared_ptr<DB::IDatabase>(new TempDB());
	shared_ptr<Timer> timer = std::shared_ptr<Timer>(new Timer());
	shared_ptr<MockTimeKeeper> timekeeper = std::shared_ptr<MockTimeKeeper>(new MockTimeKeeper());
	shared_ptr<MockGuiFactory> guiFactory= std::shared_ptr<MockGuiFactory>(new MockGuiFactory());

	shared_ptr<GUI::IGUIFactory> gfactory = std::static_pointer_cast<GUI::IGUIFactory>(guiFactory);
	shared_ptr<ITimeKeeper> tkeeper = std::shared_ptr<ITimeKeeper>(timekeeper);

	Controller controller(gfactory, tkeeper, database);

	ASSERT_EQUALM("Checking status of widgetIdentifier before about event ", GUI::MAX_WIDGETS, guiFactory->widgetIdentifier);
	ASSERT_EQUALM("Checking status of mockWidget before about event ", false, guiFactory->widget->is_visible());
	controller.on_action_about();
	ASSERT_EQUALM("Checking status of widgetIdentifier after about event ", GUI::ABOUT_DIALOG, guiFactory->widgetIdentifier);
	ASSERT_EQUALM("Checking status of mockWidget after about event", true, guiFactory->widget->is_visible());

	guiFactory->widget->hide();
	ASSERT_EQUALM("Checking status of mockWidget before add task event ", false, guiFactory->widget->is_visible());
	controller.on_action_add_task();
	ASSERT_EQUALM("Checking status of widgetIdentifier after add task event ", GUI::ADD_TASK_DIALOG, guiFactory->widgetIdentifier);
	ASSERT_EQUALM("Checking status of mockWidget after add task event", true, guiFactory->widget->is_visible());

	guiFactory->widget->hide();
	ASSERT_EQUALM("Checking status of mockWidget before preferences event ", false, guiFactory->widget->is_visible());
	controller.on_action_preferences();
	ASSERT_EQUALM("Checking status of widgetIdentifier after preferences event ", GUI::PREFERENCE_DIALOG, guiFactory->widgetIdentifier);
	ASSERT_EQUALM("Checking status of mockWidget after preferences event", true, guiFactory->widget->is_visible());

	guiFactory->widget->hide();
	ASSERT_EQUALM("Checking status of mockWidget before edit task event ", false, guiFactory->widget->is_visible());
	controller.on_action_edit_task();
	ASSERT_EQUALM("Checking status of widgetIdentifier after edit task event ", GUI::EDIT_TASK_DIALOG, guiFactory->widgetIdentifier);
	ASSERT_EQUALM("Checking status of mockWidget after edit task event", true, guiFactory->widget->is_visible());

	guiFactory->widget->hide();
	ASSERT_EQUALM("Checking status of mockWidget before toggling main window ", false, guiFactory->widget->is_visible());
	controller.on_action_toggleMainWindow();
	ASSERT_EQUALM("Checking status of widgetIdentifier after toggling main window ", GUI::MAIN_WINDOW, guiFactory->widgetIdentifier);
	ASSERT_EQUALM("Checking status of mockWidget after toggling main window", true, guiFactory->widget->is_visible());
	controller.on_action_toggleMainWindow();
	ASSERT_EQUALM("Checking status of mockWidget after toggling main window again", false, guiFactory->widget->is_visible());

	int selectedTaskId=4;
	timekeeper->startedTask=0;
	controller.on_action_task_selection_changed(selectedTaskId);
	controller.on_action_start_task();
	ASSERT_EQUALM("Check that controller is starting the correct task ", selectedTaskId, timekeeper->startedTask );

	selectedTaskId++;
	controller.on_action_task_selection_changed(selectedTaskId);
	controller.on_action_stop_task();
	ASSERT_EQUALM("Check that controller is starting the correct task ", selectedTaskId, timekeeper->stopedTask );

}