2
Copyright 2012 Canonical Ltd.
5
Charles Kerr <charles.kerr@canonical.com>
7
This program is free software: you can redistribute it and/or modify it
8
under the terms of the GNU General Public License version 3, as published
9
by the Free Software Foundation.
11
This program is distributed in the hope that it will be useful, but
12
WITHOUT ANY WARRANTY; without even the implied warranties of
13
MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
14
PURPOSE. See the GNU General Public License for more details.
16
You should have received a copy of the GNU General Public License along
17
with this program. If not, see <http://www.gnu.org/licenses/>.
20
#include <gtest/gtest.h>
22
#include <glib-object.h>
30
void ensure_glib_initialized ()
32
static bool initialized = false;
34
if (G_UNLIKELY(!initialized))
37
g_setenv ("GSETTINGS_SCHEMA_DIR", SCHEMA_DIR, TRUE);
46
class IndicatorTest : public ::testing::Test
52
int log_count_ipower_actual;
54
static void log_count_func (const gchar *log_domain,
55
GLogLevelFlags log_level,
59
reinterpret_cast<IndicatorTest*>(user_data)->log_count_ipower_actual++;
64
int log_count_ipower_expected;
70
const GLogLevelFlags flags = GLogLevelFlags(G_LOG_LEVEL_CRITICAL|G_LOG_LEVEL_WARNING);
71
log_handler_id = g_log_set_handler ("Indicator-Power", flags, log_count_func, this);
72
log_count_ipower_expected = 0;
73
log_count_ipower_actual = 0;
75
ensure_glib_initialized ();
78
virtual void TearDown()
80
ASSERT_EQ (log_count_ipower_expected, log_count_ipower_actual);
81
g_log_remove_handler ("Indicator-Power", log_handler_id);
89
TEST_F(IndicatorTest, HelloWorld)