Make NPatchData receive LoadComplete call from TextureManager.
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit-internal / utc-Dali-ColorConversion.cpp
1 /*
2  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include <dali-toolkit-test-suite-utils.h>
19 #include <dali-toolkit/internal/helpers/color-conversion.h>
20
21 #if defined(ELDBUS_ENABLED)
22 #include <automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/dbus-wrapper.h>
23 #endif
24
25 using namespace Dali;
26 using namespace Dali::Toolkit;
27
28 void dali_color_conversion_startup(void)
29 {
30   test_return_value = TET_UNDEF;
31 #if defined(ELDBUS_ENABLED)
32   DBusWrapper::Install(std::unique_ptr<DBusWrapper>(new TestDBusWrapper));
33 #endif
34 }
35
36 void dali_color_conversion_cleanup(void)
37 {
38   test_return_value = TET_PASS;
39 }
40
41 int UtcDaliPropertyHelperConvertHtmlStringToColor(void)
42 {
43   tet_infoline( "Test to check whether An HTML style hex string can be converted" );
44
45   const std::string stringColor( "#FF0000" );
46
47   Vector4 result;
48   DALI_TEST_CHECK( Toolkit::Internal::ConvertStringToColor( stringColor, result ) );
49
50   DALI_TEST_EQUALS( result, Color::RED, TEST_LOCATION );
51
52   END_TEST;
53 }
54
55 int UtcDaliPropertyHelperConvertStringPropertyToColor(void)
56 {
57   tet_infoline( "Test to check whether A Property value containing a string can be converted" );
58
59   const std::string stringColor( "#00FF00" );
60   Property::Value colorProperty( stringColor );
61
62   Vector4 result;
63   DALI_TEST_CHECK( Toolkit::Internal::ConvertPropertyToColor( colorProperty, result ) );
64
65   DALI_TEST_EQUALS( result, Color::GREEN, TEST_LOCATION );
66
67   END_TEST;
68 }
69
70 int UtcDaliPropertyHelperConvertVector4PropertyToColor(void)
71 {
72   tet_infoline( "Test to check whether A Property value containing a string can be converted" );
73
74   const Vector4 color( 0.0, 0.0, 1.0, 1.0 );
75   Property::Value colorProperty( color );
76
77   Vector4 result;
78   DALI_TEST_CHECK( Toolkit::Internal::ConvertPropertyToColor( colorProperty, result ) );
79
80   DALI_TEST_EQUALS( result, Color::BLUE, TEST_LOCATION );
81
82   END_TEST;
83 }