2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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.
22 #include <dali/public-api/dali-core.h>
23 #include <dali-toolkit/dali-toolkit.h>
25 #include <dali-toolkit-test-suite-utils.h>
28 using namespace Dali::Toolkit;
30 static void Startup();
31 static void Cleanup();
34 void (*tet_startup)() = Startup;
35 void (*tet_cleanup)() = Cleanup;
38 static void UtcDaliOverlayConstructor();
39 static void UtcDaliOverlayUninitializedEffect();
42 POSITIVE_TC_IDX = 0x01,
46 // Add test functionality for all APIs in the class (Positive and Negative)
48 struct tet_testlist tet_testlist[] = {
49 { UtcDaliOverlayConstructor, POSITIVE_TC_IDX },
50 { UtcDaliOverlayUninitializedEffect, NEGATIVE_TC_IDX },
55 // Called only once before first test is run.
60 // Called only once after last test is run
65 // Create bitmap image
66 BitmapImage CreateBitmapImage()
68 BitmapImage image = BitmapImage::New(4,4,Pixel::RGBA8888);
70 PixelBuffer* pixbuf = image.GetBuffer();
72 // Using a 4x4 image gives a better blend with the GL implementation
74 for(size_t i=0; i<16; i++)
85 static void UtcDaliOverlayConstructor()
87 ToolkitTestApplication application;
89 BitmapImage image = CreateBitmapImage();
91 Toolkit::OverlayEffect effect = Toolkit::OverlayEffect::New( image );
92 DALI_TEST_CHECK( effect );
94 ImageActor actor = ImageActor::New( image );
95 actor.SetSize( 100.0f, 100.0f );
96 actor.SetShaderEffect( effect );
97 Stage::GetCurrent().Add( actor );
99 application.SendNotification();
100 application.Render();
104 static void UtcDaliOverlayUninitializedEffect()
106 ToolkitTestApplication application;
108 Toolkit::OverlayEffect effect;
112 BitmapImage image = CreateBitmapImage();
114 // New() must be called to create a OverlayEffect or it wont be valid.
115 effect.SetEffectImage( image );
116 DALI_TEST_CHECK( false );
118 catch (Dali::DaliException& e)
120 // Tests that a negative test of an assertion succeeds
121 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
122 DALI_TEST_CHECK(!effect);