#include <systemd/sd-event.h>
#include <time.h>

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

#include <cerrno>
#include <chrono>
#include <functional>
#include <memory>
#include <utility>

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

namespace sdeventplus
{
namespace source
{
namespace
{

using testing::DoAll;
using testing::Return;
using testing::ReturnPointee;
using testing::SaveArg;
using testing::SetArgPointee;

using UniqueEvent = std::unique_ptr<Event, std::function<void(Event*)>>;

class TimeTest : public testing::Test
{
  protected:
    testing::StrictMock<test::SdEventMock> mock;
    sd_event_source* const expected_source =
        reinterpret_cast<sd_event_source*>(1234);
    sd_event* const expected_event = reinterpret_cast<sd_event*>(2345);
    UniqueEvent event = make_event(expected_event);

    UniqueEvent make_event(sd_event* event)
    {
        auto deleter = [this, event](Event* e) {
            EXPECT_CALL(this->mock, sd_event_unref(event))
                .WillOnce(Return(nullptr));
            delete e;
        };
        return UniqueEvent(new Event(event, std::false_type(), &mock), deleter);
    }

    void expect_time_destroy(sd_event* event, sd_event_source* source)
    {
        EXPECT_CALL(mock, sd_event_source_unref(source))
            .WillOnce(Return(nullptr));
        EXPECT_CALL(mock, sd_event_unref(event)).WillOnce(Return(nullptr));
    }
};

TEST_F(TimeTest, ConstructSuccess)
{
    constexpr ClockId id = ClockId::RealTime;
    const Time<id>::TimePoint expected_time(std::chrono::seconds{2});
    const Time<id>::Accuracy expected_accuracy(std::chrono::milliseconds{50});
    Time<id>::TimePoint saved_time;
    Time<id>::Callback callback =
        [&saved_time](Time<id>&, Time<id>::TimePoint time) {
        saved_time = time;
    };

    EXPECT_CALL(mock, sd_event_ref(expected_event))
        .WillOnce(Return(expected_event));
    sd_event_time_handler_t handler;
    EXPECT_CALL(mock,
                sd_event_add_time(expected_event, testing::_, CLOCK_REALTIME,
                                  2000000, 50000, testing::_, nullptr))
        .WillOnce(DoAll(SetArgPointee<1>(expected_source), SaveArg<5>(&handler),
                        Return(0)));
    sd_event_destroy_t destroy;
    void* userdata;
    {
        testing::InSequence seq;
        EXPECT_CALL(mock, sd_event_source_set_destroy_callback(expected_source,
                                                               testing::_))
            .WillOnce(DoAll(SaveArg<1>(&destroy), Return(0)));
        EXPECT_CALL(mock,
                    sd_event_source_set_userdata(expected_source, testing::_))
            .WillOnce(DoAll(SaveArg<1>(&userdata), Return(nullptr)));
        EXPECT_CALL(mock, sd_event_source_get_userdata(expected_source))
            .WillRepeatedly(ReturnPointee(&userdata));
    }
    Time<id> time(*event, expected_time, expected_accuracy,
                  std::move(callback));
    EXPECT_FALSE(callback);
    EXPECT_NE(&time, userdata);
    EXPECT_EQ(expected_event, time.get_event().get());
    EXPECT_EQ(expected_source, time.get());

    EXPECT_EQ(0, handler(nullptr, 2000100, userdata));
    EXPECT_EQ(Time<id>::TimePoint(std::chrono::microseconds(2000100)),
              saved_time);

    time.set_callback(std::bind([]() {}));
    EXPECT_EQ(0, handler(nullptr, 0, userdata));
    EXPECT_EQ(Time<id>::TimePoint(std::chrono::microseconds(2000100)),
              saved_time);

    expect_time_destroy(expected_event, expected_source);
    destroy(userdata);
}

TEST_F(TimeTest, ConstructError)
{
    constexpr ClockId id = ClockId::Monotonic;
    const Time<id>::TimePoint expected_time(std::chrono::seconds{2});
    const Time<id>::Accuracy expected_accuracy(std::chrono::milliseconds{50});
    Time<id>::Callback callback = [](Time<id>&, Time<id>::TimePoint) {};

    EXPECT_CALL(mock,
                sd_event_add_time(expected_event, testing::_, CLOCK_MONOTONIC,
                                  2000000, 50000, testing::_, nullptr))
        .WillOnce(Return(-ENOSYS));
    EXPECT_THROW(
        Time<id>(*event, expected_time, expected_accuracy, std::move(callback)),
        SdEventError);
    EXPECT_TRUE(callback);
}

class TimeMethodTest : public TimeTest
{
  protected:
    static constexpr ClockId id = ClockId::BootTime;
    std::unique_ptr<Time<id>> time;
    sd_event_destroy_t destroy;
    void* userdata;

    void SetUp()
    {
        EXPECT_CALL(mock, sd_event_ref(expected_event))
            .WillOnce(Return(expected_event));
        EXPECT_CALL(mock, sd_event_add_time(expected_event, testing::_,
                                            CLOCK_BOOTTIME, 2000000, 50000,
                                            testing::_, nullptr))
            .WillOnce(DoAll(SetArgPointee<1>(expected_source), Return(0)));
        {
            testing::InSequence seq;
            EXPECT_CALL(mock, sd_event_source_set_destroy_callback(
                                  expected_source, testing::_))
                .WillOnce(DoAll(SaveArg<1>(&destroy), Return(0)));
            EXPECT_CALL(
                mock, sd_event_source_set_userdata(expected_source, testing::_))
                .WillOnce(DoAll(SaveArg<1>(&userdata), Return(nullptr)));
            EXPECT_CALL(mock, sd_event_source_get_userdata(expected_source))
                .WillRepeatedly(ReturnPointee(&userdata));
        }
        time = std::make_unique<Time<id>>(
            *event, Time<id>::TimePoint(std::chrono::seconds{2}),
            std::chrono::milliseconds{50},
            [](Time<id>&, Time<id>::TimePoint) {});
    }

    void TearDown()
    {
        expect_time_destroy(expected_event, expected_source);
        time.reset();
        destroy(userdata);
    }
};

TEST_F(TimeMethodTest, Copy)
{
    EXPECT_CALL(mock, sd_event_ref(expected_event))
        .WillOnce(Return(expected_event));
    EXPECT_CALL(mock, sd_event_source_ref(expected_source))
        .WillOnce(Return(expected_source));
    auto time2 = std::make_unique<Time<id>>(*time);
    {
        EXPECT_CALL(mock, sd_event_ref(expected_event))
            .WillOnce(Return(expected_event));
        EXPECT_CALL(mock, sd_event_source_ref(expected_source))
            .WillOnce(Return(expected_source));
        Time<id> time3(*time);

        expect_time_destroy(expected_event, expected_source);
        EXPECT_CALL(mock, sd_event_ref(expected_event))
            .WillOnce(Return(expected_event));
        EXPECT_CALL(mock, sd_event_source_ref(expected_source))
            .WillOnce(Return(expected_source));
        *time2 = time3;

        expect_time_destroy(expected_event, expected_source);
    }

    // Delete the original time
    time2.swap(time);
    expect_time_destroy(expected_event, expected_source);
    time2.reset();

    // Make sure our new copy can still access data
    time->set_callback(nullptr);
}

TEST_F(TimeMethodTest, SetTimeSuccess)
{
    EXPECT_CALL(mock, sd_event_source_set_time(expected_source, 1000000))
        .WillOnce(Return(0));
    time->set_time(Time<id>::TimePoint(std::chrono::seconds{1}));
}

TEST_F(TimeMethodTest, SetTimeError)
{
    EXPECT_CALL(mock, sd_event_source_set_time(expected_source, 1000000))
        .WillOnce(Return(-EINVAL));
    EXPECT_THROW(time->set_time(Time<id>::TimePoint(std::chrono::seconds{1})),
                 SdEventError);
}

TEST_F(TimeMethodTest, GetTimeSuccess)
{
    EXPECT_CALL(mock, sd_event_source_get_time(expected_source, testing::_))
        .WillOnce(DoAll(SetArgPointee<1>(10), Return(0)));
    EXPECT_EQ(Time<id>::TimePoint(std::chrono::microseconds{10}),
              time->get_time());
}

TEST_F(TimeMethodTest, GetTimeError)
{
    EXPECT_CALL(mock, sd_event_source_get_time(expected_source, testing::_))
        .WillOnce(Return(-ENOSYS));
    EXPECT_THROW(time->get_time(), SdEventError);
}

TEST_F(TimeMethodTest, SetAccuracySuccess)
{
    EXPECT_CALL(mock,
                sd_event_source_set_time_accuracy(expected_source, 5000000))
        .WillOnce(Return(0));
    time->set_accuracy(std::chrono::seconds{5});
}

TEST_F(TimeMethodTest, SetAccuracyError)
{
    EXPECT_CALL(mock,
                sd_event_source_set_time_accuracy(expected_source, 5000000))
        .WillOnce(Return(-EINVAL));
    EXPECT_THROW(time->set_accuracy(std::chrono::seconds{5}), SdEventError);
}

TEST_F(TimeMethodTest, GetAccuracySuccess)
{
    EXPECT_CALL(mock,
                sd_event_source_get_time_accuracy(expected_source, testing::_))
        .WillOnce(DoAll(SetArgPointee<1>(1000), Return(0)));
    EXPECT_EQ(std::chrono::milliseconds{1}, time->get_accuracy());
}

TEST_F(TimeMethodTest, GetAccuracyError)
{
    EXPECT_CALL(mock,
                sd_event_source_get_time_accuracy(expected_source, testing::_))
        .WillOnce(Return(-ENOSYS));
    EXPECT_THROW(time->get_accuracy(), SdEventError);
}

} // namespace
} // namespace source
} // namespace sdeventplus
