[dali_2.3.20] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / toolkit-event-thread-callback.h
1 #ifndef DALI_TOOLKIT_EVENT_THREAD_CALLBACK_H
2 #define DALI_TOOLKIT_EVENT_THREAD_CALLBACK_H
3
4 /*
5  * Copyright (c) 2023 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20 #define DALI_EVENT_THREAD_CALLBACK_H
21
22 // EXTERNAL INCLUDES
23 #include <dali-toolkit/public-api/dali-toolkit-common.h>
24 #include <dali/public-api/signals/callback.h>
25
26 namespace Dali
27 {
28 class DALI_TOOLKIT_API EventThreadCallback
29 {
30 public:
31   EventThreadCallback(CallbackBase* callback);
32
33   ~EventThreadCallback();
34
35   void Trigger();
36
37   bool WaitingForTrigger();
38
39   CallbackBase* GetCallback();
40
41 private:
42   // undefined copy constructor.
43   EventThreadCallback(const EventThreadCallback&);
44
45   // undefined assignment operator
46   EventThreadCallback& operator=(const EventThreadCallback&);
47
48 private:
49   struct Impl;
50   Impl* mImpl;
51 };
52
53 } // namespace Dali
54
55 namespace Test
56 {
57 /**
58  * Wait for the tested code to create an event trigger, then
59  * wait for triggerCount Trigger calls to occur, and execute the trigger
60  * callback afterwards.
61  *
62  * Will wait for a maximum of 30s before failing the test and returning.
63  */
64 bool WaitForEventThreadTrigger(int triggerCount, int timeoutInSeconds = 30, int executeCallbacks = true);
65
66 } // namespace Test
67
68 #endif // DALI_TOOLKIT_EVENT_THREAD_CALLBACK_H