2 * Copyright (c) 2018 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/internal/controls/control/control-debug.h>
32 using namespace Toolkit;
35 int UtcDaliControlActionOnVisual(void)
37 ToolkitTestApplication application;
39 tet_infoline( "Register an ImageVisual and perform image reload Action on it. Tests Actions are completed." );
40 Vector2 controlSize( 20.f, 30.f );
43 Property::Map settings;
44 Toolkit::Internal::DummyVisualPtr dummyVisualPtr = Toolkit::Internal::DummyVisual::New( settings );
46 DummyControl dummyControl = DummyControl::New( true );
47 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
49 tet_infoline( "Register test visual and stage control" );
51 Toolkit::Visual::Base visualBaseHandle = Toolkit::Visual::Base( dummyVisualPtr.Get() );
52 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visualBaseHandle );
53 dummyControl.SetSize(200.f, 200.f);
54 Stage::GetCurrent().Add( dummyControl );
56 application.SendNotification();
59 tet_infoline( "Check action counter is 0 before DoAction" );
60 DALI_TEST_EQUALS( dummyVisualPtr->GetActionCounter() , 0, TEST_LOCATION );
62 tet_infoline( "Perform TEST_ACTION action on registered test visual. Should increase the action counter" );
64 Property::Map attributes;
65 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::Internal::DummyVisual::TEST_ACTION, attributes );
67 application.SendNotification();
68 DALI_TEST_EQUALS( dummyVisualPtr->GetActionCounter() , 1, TEST_LOCATION );
73 int UtcDaliControlDebugHierarchy(void)
75 ToolkitTestApplication application;
76 tet_infoline( "Create a control hierarchy, and test that the debug produces output" );
78 auto tableView = Toolkit::TableView::New(1, 2);
79 tableView.AddChild( ImageView::New( TEST_RESOURCE_DIR "/gallery-small-1.jpg" ), TableView::CellPosition( 1, 1 ) );
80 tableView.AddChild( TextLabel::New("Stuff"), TableView::CellPosition( 1, 2 ) );
82 Stage::GetCurrent().Add( tableView );
84 Property::Value v(Matrix3::IDENTITY);
85 tableView.RegisterProperty( "SomeMatrix3", v);
87 std::ostringstream oss;
88 Dali::Toolkit::Internal::DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
89 DALI_TEST_CHECK( oss.str().length() != 0 );
90 tet_printf("Control hierarchy: \n%s\n", oss.str().c_str() );