2020-02-15 14:11:35 +00:00
|
|
|
#include <gtest/gtest.h>
|
2020-02-15 14:50:32 +00:00
|
|
|
#include <gmock/gmock.h>
|
2020-02-15 14:11:35 +00:00
|
|
|
#include "webfuse/adapter/mountpoint.h"
|
|
|
|
|
2020-02-15 14:50:32 +00:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
class MockMountpointDisposer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
MOCK_METHOD1(ondispose, void(wf_mountpoint * mountpoint));
|
|
|
|
};
|
|
|
|
|
|
|
|
MockMountpointDisposer * global_disposer = nullptr;
|
|
|
|
|
|
|
|
void ondispose(wf_mountpoint * mountpoint)
|
|
|
|
{
|
|
|
|
global_disposer->ondispose(mountpoint);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-15 14:11:35 +00:00
|
|
|
TEST(mountpoint, get_path)
|
|
|
|
{
|
|
|
|
wf_mountpoint * mountpoint = wf_mountpoint_create("/some/path");
|
|
|
|
ASSERT_NE(nullptr, mountpoint);
|
2020-02-15 14:50:32 +00:00
|
|
|
|
2020-02-15 14:11:35 +00:00
|
|
|
ASSERT_STREQ("/some/path", wf_mountpoint_get_path(mountpoint));
|
|
|
|
|
|
|
|
wf_mountpoint_dispose(mountpoint);
|
|
|
|
}
|
2020-02-15 14:50:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TEST(mountpoint, ondispose)
|
|
|
|
{
|
|
|
|
MockMountpointDisposer disposer;
|
|
|
|
global_disposer = &disposer;
|
|
|
|
|
|
|
|
wf_mountpoint * mountpoint = wf_mountpoint_create("/some/path");
|
|
|
|
ASSERT_NE(nullptr, mountpoint);
|
|
|
|
|
|
|
|
wf_mountpoint_set_ondispose(mountpoint, ondispose);
|
|
|
|
EXPECT_CALL(disposer, ondispose(mountpoint)).Times(1);
|
|
|
|
|
|
|
|
wf_mountpoint_dispose(mountpoint);
|
|
|
|
}
|