~ubuntu-branches/ubuntu/vivid/upower/vivid

« back to all changes in this revision

Viewing changes to .pc/00git_updates.patch/src/linux/hidpp-test.c

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2013-10-08 18:26:25 UTC
  • mfrom: (49.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20131008182625-roccyppydypnly0t
Tags: 0.9.22-1
* New upstream release.
* Drop 00git_updates.patch, included in new release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
2
 
 *
3
 
 * Copyright (C) 2012 Richard Hughes <richard@hughsie.com>
4
 
 *
5
 
 * Licensed under the GNU General Public License Version 2
6
 
 *
7
 
 * This program is free software; you can redistribute it and/or modify
8
 
 * it under the terms of the GNU General Public License as published by
9
 
 * the Free Software Foundation; either version 2 of the License, or
10
 
 * (at your option) any later version.
11
 
 *
12
 
 * This program is distributed in the hope that it will be useful,
13
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 
 * GNU General Public License for more details.
16
 
 *
17
 
 * You should have received a copy of the GNU General Public License
18
 
 * along with this program; if not, write to the Free Software
19
 
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
 
 */
21
 
 
22
 
 
23
 
#include "config.h"
24
 
 
25
 
#include <glib.h>
26
 
#include <glib-object.h>
27
 
 
28
 
#include "hidpp-device.h"
29
 
 
30
 
int
31
 
main (int argc, char **argv)
32
 
{
33
 
//      const gchar *model;
34
 
//      guint batt_percentage;
35
 
//      guint version;
36
 
//      HidppDeviceBattStatus batt_status;
37
 
        HidppDevice *d;
38
 
//      HidppDeviceKind kind;
39
 
        gboolean ret;
40
 
        GError *error = NULL;
41
 
 
42
 
        g_type_init ();
43
 
        g_test_init (&argc, &argv, NULL);
44
 
 
45
 
        d = hidpp_device_new ();
46
 
        hidpp_device_set_enable_debug (d, TRUE);
47
 
        g_assert_cmpint (hidpp_device_get_version (d), ==, 0);
48
 
        g_assert_cmpstr (hidpp_device_get_model (d), ==, NULL);
49
 
        g_assert_cmpint (hidpp_device_get_batt_percentage (d), ==, 0);
50
 
        g_assert_cmpint (hidpp_device_get_batt_status (d), ==, HIDPP_DEVICE_BATT_STATUS_UNKNOWN);
51
 
        g_assert_cmpint (hidpp_device_get_kind (d), ==, HIDPP_DEVICE_KIND_UNKNOWN);
52
 
 
53
 
        /* setup */
54
 
        hidpp_device_set_hidraw_device (d, "/dev/hidraw0");
55
 
        hidpp_device_set_index (d, 1);
56
 
        ret = hidpp_device_refresh (d,
57
 
                                    HIDPP_REFRESH_FLAGS_VERSION |
58
 
                                    HIDPP_REFRESH_FLAGS_KIND |
59
 
                                    HIDPP_REFRESH_FLAGS_BATTERY |
60
 
                                    HIDPP_REFRESH_FLAGS_MODEL,
61
 
                                    &error);
62
 
        g_assert_no_error (error);
63
 
        g_assert (ret);
64
 
 
65
 
        g_assert_cmpint (hidpp_device_get_version (d), !=, 0);
66
 
        g_assert_cmpstr (hidpp_device_get_model (d), !=, NULL);
67
 
        g_assert_cmpint (hidpp_device_get_batt_percentage (d), !=, 0);
68
 
        g_assert_cmpint (hidpp_device_get_batt_status (d), !=, HIDPP_DEVICE_BATT_STATUS_UNKNOWN);
69
 
        g_assert_cmpint (hidpp_device_get_kind (d), !=, HIDPP_DEVICE_KIND_UNKNOWN);
70
 
 
71
 
        g_print ("Version:\t\t%i\n", hidpp_device_get_version (d));
72
 
        g_print ("Kind:\t\t\t%i\n", hidpp_device_get_kind (d));
73
 
        g_print ("Model:\t\t\t%s\n", hidpp_device_get_model (d));
74
 
        g_print ("Battery Percentage:\t%i\n", hidpp_device_get_batt_percentage (d));
75
 
        g_print ("Battery Status:\t\t%i\n", hidpp_device_get_batt_status (d));
76
 
 
77
 
        g_object_unref (d);
78
 
        return 0;
79
 
}