[AT-SPI] Add TestDBusWrapper and bypass compilation problems
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit-internal / utc-Dali-PropertyHelper.cpp
1 /*
2  * Copyright (c) 2017 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/property-helper.h>
20
21 #include <automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/dbus-wrapper.h>
22
23 using namespace Dali;
24 using namespace Dali::Toolkit;
25
26 void dali_property_helper_startup(void)
27 {
28   test_return_value = TET_UNDEF;
29   DBusWrapper::Install(std::unique_ptr<DBusWrapper>(new TestDBusWrapper));
30 }
31
32 void dali_property_helper_cleanup(void)
33 {
34   test_return_value = TET_PASS;
35 }
36
37 int UtcDaliPropertyHelperGetStringFromPropertyWithString(void)
38 {
39   tet_infoline( "Test to check if a simple string is parsed correctly" );
40
41   const std::string inputString = "Hello World";
42   Property::Value value( inputString );
43
44   std::string output;
45   DALI_TEST_CHECK( Toolkit::Internal::GetStringFromProperty( value, output ) );
46   DALI_TEST_EQUALS( output, inputString, TEST_LOCATION );
47
48   END_TEST;
49 }
50
51 int UtcDaliPropertyHelperGetStringFromPropertyWithEmptyValue(void)
52 {
53   tet_infoline( "Test to ensure if an empty value returns false" );
54
55   std::string output;
56   DALI_TEST_CHECK( ! Toolkit::Internal::GetStringFromProperty( Property::Value(), output ) );
57
58   END_TEST;
59 }
60
61 int UtcDaliPropertyHelperGetStringFromPropertyWithStringArray(void)
62 {
63   tet_infoline( "Test to check if a string array is parsed correctly and adds new line characters too" );
64
65   Property::Value value( Property::Array().Add( "Hello World" )
66                                           .Add( "The Quick Brown Fox" )
67                                           .Add( "Jumps over the lazy dog" ) );
68
69   std::string output;
70   DALI_TEST_CHECK( Toolkit::Internal::GetStringFromProperty( value, output ) );
71   DALI_TEST_CHECK( output.find( "Hello World\n" ) != std::string::npos );
72   DALI_TEST_CHECK( output.find( "The Quick Brown Fox\n" ) != std::string::npos );
73   DALI_TEST_CHECK( output.find( "Jumps over the lazy dog\n" ) != std::string::npos );
74
75   END_TEST;
76 }
77
78 int UtcDaliPropertyHelperGetStringFromPropertyWithEmptyArray(void)
79 {
80   tet_infoline( "Test to check if an empty array returns false" );
81
82   Property::Array array;
83
84   std::string output;
85   DALI_TEST_CHECK( ! Toolkit::Internal::GetStringFromProperty( Property::Value( array ), output ) );
86
87   END_TEST;
88 }
89
90 int UtcDaliPropertyHelperGetStringFromPropertyWithMultipleTypesInArray(void)
91 {
92   tet_infoline( "Test to ensure an array with multiple types returns false" );
93
94   Property::Value value( Property::Array().Add( "Hello World" )
95                                           .Add( "The Quick Brown Fox" )
96                                           .Add( 1 )
97                                           .Add( "Jumps" )
98                                           .Add( 25 )
99                                           .Add( "Over" ) );
100
101   std::string output;
102   DALI_TEST_CHECK( ! Toolkit::Internal::GetStringFromProperty( value, output ) );
103   DALI_TEST_CHECK( output.empty() );
104
105   END_TEST;
106 }