aboutsummaryrefslogtreecommitdiff
path: root/tests/test-timezone-timedated.cpp
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2016-04-09 19:05:39 -0500
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2021-08-29 14:37:39 +0200
commit907a22aaab79104150406e5d4de08aaeca0dc602 (patch)
treea57e73ae5ea1a4c1c2069c184ae78f4adaf04c36 /tests/test-timezone-timedated.cpp
parent8b3ba566108578f5e49ed50129f341bab2429dab (diff)
downloadayatana-indicator-datetime-907a22aaab79104150406e5d4de08aaeca0dc602.tar.gz
ayatana-indicator-datetime-907a22aaab79104150406e5d4de08aaeca0dc602.tar.bz2
ayatana-indicator-datetime-907a22aaab79104150406e5d4de08aaeca0dc602.zip
in tests/, remove the handrolled timedate1 bus mock. It doesn't add anything over the dbusmock template
Diffstat (limited to 'tests/test-timezone-timedated.cpp')
-rw-r--r--tests/test-timezone-timedated.cpp98
1 files changed, 7 insertions, 91 deletions
diff --git a/tests/test-timezone-timedated.cpp b/tests/test-timezone-timedated.cpp
index e613806..8c56459 100644
--- a/tests/test-timezone-timedated.cpp
+++ b/tests/test-timezone-timedated.cpp
@@ -18,110 +18,26 @@
* Ted Gould <ted.gould@canonical.com>
*/
-#include "glib-fixture.h"
+#include "timedated-fixture.h"
-#include <datetime/dbus-shared.h>
#include <datetime/timezone-timedated.h>
-#include <gio/gio.h>
-
-
using namespace ayatana::indicator::datetime;
-
-struct Timedate1Fixture: public GlibFixture
-{
-private:
-
- typedef GlibFixture super;
-
-protected:
-
- GDBusConnection* m_bus {};
- GTestDBus* m_test_bus {};
-
- void SetUp() override
- {
- super::SetUp();
-
- // use a fake bus
- m_test_bus = g_test_dbus_new(G_TEST_DBUS_NONE);
- g_test_dbus_up(m_test_bus);
- const char * address = g_test_dbus_get_bus_address(m_test_bus);
- g_setenv("DBUS_SYSTEM_BUS_ADDRESS", address, true);
- g_setenv("DBUS_SESSION_BUS_ADDRESS", address, true);
- g_debug("test_dbus's address is %s", address);
-
- // get the bus
- m_bus = g_bus_get_sync(G_BUS_TYPE_SESSION, nullptr, nullptr);
- g_dbus_connection_set_exit_on_close(m_bus, FALSE);
- g_object_add_weak_pointer(G_OBJECT(m_bus), (gpointer*)&m_bus);
- }
-
- void TearDown() override
- {
- g_clear_object(&m_bus);
- g_clear_object(&m_test_bus);
-
- super::TearDown();
- }
-
- void start_timedate1(const std::string& tzid)
- {
- // start dbusmock with the timedated template
- auto json_parameters = g_strdup_printf("{\"Timezone\": \"%s\"}", tzid.c_str());
- const gchar* child_argv[] = { "python3", "-m", "dbusmock", "--template", "timedated", "--parameters", json_parameters, nullptr };
- GError* error = nullptr;
- g_spawn_async(nullptr, (gchar**)child_argv, nullptr, G_SPAWN_SEARCH_PATH, nullptr, nullptr, nullptr, &error);
- g_assert_no_error(error);
- g_free(json_parameters);
-
- // wait for it to appear on the bus
- wait_for_name_owned(m_bus, Bus::Timedate1::BUSNAME);
- }
-
- bool wait_for_tzid(const std::string& tzid, Timezone& tz)
- {
- return wait_for([&tzid, &tz](){return tzid == tz.timezone.get();});
- }
-
- void set_timedate1_timezone(const std::string& tzid)
- {
- GError* error {};
- auto v = g_dbus_connection_call_sync(
- m_bus,
- Bus::Timedate1::BUSNAME,
- Bus::Timedate1::ADDR,
- Bus::Timedate1::IFACE,
- Bus::Timedate1::Methods::SET_TIMEZONE,
- g_variant_new("(sb)", tzid.c_str(), FALSE),
- nullptr,
- G_DBUS_CALL_FLAGS_NONE,
- -1,
- nullptr,
- &error);
- g_clear_pointer(&v, g_variant_unref);
- g_assert_no_error(error);
- }
-};
-
-#define EXPECT_TZID(expected_tzid, tmp) \
- EXPECT_TRUE(wait_for_tzid(expected_tzid, tmp)) \
- << "expected " << expected_tzid \
- << " got " << tmp.timezone.get();
+using TestTimedatedFixture = TimedatedFixture;
/***
****
***/
-TEST_F(Timedate1Fixture, HelloWorld)
+TEST_F(TestTimedatedFixture, HelloWorld)
{
}
/**
* Test that the tzid is right if timedated isn't available
*/
-TEST_F(Timedate1Fixture, DefaultTimezone)
+TEST_F(TestTimedatedFixture, DefaultTimezone)
{
const std::string expected_tzid{"Etc/Utc"};
@@ -132,7 +48,7 @@ TEST_F(Timedate1Fixture, DefaultTimezone)
/**
* Test that the tzid is right if timedated shows BEFORE we start
*/
-TEST_F(Timedate1Fixture, Timedate1First)
+TEST_F(TestTimedatedFixture, Timedate1First)
{
const std::string expected_tzid{"America/Chicago"};
@@ -144,7 +60,7 @@ TEST_F(Timedate1Fixture, Timedate1First)
/**
* Test that the tzid is right if timedated shows AFTER we start
*/
-TEST_F(Timedate1Fixture, Timedate1Last)
+TEST_F(TestTimedatedFixture, Timedate1Last)
{
const std::string expected_tzid("America/Los_Angeles");
@@ -156,7 +72,7 @@ TEST_F(Timedate1Fixture, Timedate1Last)
/**
* Test that the tzid is right if timedated's property changes
*/
-TEST_F(Timedate1Fixture, TimezoneChange)
+TEST_F(TestTimedatedFixture, TimezoneChange)
{
const std::vector<std::string> expected_tzids{"America/Los_Angeles", "America/Chicago", "Etc/Utc"};