Upload package dali-toolkit_0.9.21
[platform/core/uifw/dali-toolkit.git] / automated-tests / TET / dali-test-suite / shader-effects / utc-Dali-PageTurnEffect.cpp
1 //
2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
3 //
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
7 //
8 //     http://floralicense.org/license/
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 #include <iostream>
18
19 #include <stdlib.h>
20 #include <tet_api.h>
21
22 #include <dali/public-api/dali-core.h>
23 #include <dali-toolkit/dali-toolkit.h>
24
25 #include <dali-toolkit-test-suite-utils.h>
26
27 using namespace Dali;
28
29 static void Startup();
30 static void Cleanup();
31
32 extern "C" {
33   void (*tet_startup)() = Startup;
34   void (*tet_cleanup)() = Cleanup;
35 }
36
37
38 enum {
39   POSITIVE_TC_IDX = 0x01,
40   NEGATIVE_TC_IDX,
41 };
42
43
44 #define MAX_NUMBER_OF_TESTS 10000
45 extern "C" {
46   struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS];
47 }
48
49 // Add test functionality for all APIs in the class (Positive and Negative)
50 TEST_FUNCTION( UtcDaliPageTurnEffectApply, POSITIVE_TC_IDX );
51 TEST_FUNCTION( UtcDaliPageTurnEffectConstruct, POSITIVE_TC_IDX );
52
53 // Called only once before first test is run.
54 static void Startup()
55 {
56 }
57
58 // Called only once after last test is run
59 static void Cleanup()
60 {
61 }
62
63 // Create bitmap image
64 static BitmapImage CreateBitmapImage()
65 {
66   BitmapImage image = BitmapImage::New(4,4,Pixel::RGBA8888);
67
68   PixelBuffer* pixbuf = image.GetBuffer();
69
70   // Using a 4x4 image gives a better blend with the GL implementation
71   // than a 3x3 image
72   for(size_t i=0; i<16; i++)
73   {
74     pixbuf[i*4+0] = 0xFF;
75     pixbuf[i*4+1] = 0xFF;
76     pixbuf[i*4+2] = 0xFF;
77     pixbuf[i*4+3] = 0xFF;
78   }
79
80   return image;
81 }
82
83 static void UtcDaliPageTurnEffectApply()
84 {
85   ToolkitTestApplication application;
86
87   BitmapImage image = CreateBitmapImage();
88
89   Toolkit::PageTurnEffect pageTurnEffect = Toolkit::PageTurnEffect::New();
90   Toolkit::PageTurnEffect pageTurnEffect2 = Toolkit::PageTurnEffect::New(false);
91
92   ImageActor pageActor = ImageActor::New( image );
93   ImageActor backPageActor = ImageActor::New( image );
94   pageActor.Add( backPageActor );
95
96   pageTurnEffect.SetIsTurningBack( true );
97   pageTurnEffect.SetShadowWidth( 0.0f );
98   pageTurnEffect.SetSpineShadowParameter( Vector2( 0.0f, 0.0f ) );
99
100   pageActor.SetShaderEffect( pageTurnEffect );
101   Stage::GetCurrent().Add( pageActor );
102
103   application.SendNotification();
104   application.Render();
105
106   const Vector2 pageSize( 0.0f, 0.0f );
107   pageTurnEffect.SetPageSize( pageSize );
108
109   const Vector2 originalCenter( 0.0f, 0.0f );
110   pageTurnEffect.SetOriginalCenter( originalCenter );
111
112   const Vector2 currentCenter( 0.0f, 0.0f );
113   pageTurnEffect.SetCurrentCenter( currentCenter );
114
115   application.SendNotification();
116   application.Render();
117
118   TestGlAbstraction& gl = application.GetGlAbstraction();
119   DALI_TEST_CHECK( gl.CheckUniformValue( pageTurnEffect.GetPageSizePropertyName().c_str(), pageSize ) );
120   DALI_TEST_CHECK( gl.CheckUniformValue( pageTurnEffect.GetOriginalCenterPropertyName().c_str(), originalCenter ) );
121   DALI_TEST_CHECK( gl.CheckUniformValue( pageTurnEffect.GetCurrentCenterPropertyName().c_str(), currentCenter ) );
122 }
123
124 static void UtcDaliPageTurnEffectConstruct()
125 {
126   ToolkitTestApplication application;
127
128   Toolkit::PageTurnEffect* effect = new Toolkit::PageTurnEffect();
129   delete effect;
130
131   DALI_TEST_CHECK( true );
132 }