2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 static GMainLoop* __mainloop = NULL;
21 void test::start_mainloop()
24 __mainloop = g_main_loop_new(NULL, FALSE);
25 g_main_loop_run(__mainloop);
29 void test::stop_mainloop()
32 g_main_loop_quit(__mainloop);
33 g_main_loop_unref(__mainloop);
38 bool test::is_mainloop_running()
40 return (__mainloop != NULL);
48 int test::read_int(const std::string& msg)
52 std::getline(std::cin, line);
57 return atoi(line.c_str());
60 std::string test::read_str()
65 std::string test::read_str(const std::string& msg)
69 std::getline(std::cin, line);
74 void test::run_test_case(const char *tcName, bool (*tcFunc)(void))
76 IF_FAIL_VOID(tcName && tcFunc);
78 g_print(CYAN("%s") ": ", tcName);
81 bool result = tcFunc();
83 g_print(">> " GREEN("PASS") "\n");