2 * Copyright (c) 2020 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.
21 #include <dali-toolkit-test-suite-utils.h>
22 #include <dali-toolkit/dali-toolkit.h>
23 #include "dali-toolkit-test-utils/test-addon-manager.h"
24 #include <toolkit-event-thread-callback.h>
26 using namespace Dali::Toolkit::Internal;
31 const char* TEST_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/application-icon-20.png";
32 const char* TEST_IMAGE_FILE_NAME_9 = TEST_RESOURCE_DIR "/heartsframe.9.png";
33 const char* TEST_IMAGE_FILE_NAME2_9 = TEST_RESOURCE_DIR "/button-up.9.png";
34 int CountFunctionCalls( const std::vector<std::string>& callstack, const std::string& function )
37 std::find_if( callstack.begin(), callstack.end(), [&counter, &function]( const std::string& item )
39 if( item == function )
51 int UtcRenderingAddOnTestP(void)
53 Dali::Integration::AddOnManager* addOnManager = new Dali::Test::AddOnManager();
55 bool valid = addOnManager->Get() != nullptr;
56 DALI_TEST_EQUALS( valid, true, TEST_LOCATION );
57 auto addon = addOnManager->GetAddOn( "oo-rendering" );
58 auto GetCallStack = addOnManager->GetGlobalProc<std::vector<std::string>(bool)>( addon, "GetCallStack" );
60 ToolkitTestApplication application;
61 tet_infoline( "UtcRenderingAddOnTestP" );
63 // Load regular image view
64 auto imageView = Dali::Toolkit::ImageView::New( TEST_IMAGE_FILE_NAME );
65 imageView.SetProperty( Actor::Property::SIZE, Vector2( 400.f, 60.f ) );
66 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
67 imageView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
69 // Load npatch image view
70 auto imageView2 = Dali::Toolkit::ImageView::New( TEST_IMAGE_FILE_NAME_9 );
71 imageView2.SetProperty( Actor::Property::SIZE, Vector2( 400.f, 60.f ) );
72 imageView2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
73 imageView2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
75 // Load npatch image view
76 auto imageView3 = Dali::Toolkit::ImageView::New( TEST_IMAGE_FILE_NAME2_9 );
77 imageView3.SetProperty( Actor::Property::SIZE, Vector2( 400.f, 60.f ) );
78 imageView3.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
79 imageView3.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
81 application.GetScene().Add( imageView );
82 application.GetScene().Add( imageView2 );
83 application.GetScene().Add( imageView3 );
85 application.SendNotification();
88 DALI_TEST_EQUALS( ::Test::WaitForEventThreadTrigger( 3 ), true, TEST_LOCATION );
90 application.SendNotification();
93 auto callstack = GetCallStack(true);
95 DALI_TEST_EQUALS( CountFunctionCalls( callstack, "GetGeometry" ), 2, TEST_LOCATION);
96 DALI_TEST_EQUALS( CountFunctionCalls( callstack, "CreateGeometry" ), 1, TEST_LOCATION);
97 DALI_TEST_EQUALS( CountFunctionCalls( callstack, "CreateGeometryGrid" ), 2, TEST_LOCATION);
98 DALI_TEST_EQUALS( CountFunctionCalls( callstack, "BuildNPatch" ), 2, TEST_LOCATION);