~ubuntu-branches/ubuntu/saucy/epiphany-browser/saucy

« back to all changes in this revision

Viewing changes to tests/ephy-encodings-test.c

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2012-10-02 20:30:38 UTC
  • mfrom: (1.6.14)
  • Revision ID: package-import@ubuntu.com-20121002203038-ijw6x1x3vgv6tyi5
Tags: 3.6.0-0ubuntu1
* New upstream release (LP: #1033909)
  - New overview with most visited sites as start page (LP: #343397)
* Rename gir1.2-epiphany-3.4 -> gir1.2-epiphany-3.6
* debian/control.in:
  - Bump minimum webkit and libsoup
  - Drop build-depends on gnome-doc-utils and seed
  - Build-depend on gcr and gnome-desktop3
* debian/rules:
  - Copy Debian fix to rename epiphany.desktop to
    epiphany-browser.desktop so that the shell recognizes it.
* debian/patches/00_epiphany-browser.patch: Refreshed
* debian/patches/14_pkglibdir.patch:
  - Dropped, applied in new version

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
2
/*
 
3
 * Copyright © 2012 - Igalia S.L.
 
4
 *
 
5
 * Epiphany is free software; you can redistribute it and/or modify
 
6
 * it under the terms of the GNU General Public License as published by
 
7
 * the Free Software Foundation; either version 2 of the License, or
 
8
 * (at your option) any later version.
 
9
 *
 
10
 * Epiphany is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 * GNU General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU General Public License
 
16
 * along with Epiphany; if not, write to the Free Software
 
17
 * Foundation, Inc., 51 Franklin St, Fifth Floor,
 
18
 * Boston, MA  02110-1301  USA
 
19
 */
 
20
 
 
21
#include "config.h"
 
22
 
 
23
#include "ephy-debug.h"
 
24
#include "ephy-embed-prefs.h"
 
25
#include "ephy-encodings.h"
 
26
#include "ephy-file-helpers.h"
 
27
#include "ephy-private.h"
 
28
#include "ephy-shell.h"
 
29
 
 
30
#include <gtk/gtk.h>
 
31
 
 
32
/* TODO: don't hardcode the number of encodings in ephy-encodings.c here! */
 
33
#define NUM_ENCODINGS 78
 
34
 
 
35
static void
 
36
test_ephy_encodings_create ()
 
37
{
 
38
  EphyEncoding *encoding;
 
39
 
 
40
  encoding = ephy_encoding_new ("UTF-8", "Unicode (UTF-8)",
 
41
                                LG_UNICODE);
 
42
  g_assert (encoding);
 
43
  g_assert_cmpstr (ephy_encoding_get_encoding (encoding), ==, "UTF-8");
 
44
  g_assert_cmpstr (ephy_encoding_get_title (encoding), ==, "Unicode (UTF-8)");
 
45
  g_assert_cmpstr (ephy_encoding_get_title_elided (encoding), ==, "Unicode (UTF-8)");
 
46
  g_assert_cmpstr (ephy_encoding_get_collation_key (encoding), ==, "Unicode (UTF-8)");
 
47
  g_assert_cmpint (ephy_encoding_get_language_groups (encoding), ==, LG_UNICODE);
 
48
 
 
49
  g_object_unref (encoding);
 
50
}
 
51
 
 
52
static void
 
53
test_ephy_encodings_get ()
 
54
{
 
55
  EphyEncodings *encodings;
 
56
  GList *all, *p;
 
57
 
 
58
  encodings = EPHY_ENCODINGS (ephy_embed_shell_get_encodings (embed_shell));
 
59
  g_assert (encodings);
 
60
 
 
61
  all = ephy_encodings_get_all (encodings);
 
62
  g_assert (all);
 
63
  g_assert_cmpint (g_list_length (all), ==, NUM_ENCODINGS);
 
64
 
 
65
  for (p = all; p; p = p->next) {
 
66
    EphyEncoding *encoding = EPHY_ENCODING (p->data);
 
67
    g_assert (encoding);
 
68
    g_assert (EPHY_IS_ENCODING (encoding));
 
69
  }
 
70
 
 
71
  g_list_free (all);
 
72
}
 
73
 
 
74
int
 
75
main (int argc, char *argv[])
 
76
{
 
77
  int ret;
 
78
 
 
79
  gtk_test_init (&argc, &argv);
 
80
 
 
81
  ephy_debug_init ();
 
82
  ephy_embed_prefs_init ();
 
83
 
 
84
  if (!ephy_file_helpers_init (NULL,
 
85
                               EPHY_FILE_HELPERS_PRIVATE_PROFILE | EPHY_FILE_HELPERS_ENSURE_EXISTS,
 
86
                               NULL)) {
 
87
    g_debug ("Something wrong happened with ephy_file_helpers_init()");
 
88
    return -1;
 
89
  }
 
90
 
 
91
  _ephy_shell_create_instance (EPHY_EMBED_SHELL_MODE_TEST);
 
92
  g_assert (ephy_shell);
 
93
 
 
94
  g_test_add_func ("/src/ephy-encodings/create",
 
95
                   test_ephy_encodings_create);
 
96
 
 
97
  g_test_add_func ("/src/ephy-encodings/get",
 
98
                   test_ephy_encodings_get);
 
99
 
 
100
  ret = g_test_run ();
 
101
 
 
102
  ephy_file_helpers_shutdown ();
 
103
  g_object_unref (ephy_shell);
 
104
 
 
105
  return ret;
 
106
}