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>
27 #include <dali-toolkit/devel-api/shader-effects/dissolve-effect.h>
32 void utc_dali_toolkit_dissolve_effect_startup(void)
34 test_return_value = TET_UNDEF;
37 void utc_dali_toolkit_dissolve_effect_cleanup(void)
39 test_return_value = TET_PASS;
43 int UtcDaliDissolveUninitializedEffect(void)
45 ToolkitTestApplication application;
47 Toolkit::DissolveEffect effect;
51 // New() must be called to create a DissolveEffect or it wont be valid.
52 effect.SetDistortion( 2.0f );
53 DALI_TEST_CHECK( false );
55 catch (Dali::DaliException& e)
57 // Tests that a negative test of an assertion succeeds
58 DALI_TEST_PRINT_ASSERT( e );
59 DALI_TEST_CHECK(!effect);
64 int UtcDaliDissolvePropertyNamesEffect(void)
66 ToolkitTestApplication application;
68 Toolkit::DissolveEffect effectHighPrecision = Toolkit::DissolveEffect::New();
69 Toolkit::DissolveEffect effectMediumPrecision = Toolkit::DissolveEffect::New( false );
71 // Check the names, this names are used in the shaders code,
72 // if they change the shader code has to be updated
73 DALI_TEST_EQUALS( effectHighPrecision.GetDistortionPropertyName(), "uPercentage", TEST_LOCATION );
74 DALI_TEST_EQUALS( effectMediumPrecision.GetDistortionPropertyName(), "uPercentage", TEST_LOCATION );
78 int UtcDaliDissolveDefaultValuesEffect(void)
80 ToolkitTestApplication application;
82 Toolkit::DissolveEffect effect = Toolkit::DissolveEffect::New();
83 DALI_TEST_CHECK( effect );
85 BufferImage image = CreateBufferImage();
87 ImageActor actor = ImageActor::New( image );
88 actor.SetSize( 100.0f, 100.0f );
89 actor.SetShaderEffect( effect );
90 effect.SetCentralLine( Vector2(0.0,0.5), Vector2(1.0, -0.1) );
91 Stage::GetCurrent().Add( actor );
93 application.SendNotification();
96 Property::Index index = effect.GetPropertyIndex( effect.GetDistortionPropertyName());
98 (effect.GetProperty(index)).Get( value );
99 DALI_TEST_EQUALS(value, 0.f, TEST_LOCATION );
103 int UtcDaliDissolveCustomValuesEffect(void)
105 ToolkitTestApplication application;
107 Toolkit::DissolveEffect effect = Toolkit::DissolveEffect::New();
108 DALI_TEST_CHECK( effect );
110 BufferImage image = CreateBufferImage();
112 ImageActor actor = ImageActor::New( image );
113 actor.SetSize( 100.0f, 100.0f );
115 effect.SetDistortion( 0.5f );
117 actor.SetShaderEffect(effect);
118 Stage::GetCurrent().Add(actor);
120 application.SendNotification();
121 application.Render();
123 Property::Index index = effect.GetPropertyIndex( effect.GetDistortionPropertyName());
125 (effect.GetProperty(index)).Get( value );
126 DALI_TEST_EQUALS(value, 0.5f, TEST_LOCATION );
130 int UtcDaliSetEffectImageEffect(void)
132 ToolkitTestApplication application;
134 Toolkit::DissolveEffect effect = Toolkit::DissolveEffect::New();
135 DALI_TEST_CHECK( effect );
137 Image effectImage = CreateBufferImage();
138 effect.SetEffectImage(effectImage);
140 BufferImage image = CreateBufferImage();
142 ImageActor actor = ImageActor::New( image );
143 actor.SetSize( 100.0f, 100.0f );
144 actor.SetShaderEffect( effect );
145 Stage::GetCurrent().Add( actor );
147 application.SendNotification();
148 application.Render();
150 Property::Index index = effect.GetPropertyIndex( effect.GetDistortionPropertyName());
152 (effect.GetProperty(index)).Get( value );
153 DALI_TEST_EQUALS(value, 0.f, TEST_LOCATION );