2
* Copyright © 2015 Canonical Ltd.
4
* This program is free software: you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License version 3,
6
* as published by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
* Authored by: Andreas Pokorny <andreas.pokorny@canonical.com>
19
#ifndef MIR_TEST_DOUBLES_TRIGGERED_MAIN_LOOP_H_
20
#define MIR_TEST_DOUBLES_TRIGGERED_MAIN_LOOP_H_
22
#include "mir_test_doubles/mock_main_loop.h"
33
class TriggeredMainLoop : public ::testing::NiceMock<MockMainLoop>
36
using fd_callback = std::function<void(int)>;
37
using signal_callback = std::function<void(int)>;
38
using callback = std::function<void()>;
40
void register_fd_handler(std::initializer_list<int> fds, void const* owner, fd_callback const& handler) override;
41
void unregister_fd_handler(void const* owner) override;
42
std::unique_ptr<mir::time::Alarm> notify_in(std::chrono::milliseconds delay, callback call) override;
43
void enqueue(void const* owner, ServerAction const& action) override;
45
void trigger_pending_fds();
46
void fire_all_alarms();
47
void trigger_server_actions();
50
std::vector<callback> timeout_callbacks;
58
std::vector<Item> fd_callbacks;
59
std::vector<ServerAction> actions;