1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
3
* Copyright (C) 2012 Richard Hughes <richard@hughsie.com>
5
* Licensed under the GNU General Public License Version 2
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.
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.
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.
26
#include <glib-object.h>
28
#include "hidpp-device.h"
31
main (int argc, char **argv)
33
// const gchar *model;
34
// guint batt_percentage;
36
// HidppDeviceBattStatus batt_status;
38
// HidppDeviceKind kind;
43
g_test_init (&argc, &argv, NULL);
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);
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,
62
g_assert_no_error (error);
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);
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));