Fix svace issue (uint32_t to long or std::streamsize)
[platform/core/uifw/dali-adaptor.git] / automated-tests / src / dali-graphics / utc-Dali-GraphicsNativeImage.cpp
1 /*
2  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
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 <dali-test-suite-utils.h>
18 #include <dali/dali.h>
19
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>
24
25 using namespace Dali;
26
27 void utc_dali_native_image_startup(void)
28 {
29   test_return_value = TET_UNDEF;
30 }
31 void utc_dali_native_image_cleanup(void)
32 {
33   test_return_value = TET_PASS;
34 }
35
36 int UtcDaliGraphicsNativeImage(void)
37 {
38   TestGraphicsApplication app;
39   tet_infoline("UtcDaliNativeImageTexture01");
40
41   TestNativeImagePointer imageInterface = TestNativeImage::New(16, 16);
42   TraceCallStack&        callStack      = imageInterface->mCallStack;
43   callStack.EnableLogging(true);
44   callStack.Enable(true);
45
46   auto& gl               = app.GetGlAbstraction();
47   auto& textureCallStack = gl.GetTextureTrace();
48   textureCallStack.EnableLogging(true);
49   textureCallStack.Enable(true);
50
51   {
52     Texture texture = Texture::New(*(imageInterface.Get()));
53     Actor   actor   = CreateRenderableActor(texture, "", "");
54     app.GetScene().Add(actor);
55
56     app.SendNotification();
57     app.Render(16);
58
59     DALI_TEST_EQUALS(imageInterface->mExtensionCreateCalls, 1, TEST_LOCATION);
60     DALI_TEST_EQUALS(imageInterface->mExtensionDestroyCalls, 0, TEST_LOCATION);
61
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);
67   }
68
69   app.SendNotification();
70   app.Render(16); // Puts texture on discard queue.
71
72   app.SendNotification();
73   app.Render(16);
74
75   // Flush the queues
76   Graphics::SubmitInfo submitInfo{{}, 0 | Graphics::SubmitFlagBits::FLUSH};
77   app.GetGraphicsController().SubmitCommandBuffers(submitInfo);
78
79   DALI_TEST_EQUALS(imageInterface->mExtensionDestroyCalls, 1, TEST_LOCATION);
80
81   END_TEST;
82 }