Fix svace issue (uint32_t to long or std::streamsize)
[platform/core/uifw/dali-adaptor.git] / automated-tests / src / dali-graphics / utc-Dali-GraphicsGeometry.cpp
1 #include <dali-test-suite-utils.h>
2
3 #include <dali/graphics-api/graphics-controller.h>
4 #include <dali/internal/graphics/gles-impl/egl-graphics-controller.h>
5 #include <test-graphics-application.h>
6 //#include <dali/graphics-api/graphics-api-buffer.h>
7
8 int UtcDaliGraphicsCreateGeometry(void)
9 {
10   // Initialize actual egl graphics controller (without initializing egl!)
11   TestGraphicsApplication app;
12
13   struct Vertex
14   {
15     float x;
16     float y;
17   };
18
19   std::vector<Vertex>   someData(100);
20   Graphics::Controller& graphicsController = app.GetGraphicsController();
21
22   Graphics::BufferCreateInfo createInfo;
23   createInfo
24     .SetUsage(0 | Graphics::BufferUsage::VERTEX_BUFFER)
25     .SetSize(someData.size());
26
27   auto                    buffer = graphicsController.CreateBuffer(createInfo, nullptr);
28   Graphics::MapBufferInfo info;
29   info.buffer = buffer.get();
30   info.usage  = 0 | Graphics::MemoryUsageFlagBits::WRITE;
31   info.offset = 0;
32   info.size   = someData.size();
33
34   auto  memory = graphicsController.MapBufferRange(info);
35   void* ptr    = memory->LockRegion(0, someData.size());
36   DALI_TEST_CHECK(ptr != nullptr);
37   memory->Unlock(true);
38   graphicsController.UnmapMemory(std::move(memory));
39
40   // Test that data has been uploaded to GL, e.g. test that GPU buffer has been created
41   auto& gl              = app.GetGlAbstraction();
42   auto& bufferDataCalls = gl.GetBufferDataCalls();
43   DALI_TEST_EQUALS(bufferDataCalls.size(), 1u, TEST_LOCATION);
44   DALI_TEST_EQUALS(bufferDataCalls[0], someData.size(), TEST_LOCATION);
45   DALI_TEST_CHECK(1);
46   END_TEST;
47 }