X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Fdali-toolkit-test-utils%2Fdali-test-suite-utils.h;h=79d422b15aacbef6044ce707045404885da801c9;hb=8e7cfd0c114bf778287cc6e67d0f42f3c866e205;hp=baeaa6a448d2e9d7788c7497386c6ce3cb1b0746;hpb=e50ad843a871ba17493a375d47e7197aa91de584;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dali-test-suite-utils.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dali-test-suite-utils.h index baeaa6a..79d422b 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dali-test-suite-utils.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dali-test-suite-utils.h @@ -2,7 +2,7 @@ #define __DALI_TEST_SUITE_UTILS_H__ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -153,6 +153,97 @@ inline bool CompareType(Degree q1, Degree q2, float epsilon) return CompareType(q1.degree, q2.degree, epsilon); } +template <> +inline bool CompareType(Property::Value q1, Property::Value q2, float epsilon) +{ + Property::Type type = q1.GetType(); + if( type != q2.GetType() ) + { + return false; + } + + bool result = false; + switch(type) + { + case Property::BOOLEAN: + { + bool a, b; + q1.Get(a); + q2.Get(b); + result = a == b; + break; + } + case Property::INTEGER: + { + int a, b; + q1.Get(a); + q2.Get(b); + result = a == b; + break; + } + case Property::FLOAT: + { + float a, b; + q1.Get(a); + q2.Get(b); + result = CompareType(a, b, epsilon); + break; + } + case Property::VECTOR2: + { + Vector2 a, b; + q1.Get(a); + q2.Get(b); + result = CompareType(a, b, epsilon); + break; + } + case Property::VECTOR3: + { + Vector3 a, b; + q1.Get(a); + q2.Get(b); + result = CompareType(a, b, epsilon); + break; + } + case Property::RECTANGLE: + case Property::VECTOR4: + { + Vector4 a, b; + q1.Get(a); + q2.Get(b); + result = CompareType(a, b, epsilon); + break; + } + case Property::ROTATION: + { + Quaternion a, b; + q1.Get(a); + q2.Get(b); + result = CompareType(a, b, epsilon); + break; + } + case Property::MATRIX: + case Property::MATRIX3: + case Property::STRING: + case Property::ARRAY: + case Property::MAP: + { + //TODO: Implement this? + DALI_ASSERT_ALWAYS( 0 && "Not implemented"); + result = false; + break; + } + case Property::NONE: + { + result = false; + break; + } + } + + return result; +} + + bool operator==(TimePeriod a, TimePeriod b); std::ostream& operator<<( std::ostream& ostream, TimePeriod value ); std::ostream& operator<<( std::ostream& ostream, Radian angle ); @@ -196,6 +287,23 @@ inline void DALI_TEST_EQUALS(Type value1, Type value2, float epsilon, const char } } +template +inline void DALI_TEST_NOT_EQUALS(Type value1, Type value2, float epsilon, const char* location) +{ + if( CompareType(value1, value2, epsilon) ) + { + std::ostringstream o; + o << value1 << " != " << value2 << std::endl; + fprintf(stderr, "%s, checking %s", location, o.str().c_str()); + tet_result(TET_FAIL); + } + else + { + tet_result(TET_PASS); + } +} + + /** * Test whether two TimePeriods are within a certain distance of each other. * @param[in] value1 The first value @@ -316,6 +424,14 @@ inline void DALI_TEST_EQUALS( const std::string &str1, const * @param[in] str2 The second string * @param[in] location The TEST_LOCATION macro should be used here */ +void DALI_TEST_EQUALS( Property::Value& str1, const char* str2, const char* location); + +/** + * Test whether two strings are equal. + * @param[in] str1 The first string + * @param[in] str2 The second string + * @param[in] location The TEST_LOCATION macro should be used here + */ void DALI_TEST_EQUALS( const std::string &str1, const char* str2, const char* location); /** @@ -398,4 +514,48 @@ struct DefaultFunctionCoverage BufferImage CreateBufferImage(); BufferImage CreateBufferImage(int width, int height, const Vector4& color); +// Prepare a resource image to be loaded. Should be called before creating the ResourceImage +void PrepareResourceImage( TestApplication& application, unsigned int imageWidth, unsigned int imageHeight, Pixel::Format pixelFormat ); + +// Test namespace to prevent pollution of Dali namespace, add Test helper functions here +namespace Test +{ +/** + * @brief + * + * Helper to check object destruction occurred + * 1) In main part of code create an ObjectDestructionTracker + * 2) Within sub section of main create object Actor test and call Start with Actor to test for destruction + * 3) Perform code which is expected to destroy Actor + * 4) Back in main part of code use IsDestroyed() to test if Actor was destroyed + */ +class ObjectDestructionTracker : public ConnectionTracker +{ +public: + + /** + * @brief Call in main part of code + */ + ObjectDestructionTracker(); + + /** + * @brief Call in sub bock of code where the Actor being checked is still alive. + * + * @param[in] actor Actor to be checked for destruction + */ + void Start( Actor actor ); + + /** + * @brief Call to check if Actor alive or destroyed. + * + * @return bool true if Actor was destroyed + */ + bool IsDestroyed(); + +private: + bool mRefObjectDestroyed; +}; + +} // namespace Test + #endif // __DALI_TEST_SUITE_UTILS_H__