1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#include <sdbusplus/bus.hpp>
#include <gtest/gtest.h>
constexpr auto this_name = "xyz.openbmc_project.sdbusplus.test.ListNames";
class ListNames : public ::testing::Test
{
protected:
decltype(sdbusplus::bus::new_default()) bus = sdbusplus::bus::new_default();
};
TEST_F(ListNames, NoServiceNameWithoutRequestName)
{
auto names = bus.list_names_acquired();
EXPECT_EQ(names.cend(), std::find(names.cbegin(), names.cend(), this_name));
}
TEST_F(ListNames, HasServiceNameAfterRequestName)
{
bus.request_name(this_name);
auto names = bus.list_names_acquired();
auto i = std::find(names.cbegin(), names.cend(), this_name);
ASSERT_NE(names.cend(), i);
EXPECT_EQ(this_name, *i);
}
TEST_F(ListNames, HasUniqueName)
{
auto names = bus.list_names_acquired();
ASSERT_FALSE(bus.get_unique_name().empty());
EXPECT_NE(names.cend(),
std::find(names.cbegin(), names.cend(), bus.get_unique_name()));
}
TEST_F(ListNames, HasDbusServer)
{
auto names = bus.list_names_acquired();
auto dbus_server = "org.freedesktop.DBus";
auto i = std::find(names.cbegin(), names.cend(), dbus_server);
ASSERT_NE(names.cend(), i);
EXPECT_EQ(dbus_server, *i);
}
|