Back to index

indicator-appmenu  12.10.0
test-usage-db-testapp.c
Go to the documentation of this file.
00001 /*
00002 Test code for usage DB based on testapp data
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 #include "shared-values.h"
00029 
00030 HudSettings hud_settings = {
00031   .store_usage_data = TRUE
00032 };
00033 
00034 static void
00035 test_usage_testapp (void)
00036 {
00037        UsageTracker * tracker = usage_tracker_new();
00038 
00039        g_assert(tracker != NULL);
00040        g_assert(IS_USAGE_TRACKER(tracker));
00041 
00042        g_assert(usage_tracker_get_usage(tracker, "/usr/share/applications/testapp.desktop", "Menu" DB_SEPARATOR "Item") == 7);
00043 
00044        g_object_unref(tracker);
00045        return;
00046 }
00047 
00048 static void
00049 test_usage_testapp_clip (void)
00050 {
00051        UsageTracker * tracker = usage_tracker_new();
00052 
00053        g_assert(tracker != NULL);
00054        g_assert(IS_USAGE_TRACKER(tracker));
00055 
00056        g_assert(usage_tracker_get_usage(tracker, "/usr/share/applications/testapp100.desktop", "Menu" DB_SEPARATOR "Item") == 30);
00057 
00058        g_object_unref(tracker);
00059        return;
00060 }
00061 
00062 /* Build the test suite */
00063 static void
00064 test_usage_testapp_suite (void)
00065 {
00066        g_test_add_func ("/hud/usage/testapp/basic",     test_usage_testapp);
00067        g_test_add_func ("/hud/usage/testapp/clip",      test_usage_testapp_clip);
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_testapp_suite();
00081 
00082        return g_test_run ();
00083 }