[dali_1.3.1] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit-internal / utc-Dali-Control-internal.cpp
1 /*
2  * Copyright (c) 2017 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 #include <iostream>
19
20 #include <stdlib.h>
21
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
29 using namespace Dali;
30 using namespace Toolkit;
31
32
33 int UtcDaliControlActionOnVisual(void)
34 {
35   ToolkitTestApplication application;
36
37   tet_infoline( "Register an ImageVisual and perform image reload Action on it. Tests Actions are completed." );
38   Vector2 controlSize( 20.f, 30.f );
39
40   //Created DummyVisual
41   Property::Map settings;
42   Toolkit::Internal::DummyVisualPtr dummyVisualPtr = Toolkit::Internal::DummyVisual::New( settings );
43
44   DummyControl dummyControl = DummyControl::New( true );
45   Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
46
47   tet_infoline( "Register test visual and stage control" );
48
49   Toolkit::Visual::Base visualBaseHandle = Toolkit::Visual::Base( dummyVisualPtr.Get() );
50   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visualBaseHandle );
51   dummyControl.SetSize(200.f, 200.f);
52   Stage::GetCurrent().Add( dummyControl );
53
54   application.SendNotification();
55   application.Render();
56
57   tet_infoline( "Check action counter is 0 before DoAction" );
58   DALI_TEST_EQUALS( dummyVisualPtr->GetActionCounter() , 0, TEST_LOCATION );
59
60   tet_infoline( "Perform TEST_ACTION action on registered test visual. Should increase the action counter" );
61
62   Property::Map attributes;
63   DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::Internal::DummyVisual::TEST_ACTION, attributes );
64
65   application.SendNotification();
66   DALI_TEST_EQUALS( dummyVisualPtr->GetActionCounter() , 1, TEST_LOCATION );
67
68   END_TEST;
69 }