[Tizen] Add screen and client rotation itself function
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Processors.cpp
1 /*
2  * Copyright (c) 2019 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 <stdlib.h>
19 #include <dali/public-api/dali-core.h>
20 #include <dali/integration-api/core.h>
21 #include <dali-test-suite-utils.h>
22 #include <dali/integration-api/processor-interface.h>
23
24 using namespace Dali;
25
26
27 class TestProcessor : public Integration::Processor
28 {
29 public:
30
31   TestProcessor()
32   : processRun(false)
33   {
34   }
35
36   virtual void Process()
37   {
38     processRun = true;
39   }
40
41   bool processRun;
42 };
43
44
45 int UtcDaliCoreProcessorP(void)
46 {
47   TestApplication application;
48
49   TestProcessor testProcessor;
50   Integration::Core& core = application.GetCore();
51   core.RegisterProcessor( testProcessor );
52
53   tet_infoline("Test that the processor has not been executed yet:");
54   DALI_TEST_CHECK( testProcessor.processRun == false );
55
56   application.SendNotification();
57
58   tet_infoline("Test that the processor has been executed:");
59   DALI_TEST_CHECK( testProcessor.processRun );
60
61   // Clear down for next part of test
62   testProcessor.processRun = false;
63
64   core.UnregisterProcessor( testProcessor );
65   application.SendNotification();
66   tet_infoline("Test that the processor has not been executed again:");
67   DALI_TEST_CHECK( testProcessor.processRun == false );
68
69   END_TEST;
70 }
71
72 int UtcDaliCoreProcessorMultipleP(void)
73 {
74   TestApplication application;
75
76   TestProcessor testProcessor1;
77   TestProcessor testProcessor2;
78   TestProcessor testProcessor3;
79
80   Integration::Core& core = application.GetCore();
81   core.RegisterProcessor( testProcessor1 );
82
83   tet_infoline("Test that the processor has not been executed yet:");
84   DALI_TEST_CHECK( testProcessor1.processRun == false );
85
86   application.SendNotification();
87
88   tet_infoline("Test that the processor has been executed:");
89   DALI_TEST_CHECK( testProcessor1.processRun );
90
91   // Clear down for next part of test
92   testProcessor1.processRun = false;
93
94   core.RegisterProcessor( testProcessor2 );
95   core.RegisterProcessor( testProcessor3 );
96
97   tet_infoline("Test that the processors have not been executed yet:");
98   DALI_TEST_CHECK( testProcessor1.processRun == false );
99   DALI_TEST_CHECK( testProcessor2.processRun == false );
100   DALI_TEST_CHECK( testProcessor3.processRun == false );
101
102   application.SendNotification();
103
104   tet_infoline("Test that the processors have been executed:");
105   DALI_TEST_CHECK( testProcessor1.processRun );
106   DALI_TEST_CHECK( testProcessor2.processRun );
107   DALI_TEST_CHECK( testProcessor3.processRun );
108
109   // Clear down for next part of test
110   testProcessor2.processRun = false;
111
112   core.UnregisterProcessor( testProcessor2 );
113   application.SendNotification();
114   tet_infoline("Test that the unregistered processor has not been executed again but others have");
115   DALI_TEST_CHECK( testProcessor1.processRun );
116   DALI_TEST_CHECK( testProcessor2.processRun == false );
117   DALI_TEST_CHECK( testProcessor3.processRun );
118
119   END_TEST;
120 }