Back to index

indicator-appmenu  12.10.0
test-usage-db-old.c
Go to the documentation of this file.
00001 /*
00002 Test function to ensure we auto-clear the old databse
00003 
00004 Copyright 2011 Canonical Ltd.
00005 
00006 Authors:
00007     Ted Gould <ted@canonical.com>
00008 
00009 This program is free software: you can redistribute it and/or modify it 
00010 under the terms of the GNU General Public License version 3, as published 
00011 by the Free Software Foundation.
00012 
00013 This program is distributed in the hope that it will be useful, but 
00014 WITHOUT ANY WARRANTY; without even the implied warranties of 
00015 MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR 
00016 PURPOSE.  See the GNU General Public License for more details.
00017 
00018 You should have received a copy of the GNU General Public License along 
00019 with this program.  If not, see <http://www.gnu.org/licenses/>.
00020 */
00021 
00022 #include <glib.h>
00023 #include <glib-object.h>
00024 
00025 #include "hudsettings.h"
00026 #include "load-app-info.h"
00027 #include "usage-tracker.h"
00028 
00029 HudSettings hud_settings = {
00030   .store_usage_data = TRUE
00031 };
00032 
00033 /* Ensure the base object works */
00034 static void
00035 test_usage_db_base (void)
00036 {
00037        UsageTracker * tracker = usage_tracker_new();
00038        g_assert(tracker != NULL);
00039        g_assert(IS_USAGE_TRACKER(tracker));
00040 
00041        g_object_unref(tracker);
00042        return;
00043 }
00044 
00045 static void
00046 test_usage_db_counts (void)
00047 {
00048        UsageTracker * tracker = usage_tracker_new();
00049        g_assert(tracker != NULL);
00050        g_assert(IS_USAGE_TRACKER(tracker));
00051 
00052        g_assert(usage_tracker_get_usage(tracker, "testapp.desktop", "Zero") == 0);
00053        g_assert(usage_tracker_get_usage(tracker, "testapp.desktop", "One") == 1);
00054        g_assert(usage_tracker_get_usage(tracker, "testapp.desktop", "Two") == 1);
00055        g_assert(usage_tracker_get_usage(tracker, "testapp.desktop", "Three") == 1);
00056        g_assert(usage_tracker_get_usage(tracker, "testapp.desktop", "Four") == 1);
00057 
00058        g_object_unref(tracker);
00059        return;
00060 }
00061 
00062 /* Build the test suite */
00063 static void
00064 test_usage_db_suite (void)
00065 {
00066        g_test_add_func ("/hud/usage/old/base",          test_usage_db_base);
00067        g_test_add_func ("/hud/usage/old/counts",        test_usage_db_counts);
00068        return;
00069 }
00070 
00071 gint
00072 main (gint argc, gchar * argv[])
00073 {
00074        //gtk_init(&argc, &argv);
00075        g_type_init();
00076 
00077        g_test_init(&argc, &argv, NULL);
00078 
00079        /* Test suites */
00080        test_usage_db_suite();
00081 
00082        return g_test_run ();
00083 }