* index was incremented and used rather than used then incremented, resulted in wrong matches for non zero values.
* ValueToIndex moved to helper file so allow automatic testing
* Test cases added
Change-Id: Ia05ad916273d166d7b274829b60779432bec5165
Signed-off-by: Agnelo Vaz <agnelo.vaz@samsung.com>
SET(TC_SOURCES
utc-Dali-CommandLineOptions.cpp
+ utc-Dali-FontClient.cpp
utc-Dali-GifLoader.cpp
utc-Dali-ImageOperations.cpp
utc-Dali-Lifecycle-Controller.cpp
../../../adaptors/public-api/adaptor-framework
../../../adaptors/tizen
../../../adaptors/ubuntu
+ ../../../text
${${CAPI_LIB}_INCLUDE_DIRS}
../dali-adaptor/dali-test-suite-utils
)
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <iostream>
+
+#include <stdlib.h>
+#include <stdint.h>
+#include <dali/dali.h>
+#include <dali-test-suite-utils.h>
+#include <dali/internal/text-abstraction/font-client-helper.h>
+
+using namespace Dali;
+
+int UtcDaliFontClient(void)
+{
+ const int ORDERED_VALUES[] = { 50, 63, 75, 87, 100, 113, 125, 150, 200 };
+
+ const unsigned int NUM_OF_ORDERED_VALUES = sizeof( ORDERED_VALUES ) / sizeof( int );
+
+ TestApplication application;
+ int preciseIndex = 0;
+ int result=0;
+
+ tet_infoline("UtcDaliFontClient center range");
+ preciseIndex = 4;
+ result = TextAbstraction::Internal::ValueToIndex( ORDERED_VALUES[preciseIndex], ORDERED_VALUES, NUM_OF_ORDERED_VALUES - 1u );
+ DALI_TEST_EQUALS( preciseIndex, result, TEST_LOCATION );
+
+ tet_infoline("UtcDaliFontClient start of range");
+ preciseIndex = 0;
+ result = TextAbstraction::Internal::ValueToIndex( ORDERED_VALUES[preciseIndex], ORDERED_VALUES, NUM_OF_ORDERED_VALUES - 1u );
+ DALI_TEST_EQUALS( preciseIndex, result, TEST_LOCATION );
+
+ tet_infoline("UtcDaliFontClient end of range");
+ preciseIndex = 8;
+ result = TextAbstraction::Internal::ValueToIndex( ORDERED_VALUES[preciseIndex], ORDERED_VALUES, NUM_OF_ORDERED_VALUES - 1u );
+ DALI_TEST_EQUALS( preciseIndex, result, TEST_LOCATION );
+
+ tet_infoline("UtcDaliFontClient below of range");
+ result = TextAbstraction::Internal::ValueToIndex( 30, ORDERED_VALUES, NUM_OF_ORDERED_VALUES - 1u );
+ DALI_TEST_EQUALS( 0, result, TEST_LOCATION );
+
+ tet_infoline("UtcDaliFontClient below of range");
+ result = TextAbstraction::Internal::ValueToIndex( 220, ORDERED_VALUES, NUM_OF_ORDERED_VALUES - 1u );
+ DALI_TEST_EQUALS( 8, result, TEST_LOCATION );
+
+ tet_infoline("UtcDaliFontClient zero ");
+ result = TextAbstraction::Internal::ValueToIndex( 0, ORDERED_VALUES, NUM_OF_ORDERED_VALUES - 1u );
+ DALI_TEST_EQUALS( 0, result, TEST_LOCATION );
+
+ END_TEST;
+}
+
+
--- /dev/null
+/*
+ * Copyright (c) 2015 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "font-client-helper.h"
+
+// INTERNAL INCLUDES
+
+#include <dali/integration-api/debug.h>
+
+namespace
+{
+#if defined(DEBUG_ENABLED)
+Dali::Integration::Log::Filter* gLogFilter = Dali::Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_FONT_CLIENT");
+#endif
+}
+
+namespace Dali
+{
+
+namespace TextAbstraction
+{
+
+namespace Internal
+{
+
+int ValueToIndex( int value, const int* const table, unsigned int maxIndex )
+{
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "-->FontClient::Plugin::ValueToIndex value(%d)\n", value);
+
+ if( ( NULL == table ) ||
+ ( value <= table[0] ) )
+ {
+ return 0;
+ }
+
+ if( value >= table[maxIndex] )
+ {
+ return maxIndex;
+ }
+
+ for( unsigned int index = 0u; index < maxIndex; )
+ {
+ const int v1 = table[index];
+ const unsigned int indexPlus = ++index;
+ const int v2 = table[indexPlus];
+ if( ( v1 < value ) && ( value <= v2 ) )
+ {
+ const int result = ( ( value - v1 ) < ( v2 - value ) ) ? index : indexPlus;
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "FontClient::Plugin::ValueToIndex result(%d)\n", result );
+ return result;
+ }
+ }
+
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "FontClient::Plugin::ValueToIndex exit 0 <-- \n");
+
+ return 0;
+}
+
+} // namespace Internal
+
+} // namespace TextAbstraction
+
+} // namespace Dali
--- /dev/null
+/*
+ * Copyright (c) 2015 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __DALI_INTERNAL_TEXT_ABSTRACTION_FONT_CLIENT_HELPER_H__
+#define __DALI_INTERNAL_TEXT_ABSTRACTION_FONT_CLIENT_HELPER_H__
+
+namespace Dali
+{
+
+namespace TextAbstraction
+{
+
+namespace Internal
+{
+
+/**
+ * @brief Retrieves a table index for a given value.
+ *
+ * @param[in] value The value.
+ * @param[in] table The table.
+ * @param[in] maxIndex The maximum valid index of the table.
+ *
+ * @return The index to the closest available value
+ */
+int ValueToIndex( int value, const int* const table, unsigned int maxIndex );
+
+} // Internal
+
+} // TextAbstraction
+
+} // Dali
+
+#endif // __DALI_INTERNAL_TEXT_ABSTRACTION_FONT_CLIENT_HELPER_H__
#include <dali/public-api/common/vector-wrapper.h>
#include <dali/integration-api/debug.h>
#include <dali/integration-api/platform-abstraction.h>
+#include <dali/internal/text-abstraction/font-client-helper.h>
#include <adaptor-impl.h>
// EXTERNAL INCLUDES
const int FONT_SLANT_TYPE_TO_INT[] = { 0, 100, 110 };
const unsigned int NUM_FONT_SLANT_TYPE = sizeof( FONT_SLANT_TYPE_TO_INT ) / sizeof( int );
-/**
- * @brief Retrieves a table index for a given value.
- *
- * @param[in] value The value.
- * @param[in] table The table.
- * @param[in] maxIndex The maximum valid index of the table.
- *
- * @return The index to the closest available value
- */
-int ValueToIndex( int value, const int* const table, unsigned int maxIndex )
-{
- if( ( NULL == table ) ||
- ( value <= table[0] ) )
- {
- return 0;
- }
-
- if( value >= table[maxIndex] )
- {
- return maxIndex;
- }
-
- for( unsigned int index = 0u; index < maxIndex; )
- {
- const unsigned int indexPlus = ++index;
- const int v1 = table[index];
- const int v2 = table[indexPlus];
- if( ( v1 < value ) && ( value <= v2 ) )
- {
- return ( ( value - v1 ) < ( v2 - value ) ) ? index : indexPlus;
- }
-
- index = indexPlus;
- }
-
- return 0;
-}
-
-}
+} // namespace
using Dali::Vector;
$(text_src_dir)/dali/devel-api/text-abstraction/segmentation.cpp \
$(text_src_dir)/dali/devel-api/text-abstraction/shaping.cpp \
$(text_src_dir)/dali/internal/text-abstraction/bidirectional-support-impl.cpp \
+ $(text_src_dir)/dali/internal/text-abstraction/font-client-helper.cpp \
$(text_src_dir)/dali/internal/text-abstraction/font-client-impl.cpp \
$(text_src_dir)/dali/internal/text-abstraction/font-client-plugin-impl.cpp \
$(text_src_dir)/dali/internal/text-abstraction/segmentation-impl.cpp \