~3v1n0/unity/light-shortcuts

« back to all changes in this revision

Viewing changes to tests/test_panel_style.cpp

  • Committer: Marco Trevisan (Treviño)
  • Date: 2013-04-26 12:41:09 UTC
  • Revision ID: mail@3v1n0.net-20130426124109-t3b2shjah2omiqa2
Unity: Remove all the views, but the Shortcuts

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright 2012 Canonical Ltd.
3
 
 *
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.
7
 
 *
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.
12
 
 *
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/>
16
 
 *
17
 
 * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com>
18
 
 *
19
 
 */
20
 
 
21
 
#include <config.h>
22
 
 
23
 
#include <gio/gio.h>
24
 
#include <gtest/gtest.h>
25
 
 
26
 
#include "unity-shared/PanelStyle.h"
27
 
#include "unity-shared/UnitySettings.h"
28
 
 
29
 
using namespace unity;
30
 
using namespace testing;
31
 
 
32
 
namespace
33
 
{
34
 
 
35
 
const std::string TITLEBAR_FONT = "Ubuntu Bold 11";
36
 
 
37
 
class TestPanelStyle : public Test
38
 
{
39
 
public:
40
 
  glib::Object<GSettings> gsettings;
41
 
  Settings unity_settings;
42
 
  std::unique_ptr<panel::Style> panel_style_instance;
43
 
 
44
 
  /* override */ void SetUp()
45
 
  {
46
 
    g_setenv ("GSETTINGS_BACKEND", "memory", 1);
47
 
 
48
 
    gsettings = g_settings_new("org.gnome.desktop.wm.preferences");
49
 
    g_settings_set_string(gsettings, "titlebar-font", TITLEBAR_FONT.c_str());
50
 
 
51
 
    panel_style_instance.reset(new panel::Style());
52
 
  }
53
 
 
54
 
  /* override */ void TearDown()
55
 
  {
56
 
    g_unsetenv ("GSETTINGS_BACKEND");
57
 
  }
58
 
};
59
 
 
60
 
TEST_F(TestPanelStyle, TestGetFontDescription)
61
 
{
62
 
  ASSERT_EQ(panel_style_instance->GetFontDescription(panel::PanelItem::TITLE), TITLEBAR_FONT);
63
 
}
64
 
 
65
 
TEST_F(TestPanelStyle, TestChangedSignal)
66
 
{
67
 
  bool signal_received = false;
68
 
 
69
 
  panel_style_instance->changed.connect([&](){
70
 
    signal_received = true;
71
 
  });
72
 
 
73
 
  gchar *old_font = g_settings_get_string(gsettings, "titlebar-font");
74
 
  g_settings_set_string(gsettings, "titlebar-font", "Ubuntu Italic 11");
75
 
 
76
 
  sleep(1);
77
 
 
78
 
  ASSERT_TRUE(signal_received);
79
 
  ASSERT_EQ(panel_style_instance->GetFontDescription(panel::PanelItem::TITLE), "Ubuntu Italic 11");  
80
 
 
81
 
  g_settings_set_string(gsettings, "titlebar-font", old_font);
82
 
  g_free (old_font);
83
 
}
84
 
 
85
 
}