2 * Copyright (c) 2023 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-toolkit-test-suite-utils.h>
18 #include <dummy-control.h>
19 #include <toolkit-event-thread-callback.h>
21 #include <dali-toolkit/dali-toolkit.h>
22 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
25 using namespace Dali::Toolkit;
27 void dali_svg_visual_startup(void)
29 test_return_value = TET_UNDEF;
32 void dali_svg_visual_cleanup(void)
34 test_return_value = TET_PASS;
39 const char* TEST_SVG_FILE_NAME = TEST_RESOURCE_DIR "/svg1.svg";
42 int UtcDaliSvgVisualChageSize(void)
44 tet_infoline("Test change transform");
46 ToolkitTestApplication application;
48 TraceCallStack& textureTrace = application.GetGlAbstraction().GetTextureTrace();
49 textureTrace.Enable(true);
51 Visual::Base visual = VisualFactory::Get().CreateVisual(Property::Map().Add(ImageVisual::Property::URL, TEST_SVG_FILE_NAME));
52 DALI_TEST_CHECK(visual);
54 DummyControl control = DummyControl::New();
55 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(control.GetImplementation());
56 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
58 application.SendNotification();
61 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
63 control.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
64 application.GetScene().Add(control);
66 visual.SetTransformAndSize(Property::Map(), Vector2(100, 100));
68 // Wait for rasterization but not execute the callback
69 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1, 30, false), true, TEST_LOCATION);
71 // Change actor size before finishing rasterization
72 control.SetProperty(Actor::Property::SIZE, Vector2(300, 300));
73 visual.SetTransformAndSize(Property::Map(), Vector2(300, 300));
75 application.SendNotification();
77 // Wait for rasterization
78 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
80 application.SendNotification();
83 TraceCallStack::NamedParams params;
84 params["width"] << 300;
85 params["height"] << 300;
86 // Should be the final size
87 DALI_TEST_EQUALS(textureTrace.FindMethodAndParams("TexImage2D", params), true, TEST_LOCATION);