2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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.
18 * @author Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
19 * @brief Implementation file for DBusTest and DBusTestManager.
22 #include <dpl/test/test_runner.h>
23 #include "loop_control.h"
24 #include "dbus_test.h"
26 DBusTest::DBusTest(const std::string& name)
28 m_status(Status::NONE)
32 void DBusTest::run(unsigned int timeout)
34 DPL::Event::ControllerEventHandler<TimeoutEvent>::Touch();
35 DPL::Event::ControllerEventHandler<QuitEvent>::Touch();
37 DPL::Event::ControllerEventHandler<TimeoutEvent>::PostTimedEvent(
38 TimeoutEvent(), timeout);
40 LoopControl::wrt_start_loop();
45 throw DPL::Test::TestRunner::TestFailed(m_name.c_str(),
57 DPL::Event::ControllerEventHandler<QuitEvent>::PostEvent(QuitEvent());
60 void DBusTest::setStatus(Status status)
65 void DBusTest::setMessage(const std::string& message)
70 void DBusTest::success()
72 m_status = Status::SUCCESS;
75 void DBusTest::fail(const std::string& message)
77 m_status = Status::FAILED;
81 void DBusTest::OnEventReceived(const TimeoutEvent& /*event*/)
83 fail("Test timed out.");
85 // Saving one event dispatch since Quit and Timeout work on the same thread.
86 LoopControl::wrt_end_loop();
89 void DBusTest::OnEventReceived(const QuitEvent& /*event*/)
91 LoopControl::wrt_end_loop();
94 DBusTestManager& DBusTestManager::getInstance()
96 static DBusTestManager instance;
100 DBusTestManager::DBusTestManager() : m_test(NULL) { }
102 DBusTest& DBusTestManager::getCurrentTest() const
104 Assert(NULL != m_test && "Test not set.");
109 void DBusTestManager::setCurrentTest(DBusTest& test)
114 void DBusTestManager::clear()