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