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 #include <dali/public-api/dali-core.h>
22 #include <dali-test-suite-utils.h>
29 // Size of the VertexAttributeArray enables
30 // GLES specification states that there's minimum of
31 const unsigned int TEST_MAX_ATTRIBUTE_CACHE_SIZE = 8;
45 // Create bitmap image
46 static BufferImage CreateBufferImage()
48 BufferImage image = BufferImage::New(4,4,Pixel::RGBA8888);
53 static ImageActor CreateImageActor()
55 BufferImage image = CreateBufferImage();
56 ImageActor actor = ImageActor::New( image );
57 actor.SetSize( 100.0f, 100.0f );
58 actor.SetName("Test ImageActor");
62 } // anonymous namespace
65 // Positive test case for a method
66 int UtcDaliContextVertexAttribStartup(void)
68 tet_infoline("Testing vertex attrib initial state in context");
70 TestApplication application;
73 application.SendNotification();
77 // context class should initially set the vertex attrib locations to disable
78 // Make sure it has been modified
79 DALI_TEST_CHECK(application.GetGlAbstraction().GetVertexAttribArrayChanged());
81 // check the locations
82 for (unsigned int i = 0; i < TEST_MAX_ATTRIBUTE_CACHE_SIZE; i++)
84 DALI_TEST_CHECK( application.GetGlAbstraction().GetVertexAttribArrayState(i) == false);
91 // Tests to make the attribs only get set once when continually rendering an image actor
92 int UtcDaliContextVertexAttribImageRendering(void)
94 tet_infoline("Testing vertex attrib rendering state in context with images");
96 TestApplication application;
99 application.SendNotification();
100 application.Render();
101 application.Render();
103 // the vertex attribs get modified on startup to set them to disabled
104 // clear the flag to say they've changed
105 application.GetGlAbstraction().ClearVertexAttribArrayChanged();
108 // create a test image actor
109 ImageActor imageActor(CreateImageActor());
110 Stage::GetCurrent().Add(imageActor);
113 application.SendNotification();
114 application.Render();
115 application.Render();
117 // check to make sure the state has changed (the image renderer will enable some
119 DALI_TEST_CHECK(application.GetGlAbstraction().GetVertexAttribArrayChanged());
121 // Now check to make sure the state is cached, and isn't being set each frame.
122 application.GetGlAbstraction().ClearVertexAttribArrayChanged();
124 application.Render();
125 application.Render();
126 application.Render();
128 // if it has changed then the caching has failed
129 DALI_TEST_CHECK(application.GetGlAbstraction().GetVertexAttribArrayChanged() == false);
132 tet_result(TET_PASS);