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 a minimum of 8
31 const unsigned int TEST_MAX_ATTRIBUTE_CACHE_SIZE = 8;
45 // Create bitmap actor
46 static Actor CreateBitmapActor()
48 Actor actor = CreateRenderableActor();
49 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
50 actor.SetProperty( Actor::Property::NAME,"Test Image Rendering Actor");
54 } // anonymous namespace
57 // Positive test case for a method
58 int UtcDaliContextVertexAttribStartup(void)
60 tet_infoline("Testing vertex attrib initial state in context");
62 TestApplication application;
65 application.SendNotification();
69 // check the locations
70 for (unsigned int i = 0; i < TEST_MAX_ATTRIBUTE_CACHE_SIZE; i++)
72 DALI_TEST_CHECK( application.GetGlAbstraction().GetVertexAttribArrayState(i) == false);
79 // Tests to make the attribs only get set once when continually rendering an image actor
80 int UtcDaliContextVertexAttribImageRendering(void)
82 tet_infoline("Testing vertex attrib rendering state in context with images");
84 TestApplication application;
87 application.SendNotification();
91 // the vertex attribs get modified on startup to set them to disabled
92 // clear the flag to say they've changed
93 application.GetGlAbstraction().ClearVertexAttribArrayChanged();
96 // create a test bitmap actor
97 Actor actor(CreateBitmapActor());
98 application.GetScene().Add(actor);
101 application.SendNotification();
102 application.Render();
103 application.Render();
105 // check to make sure the state has changed (the image renderer will enable some
107 DALI_TEST_CHECK(application.GetGlAbstraction().GetVertexAttribArrayChanged());
109 // Now check to make sure the state is cached, and isn't being set each frame.
110 application.GetGlAbstraction().ClearVertexAttribArrayChanged();
112 application.Render();
113 application.Render();
114 application.Render();
116 // if it has changed then the caching has failed
117 DALI_TEST_CHECK(application.GetGlAbstraction().GetVertexAttribArrayChanged() == false);
120 tet_result(TET_PASS);