Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / programs / dtterm / tests / Rwrap / Rwrap.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: Rwrap.c /main/3 1995/10/31 11:55:31 rswiston $ */
24 #include <stdio.h>
25 #include <math.h>
26 #include  "synvar.h"
27 #include  "common.h"
28
29 #ifdef LOG
30 FILE *TermLog;
31 #define SAVELOG  fclose(TermLog); TermLog = fopen("term.log", "a");
32 #endif
33
34 char LogStr[200];
35
36
37 #define BLANK    ' '
38
39 void TestWrap(WinName, String, TestNum)
40 char *WinName, *String;
41 int TestNum;
42 {
43   char Str[IMAGE_FILE_LEN];
44   int i;
45      PressKeyNtimes(WinName, "C", 100);
46      for (i=0; i < 75; i++) 
47        PressBackSpace(WinName);
48      sprintf(Str, "%srwrap%d", IMAGE_DIR, TestNum);
49      MatchWindows(WinName, Str);
50      CloseTerm(WinName);
51 }
52
53 static char *ResourceArr[] = {
54 /*0*/ "autoWrap True reverseWrap True ",
55 /*1*/ "autoWrap False reverseWrap False ",
56 /*2*/ "autoWrap True reverseWrap False "
57 };
58
59 static char *LogAction[] = {
60 "Testing Resource Option: autoWrap True reverseWrap True ",
61 "Testing Resource Option:autoWrap False reverseWrap False ",
62 "Testing Resource Option:autoWrap True reverseWrap False "
63 };
64
65 #define ArrCount    (int) (sizeof(ResourceArr) / sizeof(char *))
66
67 int MakeResourceFile(ResArr)
68 char *ResArr;
69 {
70   FILE *ResFile;
71   int i, j, Len;
72   char Resource[50], Value[50];
73     
74     if ((ResFile = fopen("res", "w")) == NULL)
75        {LogError("Resource File Creation fail"); return(-1);}
76     for (i=0; i < 50; i++) Resource[i] = BLANK;
77     for (i=0; i < 50; i++) Value[i] = BLANK;
78     Len = strlen(ResArr); i=0;
79     while (i < Len) {
80       j = 0;
81       while (ResArr[i] != BLANK) Resource[j++] = ResArr[i++];
82       Resource[j] = NULLCHAR;
83       i++; j = 0;
84       while ((ResArr[i] != BLANK) && (ResArr[i] != NULLCHAR))
85             Value[j++] = ResArr[i++];
86       Value[j] = NULLCHAR;
87       i++;
88       fprintf(ResFile, "%s*%s: %s\n", TERM_EMU, Resource, Value);
89     }
90     fclose(ResFile);
91 }
92
93 main(argc, argv)
94 int argc;
95 char *argv[];
96 {
97    SynStatus Result;
98    char Command[NEED_LEN];
99    int i;
100      
101 #ifdef LOG
102 if ((TermLog = fopen("term.log", "a")) == NULL) {
103    if ((TermLog = fopen("term.log", "w")) == NULL)
104       {printf("Logfile could not be opened \n"); exit(-1);}
105 }
106 fprintf(TermLog, "**************************************************\n");
107 LogTime();
108 fprintf(TermLog, "TestName: <%s> STARTS\n", argv[0]);
109 #endif 
110      InitTest(argc, argv);
111      for (i=0; i < ArrCount; i++) {
112        CheckCapsLock();
113        ExecCommand("xrdb -load xrdb.out");
114        MakeResourceFile(ResourceArr[i]);
115        LogError(LogAction[i]);
116        strcpy(Command, "xrdb -merge res; ");
117        strcat(Command, TERM_EMU);
118        CheckCapsLock();
119        ExecCommand(Command);
120        if (WaitWinMap("TermWin") < 0) continue;
121        AssignWinName("TermWin", TERM_EMU);
122        TestWrap("TermWin", "Checking Pointer Resources ", i+1);
123        WaitWinUnMap("TermWin", 60L);
124      }
125      CheckCapsLock();
126      ExecCommand("xrdb -load xrdb.out");
127      CloseTest(False);
128 #ifdef LOG
129 fprintf(TermLog, "TestName: <%s> ENDS\n", argv[0]);
130 fclose(TermLog);
131 #endif
132 }
133