2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 // Need to override adaptor classes for toolkit test harness, so include
22 // test harness headers before dali headers.
23 #include <dali-toolkit-test-suite-utils.h>
26 #include <dali-toolkit/dali-toolkit.h>
31 void utc_dali_toolkit_dissolve_effect_startup(void)
33 test_return_value = TET_UNDEF;
36 void utc_dali_toolkit_dissolve_effect_cleanup(void)
38 test_return_value = TET_PASS;
42 int UtcDaliDissolveUninitializedEffect(void)
44 ToolkitTestApplication application;
46 Toolkit::DissolveEffect effect;
50 // New() must be called to create a DissolveEffect or it wont be valid.
51 effect.SetDistortion( 2.0f );
52 DALI_TEST_CHECK( false );
54 catch (Dali::DaliException& e)
56 // Tests that a negative test of an assertion succeeds
57 DALI_TEST_PRINT_ASSERT( e );
58 DALI_TEST_CHECK(!effect);
63 int UtcDaliDissolvePropertyNamesEffect(void)
65 ToolkitTestApplication application;
67 Toolkit::DissolveEffect effectHighPrecision = Toolkit::DissolveEffect::New();
68 Toolkit::DissolveEffect effectMediumPrecision = Toolkit::DissolveEffect::New( false );
70 // Check the names, this names are used in the shaders code,
71 // if they change the shader code has to be updated
72 DALI_TEST_EQUALS( effectHighPrecision.GetDistortionPropertyName(), "uPercentage", TEST_LOCATION );
73 DALI_TEST_EQUALS( effectMediumPrecision.GetDistortionPropertyName(), "uPercentage", TEST_LOCATION );
77 int UtcDaliDissolveDefaultValuesEffect(void)
79 ToolkitTestApplication application;
81 Toolkit::DissolveEffect effect = Toolkit::DissolveEffect::New();
82 DALI_TEST_CHECK( effect );
84 BitmapImage image = CreateBitmapImage();
86 ImageActor actor = ImageActor::New( image );
87 actor.SetSize( 100.0f, 100.0f );
88 actor.SetShaderEffect( effect );
89 effect.SetCentralLine( Vector2(0.0,0.5), Vector2(1.0, -0.1) );
90 Stage::GetCurrent().Add( actor );
92 application.SendNotification();
95 Property::Index index = effect.GetPropertyIndex( effect.GetDistortionPropertyName());
97 (effect.GetProperty(index)).Get( value );
98 DALI_TEST_EQUALS(value, 0.f, TEST_LOCATION );
102 int UtcDaliDissolveCustomValuesEffect(void)
104 ToolkitTestApplication application;
106 Toolkit::DissolveEffect effect = Toolkit::DissolveEffect::New();
107 DALI_TEST_CHECK( effect );
109 BitmapImage image = CreateBitmapImage();
111 ImageActor actor = ImageActor::New( image );
112 actor.SetSize( 100.0f, 100.0f );
114 effect.SetDistortion( 0.5f );
116 actor.SetShaderEffect(effect);
117 Stage::GetCurrent().Add(actor);
119 application.SendNotification();
120 application.Render();
122 Property::Index index = effect.GetPropertyIndex( effect.GetDistortionPropertyName());
124 (effect.GetProperty(index)).Get( value );
125 DALI_TEST_EQUALS(value, 0.5f, TEST_LOCATION );
129 int UtcDaliSetEffectImageEffect(void)
131 ToolkitTestApplication application;
133 Toolkit::DissolveEffect effect = Toolkit::DissolveEffect::New();
134 DALI_TEST_CHECK( effect );
136 Image effectImage = CreateBitmapImage();
137 effect.SetEffectImage(effectImage);
139 BitmapImage image = CreateBitmapImage();
141 ImageActor actor = ImageActor::New( image );
142 actor.SetSize( 100.0f, 100.0f );
143 actor.SetShaderEffect( effect );
144 Stage::GetCurrent().Add( actor );
146 application.SendNotification();
147 application.Render();
149 Property::Index index = effect.GetPropertyIndex( effect.GetDistortionPropertyName());
151 (effect.GetProperty(index)).Get( value );
152 DALI_TEST_EQUALS(value, 0.f, TEST_LOCATION );