2
* Copyright 2012 Canonical Ltd.
4
* This program is free software: you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License version 3, as published
6
* by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranties of
10
* MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
11
* PURPOSE. See the GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* version 3 along with this program. If not, see
15
* <http://www.gnu.org/licenses/>
17
* Authored by: Andrea Azzarone <andrea.azzarone@canonical.com>
24
#include <gtest/gtest.h>
26
#include "unity-shared/PanelStyle.h"
27
#include "unity-shared/UnitySettings.h"
29
using namespace unity;
30
using namespace testing;
35
const std::string TITLEBAR_FONT = "Ubuntu Bold 11";
37
class TestPanelStyle : public Test
40
glib::Object<GSettings> gsettings;
41
Settings unity_settings;
42
std::unique_ptr<panel::Style> panel_style_instance;
44
/* override */ void SetUp()
46
g_setenv ("GSETTINGS_BACKEND", "memory", 1);
48
gsettings = g_settings_new("org.gnome.desktop.wm.preferences");
49
g_settings_set_string(gsettings, "titlebar-font", TITLEBAR_FONT.c_str());
51
panel_style_instance.reset(new panel::Style());
54
/* override */ void TearDown()
56
g_unsetenv ("GSETTINGS_BACKEND");
60
TEST_F(TestPanelStyle, TestGetFontDescription)
62
ASSERT_EQ(panel_style_instance->GetFontDescription(panel::PanelItem::TITLE), TITLEBAR_FONT);
65
TEST_F(TestPanelStyle, TestChangedSignal)
67
bool signal_received = false;
69
panel_style_instance->changed.connect([&](){
70
signal_received = true;
73
gchar *old_font = g_settings_get_string(gsettings, "titlebar-font");
74
g_settings_set_string(gsettings, "titlebar-font", "Ubuntu Italic 11");
78
ASSERT_TRUE(signal_received);
79
ASSERT_EQ(panel_style_instance->GetFontDescription(panel::PanelItem::TITLE), "Ubuntu Italic 11");
81
g_settings_set_string(gsettings, "titlebar-font", old_font);