Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / programs / dtterm / tests / Ciconic / Ciconic.c
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $XConsortium: Ciconic.c /main/3 1995/10/31 11:48:03 rswiston $ */
24 #include <stdio.h>
25 #include <math.h>
26 #include  "synvar.h"
27
28 #ifdef LOG
29 FILE *TermLog;
30 #define SAVELOG  fclose(TermLog); TermLog = fopen("term.log", "a");
31 #endif
32
33 char LogStr[200];
34
35
36 void TestIconify(WinName, String, TestNum)
37 char *WinName, *String;
38 int TestNum;
39 {
40   char Str[IMAGE_FILE_LEN];
41     sprintf(Str, "%siconic%d", IMAGE_DIR, TestNum);
42     MatchWindows(WinName, Str);
43     Deiconify(WinName); 
44     if (WaitWinMap(WinName) < 0) LogError("Deiconify did not work");
45     PrintTermString(WinName, String);
46     sprintf(Str, "%siconic%dA", IMAGE_DIR, TestNum);
47     MatchWindows(WinName, Str);
48     CloseTerm(WinName);
49 }
50
51 void TestIconifyMap(WinName, String, TestNum)
52 char *WinName, *String;
53 int TestNum;
54 {
55   char Str[IMAGE_FILE_LEN];
56     sprintf(Str, "%siconic%d", IMAGE_DIR, TestNum);
57     MatchWindows(WinName, Str);
58     if (TestNum == 3) {
59        if (WaitWinMap(WinName) < 0) LogError("Deiconify did not work");
60        PrintTermString(WinName, String);
61        sprintf(Str, "%siconic%dA", IMAGE_DIR, TestNum);
62        MatchWindows(WinName, Str);
63        PrintTermString(WinName, "1");
64        CloseTerm(WinName);
65     }
66     else {
67        if (WaitWinMap(WinName) == 0) LogError("+map  did not work");
68        else {
69          Deiconify(WinName); 
70          if (WaitWinMap(WinName) < 0) LogError("Deiconify did not work");
71          CloseTerm(WinName);
72        }
73     }
74 }
75
76 static char *OptionArr[] = {
77 /*0*/ " -iconic ",
78 /*1*/ " -iconic -xrm 'dtterm*iconName: test' ",
79 /*2*/ " -iconic -map -xrm 'dtterm*mapOnOutputDelay: 5' -e wait5write",
80 /*3*/ " -iconic +map -xrm 'dtterm*mapOnOutputDelay: 5' -e wait5write"
81 };
82
83 static char *LogAction[] = {
84 "Testing Option  -iconic ",
85 "Testing Option  -iconic -xrm 'dtterm*iconName: test' ",
86 "Testing Option  -iconic -map -xrm 'dtterm*mapOnOutputDelay: 5' -e wait5write",
87 "Testing Option  -iconic +map -xrm 'dtterm*mapOnOutputDelay: 5' -e wait5write"
88 };
89
90 #define ArrCount    (int) (sizeof(OptionArr) / sizeof(char *))
91
92 main(argc, argv)
93 int argc;
94 char *argv[];
95 {
96    SynStatus Result;
97    char Command[NEED_LEN];
98    int i;
99      
100 #ifdef LOG
101 if ((TermLog = fopen("term.log", "a")) == NULL) {
102    if ((TermLog = fopen("term.log", "w")) == NULL)
103       {printf("Logfile could not be opened \n"); exit(-1);}
104 }
105 LogError("****************************************************************************");
106 LogTime();
107 sprintf(Command, "TestName: <%s> STARTS\n", argv[0]);
108 LogError(Command);
109 #endif 
110      InitTest(argc, argv);
111      for (i=0; i < ArrCount; i++) {
112        strcpy(Command, TERM_EMU);  
113        strcat(Command, OptionArr[i]);
114        CheckCapsLock();
115        LogError(LogAction[i]);
116        ExecCommand(Command);
117        if (WaitWinMap("TermWin") < 0) continue;
118        AssignWinName("TermWin", TERM_EMU);
119        if (i <= 1) TestIconify("TermWin", OptionArr[i], i+1);
120        else TestIconifyMap("TermWin", OptionArr[i], i+1);
121        WaitWinUnMap("TermWin", 60L);
122      }
123      CloseTest(False);
124 #ifdef LOG
125 sprintf(Command, "TestName: <%s> ENDS\n", argv[0]);
126 LogError(Command);
127 LogError("****************************************************************************");
128 fclose(TermLog);
129 #endif
130 }
131