~ctf/unity-settings-daemon/bug1389099_mic_volume_icons

« back to all changes in this revision

Viewing changes to plugins/color/gcm-self-test.c

  • Committer: Package Import Robot
  • Author(s): Robert Ancell
  • Date: 2014-02-07 11:44:36 UTC
  • Revision ID: package-import@ubuntu.com-20140207114436-7t5u3yvwc4ul7w3e
Tags: upstream-14.04.0
ImportĀ upstreamĀ versionĀ 14.04.0

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) 2007-2011 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
#include "config.h"
 
23
 
 
24
#include <glib-object.h>
 
25
#include <stdlib.h>
 
26
#include <gtk/gtk.h>
 
27
 
 
28
#include "gcm-edid.h"
 
29
#include "gcm-dmi.h"
 
30
 
 
31
static void
 
32
gcm_test_dmi_func (void)
 
33
{
 
34
        GcmDmi *dmi;
 
35
 
 
36
        dmi = gcm_dmi_new ();
 
37
        g_assert (dmi != NULL);
 
38
        g_assert (gcm_dmi_get_name (dmi) != NULL);
 
39
        g_assert (gcm_dmi_get_vendor (dmi) != NULL);
 
40
        g_object_unref (dmi);
 
41
}
 
42
 
 
43
static void
 
44
gcm_test_edid_func (void)
 
45
{
 
46
        GcmEdid *edid;
 
47
        gchar *data;
 
48
        gboolean ret;
 
49
        GError *error = NULL;
 
50
        gsize length = 0;
 
51
 
 
52
        edid = gcm_edid_new ();
 
53
        g_assert (edid != NULL);
 
54
 
 
55
        /* LG 21" LCD panel */
 
56
        ret = g_file_get_contents (TESTDATADIR "/LG-L225W-External.bin",
 
57
                                   &data, &length, &error);
 
58
        g_assert_no_error (error);
 
59
        g_assert (ret);
 
60
        ret = gcm_edid_parse (edid, (const guint8 *) data, length, &error);
 
61
        g_assert_no_error (error);
 
62
        g_assert (ret);
 
63
 
 
64
        g_assert_cmpstr (gcm_edid_get_monitor_name (edid), ==, "L225W");
 
65
        g_assert_cmpstr (gcm_edid_get_vendor_name (edid), ==, "Goldstar Company Ltd");
 
66
        g_assert_cmpstr (gcm_edid_get_serial_number (edid), ==, "34398");
 
67
        g_assert_cmpstr (gcm_edid_get_eisa_id (edid), ==, NULL);
 
68
        g_assert_cmpstr (gcm_edid_get_checksum (edid), ==, "0bb44865bb29984a4bae620656c31368");
 
69
        g_assert_cmpstr (gcm_edid_get_pnp_id (edid), ==, "GSM");
 
70
        g_assert_cmpint (gcm_edid_get_height (edid), ==, 30);
 
71
        g_assert_cmpint (gcm_edid_get_width (edid), ==, 47);
 
72
        g_assert_cmpfloat (gcm_edid_get_gamma (edid), >=, 2.2f - 0.01);
 
73
        g_assert_cmpfloat (gcm_edid_get_gamma (edid), <, 2.2f + 0.01);
 
74
        g_free (data);
 
75
 
 
76
        /* Lenovo T61 internal Panel */
 
77
        ret = g_file_get_contents (TESTDATADIR "/Lenovo-T61-Internal.bin",
 
78
                                   &data, &length, &error);
 
79
        g_assert_no_error (error);
 
80
        g_assert (ret);
 
81
        ret = gcm_edid_parse (edid, (const guint8 *) data, length, &error);
 
82
        g_assert_no_error (error);
 
83
        g_assert (ret);
 
84
 
 
85
        g_assert_cmpstr (gcm_edid_get_monitor_name (edid), ==, NULL);
 
86
        g_assert_cmpstr (gcm_edid_get_vendor_name (edid), ==, "IBM France");
 
87
        g_assert_cmpstr (gcm_edid_get_serial_number (edid), ==, NULL);
 
88
        g_assert_cmpstr (gcm_edid_get_eisa_id (edid), ==, "LTN154P2-L05");
 
89
        g_assert_cmpstr (gcm_edid_get_checksum (edid), ==, "e1865128c7cd5e5ed49ecfc8102f6f9c");
 
90
        g_assert_cmpstr (gcm_edid_get_pnp_id (edid), ==, "IBM");
 
91
        g_assert_cmpint (gcm_edid_get_height (edid), ==, 21);
 
92
        g_assert_cmpint (gcm_edid_get_width (edid), ==, 33);
 
93
        g_assert_cmpfloat (gcm_edid_get_gamma (edid), >=, 2.2f - 0.01);
 
94
        g_assert_cmpfloat (gcm_edid_get_gamma (edid), <, 2.2f + 0.01);
 
95
        g_free (data);
 
96
 
 
97
        g_object_unref (edid);
 
98
}
 
99
 
 
100
int
 
101
main (int argc, char **argv)
 
102
{
 
103
        gtk_init (&argc, &argv);
 
104
        g_test_init (&argc, &argv, NULL);
 
105
 
 
106
        g_test_add_func ("/color/dmi", gcm_test_dmi_func);
 
107
        g_test_add_func ("/color/edid", gcm_test_edid_func);
 
108
 
 
109
        return g_test_run ();
 
110
}
 
111