summaryrefslogtreecommitdiff
path: root/extensions
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2018-04-25 22:02:06 +0300
committerTor Lillqvist <tml@collabora.com>2018-05-31 15:46:25 +0300
commitf9365c47c2e77bb939ef712ee9cc8ba46f7d1931 (patch)
tree0f34b362a642cb9209a6659c34f7049d05d8d174 /extensions
parent0cae8eeaae08c9dc4ace44ee026af6f2b335c9c6 (diff)
Add a unit test for the Automation client services
Written in VBScript, yay. Change-Id: Ibbdba804939c2646aef8f8a2bb3781eaf1a6d208
Diffstat (limited to 'extensions')
-rw-r--r--extensions/CustomTarget_automationtest.mk24
-rw-r--r--extensions/Module_extensions.mk4
-rw-r--r--extensions/qa/ole/automationtest.vbs127
3 files changed, 155 insertions, 0 deletions
diff --git a/extensions/CustomTarget_automationtest.mk b/extensions/CustomTarget_automationtest.mk
new file mode 100644
index 000000000000..b1984d98d153
--- /dev/null
+++ b/extensions/CustomTarget_automationtest.mk
@@ -0,0 +1,24 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_CustomTarget_CustomTarget,extensions/automationtest))
+
+extensions_AUTOMATIONTESTDIR := $(call gb_CustomTarget_get_workdir,extensions/automationtest)
+
+extensions_AUTOMATIONTESTLOG := $(extensions_AUTOMATIONTESTDIR)/automationtest.log
+
+$(call gb_CustomTarget_get_target,extensions/automationtest) : \
+ $(SRCDIR)/extensions/qa/ole/automationtest.vbs \
+ | $(extensions_AUTOMATIONTESTDIR)/.dir
+ $(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),$(true),VBS,1) \
+ $(call gb_Helper_abbreviate_dirs, \
+ cscript -nologo $(SRCDIR)/extensions/qa/ole/automationtest.vbs $(SRCDIR)) >$(extensions_AUTOMATIONTESTLOG) || \
+ (cat $(extensions_AUTOMATIONTESTLOG) && exit 1)
+
+# vim:set shiftwidth=4 tabstop=4 noexpandtab:
diff --git a/extensions/Module_extensions.mk b/extensions/Module_extensions.mk
index 31512ff4045f..0e8dadafea47 100644
--- a/extensions/Module_extensions.mk
+++ b/extensions/Module_extensions.mk
@@ -74,6 +74,10 @@ $(eval $(call gb_Module_add_targets,extensions,\
Library_oleautobridge \
))
+$(eval $(call gb_Module_add_subsequentcheck_targets,extensions,\
+ CustomTarget_automationtest \
+))
+
endif # WNT
ifeq ($(OS),MACOSX)
diff --git a/extensions/qa/ole/automationtest.vbs b/extensions/qa/ole/automationtest.vbs
new file mode 100644
index 000000000000..efd4b8a60eda
--- /dev/null
+++ b/extensions/qa/ole/automationtest.vbs
@@ -0,0 +1,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