test: ++code safety

added null check for exceptional case.

Change-Id: I12a5e9724149f607188b67a84e46a033a16270f7
This commit is contained in:
Hermet Park 2020-07-17 17:15:16 +09:00
parent 56c0235dc5
commit a5d1542e44
20 changed files with 63 additions and 14 deletions

View file

@ -10,6 +10,8 @@ static unsigned cnt = 0;
bool tvgUpdateCmds(tvg::Canvas* canvas) bool tvgUpdateCmds(tvg::Canvas* canvas)
{ {
if (!canvas) return false;
auto t = ecore_time_get(); auto t = ecore_time_get();
//Explicitly clear all retained paint nodes. //Explicitly clear all retained paint nodes.

View file

@ -6,6 +6,8 @@
void tvgDrawCmds(tvg::Canvas* canvas) void tvgDrawCmds(tvg::Canvas* canvas)
{ {
if (!canvas) return;
canvas->reserve(5); canvas->reserve(5);
//Prepare Round Rectangle //Prepare Round Rectangle

View file

@ -6,6 +6,8 @@
void tvgDrawCmds(tvg::Canvas* canvas) void tvgDrawCmds(tvg::Canvas* canvas)
{ {
if (!canvas) return;
canvas->reserve(5); //reserve 5 shape nodes (optional) canvas->reserve(5); //reserve 5 shape nodes (optional)
//Prepare Shape1 //Prepare Shape1

View file

@ -12,14 +12,13 @@ using namespace std;
/************************************************************************/ /************************************************************************/
void tvgSwTest(uint32_t* buffer); void tvgSwTest(uint32_t* buffer);
void drawSwView(void* data, Eo* obj);
void win_del(void *data, Evas_Object *o, void *ev) void win_del(void *data, Evas_Object *o, void *ev)
{ {
elm_exit(); elm_exit();
} }
void drawSwView(void* data, Eo* obj);
static Eo* createSwView() static Eo* createSwView()
{ {
static uint32_t buffer[WIDTH * HEIGHT]; static uint32_t buffer[WIDTH * HEIGHT];

View file

@ -7,6 +7,8 @@ tvg::Shape* pShape = nullptr;
void tvgDrawCmds(tvg::Canvas* canvas) void tvgDrawCmds(tvg::Canvas* canvas)
{ {
if (!canvas) return;
//Shape1 //Shape1
auto shape = tvg::Shape::gen(); auto shape = tvg::Shape::gen();
@ -33,6 +35,8 @@ void tvgDrawCmds(tvg::Canvas* canvas)
void tvgUpdateCmds(tvg::Canvas* canvas, float progress) void tvgUpdateCmds(tvg::Canvas* canvas, float progress)
{ {
if (!canvas) return;
/* Update shape directly. /* Update shape directly.
You can update only necessary properties of this shape, You can update only necessary properties of this shape,
while retaining other properties. */ while retaining other properties. */
@ -202,4 +206,4 @@ int main(int argc, char **argv)
cout << "engine is not supported" << endl; cout << "engine is not supported" << endl;
} }
return 0; return 0;
} }

View file

@ -7,6 +7,8 @@ tvg::Shape* pShape = nullptr;
void tvgDrawCmds(tvg::Canvas* canvas) void tvgDrawCmds(tvg::Canvas* canvas)
{ {
if (!canvas) return;
//Shape //Shape
auto shape = tvg::Shape::gen(); auto shape = tvg::Shape::gen();
@ -26,6 +28,8 @@ void tvgDrawCmds(tvg::Canvas* canvas)
void tvgUpdateCmds(tvg::Canvas* canvas, float progress) void tvgUpdateCmds(tvg::Canvas* canvas, float progress)
{ {
if (!canvas) return;
/* Update shape directly. /* Update shape directly.
You can update only necessary properties of this shape, You can update only necessary properties of this shape,
while retaining other properties. */ while retaining other properties. */

View file

@ -9,6 +9,8 @@ tvg::Shape* pShape3 = nullptr;
void tvgDrawCmds(tvg::Canvas* canvas) void tvgDrawCmds(tvg::Canvas* canvas)
{ {
if (!canvas) return;
//Shape1 //Shape1
auto shape = tvg::Shape::gen(); auto shape = tvg::Shape::gen();
@ -83,6 +85,8 @@ void tvgDrawCmds(tvg::Canvas* canvas)
void tvgUpdateCmds(tvg::Canvas* canvas, float progress) void tvgUpdateCmds(tvg::Canvas* canvas, float progress)
{ {
if (!canvas) return;
/* Update shape directly. /* Update shape directly.
You can update only necessary properties of this shape, You can update only necessary properties of this shape,
while retaining other properties. */ while retaining other properties. */
@ -230,4 +234,4 @@ int main(int argc, char **argv)
cout << "engine is not supported" << endl; cout << "engine is not supported" << endl;
} }
return 0; return 0;
} }

View file

@ -6,6 +6,8 @@
void tvgDrawCmds(tvg::Canvas* canvas) void tvgDrawCmds(tvg::Canvas* canvas)
{ {
if (!canvas) return;
canvas->reserve(3); //reserve 3 shape nodes (optional) canvas->reserve(3); //reserve 3 shape nodes (optional)
//Prepare Round Rectangle //Prepare Round Rectangle

View file

@ -6,6 +6,8 @@
void tvgDrawCmds(tvg::Canvas* canvas) void tvgDrawCmds(tvg::Canvas* canvas)
{ {
if (!canvas) return;
canvas->reserve(3); //reserve 3 shape nodes (optional) canvas->reserve(3); //reserve 3 shape nodes (optional)
//Prepare Round Rectangle //Prepare Round Rectangle

View file

@ -6,6 +6,8 @@
void tvgDrawCmds(tvg::Canvas* canvas) void tvgDrawCmds(tvg::Canvas* canvas)
{ {
if (!canvas) return;
//Star //Star
auto shape1 = tvg::Shape::gen(); auto shape1 = tvg::Shape::gen();

View file

@ -6,6 +6,8 @@
void tvgDrawCmds(tvg::Canvas* canvas) void tvgDrawCmds(tvg::Canvas* canvas)
{ {
if (!canvas) return;
/* Star */ /* Star */
//Prepare Path Commands //Prepare Path Commands
@ -182,4 +184,4 @@ int main(int argc, char **argv)
cout << "engine is not supported" << endl; cout << "engine is not supported" << endl;
} }
return 0; return 0;
} }

View file

@ -6,6 +6,8 @@
void tvgDrawCmds(tvg::Canvas* canvas) void tvgDrawCmds(tvg::Canvas* canvas)
{ {
if (!canvas) return;
canvas->reserve(3); //reserve 3 shape nodes (optional) canvas->reserve(3); //reserve 3 shape nodes (optional)
//Prepare Round Rectangle //Prepare Round Rectangle
@ -168,4 +170,4 @@ int main(int argc, char **argv)
cout << "engine is not supported" << endl; cout << "engine is not supported" << endl;
} }
return 0; return 0;
} }

View file

@ -6,6 +6,8 @@
void tvgDrawCmds(tvg::Canvas* canvas) void tvgDrawCmds(tvg::Canvas* canvas)
{ {
if (!canvas) return;
//Create a Scene //Create a Scene
auto scene = tvg::Scene::gen(); auto scene = tvg::Scene::gen();
scene->reserve(3); //reserve 3 shape nodes (optional) scene->reserve(3); //reserve 3 shape nodes (optional)
@ -175,4 +177,4 @@ int main(int argc, char **argv)
cout << "engine is not supported" << endl; cout << "engine is not supported" << endl;
} }
return 0; return 0;
} }

View file

@ -8,6 +8,8 @@ tvg::Scene* pScene2 = nullptr;
void tvgDrawCmds(tvg::Canvas* canvas) void tvgDrawCmds(tvg::Canvas* canvas)
{ {
if (!canvas) return;
//Create a Scene1 //Create a Scene1
auto scene = tvg::Scene::gen(); auto scene = tvg::Scene::gen();
pScene1 = scene.get(); pScene1 = scene.get();
@ -90,6 +92,8 @@ void tvgDrawCmds(tvg::Canvas* canvas)
void tvgUpdateCmds(tvg::Canvas* canvas, float progress) void tvgUpdateCmds(tvg::Canvas* canvas, float progress)
{ {
if (!canvas) return;
/* Update scene directly. /* Update scene directly.
You can update only necessary properties of this scene, You can update only necessary properties of this scene,
while retaining other properties. */ while retaining other properties. */
@ -226,4 +230,4 @@ int main(int argc, char **argv)
cout << "engine is not supported" << endl; cout << "engine is not supported" << endl;
} }
return 0; return 0;
} }

View file

@ -6,6 +6,8 @@
void tvgDrawCmds(tvg::Canvas* canvas) void tvgDrawCmds(tvg::Canvas* canvas)
{ {
if (!canvas) return;
//Prepare a Shape (Rectangle + Rectangle + Circle + Circle) //Prepare a Shape (Rectangle + Rectangle + Circle + Circle)
auto shape1 = tvg::Shape::gen(); auto shape1 = tvg::Shape::gen();
shape1->appendRect(0, 0, 200, 200, 0, 0); //x, y, w, h, rx, ry shape1->appendRect(0, 0, 200, 200, 0, 0); //x, y, w, h, rx, ry
@ -118,4 +120,4 @@ int main(int argc, char **argv)
cout << "engine is not supported" << endl; cout << "engine is not supported" << endl;
} }
return 0; return 0;
} }

View file

@ -6,6 +6,8 @@
void tvgDrawCmds(tvg::Canvas* canvas) void tvgDrawCmds(tvg::Canvas* canvas)
{ {
if (!canvas) return;
//Shape 1 //Shape 1
auto shape1 = tvg::Shape::gen(); auto shape1 = tvg::Shape::gen();
shape1->appendRect(50, 50, 200, 200, 0, 0); shape1->appendRect(50, 50, 200, 200, 0, 0);
@ -165,4 +167,4 @@ int main(int argc, char **argv)
cout << "engine is not supported" << endl; cout << "engine is not supported" << endl;
} }
return 0; return 0;
} }

View file

@ -6,6 +6,8 @@
void tvgDrawCmds(tvg::Canvas* canvas) void tvgDrawCmds(tvg::Canvas* canvas)
{ {
if (!canvas) return;
//Test for Stroke Width //Test for Stroke Width
for (int i = 0; i < 10; ++i) { for (int i = 0; i < 10; ++i) {
auto shape = tvg::Shape::gen(); auto shape = tvg::Shape::gen();
@ -202,4 +204,4 @@ int main(int argc, char **argv)
cout << "engine is not supported" << endl; cout << "engine is not supported" << endl;
} }
return 0; return 0;
} }

View file

@ -31,6 +31,8 @@ void svgDirCallback(const char* name, const char* path, void* data)
void tvgDrawCmds(tvg::Canvas* canvas) void tvgDrawCmds(tvg::Canvas* canvas)
{ {
if (!canvas) return;
//Background //Background
auto shape = tvg::Shape::gen(); auto shape = tvg::Shape::gen();
shape->appendRect(0, 0, WIDTH, HEIGHT, 0, 0); //x, y, w, h, rx, ry shape->appendRect(0, 0, WIDTH, HEIGHT, 0, 0); //x, y, w, h, rx, ry
@ -142,4 +144,4 @@ int main(int argc, char **argv)
cout << "engine is not supported" << endl; cout << "engine is not supported" << endl;
} }
return 0; return 0;
} }

View file

@ -9,6 +9,8 @@ tvg::Shape* pShape3 = nullptr;
void tvgDrawCmds(tvg::Canvas* canvas) void tvgDrawCmds(tvg::Canvas* canvas)
{ {
if (!canvas) return;
//Shape1 //Shape1
auto shape = tvg::Shape::gen(); auto shape = tvg::Shape::gen();
@ -46,6 +48,8 @@ void tvgDrawCmds(tvg::Canvas* canvas)
void tvgUpdateCmds(tvg::Canvas* canvas, float progress) void tvgUpdateCmds(tvg::Canvas* canvas, float progress)
{ {
if (!canvas) return;
/* Update shape directly. /* Update shape directly.
You can update only necessary properties of this shape, You can update only necessary properties of this shape,
while retaining other properties. */ while retaining other properties. */
@ -193,4 +197,4 @@ int main(int argc, char **argv)
cout << "engine is not supported" << endl; cout << "engine is not supported" << endl;
} }
return 0; return 0;
} }

View file

@ -6,6 +6,8 @@
void tvgDrawCmds(tvg::Canvas* canvas) void tvgDrawCmds(tvg::Canvas* canvas)
{ {
if (!canvas) return;
//Shape //Shape
auto shape = tvg::Shape::gen(); auto shape = tvg::Shape::gen();
shape->appendRect(-100, -100, 200, 200, 0, 0); shape->appendRect(-100, -100, 200, 200, 0, 0);
@ -15,6 +17,8 @@ void tvgDrawCmds(tvg::Canvas* canvas)
void tvgUpdateCmds(tvg::Canvas* canvas, float progress) void tvgUpdateCmds(tvg::Canvas* canvas, float progress)
{ {
if (!canvas) return;
//Explicitly clear all retained paint nodes. //Explicitly clear all retained paint nodes.
if (canvas->clear() != tvg::Result::Success) return; if (canvas->clear() != tvg::Result::Success) return;
@ -154,4 +158,4 @@ int main(int argc, char **argv)
cout << "engine is not supported" << endl; cout << "engine is not supported" << endl;
} }
return 0; return 0;
} }