2 * Copyright (c) 2021 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.
17 #include <dali-test-suite-utils.h>
18 #include <dali/dali.h>
20 #include <dali/internal/graphics/gles-impl/egl-graphics-controller.h>
21 #include <test-actor-utils.h>
22 #include <test-graphics-application.h>
23 #include <test-native-image.h>
27 void utc_dali_native_image_startup(void)
29 test_return_value = TET_UNDEF;
31 void utc_dali_native_image_cleanup(void)
33 test_return_value = TET_PASS;
36 int UtcDaliGraphicsNativeImage(void)
38 TestGraphicsApplication app;
39 tet_infoline("UtcDaliNativeImageTexture01");
41 TestNativeImagePointer imageInterface = TestNativeImage::New(16, 16);
42 TraceCallStack& callStack = imageInterface->mCallStack;
43 callStack.EnableLogging(true);
44 callStack.Enable(true);
46 auto& gl = app.GetGlAbstraction();
47 auto& textureCallStack = gl.GetTextureTrace();
48 textureCallStack.EnableLogging(true);
49 textureCallStack.Enable(true);
52 Texture texture = Texture::New(*(imageInterface.Get()));
53 Actor actor = CreateRenderableActor(texture, "", "");
54 app.GetScene().Add(actor);
56 app.SendNotification();
59 DALI_TEST_EQUALS(imageInterface->mExtensionCreateCalls, 1, TEST_LOCATION);
60 DALI_TEST_EQUALS(imageInterface->mExtensionDestroyCalls, 0, TEST_LOCATION);
62 DALI_TEST_EQUALS(callStack.FindMethod("PrepareTexture"), true, TEST_LOCATION);
63 TraceCallStack::NamedParams params;
64 params["target"] << std::hex << GL_TEXTURE_EXTERNAL_OES;
65 DALI_TEST_EQUALS(textureCallStack.FindMethodAndParams("BindTexture", params), 1u, TEST_LOCATION);
66 Dali::UnparentAndReset(actor);
69 app.SendNotification();
70 app.Render(16); // Puts texture on discard queue.
72 app.SendNotification();
76 Graphics::SubmitInfo submitInfo{{}, 0 | Graphics::SubmitFlagBits::FLUSH};
77 app.GetGraphicsController().SubmitCommandBuffers(submitInfo);
79 DALI_TEST_EQUALS(imageInterface->mExtensionDestroyCalls, 1, TEST_LOCATION);