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.
22 #include <dali-toolkit-test-suite-utils.h>
23 #include <dali-toolkit/dali-toolkit.h>
24 #include <toolkit-text-utils.h>
25 #include <dummy-visual.h>
26 #include <../dali-toolkit/dali-toolkit-test-utils/dummy-control.h>
27 #include <dali-toolkit/devel-api/controls/control-devel.h>
28 #include <dali-toolkit/devel-api/controls/table-view/table-view.h>
29 #include <dali-toolkit/internal/controls/control/control-debug.h>
33 using namespace Toolkit;
36 int UtcDaliControlActionOnVisual(void)
38 ToolkitTestApplication application;
40 tet_infoline( "Register an ImageVisual and perform image reload Action on it. Tests Actions are completed." );
41 Vector2 controlSize( 20.f, 30.f );
44 Property::Map settings;
45 Toolkit::Internal::DummyVisualPtr dummyVisualPtr = Toolkit::Internal::DummyVisual::New( settings );
47 DummyControl dummyControl = DummyControl::New( true );
48 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
50 tet_infoline( "Register test visual and stage control" );
52 Toolkit::Visual::Base visualBaseHandle = Toolkit::Visual::Base( dummyVisualPtr.Get() );
53 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visualBaseHandle );
54 dummyControl.SetProperty( Actor::Property::SIZE, Vector2(200.f, 200.f) );
55 application.GetScene().Add( dummyControl );
57 application.SendNotification();
60 tet_infoline( "Check action counter is 0 before DoAction" );
61 DALI_TEST_EQUALS( dummyVisualPtr->GetActionCounter() , 0, TEST_LOCATION );
63 tet_infoline( "Perform TEST_ACTION action on registered test visual. Should increase the action counter" );
65 Property::Map attributes;
66 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::Internal::DummyVisual::TEST_ACTION, attributes );
68 application.SendNotification();
69 DALI_TEST_EQUALS( dummyVisualPtr->GetActionCounter() , 1, TEST_LOCATION );
74 int UtcDaliControlDebugHierarchy(void)
76 ToolkitTestApplication application;
77 tet_infoline( "Create a control hierarchy, and test that the debug produces output" );
79 auto tableView = Toolkit::TableView::New(1, 2);
80 tableView.AddChild( ImageView::New( TEST_RESOURCE_DIR "/gallery-small-1.jpg" ), TableView::CellPosition( 1, 1 ) );
81 tableView.AddChild( TextLabel::New("Stuff"), TableView::CellPosition( 1, 2 ) );
83 application.GetScene().Add( tableView );
85 Property::Value v(Matrix3::IDENTITY);
86 tableView.RegisterProperty( "SomeMatrix3", v);
88 std::ostringstream oss;
89 Dali::Toolkit::Internal::DumpControlHierarchy( oss, application.GetScene().GetRootLayer() );
90 DALI_TEST_CHECK( oss.str().length() != 0 );
91 tet_printf("Control hierarchy: \n%s\n", oss.str().c_str() );