Dali 3D User Interface Engine
utc-Dali-Thread.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 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 #include <stdlib.h>
20 #include <unistd.h>
21 #include <dali-test-suite-utils.h>
23 
24 using Dali::Thread;
25 
26 namespace
27 {
28 volatile bool gRunThreadEntryFunc = false;
29 
30 class TestThread : public Thread
31 {
32  virtual void Run()
33  {
34  gRunThreadEntryFunc = true;
35  }
36 };
37 }
38 
39 int UtcDaliThreadP(void)
40 {
41  tet_infoline("Testing Dali::Thread");
42 
43  gRunThreadEntryFunc = false;
44 
45  TestThread thread;
46 
47  thread.Start();
48  // wait till the thread is terminated
49  while( !gRunThreadEntryFunc )
50  {
51  usleep( 1 ); // 1 microsecond
52  }
54 
55  thread.Join();
56 
57  // Restart the thread after joined
58  gRunThreadEntryFunc = false;
59  thread.Start();
60  thread.Join();
61  // wait till the thread is terminated
62  while( !gRunThreadEntryFunc )
63  {
64  usleep( 1 ); // 1 microsecond
65  }
67 
68  END_TEST;
69 }
70 
72 {
73  // we want to make sure that mutex is not copyable (its copy constructor is not defined)
74  // this test will stop compiling if Mutex has compiler generated copy constructor
75  DALI_COMPILE_TIME_ASSERT( !__has_trivial_copy( Thread ) );
76 
77  DALI_TEST_CHECK( true );
78  END_TEST;
79 }
Dali Docs Home
Read more about Dali