Hi! It’s been 3 weeks (more than that actually, couldn’t update yesterday due to some network glitches I was facing here) and the progress so far has been good – let’s get into it! In the last week’s blog, I had reasoned why the rendering part is being developed as a library rather than directly starting the work with the framework (MLT) and the one advantage, was that the testing process becomes a whole lot easier. And that’s exactly what I have been doing the last week – writing the test module for the library, i.e. writing unit tests and it has been quite interesting as it gave me a perspective on how the code can break at points. The crucial concept of unit tests is to be able to make sure that there is no regression – meaning your code will do some particular things that it is supposed to do when we know it works, and at whatever point in the future, it will for sure do these certain things when it is working – Nice, eh? Unit testing, as the name suggests, is testing of the units – we take each functional unit of a code (or simply a function/method) and we test certain characterstics and make sure that these conditions are fulfilled. An example being that I can pick from one my unit tests is the the case of the method QmlRenderer::initializeRenderParams(…)
m_renderer->initialiseRenderParams(QDir::cleanPath(rootPath.currentPath() + "/../sampledata/test.qml"), "test_output", QDir::cleanPath(rootPath.currentPath() + "/../sampledata/output_lib/"), "jpg", QSize(1280,720), 1, 1000, 25);
QVERIFY2(m_renderer->getStatus() != m_renderer->Status::NotRunning, "STATUS ERROR:Not supposed to be running");
QVERIFY2(m_renderer->getActualFrames()!=0, "VALUE ERROR: Frames not supposed to be zero");
QVERIFY2(m_renderer->getSceneGraphStatus()!=false, "SCENE GRAPH ERROR: Scene graph not initialised");
QVERIFY2(m_renderer->getAnimationDriverStatus()==false, "ANIMATION DRIVER ERROR: Driver not supposed to be running");
QVERIFY2(m_renderer->getfboStatus()==true, "FRAME BUFFER OBJECT ERROR: FBO not bound");
What this method does is quite straightforward as the name might suggest – it initalises the parameters (like Fps, duration, etc) that we need for rendering and what I do is verify that these parameters actually got initialised. I do this for each of the methods, running them in succession. The rendering flow goes like this –
initializeRenderParams(…) -> renderQml() -> renderEntireQml() or renderSingleFrame()
There are also integration tests which verify the QML content that is actually rendered. How do I do this?
By having a directory of correctly rendered frames and comparing it with what the library produces at points of times.
That means now we have a complete library which can do all the rendering the MLT producer (which I next intend to write on) will need.
Next up: MLT Producer.
You can find the code here