blob: efd4b8a60eda7bceb84b6fbbf27c4467ffd2e3df (
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
|
' -*- tab-width: 4; indent-tabs-mode: nil -*-
If WScript.Arguments.Count <> 1 Then
WScript.Echo "Pass $(SRCDIR) as parameter"
WScript.Quit(1)
End If
srcdir = WScript.Arguments.Item(0)
exitStatus = 0
testCounter = 0
okCounter = 0
Sub ExitWithReport
If okCounter <> testCounter Then
exitStatus = 1
End If
WScript.Echo "OK (" + CStr(okCounter) + ")"
WScript.Quit(exitstatus)
End Sub
Sub CheckFatal(expr)
testCounter = testCounter + 1
If Not Eval(expr) Then
WScript.Echo "FAIL: " & expr
ExitWithReport
Else
WScript.Echo "PASS: " & expr
okCounter = okCounter + 1
End If
End Sub
Sub Check(expr)
testCounter = testCounter + 1
If Not Eval(expr) Then
WScript.Echo "FAIL: " & expr
Else
WScript.Echo "PASS: " & expr
okCounter = okCounter + 1
End If
End Sub
Sub CheckIfExpected(expr, expected)
testCounter = testCounter + 1
actual = Eval(expr)
If actual <> expected Then
WScript.Echo "FAIL: Value of '" & expr & "' was expected to be '" & CStr(expected) & "', but was " & CStr(actual)
Else
WScript.Echo "PASS: " & expr & " == " & CStr(expected)
okCounter = okCounter + 1
End If
End Sub
Sub CheckErrorFatal(test)
testCounter = testCounter + 1
Execute(test)
If Err.Number <> 0 Then
WScript.Echo "FAIL: " & test
WScript.Echo "ERROR: " & Err.Description
ExitWithReport
Else
WScript.Echo "PASS: " & test
okCounter = okCounter + 1
End If
End Sub
Sub CheckError(test)
testCounter = testCounter + 1
Execute(test)
If Err.Number <> 0 Then
WScript.Echo "FAIL: " & test
WScript.Echo "ERROR: " & Err.Description
Else
WScript.Echo "PASS: " & test
okCounter = okCounter + 1
End If
End Sub
WScript.Echo "Running Automation client tests"
On Error Resume Next
CheckErrorFatal "Set writer = WScript.CreateObject(""Writer.Application"")"
CheckErrorFatal "writer.Visible = True"
CheckErrorFatal "writer.Caption = ""=== This is Writer ==="""
CheckErrorFatal "writer.ShowMe"
CheckErrorFatal "Set documents = writer.Documents"
' Open two randomly chosen documents
CheckErrorFatal "Set d1 = documents.Open(""" & srcdir & "/sw/qa/extras/ww8export/data/n325936.doc"")"
CheckErrorFatal "Set d2 = documents.Open(""" & srcdir & "/sw/qa/extras/ww8export/data/bnc636128.doc"")"
CheckErrorFatal "n1 = d1.FullName"
CheckErrorFatal "n2 = d2.FullName"
CheckIfExpected "n1", "n325936.doc"
CheckIfExpected "n2", "bnc636128.doc"
CheckErrorFatal "Set c1 = d1.Content"
CheckErrorFatal "Set c2 = d2.Content"
' The range of characters in these documents
CheckIfExpected "c1.Start", 0
CheckIfExpected "c1.End", 4
CheckIfExpected "c2.Start", 0
CheckIfExpected "c2.End", 42
' Check number of paragraphs in each document
CheckErrorFatal "Set p1 = d1.Paragraphs"
nparas = 0
For Each i in p1
nparas = nparas + 1
Next
CheckIfExpected "nparas", 1
CheckErrorFatal "Set p2 = d2.Paragraphs"
nparas = 0
For Each i in p2
nparas = nparas + 1
Next
CheckIfExpected "nparas", 1
CheckErrorFatal "writer.Quit"
ExitWithReport
|