From a3937830bf656d5a8e2f368757b947cef0c8b1de Mon Sep 17 00:00:00 2001 From: Iain Lane Date: Tue, 1 Sep 2015 10:52:13 +0100 Subject: Rename FileTimezone to TimedatedTimezone --- tests/CMakeLists.txt | 2 +- tests/test-timezone-file.cpp | 73 --------------------------------------- tests/test-timezone-timedated.cpp | 73 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+), 74 deletions(-) delete mode 100644 tests/test-timezone-file.cpp create mode 100644 tests/test-timezone-timedated.cpp (limited to 'tests') diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 9d26484..032b84e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -58,7 +58,7 @@ add_test_by_name(test-locations) add_test_by_name(test-menus) add_test_by_name(test-planner) add_test_by_name(test-settings) -add_test_by_name(test-timezone-file) +add_test_by_name(test-timezone-timedated) add_test_by_name(test-utils) set (TEST_NAME manual-test-snap) diff --git a/tests/test-timezone-file.cpp b/tests/test-timezone-file.cpp deleted file mode 100644 index 0ec496d..0000000 --- a/tests/test-timezone-file.cpp +++ /dev/null @@ -1,73 +0,0 @@ - -/* - * Copyright 2013 Canonical Ltd. - * - * Authors: - * Charles Kerr - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3, as published - * by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranties of - * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#include "timedated-fixture.h" - -#include - -#include // fopen() -//#include // chmod() -#include // sync() - -using unity::indicator::datetime::FileTimezone; - -/** - * Test that timezone-file picks up the initial value - */ -TEST_F(TimedateFixture, InitialValue) -{ - const std::string expected_timezone = "America/Chicago"; - set_timezone(expected_timezone); - FileTimezone tz; - ASSERT_EQ(expected_timezone, tz.timezone.get()); -} - -/** - * Test that changing the tz after we are running works. - */ -TEST_F(TimedateFixture, ChangedValue) -{ - const std::string initial_timezone = "America/Chicago"; - const std::string changed_timezone = "America/New_York"; - GMainLoop *l = g_main_loop_new(nullptr, FALSE); - - set_timezone(initial_timezone); - - FileTimezone tz; - ASSERT_EQ(initial_timezone, tz.timezone.get()); - - bool changed = false; - tz.timezone.changed().connect( - [&changed, this, l](const std::string& s){ - g_message("timezone changed to %s", s.c_str()); - changed = true; - g_main_loop_quit(l); - }); - - g_idle_add([](gpointer gself){ - static_cast(gself)->set_timezone("America/New_York"); - return G_SOURCE_REMOVE; - }, this); - - g_main_loop_run(l); - - ASSERT_TRUE(changed); - ASSERT_EQ(changed_timezone, tz.timezone.get()); -} diff --git a/tests/test-timezone-timedated.cpp b/tests/test-timezone-timedated.cpp new file mode 100644 index 0000000..7086e96 --- /dev/null +++ b/tests/test-timezone-timedated.cpp @@ -0,0 +1,73 @@ + +/* + * Copyright 2013 Canonical Ltd. + * + * Authors: + * Charles Kerr + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#include "timedated-fixture.h" + +#include + +#include // fopen() +//#include // chmod() +#include // sync() + +using unity::indicator::datetime::TimedatedTimezone; + +/** + * Test that timezone-file picks up the initial value + */ +TEST_F(TimedateFixture, InitialValue) +{ + const std::string expected_timezone = "America/Chicago"; + set_timezone(expected_timezone); + TimedatedTimezone tz; + ASSERT_EQ(expected_timezone, tz.timezone.get()); +} + +/** + * Test that changing the tz after we are running works. + */ +TEST_F(TimedateFixture, ChangedValue) +{ + const std::string initial_timezone = "America/Chicago"; + const std::string changed_timezone = "America/New_York"; + GMainLoop *l = g_main_loop_new(nullptr, FALSE); + + set_timezone(initial_timezone); + + TimedatedTimezone tz; + ASSERT_EQ(initial_timezone, tz.timezone.get()); + + bool changed = false; + tz.timezone.changed().connect( + [&changed, this, l](const std::string& s){ + g_message("timezone changed to %s", s.c_str()); + changed = true; + g_main_loop_quit(l); + }); + + g_idle_add([](gpointer gself){ + static_cast(gself)->set_timezone("America/New_York"); + return G_SOURCE_REMOVE; + }, this); + + g_main_loop_run(l); + + ASSERT_TRUE(changed); + ASSERT_EQ(changed_timezone, tz.timezone.get()); +} -- cgit v1.2.3