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.
23 #include <dali/public-api/dali-core.h>
24 #include <dali-toolkit/dali-toolkit.h>
26 #include <dali-toolkit-test-suite-utils.h>
29 using namespace Dali::Toolkit;
31 static void Startup();
32 static void Cleanup();
35 void (*tet_startup)() = Startup;
36 void (*tet_cleanup)() = Cleanup;
39 static void UtcDaliOverlayConstructor();
40 static void UtcDaliOverlayUninitializedEffect();
43 POSITIVE_TC_IDX = 0x01,
47 // Add test functionality for all APIs in the class (Positive and Negative)
49 struct tet_testlist tet_testlist[] = {
50 { UtcDaliOverlayConstructor, POSITIVE_TC_IDX },
51 { UtcDaliOverlayUninitializedEffect, NEGATIVE_TC_IDX },
56 // Called only once before first test is run.
61 // Called only once after last test is run
66 // Create bitmap image
67 BitmapImage CreateBitmapImage()
69 BitmapImage image = BitmapImage::New(4,4,Pixel::RGBA8888);
71 PixelBuffer* pixbuf = image.GetBuffer();
73 // Using a 4x4 image gives a better blend with the GL implementation
75 for(size_t i=0; i<16; i++)
86 static void UtcDaliOverlayConstructor()
88 ToolkitTestApplication application;
90 BitmapImage image = CreateBitmapImage();
92 Toolkit::OverlayEffect effect = Toolkit::OverlayEffect::New( image );
93 DALI_TEST_CHECK( effect );
95 ImageActor actor = ImageActor::New( image );
96 actor.SetSize( 100.0f, 100.0f );
97 actor.SetShaderEffect( effect );
98 Stage::GetCurrent().Add( actor );
100 application.SendNotification();
101 application.Render();
105 static void UtcDaliOverlayUninitializedEffect()
107 ToolkitTestApplication application;
109 Toolkit::OverlayEffect effect;
113 BitmapImage image = CreateBitmapImage();
115 // New() must be called to create a OverlayEffect or it wont be valid.
116 effect.SetEffectImage( image );
117 DALI_TEST_CHECK( false );
119 catch (Dali::DaliException& e)
121 // Tests that a negative test of an assertion succeeds
122 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
123 DALI_TEST_CHECK(!effect);