summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ui/theme-viewer.c307
1 files changed, 0 insertions, 307 deletions
diff --git a/src/ui/theme-viewer.c b/src/ui/theme-viewer.c
index de4cc968..0553b3c0 100644
--- a/src/ui/theme-viewer.c
+++ b/src/ui/theme-viewer.c
@@ -63,10 +63,6 @@ static MetaTheme *global_theme = NULL;
static GtkWidget *previews[META_FRAME_TYPE_LAST*FONT_SIZE_LAST + BUTTON_LAYOUT_COMBINATIONS] = { NULL, };
static double milliseconds_to_draw_frame = 0.0;
-static void run_position_expression_tests (void);
-#if 0
-static void run_position_expression_timings (void);
-#endif
static void run_theme_benchmark (void);
@@ -788,11 +784,6 @@ main (int argc, char **argv)
textdomain(GETTEXT_PACKAGE);
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
- run_position_expression_tests ();
-#if 0
- run_position_expression_timings ();
-#endif
-
gtk_init (&argc, &argv);
if (g_getenv ("MARCO_DEBUG") != NULL)
@@ -1053,301 +1044,3 @@ run_theme_benchmark (void)
#undef ITERATIONS
}
-typedef struct
-{
- GdkRectangle rect;
- const char *expr;
- int expected_x;
- int expected_y;
- MetaThemeError expected_error;
-} PositionExpressionTest;
-
-#define NO_ERROR -1
-
-static const PositionExpressionTest position_expression_tests[] = {
- /* Just numbers */
- { { 10, 20, 40, 50 },
- "10", 20, 30, NO_ERROR },
- { { 10, 20, 40, 50 },
- "14.37", 24, 34, NO_ERROR },
- /* Binary expressions with 2 ints */
- { { 10, 20, 40, 50 },
- "14 * 10", 150, 160, NO_ERROR },
- { { 10, 20, 40, 50 },
- "14 + 10", 34, 44, NO_ERROR },
- { { 10, 20, 40, 50 },
- "14 - 10", 14, 24, NO_ERROR },
- { { 10, 20, 40, 50 },
- "8 / 2", 14, 24, NO_ERROR },
- { { 10, 20, 40, 50 },
- "8 % 3", 12, 22, NO_ERROR },
- /* Binary expressions with floats and mixed float/ints */
- { { 10, 20, 40, 50 },
- "7.0 / 3.5", 12, 22, NO_ERROR },
- { { 10, 20, 40, 50 },
- "12.1 / 3", 14, 24, NO_ERROR },
- { { 10, 20, 40, 50 },
- "12 / 2.95", 14, 24, NO_ERROR },
- /* Binary expressions without whitespace after first number */
- { { 10, 20, 40, 50 },
- "14* 10", 150, 160, NO_ERROR },
- { { 10, 20, 40, 50 },
- "14+ 10", 34, 44, NO_ERROR },
- { { 10, 20, 40, 50 },
- "14- 10", 14, 24, NO_ERROR },
- { { 10, 20, 40, 50 },
- "8/ 2", 14, 24, NO_ERROR },
- { { 10, 20, 40, 50 },
- "7.0/ 3.5", 12, 22, NO_ERROR },
- { { 10, 20, 40, 50 },
- "12.1/ 3", 14, 24, NO_ERROR },
- { { 10, 20, 40, 50 },
- "12/ 2.95", 14, 24, NO_ERROR },
- /* Binary expressions without whitespace before second number */
- { { 10, 20, 40, 50 },
- "14 *10", 150, 160, NO_ERROR },
- { { 10, 20, 40, 50 },
- "14 +10", 34, 44, NO_ERROR },
- { { 10, 20, 40, 50 },
- "14 -10", 14, 24, NO_ERROR },
- { { 10, 20, 40, 50 },
- "8 /2", 14, 24, NO_ERROR },
- { { 10, 20, 40, 50 },
- "7.0 /3.5", 12, 22, NO_ERROR },
- { { 10, 20, 40, 50 },
- "12.1 /3", 14, 24, NO_ERROR },
- { { 10, 20, 40, 50 },
- "12 /2.95", 14, 24, NO_ERROR },
- /* Binary expressions without any whitespace */
- { { 10, 20, 40, 50 },
- "14*10", 150, 160, NO_ERROR },
- { { 10, 20, 40, 50 },
- "14+10", 34, 44, NO_ERROR },
- { { 10, 20, 40, 50 },
- "14-10", 14, 24, NO_ERROR },
- { { 10, 20, 40, 50 },
- "8/2", 14, 24, NO_ERROR },
- { { 10, 20, 40, 50 },
- "7.0/3.5", 12, 22, NO_ERROR },
- { { 10, 20, 40, 50 },
- "12.1/3", 14, 24, NO_ERROR },
- { { 10, 20, 40, 50 },
- "12/2.95", 14, 24, NO_ERROR },
- /* Binary expressions with parentheses */
- { { 10, 20, 40, 50 },
- "(14) * (10)", 150, 160, NO_ERROR },
- { { 10, 20, 40, 50 },
- "(14) + (10)", 34, 44, NO_ERROR },
- { { 10, 20, 40, 50 },
- "(14) - (10)", 14, 24, NO_ERROR },
- { { 10, 20, 40, 50 },
- "(8) / (2)", 14, 24, NO_ERROR },
- { { 10, 20, 40, 50 },
- "(7.0) / (3.5)", 12, 22, NO_ERROR },
- { { 10, 20, 40, 50 },
- "(12.1) / (3)", 14, 24, NO_ERROR },
- { { 10, 20, 40, 50 },
- "(12) / (2.95)", 14, 24, NO_ERROR },
- /* Lots of extra parentheses */
- { { 10, 20, 40, 50 },
- "(((14)) * ((10)))", 150, 160, NO_ERROR },
- { { 10, 20, 40, 50 },
- "((((14)))) + ((((((((10))))))))", 34, 44, NO_ERROR },
- { { 10, 20, 40, 50 },
- "((((((((((14 - 10))))))))))", 14, 24, NO_ERROR },
- /* Binary expressions with variables */
- { { 10, 20, 40, 50 },
- "2 * width", 90, 100, NO_ERROR },
- { { 10, 20, 40, 50 },
- "2 * height", 110, 120, NO_ERROR },
- { { 10, 20, 40, 50 },
- "width - 10", 40, 50, NO_ERROR },
- { { 10, 20, 40, 50 },
- "height / 2", 35, 45, NO_ERROR },
- /* More than two operands */
- { { 10, 20, 40, 50 },
- "8 / 2 + 5", 19, 29, NO_ERROR },
- { { 10, 20, 40, 50 },
- "8 * 2 + 5", 31, 41, NO_ERROR },
- { { 10, 20, 40, 50 },
- "8 + 2 * 5", 28, 38, NO_ERROR },
- { { 10, 20, 40, 50 },
- "8 + 8 / 2", 22, 32, NO_ERROR },
- { { 10, 20, 40, 50 },
- "14 / (2 + 5)", 12, 22, NO_ERROR },
- { { 10, 20, 40, 50 },
- "8 * (2 + 5)", 66, 76, NO_ERROR },
- { { 10, 20, 40, 50 },
- "(8 + 2) * 5", 60, 70, NO_ERROR },
- { { 10, 20, 40, 50 },
- "(8 + 8) / 2", 18, 28, NO_ERROR },
- /* Errors */
- { { 10, 20, 40, 50 },
- "2 * foo", 0, 0, META_THEME_ERROR_UNKNOWN_VARIABLE },
- { { 10, 20, 40, 50 },
- "2 *", 0, 0, META_THEME_ERROR_FAILED },
- { { 10, 20, 40, 50 },
- "- width", 0, 0, META_THEME_ERROR_FAILED },
- { { 10, 20, 40, 50 },
- "5 % 1.0", 0, 0, META_THEME_ERROR_MOD_ON_FLOAT },
- { { 10, 20, 40, 50 },
- "1.0 % 5", 0, 0, META_THEME_ERROR_MOD_ON_FLOAT },
- { { 10, 20, 40, 50 },
- "! * 2", 0, 0, META_THEME_ERROR_BAD_CHARACTER },
- { { 10, 20, 40, 50 },
- " ", 0, 0, META_THEME_ERROR_FAILED },
- { { 10, 20, 40, 50 },
- "() () (( ) ()) ((()))", 0, 0, META_THEME_ERROR_FAILED },
- { { 10, 20, 40, 50 },
- "(*) () ((/) ()) ((()))", 0, 0, META_THEME_ERROR_FAILED },
- { { 10, 20, 40, 50 },
- "2 * 5 /", 0, 0, META_THEME_ERROR_FAILED },
- { { 10, 20, 40, 50 },
- "+ 2 * 5", 0, 0, META_THEME_ERROR_FAILED },
- { { 10, 20, 40, 50 },
- "+ 2 * 5", 0, 0, META_THEME_ERROR_FAILED }
-};
-
-static void
-run_position_expression_tests (void)
-{
-#if 0
- int i;
- MetaPositionExprEnv env;
-
- i = 0;
- while (i < (int) G_N_ELEMENTS (position_expression_tests))
- {
- GError *err;
- gboolean retval;
- const PositionExpressionTest *test;
- PosToken *tokens;
- int n_tokens;
- int x, y;
-
- test = &position_expression_tests[i];
-
- if (g_getenv ("META_PRINT_TESTS") != NULL)
- g_print ("Test expression: \"%s\" expecting x = %d y = %d",
- test->expr, test->expected_x, test->expected_y);
-
- err = NULL;
-
- env.rect = meta_rect (test->rect.x, test->rect.y,
- test->rect.width, test->rect.height);
- env.object_width = -1;
- env.object_height = -1;
- env.left_width = 0;
- env.right_width = 0;
- env.top_height = 0;
- env.bottom_height = 0;
- env.title_width = 5;
- env.title_height = 5;
- env.icon_width = 32;
- env.icon_height = 32;
- env.mini_icon_width = 16;
- env.mini_icon_height = 16;
- env.theme = NULL;
-
- if (err == NULL)
- {
- retval = meta_parse_position_expression (tokens, n_tokens,
- &env,
- &x, &y,
- &err);
- }
-
- if (retval && err)
- g_error (_("position expression test returned TRUE but set error"));
- if (!retval && err == NULL)
- g_error (_("position expression test returned FALSE but didn't set error"));
- if (((int) test->expected_error) != NO_ERROR)
- {
- if (err == NULL)
- g_error (_("Error was expected but none given"));
- if (err->code != (int) test->expected_error)
- g_error (_("Error %d was expected but %d given"),
- test->expected_error, err->code);
- }
- else
- {
- if (err)
- g_error (_("Error not expected but one was returned: %s"),
- err->message);
-
- if (x != test->expected_x)
- g_error (_("x value was %d, %d was expected"), x, test->expected_x);
-
- if (y != test->expected_y)
- g_error (_("y value was %d, %d was expected"), y, test->expected_y);
- }
-
- if (err)
- g_error_free (err);
-
- meta_pos_tokens_free (tokens, n_tokens);
- ++i;
- }
-#endif
-}
-
-#if 0
-static void
-run_position_expression_timings (void)
-{
- int i;
- int iters;
- clock_t start;
- clock_t end;
- MetaPositionExprEnv env;
-
-#define ITERATIONS 100000
-
- start = clock ();
-
- iters = 0;
- i = 0;
- while (iters < ITERATIONS)
- {
- const PositionExpressionTest *test;
- int x, y;
-
- test = &position_expression_tests[i];
-
- env.x = test->rect.x;
- env.y = test->rect.y;
- env.width = test->rect.width;
- env.height = test->rect.height;
- env.object_width = -1;
- env.object_height = -1;
- env.left_width = 0;
- env.right_width = 0;
- env.top_height = 0;
- env.bottom_height = 0;
- env.title_width = 5;
- env.title_height = 5;
- env.icon_width = 32;
- env.icon_height = 32;
- env.mini_icon_width = 16;
- env.mini_icon_height = 16;
- env.theme = NULL;
-
- meta_parse_position_expression (test->expr,
- &env,
- &x, &y, NULL);
-
- ++iters;
- ++i;
- if (i == G_N_ELEMENTS (position_expression_tests))
- i = 0;
- }
-
- end = clock ();
-
- g_print (_("%d coordinate expressions parsed in %g seconds (%g seconds average)\n"),
- ITERATIONS,
- ((double)end - (double)start) / CLOCKS_PER_SEC,
- ((double)end - (double)start) / CLOCKS_PER_SEC / (double) ITERATIONS);
-
-}
-#endif