mirror of
https://github.com/brl/mutter.git
synced 2024-11-08 23:16:20 -05:00
A preliminary attempt at a test for the theme expression tokeniser.
2008-06-10 Thomas Thurman <tthurman@gnome.org> * test/tokentest: A preliminary attempt at a test for the theme expression tokeniser. svn path=/trunk/; revision=3753
This commit is contained in:
parent
60d710a71f
commit
941e4bf967
@ -1,3 +1,8 @@
|
||||
2008-06-10 Thomas Thurman <tthurman@gnome.org>
|
||||
|
||||
* test/tokentest: A preliminary attempt at a test for the
|
||||
theme expression tokeniser.
|
||||
|
||||
2008-06-05 Thomas Thurman <tthurman@gnome.org>
|
||||
|
||||
* src/compositor/compositor-xrender.c (paint_root, destroy_win,
|
||||
|
@ -2549,6 +2549,13 @@ process_tab_grab (MetaDisplay *display,
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/* !! TO HERE !!
|
||||
* alt-f6 during alt-{Tab,Escape} does not end the grab
|
||||
* but does change the grab op (and redraws the window,
|
||||
* of course).
|
||||
* See _{SWITCH,CYCLE}_GROUP.@@@
|
||||
*/
|
||||
|
||||
popup_not_showing = FALSE;
|
||||
key_used = FALSE;
|
||||
|
7
test/tokentest/Makefile
Normal file
7
test/tokentest/Makefile
Normal file
@ -0,0 +1,7 @@
|
||||
# completely hacked-up makefile, proceed at your own risk, etc
|
||||
|
||||
default:
|
||||
@echo "Try 'make tp' or 'make glib'"
|
||||
|
||||
tp: tokentest.c
|
||||
gcc `pkg-config --cflags --libs glib-2.0 gdk-2.0 atk` -DMETACITY_DATADIR=\"/usr/share/metacity\" -I../.. -I../../src -I../../src/include tokentest.c ../../src/ui/theme.c ../../src/ui/gradient.c -o tp
|
19
test/tokentest/README
Normal file
19
test/tokentest/README
Normal file
@ -0,0 +1,19 @@
|
||||
Tokeniser test
|
||||
==============
|
||||
This directory contains a set of tools for checking the behaviour
|
||||
of the tokeniser for Metacity theme files.
|
||||
|
||||
tokentest.ini contains a list of all expressions retrieved from
|
||||
all theme files on art.gnome.org, and mappings to what the tokenising
|
||||
should be, in a separate representation. get-tokens.py produces the
|
||||
template version of this; it will produce a file with no expected
|
||||
values.
|
||||
|
||||
tokentest.c will either check that a tokeniser behaves according to
|
||||
tokentest.ini, or, if it finds a file, is empty it will print the
|
||||
values that the tokeniser it's using is producing.
|
||||
|
||||
The makefile is a hacky attempt at letting you compile either against
|
||||
Metacity's existing tokeniser or one which uses GLib's "scanner".
|
||||
|
||||
This code may or may not eventually end up in the automated test suite.
|
91
test/tokentest/get-tokens.py
Normal file
91
test/tokentest/get-tokens.py
Normal file
@ -0,0 +1,91 @@
|
||||
#!/usr/bin/python
|
||||
# Copyright (C) 2008 Thomas Thurman
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 2 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
# 02111-1307, USA.
|
||||
|
||||
|
||||
import os
|
||||
import xml.sax
|
||||
|
||||
standard = ['x', 'y', 'width', 'height']
|
||||
|
||||
expressions = {
|
||||
'line': ['x1', 'x2', 'y1', 'y2'],
|
||||
'rectangle': standard,
|
||||
'arc': standard,
|
||||
'clip': standard,
|
||||
'gradient': standard,
|
||||
'image': standard,
|
||||
'gtk_arrow': standard,
|
||||
'gtk_box': standard,
|
||||
'gtk_vline': standard,
|
||||
'icon': standard,
|
||||
'title': standard,
|
||||
'include': standard,
|
||||
'tile': ['x', 'y', 'width', 'height',
|
||||
'tile_xoffset', 'tile_yoffset',
|
||||
'tile_width', 'tile_height'],
|
||||
}
|
||||
|
||||
all_themes = '../../../all-themes/'
|
||||
|
||||
result = {}
|
||||
|
||||
class themeparser:
|
||||
def __init__(self, name):
|
||||
self.filename = name
|
||||
|
||||
def processingInstruction(self):
|
||||
pass
|
||||
|
||||
def characters(self, what):
|
||||
pass
|
||||
|
||||
def setDocumentLocator(self, where):
|
||||
pass
|
||||
|
||||
def startDocument(self):
|
||||
pass
|
||||
|
||||
def startElement(self, name, attrs):
|
||||
if expressions.has_key(name):
|
||||
for attr in expressions[name]:
|
||||
if attrs.has_key(attr):
|
||||
expression = attrs[attr]
|
||||
if not result.has_key(expression): result[expression] = {}
|
||||
result[expression][self.filename] = 1
|
||||
|
||||
def endElement(self, name):
|
||||
pass # print "end element"
|
||||
|
||||
def endDocument(self):
|
||||
pass
|
||||
|
||||
def maybe_parse(themename, filename):
|
||||
if os.access(all_themes+filename, os.F_OK):
|
||||
parser = themeparser(themename)
|
||||
xml.sax.parse(all_themes+filename, parser)
|
||||
|
||||
for theme in os.listdir(all_themes):
|
||||
maybe_parse(theme, theme+'/metacity-1/metacity-theme-1.xml')
|
||||
maybe_parse(theme, theme+'/metacity-theme-1.xml')
|
||||
|
||||
print '[tokentest0]'
|
||||
|
||||
for expr in sorted(result.keys()):
|
||||
print "# %s" % (', '.join(sorted(result[expr])))
|
||||
print "%s=REQ" % (expr)
|
||||
print
|
@ -24,16 +24,120 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <glib/gerror.h>
|
||||
#include <gtk/gtkobject.h>
|
||||
#include <gtk/gtkicontheme.h>
|
||||
#include <ui/theme.h>
|
||||
#include <util.h>
|
||||
|
||||
#define TOKENTEST_GROUP "tokentest0"
|
||||
|
||||
/************************/
|
||||
/* Dummy functions which are just here to keep the linker happy */
|
||||
|
||||
MetaTheme* meta_theme_load (const char *theme_name,
|
||||
GError **err) {
|
||||
// dummy
|
||||
/* dummy */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
meta_bug(const char *format, ...)
|
||||
{
|
||||
/* dummy */
|
||||
}
|
||||
|
||||
void
|
||||
meta_warning(const char *format, ...)
|
||||
{
|
||||
/* dummy */
|
||||
}
|
||||
|
||||
GType
|
||||
gtk_widget_get_type (void)
|
||||
{
|
||||
/* dummy */
|
||||
}
|
||||
|
||||
GtkType
|
||||
gtk_object_get_type (void)
|
||||
{
|
||||
/* dummy */
|
||||
}
|
||||
|
||||
void gtk_paint_arrow (GtkStyle *style,
|
||||
GdkWindow *window,
|
||||
GtkStateType state_type,
|
||||
GtkShadowType shadow_type,
|
||||
GdkRectangle *area,
|
||||
GtkWidget *widget,
|
||||
const gchar *detail,
|
||||
GtkArrowType arrow_type,
|
||||
gboolean fill,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
/* dummy */
|
||||
}
|
||||
|
||||
void gtk_paint_vline (GtkStyle *style,
|
||||
GdkWindow *window,
|
||||
GtkStateType state_type,
|
||||
GdkRectangle *area,
|
||||
GtkWidget *widget,
|
||||
const gchar *detail,
|
||||
gint y1_,
|
||||
gint y2_,
|
||||
gint x)
|
||||
{
|
||||
/* dummy */
|
||||
}
|
||||
void gtk_paint_box (GtkStyle *style,
|
||||
GdkWindow *window,
|
||||
GtkStateType state_type,
|
||||
GtkShadowType shadow_type,
|
||||
GdkRectangle *area,
|
||||
GtkWidget *widget,
|
||||
const gchar *detail,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
/* dummy */
|
||||
}
|
||||
|
||||
GtkIconTheme *gtk_icon_theme_get_default (void)
|
||||
{
|
||||
/* dummy */
|
||||
}
|
||||
|
||||
GdkPixbuf * gtk_icon_theme_load_icon (GtkIconTheme *icon_theme,
|
||||
const gchar *icon_name,
|
||||
gint size,
|
||||
GtkIconLookupFlags flags,
|
||||
GError **error)
|
||||
{
|
||||
/* dummy */
|
||||
}
|
||||
|
||||
MetaRectangle meta_rect (int x, int y, int width, int height)
|
||||
{
|
||||
/* dummy */
|
||||
}
|
||||
|
||||
void
|
||||
meta_topic_real (MetaDebugTopic topic,
|
||||
const char *format,
|
||||
...)
|
||||
{
|
||||
/* dummy */
|
||||
}
|
||||
|
||||
|
||||
/*********************************/
|
||||
|
||||
GString *draw_spec_to_string(MetaDrawSpec *spec)
|
||||
{
|
||||
GString *result;
|
||||
@ -133,11 +237,14 @@ load_keys ()
|
||||
GError* err = NULL;
|
||||
gchar** keys_of_file;
|
||||
gchar** cursor;
|
||||
gboolean ever_printed_header = FALSE;
|
||||
gint passes = 0, fails = 0;
|
||||
|
||||
keys = g_key_file_new ();
|
||||
|
||||
g_key_file_load_from_file (keys,
|
||||
"tokentest.ini",
|
||||
G_KEY_FILE_NONE,
|
||||
G_KEY_FILE_KEEP_COMMENTS,
|
||||
&err);
|
||||
|
||||
keys_of_file = g_key_file_get_keys (keys,
|
||||
@ -161,20 +268,35 @@ load_keys ()
|
||||
|
||||
str = draw_spec_to_string (spec);
|
||||
|
||||
if (strcmp (str->str, desideratum)==0) {
|
||||
if (strcmp ("REQ", desideratum)==0) {
|
||||
gchar *comment = g_key_file_get_comment (keys, TOKENTEST_GROUP, *cursor, &err);
|
||||
|
||||
if (!ever_printed_header) {
|
||||
g_print ("[%s]\n", TOKENTEST_GROUP);
|
||||
ever_printed_header = TRUE;
|
||||
}
|
||||
|
||||
g_print ("\n#%s%s=%s\n", comment? comment: "", *cursor, str->str);
|
||||
g_free (comment);
|
||||
} else if (strcmp (str->str, desideratum)==0) {
|
||||
g_print("PASS: %s\n", *cursor);
|
||||
passes++;
|
||||
} else {
|
||||
g_warning ("FAIL: %s, wanted %s, got %s\n",
|
||||
*cursor, desideratum, str->str);
|
||||
fails++;
|
||||
}
|
||||
|
||||
meta_theme_free (dummy);
|
||||
g_string_free (str, TRUE);
|
||||
g_free (desideratum);
|
||||
|
||||
cursor++;
|
||||
}
|
||||
|
||||
g_strfreev (keys_of_file);
|
||||
|
||||
g_print("\n# Passes: %d. Fails: %d.\n", passes, fails);
|
||||
}
|
||||
|
||||
int
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user