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.
18 #include <dali-test-suite-utils.h>
19 #include <dali/public-api/dali-core.h>
28 // Size of the VertexAttributeArray enables
29 // GLES specification states that there's a minimum of 8
30 const unsigned int TEST_MAX_ATTRIBUTE_CACHE_SIZE = 8;
44 // Create bitmap actor
45 static Actor CreateBitmapActor()
47 Actor actor = CreateRenderableActor();
48 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
49 actor.SetProperty(Actor::Property::NAME, "Test Image Rendering Actor");
53 } // anonymous namespace
55 // Positive test case for a method
56 int UtcDaliContextVertexAttribStartup(void)
58 tet_infoline("Testing vertex attrib initial state in context");
60 TestApplication application;
63 application.SendNotification();
67 // check the locations
68 for(unsigned int i = 0; i < TEST_MAX_ATTRIBUTE_CACHE_SIZE; i++)
70 DALI_TEST_CHECK(application.GetGlAbstraction().GetVertexAttribArrayState(i) == false);
77 // Tests to make the attribs only get set once when continually rendering an image actor
78 int UtcDaliContextVertexAttribImageRendering(void)
80 tet_infoline("Testing vertex attrib rendering state in context with images");
82 TestApplication application;
85 application.SendNotification();
89 // the vertex attribs get modified on startup to set them to disabled
90 // clear the flag to say they've changed
91 application.GetGlAbstraction().ClearVertexAttribArrayChanged();
93 // create a test bitmap actor
94 Actor actor(CreateBitmapActor());
95 application.GetScene().Add(actor);
97 application.SendNotification();
101 // check to make sure the state has changed (the image renderer will enable some
103 DALI_TEST_CHECK(application.GetGlAbstraction().GetVertexAttribArrayChanged());
105 // Now check to make sure the state is cached, and isn't being set each frame.
106 application.GetGlAbstraction().ClearVertexAttribArrayChanged();
108 application.Render();
109 application.Render();
110 application.Render();
112 // if it has changed then the caching has failed
113 DALI_TEST_CHECK(application.GetGlAbstraction().GetVertexAttribArrayChanged() == false);
115 tet_result(TET_PASS);