aboutsummaryrefslogtreecommitdiff
path: root/tests/tc_banner_truncate.c
blob: a205289bebf92952abb0be409d376c3196b87f82 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/*
 * This file is a part of hildon tests
 *
 * Copyright (C) 2006, 2007 Nokia Corporation, all rights reserved.
 *
 * Author:  Luc Pionchon <luc.pionchon@nokia.com>
 * Contact: Michael Dominic Kostrzewa <michael.kostrzewa@nokia.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA
 *
 */

/*

 gcc `pkg-config --cflags gtk+-2.0 hildon-libs` `pkg-config --libs gtk+-2.0 hildon-libs`  \
     -o tc_banner_truncate tc_banner_truncate.c && DISPLAY=:2 run-standalone.sh  ./tc_banner_truncate 1

 Usage 1: tc_banner_truncate <case #>
 Usage 2: tc_banner_truncate <1|2|3> the string you like to be displayed
                              1 -> information banner
                              2 -> progress banner
                              3 -> animation banner
*/

#include <stdio.h>
#include <gtk/gtk.h>
#include <hildon-widgets/hildon-banner.h>

#define WAIT g_timeout_add(3000, (GSourceFunc)(gtk_main_quit), NULL);

#define TC_INFO(string) hildon_banner_show_information(window,  NULL, string); WAIT;
#define TC_ANIM(string) banner = hildon_banner_show_animation(NULL, NULL, string);
#define TC_PROG(string) banner = hildon_banner_show_progress (NULL, NULL, string);

static void get_argv_string(int argc, char ** argv, char *text);

int main(int argc, char **argv)
{
  GtkWidget *window;
  GtkWidget *banner;
  int n;
  char text[10000];

  if(argc <  2){ fprintf(stderr, "Add case # as parameter.\n");  return 1;}
  if(argc >= 2){ if(sscanf(argv[1], "%d", &n) == 0) n = 1;}
  if(argc >  2){ get_argv_string(argc, argv, text);}

  gtk_init(&argc, &argv);
  
  window = gtk_dialog_new();
  
  if(argc > 2){
    /* text is given in the command line */
    switch (n){
    case 1: TC_INFO(text); break;
    case 2: TC_PROG(text); break;
    case 3: TC_ANIM(text); break;
    default:TC_INFO(text); break;
    }
    n = -99999;
  }

  switch (n) {
  /* NOTE: comments (*) are given for 0.12.12, with default theme (orange)
   *       (*) "truncated", WRAPPED", etc.
   */

  case 0: TC_INFO(""); break;
  case 1: TC_INFO("loading..."); break;

  case 11: TC_INFO("mmmmmmmmmmmmmmmmmm m.."       ); break; //1 line
  case 12: TC_INFO("mmmmmmmmmmmmmmmmmm m..."      ); break; //truncated
  case 13: TC_INFO("mmmmmmmmmmmmmmmmmm m...."     ); break; //truncated
  case 14: TC_INFO("mmmmmmmmmmmmmmmmmm m....."    ); break; //truncated
  case 15: TC_INFO("mmmmmmmmmmmmmmmmmm m......"   ); break; //truncated
  case 16: TC_INFO("mmmmmmmmmmmmmmmmmm m......."  ); break; //truncated
  case 17: TC_INFO("mmmmmmmmmmmmmmmmmm m........" ); break; //truncated
  case 18: TC_INFO("mmmmmmmmmmmmmmmmmm m........."); break; //WRAPPED

  case 21: TC_INFO("maximum number of characters xxxxxxxx");  break; //WRAPPED
  case 22: TC_INFO("maximum number of characters xxxxxxxi");  break; //truncated

  case 23: TC_INFO("Maximum number of characters reache"   ); break; //1 line
  case 24: TC_INFO("Maximum number of characters reached"  ); break; //truncated
  case 25: TC_INFO("Maximum number of characters reached." ); break; //truncated
  case 26: TC_INFO("Maximum number of characters reached " ); break; //truncated
  case 27: TC_INFO("Maximum number of characters reached a"); break; //WRAPPED

  /* progress banners */
  case 101: TC_PROG(""               ); break;
  case 102: TC_PROG("hello"          ); break;
  case 103: TC_PROG("hello progress" ); break;

  /* Bugzilla related TC */
  case -1: case 25305: TC_INFO("Maximum number of characters reached");      break;
  case -2: case 23430: TC_INFO("Unable to manage folders during searching"); break; //PASSED
  case -3: case 26624: TC_ANIM("Connection Manager - Loading");              break;
  case -4: case 26161: TC_ANIM("Painel de Controle - carregando");           break;
  case -5: case 26203: TC_ANIM("Caricamento di Pannello di controllo");      break;
  case -6: case 27875: TC_ANIM("Instant messaging - loading");               break;
  case -7: case 28760: TC_ANIM("Teach Handwriting- Loading");                break;

  /* word longer than max width */
  case 201: TC_INFO("mmmmmmmmmmmmmmmmmmmmmmmmmmmmm 1 2 3 4");  break;

  /* misc */
  case 202: TC_INFO("Maximum number of characters reached osaidfh galds hgdslf helius grkdsz vfliesdfrjaesfrszri os o ozx oyli l ilij ero worjw aeowaijf osijf a jfaowijef aoweijf s faoij flsaijf sajfd oaijfe aosi e 1 2 3 4"); break; /* TRUNCATED after last 'e' */


  /* TC for plain GTK (no theme) */
  case -1031: TC_INFO("iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiil i."); break; //1 line
  case -1032: TC_INFO("iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiil i."); break; //WRAPPED

  case -1033: TC_INFO("mmmmmmmmmmmmmmmmmm m................................................i" ); break; //1 line
  case -1034: TC_INFO("mmmmmmmmmmmmmmmmmm m.................................................i"); break; //WRAPPED


  default:
    WAIT;
  }

  gtk_main();
  return 0;
}








/* ############################################################################## */
/* ############################################################################## */
/* ############################################################################## */

static void get_argv_string(int argc, char ** argv, char *text){
  int i,j;
  char * s;
  s = text;
  for(i=2; i<argc; i++){
    for(j=0; argv[i][j] != '\0'; j++){
      *s = argv[i][j];
      s++;
    }
    if(i<(argc-1)){
      *s=' ';
      s++;
    }
  }
  /* hem */
}