From 3a289377436005f632a2dca8916706879b7e3a28 Mon Sep 17 00:00:00 2001 From: Paul Wisbey Date: Wed, 17 Feb 2016 11:02:16 +0000 Subject: [PATCH 1/1] Set DPI when testing font-client Change-Id: Ifd4fcf18225ea175195e91593b1395c24c7e4c7b --- .../toolkit-test-application.h | 8 ++ .../src/dali-toolkit/utc-Dali-PushButton.cpp | 91 +++++++++++++++++++++- 2 files changed, 95 insertions(+), 4 deletions(-) diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-test-application.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-test-application.h index 8722ab3..3c83f7e 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-test-application.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-test-application.h @@ -20,6 +20,7 @@ // INTERNAL INCLUDES #include +#include #include "toolkit-orientation.h" @@ -40,6 +41,13 @@ public: : TestApplication( false, surfaceWidth, surfaceHeight, horizontalDpi, verticalDpi ) { Initialize(); + + // set the DPI value for font rendering + Dali::TextAbstraction::FontClient fontClient = Dali::TextAbstraction::FontClient::Get(); + if( fontClient ) + { + fontClient.SetDpi( mDpi.x, mDpi.y ); + } } ~ToolkitTestApplication() diff --git a/automated-tests/src/dali-toolkit/utc-Dali-PushButton.cpp b/automated-tests/src/dali-toolkit/utc-Dali-PushButton.cpp index 17ebc5f..f785c63 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-PushButton.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-PushButton.cpp @@ -725,9 +725,31 @@ int UtcDaliPushButtonAlignmentLayout(void) ToolkitTestApplication application; tet_infoline(" UtcDaliPushButtonAlignmentLayout"); - // This test checks different alignments for the icon against the label. - // The icon is then moved around the label in each of it's alignments. - // The final relayed out size is checked to confirm the layout has been done correctly. + /* + * This test checks different alignments for the icon against the label. + * The icon is then moved around the label in each of it's alignments. + * The final relayed out size is checked to confirm the layout has been done correctly. + * + * There is an Icon which has 0 width and height, but with 75 padding on all sides. + * - Therefore total width and height are both 150. + * + * There is a Label which has "an unknown" width and height, but with 30 padding on all sides. + * - Therefore total width and height are 60+x and 60+y respectively. + * Where x & y are the width and height of the text. + * + * The width of the button will always expand to the largest of the icon and label sizes (plus padding). + * So We use the padding to help us determine the orientation is correct for each alignment. + * + * |<- 150 ->| |<-- 60+x -->| + * + * +---------+ - + * | | ^ +------------+ - + * | | | | | ^ + * | Icon | 150 | Label | 60+y + * | | | | | v + * | | v +------------+ - + * +---------+ - + */ PushButton pushButton = PushButton::New(); pushButton.SetProperty( Toolkit::PushButton::Property::LABEL_PADDING, Vector4( 30.0f, 30.0f, 30.0f, 30.0f ) ); @@ -765,6 +787,20 @@ int UtcDaliPushButtonAlignmentLayout(void) size.width = pushButton.GetRelayoutSize( Dimension::WIDTH ); size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT ); + + /* + * Test Icon right alignment. + * Height grows to largest of Icon or Label (+ padding). + * Normally this will be Icons height, except with very large font sizes. + * + * +------------+---------+ + * |............+ | + * | | | + * | Label | Icon | + * | | | + * |............+ | + * +------------+---------+ + */ DALI_TEST_GREATER( size.width, 150.0f + 60.0f, TEST_LOCATION ); DALI_TEST_EQUALS( size.height, 150.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); @@ -778,6 +814,19 @@ int UtcDaliPushButtonAlignmentLayout(void) compareSize.width = pushButton.GetRelayoutSize( Dimension::WIDTH ); compareSize.height = pushButton.GetRelayoutSize( Dimension::HEIGHT ); + /* + * Test Icon left alignment. + * Height grows to largest of Icon or Label (+ padding). + * Normally this will be Icons height, except with very large font sizes. + * + * +---------+------------+ + * | +............| + * | | | + * | Icon | Label | + * | | | + * | +............| + * +---------+------------+ + */ DALI_TEST_EQUALS( size, compareSize, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); // Test top alignment. @@ -789,7 +838,25 @@ int UtcDaliPushButtonAlignmentLayout(void) compareSize.width = pushButton.GetRelayoutSize( Dimension::WIDTH ); compareSize.height = pushButton.GetRelayoutSize( Dimension::HEIGHT ); - DALI_TEST_EQUALS( compareSize.width, 150.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); + /* + * Test Icon top alignment. + * Width grows to largest of Icon or Label (+ padding). + * + * +---------+ + * | | + * | | + * | Icon | + * | | + * | | + * +---------+ + * | | + * | Label | + * | | + * +---------+ + * + * Note: We subtract a small number as we want to do a >= test. + */ + DALI_TEST_GREATER( size.width, 150.0f - Math::MACHINE_EPSILON_1000, TEST_LOCATION ); DALI_TEST_GREATER( compareSize.height, 150.0f + 60.0f, TEST_LOCATION ); // Test bottom alignment. @@ -801,6 +868,22 @@ int UtcDaliPushButtonAlignmentLayout(void) size.width = pushButton.GetRelayoutSize( Dimension::WIDTH ); size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT ); + /* + * Test Icon bottom alignment. + * Width grows to largest of Icon or Label (+ padding). + * + * +---------+ + * | | + * | Label | + * | | + * +---------+ + * | | + * | | + * | Icon | + * | | + * | | + * +---------+ + */ DALI_TEST_EQUALS( size, compareSize, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); END_TEST; -- 2.7.4