#include <systemd/sd-event.h>

#include <sdeventplus/clock.hpp>
#include <sdeventplus/event.hpp>
#include <sdeventplus/exception.hpp>
#include <sdeventplus/test/sdevent.hpp>

#include <cerrno>
#include <type_traits>
#include <utility>

#include <gmock/gmock.h>
#include <gtest/gtest.h>

namespace sdeventplus
{
namespace
{

using testing::DoAll;
using testing::Return;
using testing::SetArgPointee;

class ClockTest : public testing::Test
{
  protected:
    testing::StrictMock<test::SdEventMock> mock;
    sd_event* const expected_event = reinterpret_cast<sd_event*>(1234);
};

TEST_F(ClockTest, CopyEvent)
{
    Event event(expected_event, std::false_type(), &mock);

    EXPECT_CALL(mock, sd_event_ref(expected_event))
        .WillOnce(Return(expected_event));
    Clock<ClockId::RealTime> clock(event);
    EXPECT_CALL(mock, sd_event_now(expected_event, CLOCK_REALTIME, testing::_))
        .WillOnce(DoAll(SetArgPointee<2>(2000000), Return(0)));
    EXPECT_EQ(Clock<ClockId::RealTime>::time_point(std::chrono::seconds{2}),
              clock.now());

    EXPECT_CALL(mock, sd_event_unref(expected_event))
        .Times(2)
        .WillRepeatedly(Return(nullptr));
}

TEST_F(ClockTest, MoveEvent)
{
    Event event(expected_event, std::false_type(), &mock);

    Clock<ClockId::Monotonic> clock(std::move(event));
    EXPECT_CALL(mock, sd_event_now(expected_event, CLOCK_MONOTONIC, testing::_))
        .WillOnce(Return(-EINVAL));
    EXPECT_THROW(clock.now(), SdEventError);

    EXPECT_CALL(mock, sd_event_unref(expected_event)).WillOnce(Return(nullptr));
}

} // namespace
} // namespace sdeventplus
