From f7389c82918dd26aa88387f8d8bdd91149aeb066 Mon Sep 17 00:00:00 2001 From: Kimmo Hoikka Date: Fri, 12 Oct 2018 12:17:17 +0100 Subject: [PATCH] Making DALi core internals typesafe using guaranteed types; uint8_t, uint32_t and enabling -Wconversion unsigned char -> uint8_t unsigned short -> uint16_t unsigned int -> uint32_t int -> int32_t -Wconversion will prevent any implicit conversions where precision may be lost such as: uint32_t a = (size_t)b or int x = (float)y static_cast has to be used to tell the compiler how and where to do the conversion Change-Id: Ic1475a59acf55601100cd603a455b96e9eb7c53e --- .../dali-test-suite-utils.cpp | 28 ++++----- .../dali-test-suite-utils/dali-test-suite-utils.h | 16 +++--- .../dali-test-suite-utils/test-application.cpp | 52 ++++++----------- .../dali/dali-test-suite-utils/test-application.h | 55 ++++++++---------- .../dali-test-suite-utils/test-custom-actor.cpp | 2 +- .../dali/dali-test-suite-utils/test-custom-actor.h | 8 +-- .../test-gl-sync-abstraction.cpp | 4 +- .../test-gl-sync-abstraction.h | 2 +- .../dali/dali-test-suite-utils/test-harness.cpp | 66 +++++++++++----------- .../src/dali/dali-test-suite-utils/test-harness.h | 17 +++--- .../dali-test-suite-utils/test-native-image.cpp | 10 ++-- .../dali/dali-test-suite-utils/test-native-image.h | 38 ++++++------- .../test-platform-abstraction.cpp | 8 +-- .../test-platform-abstraction.h | 4 +- .../test-trace-call-stack.cpp | 10 ++-- .../dali-test-suite-utils/test-trace-call-stack.h | 4 +- automated-tests/src/dali/utc-Dali-RenderTask.cpp | 2 +- automated-tests/src/dali/utc-Dali-Stage.cpp | 2 +- build/tizen/configure.ac | 2 +- 19 files changed, 152 insertions(+), 178 deletions(-) diff --git a/automated-tests/src/dali/dali-test-suite-utils/dali-test-suite-utils.cpp b/automated-tests/src/dali/dali-test-suite-utils/dali-test-suite-utils.cpp index cf97813..b9c8245 100644 --- a/automated-tests/src/dali/dali-test-suite-utils/dali-test-suite-utils.cpp +++ b/automated-tests/src/dali/dali-test-suite-utils/dali-test-suite-utils.cpp @@ -26,9 +26,9 @@ using namespace Dali; -int test_return_value = TET_UNDEF; +int32_t test_return_value = TET_UNDEF; -void tet_result(int value) +void tet_result(int32_t value) { // First TET_PASS should set to zero // first TET_FAIL should prevent any further TET_PASS from setting back to zero @@ -81,14 +81,14 @@ void DALI_TEST_EQUALS( const BaseHandle& baseHandle1, const BaseHandle& baseHand DALI_TEST_EQUALS< const BaseHandle& >( baseHandle1, baseHandle2, location ); } -void DALI_TEST_EQUALS( const size_t value1, const unsigned int value2, const char* location ) +void DALI_TEST_EQUALS( const size_t value1, const uint32_t value2, const char* location ) { - DALI_TEST_EQUALS< unsigned int>( ( unsigned int )( value1 ), value2, location ); + DALI_TEST_EQUALS< uint32_t >( ( uint32_t )( value1 ), value2, location ); } -void DALI_TEST_EQUALS( const unsigned int value1, const size_t value2, const char* location ) +void DALI_TEST_EQUALS( const uint32_t value1, const size_t value2, const char* location ) { - DALI_TEST_EQUALS< unsigned int >( value1, ( unsigned int )( value2 ), location ); + DALI_TEST_EQUALS< uint32_t >( value1, ( uint32_t )( value2 ), location ); } void DALI_TEST_EQUALS( const Matrix3& matrix1, const Matrix3& matrix2, const char* location) @@ -97,7 +97,7 @@ void DALI_TEST_EQUALS( const Matrix3& matrix1, const Matrix3& matrix2, const cha const float* m2 = matrix2.AsFloat(); bool equivalent = true; - for (int i=0;i<9;++i) + for (int32_t i=0;i<9;++i) { if( ! (fabsf(m1[i] - m2[i])< GetRangedEpsilon(m1[i], m2[i])) ) { @@ -132,7 +132,7 @@ void DALI_TEST_EQUALS( const Matrix3& matrix1, const Matrix3& matrix2, float eps const float* m2 = matrix2.AsFloat(); bool equivalent = true; - for (int i=0;i<9;++i) + for (int32_t i=0;i<9;++i) { equivalent &= (fabsf(m1[i] - m2[i])GetPackedPixelsProfile()->ReserveBuffer( pixelFormat, imageWidth, imageHeight, imageWidth, imageHeight ); - unsigned int bytesPerPixel = GetBytesPerPixel( pixelFormat ); - unsigned int initialColor = 0xFF; + uint32_t bytesPerPixel = GetBytesPerPixel( pixelFormat ); + uint32_t initialColor = 0xFF; memset( pixbuffer, initialColor, imageHeight*imageWidth*bytesPerPixel); Integration::ResourcePointer resourcePtr(bitmap); diff --git a/automated-tests/src/dali/dali-test-suite-utils/dali-test-suite-utils.h b/automated-tests/src/dali/dali-test-suite-utils/dali-test-suite-utils.h index 4f71920..ed1a65f 100644 --- a/automated-tests/src/dali/dali-test-suite-utils/dali-test-suite-utils.h +++ b/automated-tests/src/dali/dali-test-suite-utils/dali-test-suite-utils.h @@ -64,9 +64,9 @@ constexpr int32_t basenameIndex( const char * const path, const int32_t index = #define TET_FAIL 1 #define TET_PASS 0 -extern int test_return_value; +extern int32_t test_return_value; -void tet_result(int value); +void tet_result(int32_t value); #define END_TEST \ return ((test_return_value>0)?1:0) @@ -199,20 +199,20 @@ inline void DALI_TEST_EQUALS( TimePeriod value1, TimePeriod value2, void DALI_TEST_EQUALS( const BaseHandle& baseHandle1, const BaseHandle& baseHandle2, const char* location ); /** - * Test whether a size_t value and an unsigned int are equal. + * Test whether a size_t value and an uint32_t are equal. * @param[in] value1 The first value * @param[in] value2 The second value * @param[in] location The TEST_LOCATION macro should be used here */ -void DALI_TEST_EQUALS( const size_t value1, const unsigned int value2, const char* location ); +void DALI_TEST_EQUALS( const size_t value1, const uint32_t value2, const char* location ); /** - * Test whether an unsigned int and a size_t value and are equal. + * Test whether an uint32_t and a size_t value and are equal. * @param[in] value1 The first value * @param[in] value2 The second value * @param[in] location The TEST_LOCATION macro should be used here */ -void DALI_TEST_EQUALS( const unsigned int value1, const size_t value2, const char* location ); +void DALI_TEST_EQUALS( const uint32_t value1, const size_t value2, const char* location ); /** * Test whether two Matrix3 objects are equal. @@ -374,11 +374,11 @@ struct DefaultFunctionCoverage // Helper to Create buffer image BufferImage CreateBufferImage(); -BufferImage CreateBufferImage(int width, int height, const Vector4& color); +BufferImage CreateBufferImage(int32_t width, int32_t 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 ); +void PrepareResourceImage( TestApplication& application, uint32_t imageWidth, uint32_t imageHeight, Pixel::Format pixelFormat ); // Test namespace to prevent pollution of Dali namespace, add Test helper functions here namespace Test diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-application.cpp b/automated-tests/src/dali/dali-test-suite-utils/test-application.cpp index 8bb7176..a20ef6d 100644 --- a/automated-tests/src/dali/dali-test-suite-utils/test-application.cpp +++ b/automated-tests/src/dali/dali-test-suite-utils/test-application.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -21,42 +21,22 @@ namespace Dali { -TestApplication::TestApplication( size_t surfaceWidth, - size_t surfaceHeight, - float horizontalDpi, - float verticalDpi, +TestApplication::TestApplication( uint32_t surfaceWidth, + uint32_t surfaceHeight, + uint32_t horizontalDpi, + uint32_t verticalDpi, ResourcePolicy::DataRetention policy) : mCore( NULL ), mSurfaceWidth( surfaceWidth ), mSurfaceHeight( surfaceHeight ), mFrame( 0u ), - mDpi( horizontalDpi, verticalDpi ), + mDpi{ horizontalDpi, verticalDpi }, mLastVSyncTime(0u), mDataRetentionPolicy( policy ) { Initialize(); } -TestApplication::TestApplication( bool initialize, - size_t surfaceWidth, - size_t surfaceHeight, - float horizontalDpi, - float verticalDpi, - ResourcePolicy::DataRetention policy) -: mCore( NULL ), - mSurfaceWidth( surfaceWidth ), - mSurfaceHeight( surfaceHeight ), - mFrame( 0u ), - mDpi( horizontalDpi, verticalDpi ), - mLastVSyncTime(0u), - mDataRetentionPolicy( policy ) -{ - if ( initialize ) - { - Initialize(); - } -} - void TestApplication::Initialize() { // We always need the first update! @@ -165,7 +145,7 @@ void TestApplication::SendNotification() mCore->ProcessEvents(); } -void TestApplication::SetSurfaceWidth( unsigned int width, unsigned height ) +void TestApplication::SetSurfaceWidth( uint32_t width, uint32_t height ) { mSurfaceWidth = width; mSurfaceHeight = height; @@ -173,12 +153,12 @@ void TestApplication::SetSurfaceWidth( unsigned int width, unsigned height ) mCore->SurfaceResized( mSurfaceWidth, mSurfaceHeight ); } -void TestApplication::SetTopMargin( unsigned int margin ) +void TestApplication::SetTopMargin( uint32_t margin ) { mCore->SetTopMargin( margin ); } -void TestApplication::DoUpdate( unsigned int intervalMilliseconds, const char* location ) +void TestApplication::DoUpdate( uint32_t intervalMilliseconds, const char* location ) { if( GetUpdateStatus() == 0 && mRenderStatus.NeedsUpdate() == false && @@ -187,8 +167,8 @@ void TestApplication::DoUpdate( unsigned int intervalMilliseconds, const char* l fprintf(stderr, "WARNING - Update not required :%s\n", location==NULL?"NULL":location); } - unsigned int nextVSyncTime = mLastVSyncTime + intervalMilliseconds; - float elapsedSeconds = intervalMilliseconds / 1e3f; + uint32_t nextVSyncTime = mLastVSyncTime + intervalMilliseconds; + float elapsedSeconds = static_cast( intervalMilliseconds ) * 0.001f; mCore->Update( elapsedSeconds, mLastVSyncTime, nextVSyncTime, mStatus, false, false ); @@ -197,7 +177,7 @@ void TestApplication::DoUpdate( unsigned int intervalMilliseconds, const char* l mLastVSyncTime = nextVSyncTime; } -bool TestApplication::Render( unsigned int intervalMilliseconds, const char* location ) +bool TestApplication::Render( uint32_t intervalMilliseconds, const char* location ) { DoUpdate( intervalMilliseconds, location ); mCore->Render( mRenderStatus, false ); @@ -207,12 +187,12 @@ bool TestApplication::Render( unsigned int intervalMilliseconds, const char* loc return mStatus.KeepUpdating() || mRenderStatus.NeedsUpdate(); } -unsigned int TestApplication::GetUpdateStatus() +uint32_t TestApplication::GetUpdateStatus() { return mStatus.KeepUpdating(); } -bool TestApplication::UpdateOnly( unsigned int intervalMilliseconds ) +bool TestApplication::UpdateOnly( uint32_t intervalMilliseconds ) { DoUpdate( intervalMilliseconds ); return mStatus.KeepUpdating(); @@ -240,11 +220,11 @@ void TestApplication::ResetContext() mCore->ContextCreated(); } -unsigned int TestApplication::Wait( unsigned int durationToWait ) +uint32_t TestApplication::Wait( uint32_t durationToWait ) { int time = 0; - for(unsigned int i = 0; i <= ( durationToWait / RENDER_FRAME_INTERVAL); i++) + for(uint32_t i = 0; i <= ( durationToWait / RENDER_FRAME_INTERVAL); i++) { SendNotification(); Render(RENDER_FRAME_INTERVAL); diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-application.h b/automated-tests/src/dali/dali-test-suite-utils/test-application.h index 6b8b236..49f2b3c 100644 --- a/automated-tests/src/dali/dali-test-suite-utils/test-application.h +++ b/automated-tests/src/dali/dali-test-suite-utils/test-application.h @@ -36,32 +36,25 @@ class DALI_CORE_API TestApplication : public ConnectionTracker public: // Default values derived from H2 device. - static const unsigned int DEFAULT_SURFACE_WIDTH = 480; - static const unsigned int DEFAULT_SURFACE_HEIGHT = 800; + static const uint32_t DEFAULT_SURFACE_WIDTH = 480; + static const uint32_t DEFAULT_SURFACE_HEIGHT = 800; #ifdef _CPP11 - static constexpr float DEFAULT_HORIZONTAL_DPI = 220.0f; - static constexpr float DEFAULT_VERTICAL_DPI = 217.0f; + static constexpr uint32_t DEFAULT_HORIZONTAL_DPI = 220; + static constexpr uint32_t DEFAULT_VERTICAL_DPI = 217; #else - static const float DEFAULT_HORIZONTAL_DPI = 220.0f; - static const float DEFAULT_VERTICAL_DPI = 217.0f; + static const uint32_t DEFAULT_HORIZONTAL_DPI = 220; + static const uint32_t DEFAULT_VERTICAL_DPI = 217; #endif - static const unsigned int DEFAULT_RENDER_INTERVAL = 1; + static const uint32_t DEFAULT_RENDER_INTERVAL = 1; - static const unsigned int RENDER_FRAME_INTERVAL = 16; + static const uint32_t RENDER_FRAME_INTERVAL = 16; - TestApplication( size_t surfaceWidth = DEFAULT_SURFACE_WIDTH, - size_t surfaceHeight = DEFAULT_SURFACE_HEIGHT, - float horizontalDpi = DEFAULT_HORIZONTAL_DPI, - float verticalDpi = DEFAULT_VERTICAL_DPI, - ResourcePolicy::DataRetention policy = ResourcePolicy::DALI_DISCARDS_ALL_DATA); - - TestApplication( bool initialize, - size_t surfaceWidth = DEFAULT_SURFACE_WIDTH, - size_t surfaceHeight = DEFAULT_SURFACE_HEIGHT, - float horizontalDpi = DEFAULT_HORIZONTAL_DPI, - float verticalDpi = DEFAULT_VERTICAL_DPI, + TestApplication( uint32_t surfaceWidth = DEFAULT_SURFACE_WIDTH, + uint32_t surfaceHeight = DEFAULT_SURFACE_HEIGHT, + uint32_t horizontalDpi = DEFAULT_HORIZONTAL_DPI, + uint32_t verticalDpi = DEFAULT_VERTICAL_DPI, ResourcePolicy::DataRetention policy = ResourcePolicy::DALI_DISCARDS_ALL_DATA); void Initialize(); @@ -76,18 +69,18 @@ public: TestGestureManager& GetGestureManager(); void ProcessEvent(const Integration::Event& event); void SendNotification(); - void SetSurfaceWidth( unsigned int width, unsigned height ); - void SetTopMargin( unsigned int margin ); - bool Render( unsigned int intervalMilliseconds = DEFAULT_RENDER_INTERVAL, const char* location=NULL ); - unsigned int GetUpdateStatus(); - bool UpdateOnly( unsigned int intervalMilliseconds = DEFAULT_RENDER_INTERVAL ); + void SetSurfaceWidth( uint32_t width, unsigned height ); + void SetTopMargin( uint32_t margin ); + bool Render( uint32_t intervalMilliseconds = DEFAULT_RENDER_INTERVAL, const char* location=NULL ); + uint32_t GetUpdateStatus(); + bool UpdateOnly( uint32_t intervalMilliseconds = DEFAULT_RENDER_INTERVAL ); bool RenderOnly( ); void ResetContext(); bool GetRenderNeedsUpdate(); - unsigned int Wait( unsigned int durationToWait ); + uint32_t Wait( uint32_t durationToWait ); private: - void DoUpdate( unsigned int intervalMilliseconds, const char* location=NULL ); + void DoUpdate( uint32_t intervalMilliseconds, const char* location=NULL ); protected: TestPlatformAbstraction mPlatformAbstraction; @@ -101,12 +94,12 @@ protected: Integration::Core* mCore; - unsigned int mSurfaceWidth; - unsigned int mSurfaceHeight; - unsigned int mFrame; + uint32_t mSurfaceWidth; + uint32_t mSurfaceHeight; + uint32_t mFrame; - Vector2 mDpi; - unsigned int mLastVSyncTime; + struct { uint32_t x; uint32_t y; } mDpi; + uint32_t mLastVSyncTime; ResourcePolicy::DataRetention mDataRetentionPolicy; }; diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-custom-actor.cpp b/automated-tests/src/dali/dali-test-suite-utils/test-custom-actor.cpp index 758579e..d300568 100644 --- a/automated-tests/src/dali/dali-test-suite-utils/test-custom-actor.cpp +++ b/automated-tests/src/dali/dali-test-suite-utils/test-custom-actor.cpp @@ -200,7 +200,7 @@ bool TestCustomActor::TestRelayoutDependentOnChildrenBase( Dimension::Type dimen return GetImpl().TestRelayoutDependentOnChildrenBase( dimension ); } -unsigned int TestCustomActor::GetDepth() +uint32_t TestCustomActor::GetDepth() { return GetImpl().mDepth; } diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-custom-actor.h b/automated-tests/src/dali/dali-test-suite-utils/test-custom-actor.h index 8af0693..e10b28b 100644 --- a/automated-tests/src/dali/dali-test-suite-utils/test-custom-actor.h +++ b/automated-tests/src/dali/dali-test-suite-utils/test-custom-actor.h @@ -67,7 +67,7 @@ public: float TestGetWidthForHeightBase( float height ); float TestCalculateChildSizeBase( const Dali::Actor& child, Dali::Dimension::Type dimension ); bool TestRelayoutDependentOnChildrenBase( Dali::Dimension::Type dimension ); - unsigned int GetDepth(); + uint32_t GetDepth(); private: TestCustomActor( Impl::TestCustomActor& impl ); @@ -148,7 +148,7 @@ public: Dali::Vector3 mSizeSet; Dali::Vector3 mTargetSize; bool mNego; - unsigned int mDepth; + uint32_t mDepth; float prop1; Dali::Vector4 prop2; @@ -218,7 +218,7 @@ struct TestCustomActorVariant2 : public TestCustomActor TestCustomActor::OnStageConnection( depth ); // Remove all the children - for( unsigned int i=0, num=Self().GetChildCount(); i( mSyncObjects.size() ); } diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-gl-sync-abstraction.h b/automated-tests/src/dali/dali-test-suite-utils/test-gl-sync-abstraction.h index 979987b..c2db8d2 100644 --- a/automated-tests/src/dali/dali-test-suite-utils/test-gl-sync-abstraction.h +++ b/automated-tests/src/dali/dali-test-suite-utils/test-gl-sync-abstraction.h @@ -105,7 +105,7 @@ public: // TEST FUNCTIONS * * @return the number of sync objects */ - int GetNumberOfSyncObjects(); + int32_t GetNumberOfSyncObjects(); private: diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-harness.cpp b/automated-tests/src/dali/dali-test-suite-utils/test-harness.cpp index 645d74b..c4a27d1 100644 --- a/automated-tests/src/dali/dali-test-suite-utils/test-harness.cpp +++ b/automated-tests/src/dali/dali-test-suite-utils/test-harness.cpp @@ -27,7 +27,7 @@ namespace TestHarness { -typedef std::map RunningTestCases; +typedef std::map RunningTestCases; const char* basename(const char* path) { @@ -41,9 +41,9 @@ const char* basename(const char* path) return slash; } -int RunTestCase( struct ::testcase_s& testCase ) +int32_t RunTestCase( struct ::testcase_s& testCase ) { - int result = EXIT_STATUS_TESTCASE_FAILED; + int32_t result = EXIT_STATUS_TESTCASE_FAILED; // dont want to catch exception as we want to be able to get // gdb stack trace from the first error @@ -69,11 +69,11 @@ int RunTestCase( struct ::testcase_s& testCase ) } -int RunTestCaseInChildProcess( struct ::testcase_s& testCase, bool suppressOutput ) +int32_t RunTestCaseInChildProcess( struct ::testcase_s& testCase, bool suppressOutput ) { - int testResult = EXIT_STATUS_TESTCASE_FAILED; + int32_t testResult = EXIT_STATUS_TESTCASE_FAILED; - int pid = fork(); + int32_t pid = fork(); if( pid == 0 ) // Child process { if( suppressOutput ) @@ -84,12 +84,12 @@ int RunTestCaseInChildProcess( struct ::testcase_s& testCase, bool suppressOutpu else { printf("\n"); - for(int i=0; i<80; ++i) printf("#"); + for(int32_t i=0; i<80; ++i) printf("#"); printf("\nTC: %s\n", testCase.name); fflush(stdout); } - int status = RunTestCase( testCase ); + int32_t status = RunTestCase( testCase ); if( ! suppressOutput ) { @@ -107,8 +107,8 @@ int RunTestCaseInChildProcess( struct ::testcase_s& testCase, bool suppressOutpu } else // Parent process { - int status = 0; - int childPid = waitpid(pid, &status, 0); + int32_t status = 0; + int32_t childPid = waitpid(pid, &status, 0); if( childPid == -1 ) { perror("waitpid"); @@ -127,7 +127,7 @@ int RunTestCaseInChildProcess( struct ::testcase_s& testCase, bool suppressOutpu } else if(WIFSIGNALED(status) ) { - int signal = WTERMSIG(status); + int32_t signal = WTERMSIG(status); testResult = EXIT_STATUS_TESTCASE_ABORTED; if( signal == SIGABRT ) { @@ -148,7 +148,7 @@ int RunTestCaseInChildProcess( struct ::testcase_s& testCase, bool suppressOutpu return testResult; } -void OutputStatistics( const char* processName, int numPasses, int numFailures ) +void OutputStatistics( const char* processName, int32_t numPasses, int32_t numFailures ) { FILE* fp=fopen("summary.xml", "a"); if( fp != NULL ) @@ -175,15 +175,15 @@ void OutputStatistics( const char* processName, int numPasses, int numFailures ) } } -int RunAll( const char* processName, ::testcase tc_array[] ) +int32_t RunAll( const char* processName, ::testcase tc_array[] ) { - int numFailures = 0; - int numPasses = 0; + int32_t numFailures = 0; + int32_t numPasses = 0; // Run test cases in child process( to kill output/handle signals ), but run serially. - for( unsigned int i=0; tc_array[i].name; i++) + for( uint32_t i=0; tc_array[i].name; i++) { - int result = RunTestCaseInChildProcess( tc_array[i], false ); + int32_t result = RunTestCaseInChildProcess( tc_array[i], false ); if( result == 0 ) { numPasses++; @@ -200,26 +200,26 @@ int RunAll( const char* processName, ::testcase tc_array[] ) } // Constantly runs up to MAX_NUM_CHILDREN processes -int RunAllInParallel( const char* processName, ::testcase tc_array[], bool reRunFailed) +int32_t RunAllInParallel( const char* processName, ::testcase tc_array[], bool reRunFailed) { - int numFailures = 0; - int numPasses = 0; + int32_t numFailures = 0; + int32_t numPasses = 0; RunningTestCases children; - std::vector failedTestCases; + std::vector failedTestCases; // Fork up to MAX_NUM_CHILDREN processes, then // wait. As soon as a proc completes, fork the next. - int nextTestCase = 0; - int numRunningChildren = 0; + int32_t nextTestCase = 0; + int32_t numRunningChildren = 0; while( tc_array[nextTestCase].name || numRunningChildren > 0) { // Create more children (up to the max number or til the end of the array) while( numRunningChildren < MAX_NUM_CHILDREN && tc_array[nextTestCase].name ) { - int pid = fork(); + int32_t pid = fork(); if( pid == 0 ) // Child process { close(STDOUT_FILENO); @@ -242,8 +242,8 @@ int RunAllInParallel( const char* processName, ::testcase tc_array[], bool reRu // Wait for the next child to finish - int status=0; - int childPid = waitpid(-1, &status, 0); + int32_t status=0; + int32_t childPid = waitpid(-1, &status, 0); if( childPid == -1 ) { perror("waitpid"); @@ -254,7 +254,7 @@ int RunAllInParallel( const char* processName, ::testcase tc_array[], bool reRu { if( childPid > 0 ) { - int testResult = WEXITSTATUS(status); + int32_t testResult = WEXITSTATUS(status); if( testResult ) { printf("Test case %s failed: %d\n", children[childPid].testCaseName, testResult); @@ -296,12 +296,12 @@ int RunAllInParallel( const char* processName, ::testcase tc_array[], bool reRu if( reRunFailed ) { - for( unsigned int i=0; i #include +#include namespace TestHarness { @@ -34,11 +35,11 @@ enum ExitStatus EXIT_STATUS_TESTCASE_NOT_FOUND // 6 }; -const int MAX_NUM_CHILDREN(16); +const int32_t MAX_NUM_CHILDREN(16); struct TestCase { - int testCase; + int32_t testCase; const char* testCaseName; TestCase() @@ -47,7 +48,7 @@ struct TestCase { } - TestCase(int tc, const char* name) + TestCase(int32_t tc, const char* name) : testCase(tc), testCaseName(name) { @@ -70,7 +71,7 @@ struct TestCase * Run a test case * @param[in] testCase The Testkit-lite test case to run */ -int RunTestCase( struct testcase_s& testCase ); +int32_t RunTestCase( struct testcase_s& testCase ); /** * Run all test cases in parallel @@ -79,7 +80,7 @@ int RunTestCase( struct testcase_s& testCase ); * @param[in] reRunFailed True if failed test cases should be re-run * @return 0 on success */ -int RunAllInParallel(const char* processName, testcase tc_array[], bool reRunFailed); +int32_t RunAllInParallel(const char* processName, testcase tc_array[], bool reRunFailed); /** * Run all test cases in serial @@ -87,7 +88,7 @@ int RunAllInParallel(const char* processName, testcase tc_array[], bool reRunFai * @param[in] tc_array The array of auto-generated testkit-lite test cases * @return 0 on success */ -int RunAll( const char* processName, testcase tc_array[] ); +int32_t RunAll( const char* processName, testcase tc_array[] ); /** * Find the named test case in the given array, and run it @@ -95,7 +96,7 @@ int RunAll( const char* processName, testcase tc_array[] ); * @param[in] testCaseName the name of the test case to run * @return 0 on success */ -int FindAndRunTestCase(::testcase tc_array[], const char* testCaseName); +int32_t FindAndRunTestCase(::testcase tc_array[], const char* testCaseName); /** * Display usage instructions for this program diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-native-image.cpp b/automated-tests/src/dali/dali-test-suite-utils/test-native-image.cpp index da4e7e8..ee6c17a 100644 --- a/automated-tests/src/dali/dali-test-suite-utils/test-native-image.cpp +++ b/automated-tests/src/dali/dali-test-suite-utils/test-native-image.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -23,12 +23,12 @@ namespace Dali { -TestNativeImagePointer TestNativeImage::New(int width, int height) +TestNativeImagePointer TestNativeImage::New(uint32_t width, uint32_t height) { return new TestNativeImage(width, height); } -TestNativeImage::TestNativeImage(int width, int height) +TestNativeImage::TestNativeImage(uint32_t width, uint32_t height) : mWidth(width), mHeight(height), mExtensionCreateCalls(0), mExtensionDestroyCalls(0), mTargetTextureCalls(0),createResult(true) { mExtension = new TestNativeImageExtension(); @@ -39,12 +39,12 @@ TestNativeImage::~TestNativeImage() } -TestNativeImageNoExtPointer TestNativeImageNoExt::New(int width, int height) +TestNativeImageNoExtPointer TestNativeImageNoExt::New(uint32_t width, uint32_t height) { return new TestNativeImageNoExt(width, height); } -TestNativeImageNoExt::TestNativeImageNoExt(int width, int height) +TestNativeImageNoExt::TestNativeImageNoExt(uint32_t width, uint32_t height) : mWidth(width), mHeight(height), mExtensionCreateCalls(0), mExtensionDestroyCalls(0), mTargetTextureCalls(0),createResult(true) { } diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-native-image.h b/automated-tests/src/dali/dali-test-suite-utils/test-native-image.h index 5cb4b27..a664107 100644 --- a/automated-tests/src/dali/dali-test-suite-utils/test-native-image.h +++ b/automated-tests/src/dali/dali-test-suite-utils/test-native-image.h @@ -36,35 +36,35 @@ public: inline const char* GetCustomFragmentPreFix(){return "#extension GL_OES_EGL_image_external:require\n";} inline const char* GetCustomSamplerTypename(){return "samplerExternalOES";} - inline int GetEglImageTextureTarget(){return GL_TEXTURE_EXTERNAL_OES;} + inline int32_t GetEglImageTextureTarget(){return GL_TEXTURE_EXTERNAL_OES;} }; class DALI_CORE_API TestNativeImage : public Dali::NativeImageInterface { public: - static TestNativeImagePointer New(int width, int height); + static TestNativeImagePointer New(uint32_t width, uint32_t height); inline void SetGlExtensionCreateResult(bool result){ createResult = result;} inline virtual bool GlExtensionCreate() { ++mExtensionCreateCalls; return createResult;}; inline virtual void GlExtensionDestroy() { ++mExtensionDestroyCalls; }; inline virtual GLenum TargetTexture() { ++mTargetTextureCalls; return 0;}; inline virtual void PrepareTexture() {}; - inline virtual unsigned int GetWidth() const {return mWidth;}; - inline virtual unsigned int GetHeight() const {return mHeight;}; + inline virtual uint32_t GetWidth() const {return mWidth;}; + inline virtual uint32_t GetHeight() const {return mHeight;}; inline virtual bool RequiresBlending() const {return true;}; inline virtual Dali::NativeImageInterface::Extension* GetExtension() {return mExtension;} private: - TestNativeImage(int width, int height); + TestNativeImage(uint32_t width, uint32_t height); virtual ~TestNativeImage(); - int mWidth; - int mHeight; + uint32_t mWidth; + uint32_t mHeight; public: - int mExtensionCreateCalls; - int mExtensionDestroyCalls; - int mTargetTextureCalls; + int32_t mExtensionCreateCalls; + int32_t mExtensionDestroyCalls; + int32_t mTargetTextureCalls; bool createResult; TestNativeImageExtension* mExtension; @@ -74,27 +74,27 @@ public: class DALI_CORE_API TestNativeImageNoExt : public Dali::NativeImageInterface { public: - static TestNativeImageNoExtPointer New(int width, int height); + static TestNativeImageNoExtPointer New(uint32_t width, uint32_t height); inline void SetGlExtensionCreateResult(bool result){ createResult = result;} inline virtual bool GlExtensionCreate() { ++mExtensionCreateCalls; return createResult;}; inline virtual void GlExtensionDestroy() { ++mExtensionDestroyCalls; }; inline virtual GLenum TargetTexture() { ++mTargetTextureCalls; return 1;}; inline virtual void PrepareTexture() {}; - inline virtual unsigned int GetWidth() const {return mWidth;}; - inline virtual unsigned int GetHeight() const {return mHeight;}; + inline virtual uint32_t GetWidth() const {return mWidth;}; + inline virtual uint32_t GetHeight() const {return mHeight;}; inline virtual bool RequiresBlending() const {return true;}; private: - TestNativeImageNoExt(int width, int height); + TestNativeImageNoExt(uint32_t width, uint32_t height); virtual ~TestNativeImageNoExt(); - int mWidth; - int mHeight; + uint32_t mWidth; + uint32_t mHeight; public: - int mExtensionCreateCalls; - int mExtensionDestroyCalls; - int mTargetTextureCalls; + int32_t mExtensionCreateCalls; + int32_t mExtensionDestroyCalls; + int32_t mTargetTextureCalls; bool createResult; }; diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-platform-abstraction.cpp b/automated-tests/src/dali/dali-test-suite-utils/test-platform-abstraction.cpp index cb0b39c..190aa63 100644 --- a/automated-tests/src/dali/dali-test-suite-utils/test-platform-abstraction.cpp +++ b/automated-tests/src/dali/dali-test-suite-utils/test-platform-abstraction.cpp @@ -43,7 +43,7 @@ ImageDimensions TestPlatformAbstraction::GetClosestImageSize( const std::string& SamplingMode::Type samplingMode, bool orientationCorrection ) { - ImageDimensions closestSize = ImageDimensions( mClosestSize.x, mClosestSize.y ); + ImageDimensions closestSize = ImageDimensions( mClosestSize ); mTrace.PushCall("GetClosestImageSize", ""); return closestSize; } @@ -54,7 +54,7 @@ ImageDimensions TestPlatformAbstraction::GetClosestImageSize( Integration::Resou SamplingMode::Type samplingMode, bool orientationCorrection ) { - ImageDimensions closestSize = ImageDimensions( mClosestSize.x, mClosestSize.y ); + ImageDimensions closestSize = ImageDimensions( mClosestSize ); mTrace.PushCall("GetClosestImageSize", ""); return closestSize; } @@ -115,9 +115,9 @@ void TestPlatformAbstraction::ClearReadyResources() mDecodedBitmap.Reset(); } -void TestPlatformAbstraction::SetClosestImageSize(const Vector2& size) +void TestPlatformAbstraction::SetClosestImageSize( const Vector2& size ) { - mClosestSize = size; + mClosestSize = ImageDimensions( static_cast( size.x ), static_cast( size.y ) ); } void TestPlatformAbstraction::SetLoadFileResult( bool result, Dali::Vector< unsigned char >& buffer ) diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-platform-abstraction.h b/automated-tests/src/dali/dali-test-suite-utils/test-platform-abstraction.h index f31561e..dfa4d6c 100644 --- a/automated-tests/src/dali/dali-test-suite-utils/test-platform-abstraction.h +++ b/automated-tests/src/dali/dali-test-suite-utils/test-platform-abstraction.h @@ -129,7 +129,7 @@ public: // TEST FUNCTIONS * @brief Sets the value returned by GetClosestImageSize. * @param[in] size The size that should be returned. */ - void SetClosestImageSize(const Vector2& size); + void SetClosestImageSize( const Vector2& size ); /** * @brief Sets the result return by LoadFile. @@ -177,7 +177,7 @@ private: mutable TraceCallStack mTrace; bool mIsLoadingResult; - Vector2 mClosestSize; + ImageDimensions mClosestSize; LoadFileResult mLoadFileResult; bool mSaveFileResult; diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-trace-call-stack.cpp b/automated-tests/src/dali/dali-test-suite-utils/test-trace-call-stack.cpp index f57dc50..f894389 100644 --- a/automated-tests/src/dali/dali-test-suite-utils/test-trace-call-stack.cpp +++ b/automated-tests/src/dali/dali-test-suite-utils/test-trace-call-stack.cpp @@ -164,14 +164,14 @@ bool TraceCallStack::FindMethodAndParamsFromStartIndex( std::string method, std: * @param[in] params A comma separated list of parameter values * @return index in the stack where the method was found or -1 otherwise */ -int TraceCallStack::FindIndexFromMethodAndParams(std::string method, std::string params) const +int32_t TraceCallStack::FindIndexFromMethodAndParams(std::string method, std::string params) const { - int index = -1; + int32_t index = -1; for( size_t i=0; i < mCallStack.size(); i++ ) { if( 0 == mCallStack[i].method.compare(method) && 0 == mCallStack[i].paramList.compare(params) ) { - index = i; + index = static_cast( i ); break; } } @@ -180,7 +180,7 @@ int TraceCallStack::FindIndexFromMethodAndParams(std::string method, std::string int TraceCallStack::FindIndexFromMethodAndParams(std::string method, const TraceCallStack::NamedParams& params) const { - int index = -1; + int32_t index = -1; for( size_t i=0; i < mCallStack.size(); i++ ) { if( 0 == mCallStack[i].method.compare(method) ) @@ -198,7 +198,7 @@ int TraceCallStack::FindIndexFromMethodAndParams(std::string method, const Trace } if( match == true ) { - index = i; + index = static_cast( i ); break; } } diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-trace-call-stack.h b/automated-tests/src/dali/dali-test-suite-utils/test-trace-call-stack.h index d32f619..d569cba 100644 --- a/automated-tests/src/dali/dali-test-suite-utils/test-trace-call-stack.h +++ b/automated-tests/src/dali/dali-test-suite-utils/test-trace-call-stack.h @@ -165,8 +165,8 @@ public: std::string GetTraceString() { std::stringstream traceStream; - int functionCount = mCallStack.size(); - for( int i = 0; i < functionCount; ++i ) + std::size_t functionCount = mCallStack.size(); + for( std::size_t i = 0; i < functionCount; ++i ) { Dali::TraceCallStack::FunctionCall functionCall = mCallStack[ i ]; traceStream << "StackTrace: Index:" << i << ", Function:" << functionCall.method << ", ParamList:" << functionCall.paramList << std::endl; diff --git a/automated-tests/src/dali/utc-Dali-RenderTask.cpp b/automated-tests/src/dali/utc-Dali-RenderTask.cpp index b747b8c..b784e1a 100644 --- a/automated-tests/src/dali/utc-Dali-RenderTask.cpp +++ b/automated-tests/src/dali/utc-Dali-RenderTask.cpp @@ -2698,7 +2698,7 @@ int UtcDaliRenderTaskFinishMissingImage(void) int UtcDaliRenderTaskWorldToViewport(void) { - TestApplication application( static_cast(400), static_cast(400) ); // square surface + TestApplication application( 400u, 400u ); // square surface RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList(); diff --git a/automated-tests/src/dali/utc-Dali-Stage.cpp b/automated-tests/src/dali/utc-Dali-Stage.cpp index 1cfe084..5115340 100755 --- a/automated-tests/src/dali/utc-Dali-Stage.cpp +++ b/automated-tests/src/dali/utc-Dali-Stage.cpp @@ -602,7 +602,7 @@ int UtcDaliStageGetDpiP2(void) int UtcDaliStageGetDpiP3(void) { - TestApplication application( 480, 800, 72.0f, 120.0f ); // Initializes core DPI with specific values + TestApplication application( 480, 800, 72, 120 ); // Initializes core DPI with specific values Stage stage = Stage::GetCurrent(); diff --git a/build/tizen/configure.ac b/build/tizen/configure.ac index ba2140e..75b5615 100644 --- a/build/tizen/configure.ac +++ b/build/tizen/configure.ac @@ -31,7 +31,7 @@ AC_SUBST(DALI_VERSION) DALI_CFLAGS=-DPLATFORM_TIZEN # Use C++ 11 -DALI_CFLAGS="$DALI_CFLAGS -std=c++11 -Wnon-virtual-dtor -Woverloaded-virtual -Wold-style-cast -Werror -Wall -Wextra -Wno-unused-parameter -Wfloat-equal" +DALI_CFLAGS="$DALI_CFLAGS -std=c++11 -Wnon-virtual-dtor -Woverloaded-virtual -Wold-style-cast -Werror -Wall -Wextra -Wno-unused-parameter -Wfloat-equal -Wconversion" AC_ARG_ENABLE(exportall, [AC_HELP_STRING([--enable-exportall], -- 2.7.4