aboutsummaryrefslogtreecommitdiff
path: root/tests/test-timezone-timedated.cpp
blob: c686c39320e1017c7d2f94ac095e0efdf4fff73e (plain)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*
 * Copyright © 2014-2016 Canonical Ltd.
 *
 * 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 <http://www.gnu.org/licenses/>.
 *
 * Authors:
 *   Charles Kerr <charles.kerr@canonical.com>
 *   Ted Gould <ted.gould@canonical.com>
 */

#include "timedated-fixture.h"

#include <datetime/timezone-timedated.h>

using namespace ayatana::indicator::datetime;

using TestTimedatedFixture = TimedatedFixture;

/***
****
***/

TEST_F(TestTimedatedFixture, HelloWorld)
{
}

/**
 * Test that the tzid is right if timedated isn't available
 */
TEST_F(TestTimedatedFixture, DefaultTimezone)
{
    const std::string expected_tzid{"Etc/Utc"};

    TimedatedTimezone tmp {m_bus};
    EXPECT_TZID(expected_tzid, tmp);
}

/**
 * Test that the tzid is right if timedated shows BEFORE we start
 */
TEST_F(TestTimedatedFixture, Timedate1First)
{
    const std::string expected_tzid{"America/Chicago"};

    start_timedate1(expected_tzid);
    TimedatedTimezone tmp {m_bus};
    EXPECT_TZID(expected_tzid, tmp);
}

/**
 * Test that the tzid is right if timedated shows AFTER we start
 */
TEST_F(TestTimedatedFixture, Timedate1Last)
{
    const std::string expected_tzid("America/Los_Angeles");

    TimedatedTimezone tmp {m_bus};
    start_timedate1(expected_tzid);
    EXPECT_TZID(expected_tzid, tmp);
}

/**
 * Test that the tzid is right if timedated's property changes
 */
TEST_F(TestTimedatedFixture, TimezoneChange)
{
    const std::vector<std::string> expected_tzids{"America/Los_Angeles", "America/Chicago", "Etc/Utc"};

    TimedatedTimezone tmp {m_bus};
    start_timedate1("America/New_York");

    for(const auto& expected_tzid : expected_tzids)
    {
        set_timedate1_timezone(expected_tzid);
        EXPECT_TZID(expected_tzid, tmp);
    }
}