Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'terminal/org.eclipse.tm.terminal.test')
-rw-r--r--terminal/org.eclipse.tm.terminal.test/.classpath7
-rw-r--r--terminal/org.eclipse.tm.terminal.test/.cvsignore1
-rw-r--r--terminal/org.eclipse.tm.terminal.test/.project28
-rw-r--r--terminal/org.eclipse.tm.terminal.test/.settings/org.eclipse.jdt.core.prefs83
-rw-r--r--terminal/org.eclipse.tm.terminal.test/META-INF/MANIFEST.MF22
-rw-r--r--terminal/org.eclipse.tm.terminal.test/about.html28
-rw-r--r--terminal/org.eclipse.tm.terminal.test/about.ini27
-rw-r--r--terminal/org.eclipse.tm.terminal.test/about.mappings6
-rw-r--r--terminal/org.eclipse.tm.terminal.test/about.properties25
-rw-r--r--terminal/org.eclipse.tm.terminal.test/build.properties28
-rw-r--r--terminal/org.eclipse.tm.terminal.test/eclipse32.pngbin4594 -> 0 bytes
-rw-r--r--terminal/org.eclipse.tm.terminal.test/plugin.properties17
-rw-r--r--terminal/org.eclipse.tm.terminal.test/plugin.xml21
-rw-r--r--terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/connector/TerminalConnectorFactoryTest.java266
-rw-r--r--terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/connector/TerminalConnectorPluginTest.java59
-rw-r--r--terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/connector/TerminalConnectorTest.java236
-rw-r--r--terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/connector/TerminalToRemoteInjectionOutputStreamTest.java175
-rw-r--r--terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/emulator/AllTests.java36
-rw-r--r--terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/emulator/VT100EmulatorBackendTest.java1237
-rw-r--r--terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/AbstractITerminalTextDataTest.java817
-rw-r--r--terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/AllTests.java45
-rw-r--r--terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/SnapshotChangesTest.java679
-rw-r--r--terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/SynchronizedTerminalTextDataTest.java20
-rw-r--r--terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataFastScrollTest.java20
-rw-r--r--terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataFastScrollTestMaxHeigth.java20
-rw-r--r--terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataPerformanceTest.java224
-rw-r--r--terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataSnapshotTest.java1344
-rw-r--r--terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataSnapshotWindowTest.java191
-rw-r--r--terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataStoreTest.java20
-rw-r--r--terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataTest.java20
-rw-r--r--terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataWindowTest.java481
-rw-r--r--terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/TerminalTextTestHelper.java108
-rw-r--r--terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/speedtest/SpeedTestConnection.java116
-rw-r--r--terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/speedtest/SpeedTestConnector.java104
-rw-r--r--terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/speedtest/SpeedTestSettings.java62
-rw-r--r--terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/speedtest/SpeedTestSettingsPage.java68
-rw-r--r--terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/terminalcanvas/Main.java36
-rw-r--r--terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/terminalcanvas/Snippet48.java110
-rw-r--r--terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/terminalcanvas/TerminalTextCanvas.java103
-rw-r--r--terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/terminalcanvas/VirtualCanvas.java333
-rw-r--r--terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/ui/AbstractLineOrientedDataSource.java42
-rw-r--r--terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/ui/DataReader.java87
-rw-r--r--terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/ui/FastDataSource.java35
-rw-r--r--terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/ui/FileDataSource.java72
-rw-r--r--terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/ui/IDataSource.java21
-rw-r--r--terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/ui/IStatus.java15
-rw-r--r--terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/ui/LineCountingDataSource.java43
-rw-r--r--terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/ui/RandomDataSource.java49
-rw-r--r--terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/ui/TerminalTextUITest.java253
-rw-r--r--terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/ui/VT100DataSource.java127
-rw-r--r--terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/textcanvas/PipedInputStreamPerformanceTest.java32
-rw-r--r--terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/textcanvas/PipedStreamTest.java113
-rw-r--r--terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/terminal/model/AllTests.java37
-rw-r--r--terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/terminal/model/StyleColorTest.java36
-rw-r--r--terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/terminal/model/StyleTest.java116
-rw-r--r--terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/terminal/test/AutomatedPluginTests.java31
-rw-r--r--terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/terminal/test/AutomatedTests.java42
-rw-r--r--terminal/org.eclipse.tm.terminal.test/teamConfig/Terminal All Unit Tests.launch16
-rw-r--r--terminal/org.eclipse.tm.terminal.test/teamConfig/Terminal Plugin Tests.launch39
-rw-r--r--terminal/org.eclipse.tm.terminal.test/test.xml91
60 files changed, 0 insertions, 8520 deletions
diff --git a/terminal/org.eclipse.tm.terminal.test/.classpath b/terminal/org.eclipse.tm.terminal.test/.classpath
deleted file mode 100644
index 7cdeb7319..000000000
--- a/terminal/org.eclipse.tm.terminal.test/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/CDC-1.1%Foundation-1.1"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/terminal/org.eclipse.tm.terminal.test/.cvsignore b/terminal/org.eclipse.tm.terminal.test/.cvsignore
deleted file mode 100644
index ba077a403..000000000
--- a/terminal/org.eclipse.tm.terminal.test/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
diff --git a/terminal/org.eclipse.tm.terminal.test/.project b/terminal/org.eclipse.tm.terminal.test/.project
deleted file mode 100644
index 492f603b4..000000000
--- a/terminal/org.eclipse.tm.terminal.test/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.tm.terminal.test</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/terminal/org.eclipse.tm.terminal.test/.settings/org.eclipse.jdt.core.prefs b/terminal/org.eclipse.tm.terminal.test/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index ac884dbd2..000000000
--- a/terminal/org.eclipse.tm.terminal.test/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,83 +0,0 @@
-#Fri Apr 11 20:49:09 CEST 2008
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.4
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.4
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.doc.comment.support=enabled
-org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.autoboxing=warning
-org.eclipse.jdt.core.compiler.problem.deprecation=warning
-org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=enabled
-org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled
-org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
-org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
-org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
-org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
-org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
-org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
-org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
-org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
-org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
-org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
-org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning
-org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning
-org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled
-org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled
-org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=disabled
-org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=protected
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
-org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore
-org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=enabled
-org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
-org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=no_tag
-org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore
-org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
-org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
-org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
-org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
-org.eclipse.jdt.core.compiler.problem.nullReference=warning
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=error
-org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
-org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
-org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
-org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
-org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
-org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.unusedImport=warning
-org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
-org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
-org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
-org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
-org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.4
diff --git a/terminal/org.eclipse.tm.terminal.test/META-INF/MANIFEST.MF b/terminal/org.eclipse.tm.terminal.test/META-INF/MANIFEST.MF
deleted file mode 100644
index 79e6d013c..000000000
--- a/terminal/org.eclipse.tm.terminal.test/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,22 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %pluginName
-Bundle-SymbolicName: org.eclipse.tm.terminal.test;singleton:=true
-Bundle-Version: 2.0.0.qualifier
-Bundle-Vendor: %providerName
-Bundle-Localization: plugin
-Require-Bundle: org.junit,
- org.eclipse.tm.terminal,
- org.eclipse.core.runtime,
- org.eclipse.ui
-Bundle-RequiredExecutionEnvironment: CDC-1.1/Foundation-1.1,
- J2SE-1.4
-Export-Package: org.eclipse.tm.internal.terminal.connector;x-internal:=true,
- org.eclipse.tm.internal.terminal.emulator;x-internal:=true,
- org.eclipse.tm.internal.terminal.model;x-internal:=true,
- org.eclipse.tm.internal.terminal.speedtest;x-internal:=true,
- org.eclipse.tm.internal.terminal.test.terminalcanvas;x-internal:=true,
- org.eclipse.tm.internal.terminal.test.ui;x-internal:=true,
- org.eclipse.tm.internal.terminal.textcanvas;x-internal:=true,
- org.eclipse.tm.terminal.model,
- org.eclipse.tm.terminal.test
diff --git a/terminal/org.eclipse.tm.terminal.test/about.html b/terminal/org.eclipse.tm.terminal.test/about.html
deleted file mode 100644
index d4cc693f9..000000000
--- a/terminal/org.eclipse.tm.terminal.test/about.html
+++ /dev/null
@@ -1,28 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
-<title>About</title>
-</head>
-<body lang="EN-US">
-<h2>About This Content</h2>
-
-<p>June 5, 2007</p>
-<h3>License</h3>
-
-<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
-indicated below, the Content is provided to you under the terms and conditions of the
-Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
-at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
-For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
-
-<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
-being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
-apply to your use of any object code in the Content. Check the Redistributor's license that was
-provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
-indicated below, the terms and conditions of the EPL still apply to any source code in the Content
-and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
-
-</body>
-</html> \ No newline at end of file
diff --git a/terminal/org.eclipse.tm.terminal.test/about.ini b/terminal/org.eclipse.tm.terminal.test/about.ini
deleted file mode 100644
index fdd61ff0d..000000000
--- a/terminal/org.eclipse.tm.terminal.test/about.ini
+++ /dev/null
@@ -1,27 +0,0 @@
-# about.ini
-# contains information about a feature
-# java.io.Properties file (ISO 8859-1 with "\" escapes)
-# "%key" are externalized strings defined in about.properties
-# This file does not need to be translated.
-
-# Property "aboutText" contains blurb for "About" dialog (translated)
-aboutText=%blurb
-
-# Property "windowImage" contains path to window icon (16x16)
-# needed for primary features only
-
-# Property "featureImage" contains path to feature image (32x32)
-featureImage=eclipse32.png
-
-# Property "aboutImage" contains path to product image (500x330 or 115x164)
-# needed for primary features only
-
-# Property "appName" contains name of the application (not translated)
-# needed for primary features only
-
-# Property "welcomePage" contains path to welcome page (special XML-based format)
-# optional
-
-# Property "welcomePerspective" contains the id of the perspective in which the
-# welcome page is to be opened.
-# optional \ No newline at end of file
diff --git a/terminal/org.eclipse.tm.terminal.test/about.mappings b/terminal/org.eclipse.tm.terminal.test/about.mappings
deleted file mode 100644
index bddaab431..000000000
--- a/terminal/org.eclipse.tm.terminal.test/about.mappings
+++ /dev/null
@@ -1,6 +0,0 @@
-# about.mappings
-# contains fill-ins for about.properties
-# java.io.Properties file (ISO 8859-1 with "\" escapes)
-# This file does not need to be translated.
-
-0=@build@ \ No newline at end of file
diff --git a/terminal/org.eclipse.tm.terminal.test/about.properties b/terminal/org.eclipse.tm.terminal.test/about.properties
deleted file mode 100644
index 99ddff5ef..000000000
--- a/terminal/org.eclipse.tm.terminal.test/about.properties
+++ /dev/null
@@ -1,25 +0,0 @@
-###############################################################################
-# Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-# about.properties
-# contains externalized strings for about.ini
-# java.io.Properties file (ISO 8859-1 with "\" escapes)
-# fill-ins are supplied by about.mappings
-# This file should be translated.
-#
-# Do not translate any values surrounded by {}
-
-blurb=TM Terminal Unit Tests\n\
-\n\
-Version: {featureVersion}\n\
-Build id: {0}\n\
-\n\
-(c) Copyright Wind River Systems, Inc. and others 2007, 2008. All rights reserved.\n\
-Visit http://www.eclipse.org/dsdp/tm
diff --git a/terminal/org.eclipse.tm.terminal.test/build.properties b/terminal/org.eclipse.tm.terminal.test/build.properties
deleted file mode 100644
index 5a4e9b9d3..000000000
--- a/terminal/org.eclipse.tm.terminal.test/build.properties
+++ /dev/null
@@ -1,28 +0,0 @@
-###############################################################################
-# Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Michael Scharf (Wind River) - initial API and implementation
-###############################################################################
-source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
- .,\
- plugin.properties,\
- plugin.xml,\
- about.properties,\
- about.mappings,\
- about.ini,\
- eclipse32.png,\
- test.xml,\
- about.html
-javacSource=1.4
-javacTarget=1.4
-src.includes = .settings/,\
- build.properties,\
- teamConfig/,\
- about.html
diff --git a/terminal/org.eclipse.tm.terminal.test/eclipse32.png b/terminal/org.eclipse.tm.terminal.test/eclipse32.png
deleted file mode 100644
index 568fac1d0..000000000
--- a/terminal/org.eclipse.tm.terminal.test/eclipse32.png
+++ /dev/null
Binary files differ
diff --git a/terminal/org.eclipse.tm.terminal.test/plugin.properties b/terminal/org.eclipse.tm.terminal.test/plugin.properties
deleted file mode 100644
index f7fa5add1..000000000
--- a/terminal/org.eclipse.tm.terminal.test/plugin.properties
+++ /dev/null
@@ -1,17 +0,0 @@
-###############################################################################
-# Copyright (c) 2007 Wind River Systems, Inc. and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Initial Contributors:
-# The following Wind River employees contributed to the Terminal component
-# that contains this file: Chris Thew, Fran Litterio, Stephen Lamb,
-# Helmut Haigermoser and Ted Williams.
-#
-# Contributors:
-# Michael Scharf (Wind River) - initial API and implementation
-###############################################################################
-pluginName = Target Management Terminal Tests
-providerName = Eclipse.org
diff --git a/terminal/org.eclipse.tm.terminal.test/plugin.xml b/terminal/org.eclipse.tm.terminal.test/plugin.xml
deleted file mode 100644
index a6fe6ae01..000000000
--- a/terminal/org.eclipse.tm.terminal.test/plugin.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.2"?>
-<!--
-# Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Michael Scharf (Wind River) - initial API and implementation
-# Martin Oberhuber (Wind River) - fixed copyright headers and beautified
--->
-<plugin>
- <extension
- point="org.eclipse.tm.terminal.terminalConnectors">
- <connector name="Speed Test"
- id="org.eclipse.tm.internal.terminal.speedtest.SpeedTestConnector"
- class="org.eclipse.tm.internal.terminal.speedtest.SpeedTestConnector"/>
- </extension>
-</plugin>
diff --git a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/connector/TerminalConnectorFactoryTest.java b/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/connector/TerminalConnectorFactoryTest.java
deleted file mode 100644
index fac78d377..000000000
--- a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/connector/TerminalConnectorFactoryTest.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Michael Scharf (Wind River) - initial API and implementation
- * Martin Oberhuber (Wind River) - [225853][api] Provide more default functionality in TerminalConnectorImpl
- * Martin Oberhuber (Wind River) - [204796] Terminal should allow setting the encoding to use
- *******************************************************************************/
-package org.eclipse.tm.internal.terminal.connector;
-
-import java.io.OutputStream;
-
-import junit.framework.TestCase;
-
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.tm.internal.terminal.provisional.api.ISettingsPage;
-import org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore;
-import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl;
-import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
-import org.eclipse.tm.internal.terminal.provisional.api.provider.TerminalConnectorImpl;
-
-public class TerminalConnectorFactoryTest extends TestCase {
- public class SettingsMock implements ISettingsStore {
-
- public String get(String key) {
- return null;
- }
-
- public String get(String key, String defaultValue) {
- return null;
- }
-
- public void put(String key, String value) {
- }
-
- }
- public static class TerminalControlMock implements ITerminalControl {
-
- public void setEncoding(String encoding) {
- }
-
- public String getEncoding() {
- return "ISO-8859-1"; //$NON-NLS-1$
- }
-
- public void displayTextInTerminal(String text) {
- }
-
- public OutputStream getRemoteToTerminalOutputStream() {
- return null;
- }
-
- public Shell getShell() {
- return null;
- }
-
- public TerminalState getState() {
- return null;
- }
-
- public void setMsg(String msg) {
- }
-
- public void setState(TerminalState state) {
- }
-
- public void setTerminalTitle(String title) {
- }
-
- }
- static class ConnectorMock extends TerminalConnectorImpl {
-
- public boolean fEcho;
- public int fWidth;
- public int fHeight;
- public ITerminalControl fControl;
- public ISettingsStore fSaveStore;
- public ISettingsStore fLoadStore;
- public boolean fDisconnect;
-
- public boolean isLocalEcho() {
- return fEcho;
- }
- public void setTerminalSize(int newWidth, int newHeight) {
- fWidth=newWidth;
- fHeight=newHeight;
- }
- public void connect(ITerminalControl control) {
- super.connect(control);
- fControl = control;
- }
- public void doDisconnect() {
- fDisconnect=true;
- }
-
- public OutputStream getTerminalToRemoteStream() {
- return null;
- }
-
- public String getSettingsSummary() {
- return "Summary";
- }
-
- public void load(ISettingsStore store) {
- fLoadStore=store;
- }
-
- public ISettingsPage makeSettingsPage() {
- return new ISettingsPage(){
- public void createControl(Composite parent) {
- }
- public void loadSettings() {
- }
- public void saveSettings() {
- }
- public boolean validateSettings() {
- return false;
- }};
- }
-
- public void save(ISettingsStore store) {
- fSaveStore=store;
- }
- }
- protected TerminalConnector makeTerminalConnector() {
- return makeTerminalConnector(new ConnectorMock());
- }
-
- protected TerminalConnector makeTerminalConnector(final TerminalConnectorImpl mock) {
- TerminalConnector c=new TerminalConnector(new TerminalConnector.Factory(){
- public TerminalConnectorImpl makeConnector() throws Exception {
- return mock;
- }
- },"xID","xName");
- return c;
- }
-
- public void testGetInitializationErrorMessage() {
- TerminalConnector c=makeTerminalConnector();
- c.connect(new TerminalControlMock());
- assertNull(c.getInitializationErrorMessage());
-
- c=makeTerminalConnector(new ConnectorMock(){
- public void initialize() throws Exception {
- throw new Exception("FAILED");
- }});
- c.connect(new TerminalControlMock());
- assertEquals("FAILED",c.getInitializationErrorMessage());
-
- }
-
- public void testGetIdAndName() {
- TerminalConnector c=makeTerminalConnector();
- assertEquals("xID", c.getId());
- assertEquals("xName", c.getName());
- }
-
- public void testIsInitialized() {
- TerminalConnector c=makeTerminalConnector();
- assertFalse(c.isInitialized());
- c.getId();
- assertFalse(c.isInitialized());
- c.getName();
- assertFalse(c.isInitialized());
- c.getSettingsSummary();
- assertFalse(c.isInitialized());
- c.setTerminalSize(10,10);
- assertFalse(c.isInitialized());
- c.load(null);
- assertFalse(c.isInitialized());
- c.save(null);
- assertFalse(c.isInitialized());
- c.getAdapter(ConnectorMock.class);
- assertFalse(c.isInitialized());
- }
-
- public void testConnect() {
- TerminalConnector c=makeTerminalConnector();
- assertFalse(c.isInitialized());
- c.connect(new TerminalControlMock());
- assertTrue(c.isInitialized());
-
- }
-
- public void testDisconnect() {
- ConnectorMock mock=new ConnectorMock();
- TerminalConnector c = makeTerminalConnector(mock);
- TerminalControlMock control=new TerminalControlMock();
- c.connect(control);
- c.disconnect();
- assertTrue(mock.fDisconnect);
- }
-
- public void testGetTerminalToRemoteStream() {
- ConnectorMock mock=new ConnectorMock();
- TerminalConnector c = makeTerminalConnector(mock);
- TerminalControlMock control=new TerminalControlMock();
- c.connect(control);
- assertSame(mock.fControl,control);
- }
- public void testGetSettingsSummary() {
- TerminalConnector c=makeTerminalConnector();
- assertEquals("Not Initialized", c.getSettingsSummary());
- c.connect(new TerminalControlMock());
- assertEquals("Summary", c.getSettingsSummary());
- }
-
- public void testIsLocalEcho() {
- ConnectorMock mock=new ConnectorMock();
- TerminalConnector c = makeTerminalConnector(mock);
- assertFalse(c.isLocalEcho());
- mock.fEcho=true;
- assertTrue(c.isLocalEcho());
- }
-
- public void testLoad() {
- ConnectorMock mock=new ConnectorMock();
- TerminalConnector c = makeTerminalConnector(mock);
- ISettingsStore s=new SettingsMock();
- c.load(s);
- // the load is called after the connect...
- assertNull(mock.fLoadStore);
- c.connect(new TerminalControlMock());
- assertSame(s,mock.fLoadStore);
- }
-
- public void testSave() {
- ConnectorMock mock=new ConnectorMock();
- TerminalConnector c = makeTerminalConnector(mock);
- ISettingsStore s=new SettingsMock();
- c.save(s);
- assertNull(mock.fSaveStore);
- c.connect(new TerminalControlMock());
- c.save(s);
- assertSame(s,mock.fSaveStore);
- }
-
- public void testMakeSettingsPage() {
- ConnectorMock mock=new ConnectorMock();
- TerminalConnector c = makeTerminalConnector(mock);
- assertNotNull(c.makeSettingsPage());
- }
-
- public void testSetTerminalSize() {
- ConnectorMock mock=new ConnectorMock();
- TerminalConnector c = makeTerminalConnector(mock);
- c.setTerminalSize(100, 200);
-
- }
-
- public void testGetAdapter() {
- ConnectorMock mock=new ConnectorMock();
- TerminalConnector c = makeTerminalConnector(mock);
- assertNull(c.getAdapter(ConnectorMock.class));
- // the load is called after the connect...
- c.connect(new TerminalControlMock());
-
- assertSame(mock, c.getAdapter(ConnectorMock.class));
- }
-
-}
diff --git a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/connector/TerminalConnectorPluginTest.java b/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/connector/TerminalConnectorPluginTest.java
deleted file mode 100644
index cc0c9ee3a..000000000
--- a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/connector/TerminalConnectorPluginTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.tm.internal.terminal.connector;
-
-import junit.framework.TestCase;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.tm.internal.terminal.connector.TerminalConnectorTest.ConnectorMock;
-import org.eclipse.tm.internal.terminal.connector.TerminalConnectorTest.SimpleFactory;
-import org.eclipse.tm.internal.terminal.connector.TerminalConnectorTest.TerminalControlMock;
-
-/**
- * Testcase for TerminalConnector that must run as a JUnit plug-in test.
- */
-public class TerminalConnectorPluginTest extends TestCase {
-
- public void testIsInitialized() {
- if (!Platform.isRunning())
- return;
- TerminalConnector c = new TerminalConnector(new SimpleFactory(new ConnectorMock()), "xID", "xName");
- assertFalse(c.isInitialized());
- c.getId();
- assertFalse(c.isInitialized());
- c.getName();
- assertFalse(c.isInitialized());
- c.getSettingsSummary();
- assertFalse(c.isInitialized());
- c.setTerminalSize(10, 10);
- assertFalse(c.isInitialized());
- c.load(null);
- assertFalse(c.isInitialized());
- c.save(null);
- assertFalse(c.isInitialized());
- c.getAdapter(ConnectorMock.class);
- assertFalse(c.isInitialized());
- }
-
- public void testGetAdapter() {
- if (!Platform.isRunning())
- return;
- ConnectorMock mock = new ConnectorMock();
- TerminalConnector c = new TerminalConnector(new SimpleFactory(mock), "xID", "xName");
- assertNull(c.getAdapter(ConnectorMock.class));
- // the load is called after the connect...
- c.connect(new TerminalControlMock());
-
- assertSame(mock, c.getAdapter(ConnectorMock.class));
- }
-
-}
diff --git a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/connector/TerminalConnectorTest.java b/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/connector/TerminalConnectorTest.java
deleted file mode 100644
index ffb0efe67..000000000
--- a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/connector/TerminalConnectorTest.java
+++ /dev/null
@@ -1,236 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Michael Scharf (Wind River) - initial API and implementation
- * Martin Oberhuber (Wind River) - [225853][api] Provide more default functionality in TerminalConnectorImpl
- * Martin Oberhuber (Wind River) - [204796] Terminal should allow setting the encoding to use
- *******************************************************************************/
-package org.eclipse.tm.internal.terminal.connector;
-
-import java.io.OutputStream;
-
-import junit.framework.TestCase;
-
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.tm.internal.terminal.connector.TerminalConnector.Factory;
-import org.eclipse.tm.internal.terminal.provisional.api.ISettingsPage;
-import org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore;
-import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl;
-import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
-import org.eclipse.tm.internal.terminal.provisional.api.provider.TerminalConnectorImpl;
-
-public class TerminalConnectorTest extends TestCase {
- public class SettingsMock implements ISettingsStore {
-
- public String get(String key) {
- return null;
- }
-
- public String get(String key, String defaultValue) {
- return null;
- }
-
- public void put(String key, String value) {
- }
-
- }
- public static class TerminalControlMock implements ITerminalControl {
-
- public void setEncoding(String encoding) {
- }
-
- public String getEncoding() {
- return "ISO-8859-1"; //$NON-NLS-1$
- }
-
- public void displayTextInTerminal(String text) {
- }
-
- public OutputStream getRemoteToTerminalOutputStream() {
- return null;
- }
-
- public Shell getShell() {
- return null;
- }
-
- public TerminalState getState() {
- return null;
- }
-
- public void setMsg(String msg) {
- }
-
- public void setState(TerminalState state) {
- }
-
- public void setTerminalTitle(String title) {
- }
-
- }
- static class ConnectorMock extends TerminalConnectorImpl {
-
- public boolean fEcho;
- public int fWidth;
- public int fHeight;
- public ITerminalControl fControl;
- public ISettingsStore fSaveStore;
- public ISettingsStore fLoadStore;
- public boolean fDisconnect;
-
- public boolean isLocalEcho() {
- return fEcho;
- }
- public void setTerminalSize(int newWidth, int newHeight) {
- fWidth=newWidth;
- fHeight=newHeight;
- }
- public void connect(ITerminalControl control) {
- super.connect(control);
- fControl = control;
- }
- public void doDisconnect() {
- fDisconnect=true;
- }
-
- public OutputStream getTerminalToRemoteStream() {
- return null;
- }
-
- public String getSettingsSummary() {
- return "Summary";
- }
-
- public void load(ISettingsStore store) {
- fLoadStore=store;
- }
-
- public ISettingsPage makeSettingsPage() {
- return new ISettingsPage(){
- public void createControl(Composite parent) {
- }
- public void loadSettings() {
- }
- public void saveSettings() {
- }
- public boolean validateSettings() {
- return false;
- }};
- }
-
- public void save(ISettingsStore store) {
- fSaveStore=store;
- }
- }
- static class SimpleFactory implements Factory {
- final TerminalConnectorImpl fConnector;
- public SimpleFactory(TerminalConnectorImpl connector) {
- fConnector = connector;
- }
- public TerminalConnectorImpl makeConnector() throws Exception {
- // TODO Auto-generated method stub
- return fConnector;
- }
- }
- public void testGetInitializationErrorMessage() {
- TerminalConnector c=new TerminalConnector(new SimpleFactory(new ConnectorMock()),"xID","xName");
- c.connect(new TerminalControlMock());
- assertNull(c.getInitializationErrorMessage());
-
- c=new TerminalConnector(new SimpleFactory(new ConnectorMock(){
- public void initialize() throws Exception {
- throw new Exception("FAILED");
- }}),"xID","xName");
- c.connect(new TerminalControlMock());
- assertEquals("FAILED",c.getInitializationErrorMessage());
-
- }
-
- public void testGetIdAndName() {
- TerminalConnector c=new TerminalConnector(new SimpleFactory(new ConnectorMock()),"xID","xName");
- assertEquals("xID", c.getId());
- assertEquals("xName", c.getName());
- }
-
- public void testConnect() {
- TerminalConnector c=new TerminalConnector(new SimpleFactory(new ConnectorMock()),"xID","xName");
- assertFalse(c.isInitialized());
- c.connect(new TerminalControlMock());
- assertTrue(c.isInitialized());
-
- }
-
- public void testDisconnect() {
- ConnectorMock mock=new ConnectorMock();
- TerminalConnector c=new TerminalConnector(new SimpleFactory(mock),"xID","xName");
- TerminalControlMock control=new TerminalControlMock();
- c.connect(control);
- c.disconnect();
- assertTrue(mock.fDisconnect);
- }
-
- public void testGetTerminalToRemoteStream() {
- ConnectorMock mock=new ConnectorMock();
- TerminalConnector c=new TerminalConnector(new SimpleFactory(mock),"xID","xName");
- TerminalControlMock control=new TerminalControlMock();
- c.connect(control);
- assertSame(mock.fControl,control);
- }
-
- public void testGetSettingsSummary() {
- TerminalConnector c=new TerminalConnector(new SimpleFactory(new ConnectorMock()),"xID","xName");
- assertEquals("Not Initialized", c.getSettingsSummary());
- c.connect(new TerminalControlMock());
- assertEquals("Summary", c.getSettingsSummary());
- }
-
- public void testIsLocalEcho() {
- ConnectorMock mock=new ConnectorMock();
- TerminalConnector c=new TerminalConnector(new SimpleFactory(mock),"xID","xName");
- assertFalse(c.isLocalEcho());
- mock.fEcho=true;
- assertTrue(c.isLocalEcho());
- }
-
- public void testLoad() {
- ConnectorMock mock=new ConnectorMock();
- TerminalConnector c=new TerminalConnector(new SimpleFactory(mock),"xID","xName");
- ISettingsStore s=new SettingsMock();
- c.load(s);
- // the load is called after the connect...
- assertNull(mock.fLoadStore);
- c.connect(new TerminalControlMock());
- assertSame(s,mock.fLoadStore);
- }
-
- public void testSave() {
- ConnectorMock mock=new ConnectorMock();
- TerminalConnector c=new TerminalConnector(new SimpleFactory(mock),"xID","xName");
- ISettingsStore s=new SettingsMock();
- c.save(s);
- assertNull(mock.fSaveStore);
- c.connect(new TerminalControlMock());
- c.save(s);
- assertSame(s,mock.fSaveStore);
- }
-
- public void testMakeSettingsPage() {
- ConnectorMock mock=new ConnectorMock();
- TerminalConnector c=new TerminalConnector(new SimpleFactory(mock),"xID","xName");
- assertNotNull(c.makeSettingsPage());
- }
-
- public void testSetTerminalSize() {
- ConnectorMock mock=new ConnectorMock();
- TerminalConnector c=new TerminalConnector(new SimpleFactory(mock),"xID","xName");
- c.setTerminalSize(100, 200);
-
- }
-
-}
diff --git a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/connector/TerminalToRemoteInjectionOutputStreamTest.java b/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/connector/TerminalToRemoteInjectionOutputStreamTest.java
deleted file mode 100644
index eb5ea8417..000000000
--- a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/connector/TerminalToRemoteInjectionOutputStreamTest.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Michael Scharf (Wind River) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tm.internal.terminal.connector;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-
-import junit.framework.TestCase;
-
-public class TerminalToRemoteInjectionOutputStreamTest extends TestCase {
- final static String ENCODING="UTF-8";
- /**
- * This class escapes strings coming on the original
- * terminal..
- *
- */
- class CleverInterceptor extends TerminalToRemoteInjectionOutputStream.Interceptor {
-
- public void close() throws IOException {
- }
- public void write(int b) throws IOException {
- fOriginal.write('[');
- fOriginal.write(b);
- fOriginal.write(']');
- }
- public void write(byte[] b, int off, int len) throws IOException {
- fOriginal.write('[');
- fOriginal.write(b,off,len);
- fOriginal.write(']');
- }
-
- }
- class NullInterceptor extends TerminalToRemoteInjectionOutputStream.Interceptor {
- }
- public void testClose() throws UnsupportedEncodingException, IOException {
- ByteArrayOutputStream bs=new ByteArrayOutputStream();
- TerminalToRemoteInjectionOutputStream s= new TerminalToRemoteInjectionOutputStream(bs);
- s.write("begin:".getBytes(ENCODING));
- assertEquals("begin:", new String(bs.toByteArray(),ENCODING));
- OutputStream os1=s.grabOutput();
- os1.write('x');
- s.write('A');
- os1.write('y');
- s.write('B');
- os1.close();
-
- s.write('-');
- OutputStream os=s.grabOutput();
- // make sure the closed output does not inject anything
- try {
- os1.write('k');
- fail("...");
- } catch (Exception e) {
- }
- os.write('X');
- s.write('a');
- os.write('Y');
- // make sure the closed output does not inject anything
- try {
- os1.write('l');
- fail("...");
- } catch (Exception e) {
- }
- s.write('b');
- os.close();
- assertEquals("begin:xyAB-XYab", new String(bs.toByteArray(),ENCODING));
- }
-
- public void testFlush() {
- }
-
- public void testWriteInt() throws UnsupportedEncodingException, IOException {
- ByteArrayOutputStream bs=new ByteArrayOutputStream();
- TerminalToRemoteInjectionOutputStream s= new TerminalToRemoteInjectionOutputStream(bs);
- s.write("begin:".getBytes(ENCODING));
- assertEquals("begin:", new String(bs.toByteArray(),ENCODING));
- OutputStream os=s.grabOutput();
- os.write('x');
- s.write('A');
- os.write('y');
- s.write('B');
- s.close();
- assertEquals("begin:xyAB", new String(bs.toByteArray(),ENCODING));
-
- }
-
- public void testWriteByteArray() {
- }
-
- public void testWriteByteArrayIntInt() {
- }
- public void testGrabOutput() throws UnsupportedEncodingException, IOException {
- ByteArrayOutputStream bs=new ByteArrayOutputStream();
- TerminalToRemoteInjectionOutputStream s= new TerminalToRemoteInjectionOutputStream(bs);
- s.write("begin:".getBytes(ENCODING));
- assertEquals("begin:", new String(bs.toByteArray(),ENCODING));
- OutputStream os1=s.grabOutput();
- OutputStream os2;
- try {
- os2=s.grabOutput();
- fail("should fail until the foirst output is closed");
- } catch (IOException e) {
- }
- os1.close();
- os2=s.grabOutput();
- assertEquals("begin:", new String(bs.toByteArray(),ENCODING));
- os2.write("Test".getBytes(ENCODING));
- assertEquals("begin:Test", new String(bs.toByteArray(),ENCODING));
- s.write(" west".getBytes(ENCODING));
- assertEquals("begin:Test", new String(bs.toByteArray(),ENCODING));
- os2.write(" the".getBytes(ENCODING));
- assertEquals("begin:Test the", new String(bs.toByteArray(),ENCODING));
- os2.close();
- assertEquals("begin:Test the west", new String(bs.toByteArray(),ENCODING));
- s.write('!');
- assertEquals("begin:Test the west!", new String(bs.toByteArray(),ENCODING));
-
- }
- public void testGrabOutputWithCleverInterceptor() throws UnsupportedEncodingException, IOException {
- ByteArrayOutputStream bs=new ByteArrayOutputStream();
- TerminalToRemoteInjectionOutputStream s= new TerminalToRemoteInjectionOutputStream(bs);
- s.write("begin:".getBytes(ENCODING));
- assertEquals("begin:", new String(bs.toByteArray(),ENCODING));
- // the injector escapes the output coming from the main stream
- OutputStream os=s.grabOutput(new CleverInterceptor());
- assertEquals("begin:", new String(bs.toByteArray(),ENCODING));
- os.write("Test".getBytes(ENCODING));
- assertEquals("begin:Test", new String(bs.toByteArray(),ENCODING));
- s.write(" west".getBytes(ENCODING));
- assertEquals("begin:Test[ west]", new String(bs.toByteArray(),ENCODING));
- os.write(" the".getBytes(ENCODING));
- assertEquals("begin:Test[ west] the", new String(bs.toByteArray(),ENCODING));
- s.write('x');
- assertEquals("begin:Test[ west] the[x]", new String(bs.toByteArray(),ENCODING));
- os.close();
- assertEquals("begin:Test[ west] the[x]", new String(bs.toByteArray(),ENCODING));
- s.write('!');
- assertEquals("begin:Test[ west] the[x]!", new String(bs.toByteArray(),ENCODING));
-
- }
- public void testGrabOutputWithNullInterceptor() throws UnsupportedEncodingException, IOException {
- ByteArrayOutputStream bs=new ByteArrayOutputStream();
- TerminalToRemoteInjectionOutputStream s= new TerminalToRemoteInjectionOutputStream(bs);
- s.write("begin:".getBytes(ENCODING));
- assertEquals("begin:", new String(bs.toByteArray(),ENCODING));
- // bytes written to the main stream are ignored while the injector
- // is active
- OutputStream os=s.grabOutput(new NullInterceptor());
- assertEquals("begin:", new String(bs.toByteArray(),ENCODING));
- os.write("Test".getBytes(ENCODING));
- assertEquals("begin:Test", new String(bs.toByteArray(),ENCODING));
- s.write(" west".getBytes(ENCODING));
- assertEquals("begin:Test", new String(bs.toByteArray(),ENCODING));
- os.write(" the".getBytes(ENCODING));
- assertEquals("begin:Test the", new String(bs.toByteArray(),ENCODING));
- s.write('x');
- assertEquals("begin:Test the", new String(bs.toByteArray(),ENCODING));
- os.close();
- assertEquals("begin:Test the", new String(bs.toByteArray(),ENCODING));
- s.write('!');
- assertEquals("begin:Test the!", new String(bs.toByteArray(),ENCODING));
-
- }
-
-}
diff --git a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/emulator/AllTests.java b/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/emulator/AllTests.java
deleted file mode 100644
index 9817ae968..000000000
--- a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/emulator/AllTests.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tm.internal.terminal.emulator;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- * Terminal emulator test cases.
- * Runs in emulator package to allow access to default visible items.
- */
-public class AllTests extends TestCase {
- public AllTests() {
- super(null);
- }
-
- public AllTests(String name) {
- super(name);
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite(AllTests.class.getName());
- suite.addTestSuite(VT100EmulatorBackendTest.class);
- return suite;
- }
-
-}
diff --git a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/emulator/VT100EmulatorBackendTest.java b/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/emulator/VT100EmulatorBackendTest.java
deleted file mode 100644
index 9e711db97..000000000
--- a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/emulator/VT100EmulatorBackendTest.java
+++ /dev/null
@@ -1,1237 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Michael Scharf (Wind River) - initial API and implementation
- * Martin Oberhuber (Wind River) - [168197] Fix Terminal for CDC-1.1/Foundation-1.1
- *******************************************************************************/
-package org.eclipse.tm.internal.terminal.emulator;
-
-import junit.framework.TestCase;
-
-import org.eclipse.tm.internal.terminal.model.TerminalTextDataStore;
-import org.eclipse.tm.internal.terminal.model.TerminalTextTestHelper;
-import org.eclipse.tm.terminal.model.ITerminalTextData;
-import org.eclipse.tm.terminal.model.ITerminalTextDataReadOnly;
-import org.eclipse.tm.terminal.model.Style;
-
-public class VT100EmulatorBackendTest extends TestCase {
-
- protected IVT100EmulatorBackend makeBakend(ITerminalTextData term) {
- return new VT100EmulatorBackend(term);
- }
-
- protected ITerminalTextData makeITerminalTextData() {
- return new TerminalTextDataStore();
- }
-
- protected String toSimple(ITerminalTextData term) {
- return TerminalTextTestHelper.toSimple(term);
- }
- protected String toMultiLineText(ITerminalTextDataReadOnly term) {
- return TerminalTextTestHelper.toMultiLineText(term);
- }
-
- protected void fill(ITerminalTextData term, String s) {
- TerminalTextTestHelper.fill(term,s);
- }
-
- protected void fillSimple(ITerminalTextData term, String s) {
- TerminalTextTestHelper.fillSimple(term, s);
- }
-
-
- /**
- * Used for multi line text
- * @param expected
- * @param actual
- */
- protected void assertEqualsTerm(String expected,String actual) {
- assertEquals(expected.replace(' ', '.'), actual.replace('\000', '.'));
- }
- /**
- * Used for simple text
- * @param expected
- * @param actual
- */
- protected void assertEqualsSimple(String expected,String actual) {
- assertEquals(-1,actual.indexOf('\n'));
- assertEquals(expected, actual);
- }
- public void testClearAll() {
- ITerminalTextData term=makeITerminalTextData();
- IVT100EmulatorBackend vt100=makeBakend(term);
- vt100.setDimensions(3, 4);
- fill(term, "0000\n" +
- "1111\n" +
- "2222\n" +
- "3333\n" +
- "4444\n" +
- "5555");
- vt100.clearAll();
- assertEqualsTerm(
- " \n" +
- " \n" +
- " ",toMultiLineText(term));
- }
- public void testSetDimensions() {
- ITerminalTextData term=makeITerminalTextData();
- IVT100EmulatorBackend vt100=makeBakend(term);
- String s = "0000\n" +
- "1111\n" +
- "2222\n" +
- "3333\n" +
- "4444\n" +
- "5555";
- fill(term, s);
- vt100.setDimensions(3, 4);
- assertEquals(3,vt100.getLines());
- assertEquals(4,vt100.getColumns());
- assertEqualsTerm(s,toMultiLineText(term));
-
- vt100.setCursor(0, 2);
- vt100.setDimensions(2, 4);
- assertEquals(0, vt100.getCursorLine());
- assertEquals(2, vt100.getCursorColumn());
-
- vt100.setCursor(0, 2);
- vt100.setDimensions(5, 4);
- assertEquals(3, vt100.getCursorLine());
- assertEquals(2, vt100.getCursorColumn());
-
- assertEqualsTerm(s,toMultiLineText(term));
-
- vt100.setCursor(0, 3);
- vt100.setDimensions(5, 2);
- assertEquals(0, vt100.getCursorLine());
- assertEquals(1, vt100.getCursorColumn());
- }
-
- public void testToAbsoluteLine() {
- ITerminalTextData term=makeITerminalTextData();
- VT100EmulatorBackend vt100=new VT100EmulatorBackend(term);
- vt100.setDimensions(2, 3);
- assertEquals(vt100.toAbsoluteLine(0),0);
- // TODO
- term=makeITerminalTextData();
- vt100=new VT100EmulatorBackend(term);
- vt100.setDimensions(1, 10);
- assertEquals(vt100.toAbsoluteLine(0),0);
- }
-
- public void testInsertCharacters() {
- ITerminalTextData term=makeITerminalTextData();
- IVT100EmulatorBackend vt100=makeBakend(term);
- vt100.setDimensions(3, 4);
- String s =
- "aaaa\n" +
- "bbbb\n" +
- "cccc\n" +
- "dddd\n" +
- "eeee\n" +
- "ffff\n" +
- "1234\n" +
- "4567\n" +
- "9012";
- fill(term, s);
- vt100.setCursor(0, 0);
- vt100.insertCharacters(1);
- assertEqualsTerm("aaaa\n" +
- "bbbb\n" +
- "cccc\n" +
- "dddd\n" +
- "eeee\n" +
- "ffff\n" +
- " 123\n" +
- "4567\n" +
- "9012",toMultiLineText(term));
-
- fill(term, s);
- vt100.setCursor(1, 1);
- vt100.insertCharacters(1);
- assertEqualsTerm("aaaa\n" +
- "bbbb\n" +
- "cccc\n" +
- "dddd\n" +
- "eeee\n" +
- "ffff\n" +
- "1234\n" +
- "4 56\n" +
- "9012",toMultiLineText(term));
-
- fill(term, s);
- vt100.setCursor(1, 1);
- vt100.insertCharacters(2);
- assertEqualsTerm("aaaa\n" +
- "bbbb\n" +
- "cccc\n" +
- "dddd\n" +
- "eeee\n" +
- "ffff\n" +
- "1234\n" +
- "4 5\n" +
- "9012",toMultiLineText(term));
-
- vt100.setDimensions(1, 10);
- fill(term, "0123456789");
- vt100.setCursor(0, 0);
- vt100.insertCharacters(10);
- assertEqualsTerm(" ",toMultiLineText(term));
-
- vt100.setDimensions(1, 10);
- fill(term, "0123456789");
- vt100.setCursor(0, 0);
- vt100.insertCharacters(14);
- assertEqualsTerm(" ",toMultiLineText(term));
-
- vt100.setDimensions(1, 10);
- fill(term, "0123456789");
- vt100.setCursor(0, 3);
- vt100.insertCharacters(14);
- assertEqualsTerm("012 ",toMultiLineText(term));
-
- vt100.setDimensions(1, 10);
- fill(term, "0123456789");
- vt100.setCursor(0, 3);
- vt100.insertCharacters(0);
- assertEqualsTerm("0123456789",toMultiLineText(term));
-
- vt100.setDimensions(1, 10);
- fill(term, "0123456789");
- vt100.setCursor(0, 3);
- vt100.insertCharacters(2);
- assertEqualsTerm("012 34567",toMultiLineText(term));
- }
-
- public void testEraseToEndOfScreen() {
- ITerminalTextData term=makeITerminalTextData();
- IVT100EmulatorBackend vt100=makeBakend(term);
- vt100.setDimensions(3, 4);
- String s =
- "aaaa\n" +
- "bbbb\n" +
- "cccc\n" +
- "dddd\n" +
- "eeee\n" +
- "ffff\n" +
- "0123\n" +
- "4567\n" +
- "8901";
- fill(term, s);
- vt100.setCursor(0, 0);
- vt100.eraseToEndOfScreen();
- assertEquals(0,vt100.getCursorLine());
- assertEquals(0,vt100.getCursorColumn());
- assertEqualsTerm("aaaa\n" +
- "bbbb\n" +
- "cccc\n" +
- "dddd\n" +
- "eeee\n" +
- "ffff\n" +
- " \n" +
- " \n" +
- " ",toMultiLineText(term));
-
- fill(term, s);
- vt100.setCursor(1, 0);
- vt100.eraseToEndOfScreen();
- assertEquals(1,vt100.getCursorLine());
- assertEquals(0,vt100.getCursorColumn());
- assertEqualsTerm("aaaa\n" +
- "bbbb\n" +
- "cccc\n" +
- "dddd\n" +
- "eeee\n" +
- "ffff\n" +
- "0123\n" +
- " \n" +
- " ",toMultiLineText(term));
-
- fill(term, s);
- vt100.setCursor(1, 1);
- vt100.eraseToEndOfScreen();
- assertEquals(1,vt100.getCursorLine());
- assertEquals(1,vt100.getCursorColumn());
- assertEqualsTerm("aaaa\n" +
- "bbbb\n" +
- "cccc\n" +
- "dddd\n" +
- "eeee\n" +
- "ffff\n" +
- "0123\n" +
- "4 \n" +
- " ",toMultiLineText(term));
-
- fill(term, s);
- vt100.setCursor(1, 4);
- assertEquals(1,vt100.getCursorLine());
- assertEquals(3,vt100.getCursorColumn());
- vt100.eraseToEndOfScreen();
- assertEquals(1,vt100.getCursorLine());
- assertEquals(3,vt100.getCursorColumn());
- assertEqualsTerm("aaaa\n" +
- "bbbb\n" +
- "cccc\n" +
- "dddd\n" +
- "eeee\n" +
- "ffff\n" +
- "0123\n" +
- "456.\n" +
- " ",toMultiLineText(term));
-
-
- fill(term, s);
- vt100.setCursor(1, 5);
- vt100.eraseToEndOfScreen();
- assertEquals(1,vt100.getCursorLine());
- assertEquals(3,vt100.getCursorColumn());
- assertEqualsTerm("aaaa\n" +
- "bbbb\n" +
- "cccc\n" +
- "dddd\n" +
- "eeee\n" +
- "ffff\n" +
- "0123\n" +
- "456.\n" +
- " ",toMultiLineText(term));
-
- fill(term, s);
- vt100.setCursor(2, 3);
- vt100.eraseToEndOfScreen();
- assertEquals(2,vt100.getCursorLine());
- assertEquals(3,vt100.getCursorColumn());
- assertEqualsTerm("aaaa\n" +
- "bbbb\n" +
- "cccc\n" +
- "dddd\n" +
- "eeee\n" +
- "ffff\n" +
- "0123\n" +
- "4567\n" +
- "890 ",toMultiLineText(term));
-
- fill(term, s);
- vt100.setCursor(2, 5);
- vt100.eraseToEndOfScreen();
- assertEquals(2,vt100.getCursorLine());
- assertEquals(3,vt100.getCursorColumn());
- assertEqualsTerm("aaaa\n" +
- "bbbb\n" +
- "cccc\n" +
- "dddd\n" +
- "eeee\n" +
- "ffff\n" +
- "0123\n" +
- "4567\n" +
- "890.",toMultiLineText(term));
- }
-
- public void testEraseToCursor() {
- ITerminalTextData term=makeITerminalTextData();
- IVT100EmulatorBackend vt100=makeBakend(term);
- vt100.setDimensions(3, 4);
- String s =
- "aaaa\n" +
- "bbbb\n" +
- "cccc\n" +
- "dddd\n" +
- "eeee\n" +
- "ffff\n" +
- "0123\n" +
- "4567\n" +
- "8901";
- fill(term, s);
- vt100.setCursor(0, 0);
- vt100.eraseToCursor();
- assertEquals(0,vt100.getCursorLine());
- assertEquals(0,vt100.getCursorColumn());
- assertEqualsTerm("aaaa\n" +
- "bbbb\n" +
- "cccc\n" +
- "dddd\n" +
- "eeee\n" +
- "ffff\n" +
- " 123\n" +
- "4567\n" +
- "8901",toMultiLineText(term));
-
- fill(term, s);
- vt100.setCursor(1, 0);
- vt100.eraseToCursor();
- assertEquals(1,vt100.getCursorLine());
- assertEquals(0,vt100.getCursorColumn());
- assertEqualsTerm("aaaa\n" +
- "bbbb\n" +
- "cccc\n" +
- "dddd\n" +
- "eeee\n" +
- "ffff\n" +
- " \n" +
- " 567\n" +
- "8901",toMultiLineText(term));
-
- fill(term, s);
- vt100.setCursor(1, 1);
- vt100.eraseToCursor();
- assertEquals(1,vt100.getCursorLine());
- assertEquals(1,vt100.getCursorColumn());
- assertEqualsTerm("aaaa\n" +
- "bbbb\n" +
- "cccc\n" +
- "dddd\n" +
- "eeee\n" +
- "ffff\n" +
- " \n" +
- " 67\n" +
- "8901",toMultiLineText(term));
-
- fill(term, s);
- vt100.setCursor(1, 4);
- vt100.eraseToCursor();
- assertEquals(1,vt100.getCursorLine());
- assertEquals(3,vt100.getCursorColumn());
- assertEqualsTerm("aaaa\n" +
- "bbbb\n" +
- "cccc\n" +
- "dddd\n" +
- "eeee\n" +
- "ffff\n" +
- " \n" +
- " \n" +
- "8901",toMultiLineText(term));
-
-
- fill(term, s);
- vt100.setCursor(1, 5);
- vt100.eraseToCursor();
- assertEquals(1,vt100.getCursorLine());
- assertEquals(3,vt100.getCursorColumn());
- assertEqualsTerm("aaaa\n" +
- "bbbb\n" +
- "cccc\n" +
- "dddd\n" +
- "eeee\n" +
- "ffff\n" +
- " \n" +
- " \n" +
- "8901",toMultiLineText(term));
-
- fill(term, s);
- vt100.setCursor(2, 3);
- vt100.eraseToCursor();
- assertEquals(2,vt100.getCursorLine());
- assertEquals(3,vt100.getCursorColumn());
- assertEqualsTerm("aaaa\n" +
- "bbbb\n" +
- "cccc\n" +
- "dddd\n" +
- "eeee\n" +
- "ffff\n" +
- " \n" +
- " \n" +
- " ",toMultiLineText(term));
-
- fill(term, s);
- vt100.setCursor(2, 5);
- vt100.eraseToCursor();
- assertEquals(2,vt100.getCursorLine());
- assertEquals(3,vt100.getCursorColumn());
- assertEqualsTerm("aaaa\n" +
- "bbbb\n" +
- "cccc\n" +
- "dddd\n" +
- "eeee\n" +
- "ffff\n" +
- " \n" +
- " \n" +
- " ",toMultiLineText(term));
- }
-
- public void testEraseAll() {
- ITerminalTextData term=makeITerminalTextData();
- IVT100EmulatorBackend vt100=makeBakend(term);
- vt100.setDimensions(3, 4);
- fill(term, "0000\n" +
- "1111\n" +
- "2222\n" +
- "3333\n" +
- "4444\n" +
- "5555");
- vt100.eraseAll();
- assertEqualsTerm("0000\n" +
- "1111\n" +
- "2222\n" +
- " \n" +
- " \n" +
- " ",toMultiLineText(term));
- }
-
- public void testEraseLine() {
- String s =
- "abcde\n" +
- "fghij\n" +
- "klmno\n" +
- "pqrst\n" +
- "uvwxy\n" +
- "zABCD\n" +
- "EFGHI";
-
- ITerminalTextData term=makeITerminalTextData();
- IVT100EmulatorBackend vt100=makeBakend(term);
-
- vt100.setDimensions(3, 5);
- fill(term, s);
- vt100.setCursor(0, 3);
- vt100.eraseLine();
- assertEquals(0,vt100.getCursorLine());
- assertEquals(3,vt100.getCursorColumn());
- assertEqualsTerm("abcde\n" +
- "fghij\n" +
- "klmno\n" +
- "pqrst\n" +
- " \n" +
- "zABCD\n" +
- "EFGHI", toMultiLineText(term));
-
-
- vt100.setDimensions(3, 5);
- fill(term, s);
- vt100.setCursor(2, 3);
- vt100.eraseLine();
- assertEquals(2,vt100.getCursorLine());
- assertEquals(3,vt100.getCursorColumn());
- assertEqualsTerm("abcde\n" +
- "fghij\n" +
- "klmno\n" +
- "pqrst\n" +
- "uvwxy\n" +
- "zABCD\n" +
- " ", toMultiLineText(term));
- }
-
- public void testEraseLineToEnd() {
- String s =
- "abcde\n" +
- "fghij\n" +
- "klmno\n" +
- "pqrst\n" +
- "uvwxy\n" +
- "zABCD\n" +
- "EFGHI";
-
- ITerminalTextData term=makeITerminalTextData();
- IVT100EmulatorBackend vt100=makeBakend(term);
-
- vt100.setDimensions(3, 5);
- fill(term, s);
- vt100.setCursor(0, 3);
- vt100.eraseLineToEnd();
- assertEquals(0,vt100.getCursorLine());
- assertEquals(3,vt100.getCursorColumn());
- assertEqualsTerm("abcde\n" +
- "fghij\n" +
- "klmno\n" +
- "pqrst\n" +
- "uvw \n" +
- "zABCD\n" +
- "EFGHI", toMultiLineText(term));
-
- vt100.setDimensions(3, 5);
- fill(term, s);
- vt100.setCursor(0, 0);
- vt100.eraseLineToEnd();
- assertEquals(0,vt100.getCursorLine());
- assertEquals(0,vt100.getCursorColumn());
- assertEqualsTerm("abcde\n" +
- "fghij\n" +
- "klmno\n" +
- "pqrst\n" +
- " \n" +
- "zABCD\n" +
- "EFGHI", toMultiLineText(term));
-
-
- vt100.setDimensions(3, 5);
- fill(term, s);
- vt100.setCursor(2, 3);
- vt100.eraseLineToEnd();
- assertEquals(2,vt100.getCursorLine());
- assertEquals(3,vt100.getCursorColumn());
- assertEqualsTerm("abcde\n" +
- "fghij\n" +
- "klmno\n" +
- "pqrst\n" +
- "uvwxy\n" +
- "zABCD\n" +
- "EFG ", toMultiLineText(term));
- vt100.setDimensions(3, 5);
- fill(term, s);
-
- vt100.setCursor(2, 4);
- vt100.eraseLineToEnd();
- assertEquals(2,vt100.getCursorLine());
- assertEquals(4,vt100.getCursorColumn());
- assertEqualsTerm("abcde\n" +
- "fghij\n" +
- "klmno\n" +
- "pqrst\n" +
- "uvwxy\n" +
- "zABCD\n" +
- "EFGH ", toMultiLineText(term));
-
- vt100.setCursor(2, 5);
- vt100.eraseLineToEnd();
- assertEquals(2,vt100.getCursorLine());
- assertEquals(4,vt100.getCursorColumn());
- assertEqualsTerm("abcde\n" +
- "fghij\n" +
- "klmno\n" +
- "pqrst\n" +
- "uvwxy\n" +
- "zABCD\n" +
- "EFGH ", toMultiLineText(term));
-
- }
-
- public void testEraseLineToCursor() {
- String s =
- "abcde\n" +
- "fghij\n" +
- "klmno\n" +
- "pqrst\n" +
- "uvwxy\n" +
- "zABCD\n" +
- "EFGHI";
-
- ITerminalTextData term=makeITerminalTextData();
- IVT100EmulatorBackend vt100=makeBakend(term);
-
- vt100.setDimensions(3, 5);
- fill(term, s);
- vt100.setCursor(0, 3);
- vt100.eraseLineToCursor();
- assertEquals(0,vt100.getCursorLine());
- assertEquals(3,vt100.getCursorColumn());
- assertEqualsTerm("abcde\n" +
- "fghij\n" +
- "klmno\n" +
- "pqrst\n" +
- " y\n" +
- "zABCD\n" +
- "EFGHI", toMultiLineText(term));
-
- vt100.setDimensions(3, 5);
- fill(term, s);
- vt100.setCursor(0, 0);
- vt100.eraseLineToCursor();
- assertEquals(0,vt100.getCursorLine());
- assertEquals(0,vt100.getCursorColumn());
- assertEqualsTerm("abcde\n" +
- "fghij\n" +
- "klmno\n" +
- "pqrst\n" +
- " vwxy\n" +
- "zABCD\n" +
- "EFGHI", toMultiLineText(term));
-
-
- vt100.setDimensions(3, 5);
- fill(term, s);
- vt100.setCursor(2, 3);
- vt100.eraseLineToCursor();
- assertEquals(2,vt100.getCursorLine());
- assertEquals(3,vt100.getCursorColumn());
- assertEqualsTerm("abcde\n" +
- "fghij\n" +
- "klmno\n" +
- "pqrst\n" +
- "uvwxy\n" +
- "zABCD\n" +
- " I", toMultiLineText(term));
- vt100.setDimensions(3, 5);
- fill(term, s);
-
- vt100.setCursor(2, 4);
- vt100.eraseLineToCursor();
- assertEquals(2,vt100.getCursorLine());
- assertEquals(4,vt100.getCursorColumn());
- assertEqualsTerm("abcde\n" +
- "fghij\n" +
- "klmno\n" +
- "pqrst\n" +
- "uvwxy\n" +
- "zABCD\n" +
- " ", toMultiLineText(term));
-
- vt100.setCursor(2, 5);
- vt100.eraseLineToCursor();
- assertEquals(2,vt100.getCursorLine());
- assertEquals(4,vt100.getCursorColumn());
- assertEqualsTerm("abcde\n" +
- "fghij\n" +
- "klmno\n" +
- "pqrst\n" +
- "uvwxy\n" +
- "zABCD\n" +
- " ", toMultiLineText(term));
-
- }
-
- public void testInsertLines() {
- ITerminalTextData term=makeITerminalTextData();
- IVT100EmulatorBackend vt100=makeBakend(term);
- String s = "0000\n" +
- "1111\n" +
- "2222\n" +
- "3333\n" +
- "4444\n" +
- "5555";
- vt100.setDimensions(3, 4);
- fill(term, s);
- vt100.setCursor(0, 0);
- vt100.insertLines(1);
- assertEqualsTerm(
- "0000\n" +
- "1111\n" +
- "2222\n" +
- " \n" +
- "3333\n" +
- "4444", toMultiLineText(term));
-
- fill(term, s);
- vt100.setCursor(1, 0);
- vt100.insertLines(1);
- assertEqualsTerm(
- "0000\n" +
- "1111\n" +
- "2222\n" +
- "3333\n" +
- " \n" +
- "4444", toMultiLineText(term));
-
- fill(term, s);
- vt100.setCursor(1, 0);
- vt100.insertLines(2);
- assertEqualsTerm(
- "0000\n" +
- "1111\n" +
- "2222\n" +
- "3333\n" +
- " \n" +
- " ", toMultiLineText(term));
-
- fill(term, s);
- vt100.setCursor(1, 3);
- vt100.insertLines(2);
- assertEqualsTerm(
- "0000\n" +
- "1111\n" +
- "2222\n" +
- "3333\n" +
- " \n" +
- " ", toMultiLineText(term));
-
-
- vt100.setDimensions(6, 4);
- fill(term, s);
- vt100.setCursor(1, 3);
- vt100.insertLines(2);
- assertEqualsTerm(
- "0000\n" +
- " \n" +
- " \n" +
- "1111\n" +
- "2222\n" +
- "3333", toMultiLineText(term));
-
-
- vt100.setDimensions(6, 4);
- fill(term, s);
- vt100.setCursor(1, 3);
- vt100.insertLines(7);
- assertEqualsTerm(
- "0000\n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " ", toMultiLineText(term));
-
- vt100.setDimensions(6, 4);
- fill(term, s);
- vt100.setCursor(0, 0);
- vt100.insertLines(7);
- assertEqualsTerm(
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " ", toMultiLineText(term));
-
- vt100.setDimensions(6, 4);
- fill(term, s);
- vt100.setCursor(0, 0);
- vt100.insertLines(5);
- assertEqualsTerm(
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- "0000", toMultiLineText(term));
- }
-
- public void testDeleteCharacters() {
- ITerminalTextData term=makeITerminalTextData();
- IVT100EmulatorBackend vt100=makeBakend(term);
- vt100.setDimensions(3, 4);
- String s =
- "aaaa\n" +
- "bbbb\n" +
- "cccc\n" +
- "dddd\n" +
- "eeee\n" +
- "ffff\n" +
- "1234\n" +
- "4567\n" +
- "9012";
- fill(term, s);
- vt100.setCursor(0, 0);
- vt100.deleteCharacters(1);
- assertEqualsTerm("aaaa\n" +
- "bbbb\n" +
- "cccc\n" +
- "dddd\n" +
- "eeee\n" +
- "ffff\n" +
- "234 \n" +
- "4567\n" +
- "9012",toMultiLineText(term));
-
- fill(term, s);
- vt100.setCursor(1, 1);
- vt100.deleteCharacters(1);
- assertEqualsTerm("aaaa\n" +
- "bbbb\n" +
- "cccc\n" +
- "dddd\n" +
- "eeee\n" +
- "ffff\n" +
- "1234\n" +
- "467 \n" +
- "9012",toMultiLineText(term));
-
- fill(term, s);
- vt100.setCursor(1, 1);
- vt100.deleteCharacters(2);
- assertEqualsTerm("aaaa\n" +
- "bbbb\n" +
- "cccc\n" +
- "dddd\n" +
- "eeee\n" +
- "ffff\n" +
- "1234\n" +
- "47 \n" +
- "9012",toMultiLineText(term));
-
- vt100.setDimensions(1, 10);
- fill(term, "0123456789");
- vt100.setCursor(0, 0);
- vt100.deleteCharacters(10);
- assertEqualsTerm(" ",toMultiLineText(term));
-
- vt100.setDimensions(1, 10);
- fill(term, "0123456789");
- vt100.setCursor(0, 0);
- vt100.deleteCharacters(14);
- assertEqualsTerm(" ",toMultiLineText(term));
-
- vt100.setDimensions(1, 10);
- fill(term, "0123456789");
- vt100.setCursor(0, 3);
- vt100.deleteCharacters(0);
- assertEqualsTerm("0123456789",toMultiLineText(term));
-
- vt100.setDimensions(1, 10);
- fill(term, "0123456789");
- vt100.setCursor(0, 3);
- vt100.deleteCharacters(2);
- assertEqualsTerm("01256789 ",toMultiLineText(term));
-
- vt100.setDimensions(1, 10);
- fill(term, "0123456789");
- vt100.setCursor(0, 3);
- vt100.deleteCharacters(14);
- assertEqualsTerm("012 ",toMultiLineText(term));
-
- }
-
- public void testDeleteLines() {
- ITerminalTextData term=makeITerminalTextData();
- IVT100EmulatorBackend vt100=makeBakend(term);
- String s = "0000\n" +
- "1111\n" +
- "2222\n" +
- "3333\n" +
- "4444\n" +
- "5555";
- vt100.setDimensions(3, 4);
- fill(term, s);
- vt100.setCursor(0, 0);
- vt100.deleteLines(1);
- assertEqualsTerm(
- "0000\n" +
- "1111\n" +
- "2222\n" +
- "4444\n" +
- "5555\n" +
- " ", toMultiLineText(term));
-
- fill(term, s);
- vt100.setCursor(1, 0);
- vt100.deleteLines(1);
- assertEqualsTerm(
- "0000\n" +
- "1111\n" +
- "2222\n" +
- "3333\n" +
- "5555\n" +
- " ", toMultiLineText(term));
-
- fill(term, s);
- vt100.setCursor(1, 0);
- vt100.deleteLines(2);
- assertEqualsTerm(
- "0000\n" +
- "1111\n" +
- "2222\n" +
- "3333\n" +
- " \n" +
- " ", toMultiLineText(term));
-
- fill(term, s);
- vt100.setCursor(1, 3);
- vt100.deleteLines(2);
- assertEqualsTerm(
- "0000\n" +
- "1111\n" +
- "2222\n" +
- "3333\n" +
- " \n" +
- " ", toMultiLineText(term));
-
-
- vt100.setDimensions(6, 4);
- fill(term, s);
- vt100.setCursor(1, 3);
- vt100.deleteLines(2);
- assertEqualsTerm(
- "0000\n" +
- "3333\n" +
- "4444\n" +
- "5555\n" +
- " \n" +
- " ", toMultiLineText(term));
-
-
- vt100.setDimensions(6, 4);
- fill(term, s);
- vt100.setCursor(1, 3);
- vt100.deleteLines(7);
- assertEqualsTerm(
- "0000\n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " ", toMultiLineText(term));
-
- vt100.setDimensions(6, 4);
- fill(term, s);
- vt100.setCursor(0, 0);
- vt100.deleteLines(7);
- assertEqualsTerm(
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " ", toMultiLineText(term));
-
- vt100.setDimensions(6, 4);
- fill(term, s);
- vt100.setCursor(0, 0);
- vt100.deleteLines(5);
- assertEqualsTerm(
- "5555\n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " ", toMultiLineText(term));
- }
-
- public void testGetDefaultStyle() {
- ITerminalTextData term=makeITerminalTextData();
- IVT100EmulatorBackend vt100=makeBakend(term);
- Style style=Style.getStyle("white", "black");
- vt100.setDefaultStyle(style);
- assertSame(style, vt100.getDefaultStyle());
- Style style2=style.setBold(true);
- vt100.setDefaultStyle(style2);
- assertSame(style2, vt100.getDefaultStyle());
- }
-
- public void testGetStyle() {
- ITerminalTextData term=makeITerminalTextData();
- IVT100EmulatorBackend vt100=makeBakend(term);
- Style style=Style.getStyle("white", "black");
- vt100.setStyle(style);
- assertSame(style, vt100.getStyle());
- Style style2=style.setBold(true);
- vt100.setStyle(style2);
- assertSame(style2, vt100.getStyle());
- }
-
- public void testAppendString() {
- ITerminalTextData term=makeITerminalTextData();
- IVT100EmulatorBackend vt100=makeBakend(term);
- term.setMaxHeight(6);
- vt100.setDimensions(3, 4);
- vt100.setCursor(0, 0);
- assertEqualsTerm(
- " \n" +
- " \n" +
- " ", toMultiLineText(term));
- vt100.appendString("012");
- assertEqualsTerm(
- "012 \n" +
- " \n" +
- " ", toMultiLineText(term));
- assertEquals(0,vt100.getCursorLine());
- assertEquals(3,vt100.getCursorColumn());
- vt100.appendString("3");
- assertEqualsTerm(
- "0123\n" +
- " \n" +
- " ", toMultiLineText(term));
- assertEquals(1,vt100.getCursorLine());
- assertEquals(0,vt100.getCursorColumn());
-
- vt100.appendString("567890");
- assertEqualsTerm(
- "0123\n" +
- "5678\n" +
- "90 ", toMultiLineText(term));
- assertEquals(2,vt100.getCursorLine());
- assertEquals(2,vt100.getCursorColumn());
-
-
- vt100.appendString("a");
- assertEqualsTerm(
- "0123\n" +
- "5678\n" +
- "90a ", toMultiLineText(term));
- assertEquals(2,vt100.getCursorLine());
- assertEquals(3,vt100.getCursorColumn());
-
- vt100.appendString("b");
- assertEqualsTerm(
- "0123\n" +
- "5678\n" +
- "90ab\n" +
- " ", toMultiLineText(term));
- assertEquals(2,vt100.getCursorLine());
- assertEquals(0,vt100.getCursorColumn());
-
- vt100.appendString("cd");
- assertEqualsTerm(
- "0123\n" +
- "5678\n" +
- "90ab\n" +
- "cd ", toMultiLineText(term));
- assertEquals(2,vt100.getCursorLine());
- assertEquals(2,vt100.getCursorColumn());
-
- vt100.appendString("efgh");
- assertEqualsTerm(
- "0123\n" +
- "5678\n" +
- "90ab\n" +
- "cdef\n" +
- "gh ", toMultiLineText(term));
- assertEquals(2,vt100.getCursorLine());
- assertEquals(2,vt100.getCursorColumn());
-
- vt100.appendString("ijklmnopqrstuvwx");
- assertEqualsTerm(
- "cdef\n" +
- "ghij\n" +
- "klmn\n" +
- "opqr\n" +
- "stuv\n" +
- "wx ", toMultiLineText(term));
- assertEquals(2,vt100.getCursorLine());
- assertEquals(2,vt100.getCursorColumn());
-
- vt100.setCursor(1, 1);
- vt100.appendString("123");
- assertEqualsTerm(
- "cdef\n" +
- "ghij\n" +
- "klmn\n" +
- "opqr\n" +
- "s123\n" +
- "wx ", toMultiLineText(term));
- assertEquals(2,vt100.getCursorLine());
- assertEquals(0,vt100.getCursorColumn());
-
- vt100.setCursor(1, 1);
- vt100.appendString("ABCDEFGHIJKL");
- assertEqualsTerm(
- "klmn\n" +
- "opqr\n" +
- "sABC\n" +
- "DEFG\n" +
- "HIJK\n" +
- "L ", toMultiLineText(term));
- assertEquals(2,vt100.getCursorLine());
- assertEquals(1,vt100.getCursorColumn());
-
- }
-
- public void testProcessNewline() {
- ITerminalTextData term=makeITerminalTextData();
- IVT100EmulatorBackend vt100=makeBakend(term);
- String s = "0000\n" +
- "1111\n" +
- "2222\n" +
- "3333\n" +
- "4444\n" +
- "5555";
- term.setMaxHeight(6);
- vt100.setDimensions(3, 4);
- vt100.setCursor(0, 0);
- fill(term,s);
- assertEquals(0,vt100.getCursorLine());
- assertEquals(0,vt100.getCursorColumn());
- vt100.processNewline();
- assertEqualsTerm(s, toMultiLineText(term));
- assertEquals(1,vt100.getCursorLine());
- assertEquals(0,vt100.getCursorColumn());
- vt100.setCursorColumn(3);
- vt100.processNewline();
- assertEqualsTerm(s, toMultiLineText(term));
- assertEquals(2,vt100.getCursorLine());
- assertEquals(3,vt100.getCursorColumn());
-
- vt100.processNewline();
- assertEqualsTerm(
- "1111\n" +
- "2222\n" +
- "3333\n" +
- "4444\n" +
- "5555\n" +
- " ", toMultiLineText(term));
- assertEquals(2,vt100.getCursorLine());
- assertEquals(3,vt100.getCursorColumn());
-
-
- vt100.processNewline();
- assertEqualsTerm(
- "2222\n" +
- "3333\n" +
- "4444\n" +
- "5555\n" +
- " \n" +
- " ", toMultiLineText(term));
- assertEquals(2,vt100.getCursorLine());
- assertEquals(3,vt100.getCursorColumn());
- }
-
- public void testSetCursorLine() {
- ITerminalTextData term=makeITerminalTextData();
- IVT100EmulatorBackend vt100=makeBakend(term);
- term.setMaxHeight(6);
- vt100.setDimensions(3, 4);
- // the cursor still at the beginning....
- assertEquals(0,vt100.getCursorLine());
- assertEquals(0,vt100.getCursorColumn());
- vt100.setCursor(0, 2);
- vt100.setCursorLine(1);
- assertEquals(1,vt100.getCursorLine());
- assertEquals(2,vt100.getCursorColumn());
- vt100.setCursor(0, -2);
- vt100.setCursorLine(-1);
- assertEquals(0,vt100.getCursorLine());
- assertEquals(0,vt100.getCursorColumn());
- vt100.setCursor(0, 10);
- vt100.setCursorLine(10);
- assertEquals(2,vt100.getCursorLine());
- assertEquals(3,vt100.getCursorColumn());
- }
- public void testSetCursorAndSetDimensions() {
- ITerminalTextData term=makeITerminalTextData();
- IVT100EmulatorBackend vt100=makeBakend(term);
- term.setMaxHeight(10);
- vt100.setDimensions(3, 4);
- // the cursor still at the beginning....
- assertEquals(0,vt100.getCursorLine());
- assertEquals(0,vt100.getCursorColumn());
- vt100.setDimensions(6, 4);
- assertEquals(0,vt100.getCursorLine());
- assertEquals(0,vt100.getCursorColumn());
- vt100.setCursor(2, 3);
- vt100.setDimensions(8, 4);
- assertEquals(2,vt100.getCursorLine());
- assertEquals(3,vt100.getCursorColumn());
- }
-
- public void testSetCursorColumn() {
- ITerminalTextData term=makeITerminalTextData();
- IVT100EmulatorBackend vt100=makeBakend(term);
- term.setMaxHeight(6);
- vt100.setDimensions(3, 4);
- assertEquals(0,vt100.getCursorLine());
- assertEquals(0,vt100.getCursorColumn());
- vt100.setCursor(1, 0);
- vt100.setCursorColumn(2);
- assertEquals(1,vt100.getCursorLine());
- assertEquals(2,vt100.getCursorColumn());
- vt100.setCursor(-1, -2);
- vt100.setCursorColumn(-2);
- assertEquals(0,vt100.getCursorLine());
- assertEquals(0,vt100.getCursorColumn());
- vt100.setCursor(10, 0);
- vt100.setCursorColumn(10);
- assertEquals(2,vt100.getCursorLine());
- assertEquals(3,vt100.getCursorColumn());
- }
-
- public void testSetCursor() {
- ITerminalTextData term=makeITerminalTextData();
- IVT100EmulatorBackend vt100=makeBakend(term);
- term.setMaxHeight(6);
- vt100.setDimensions(3, 4);
- assertEquals(0,vt100.getCursorLine());
- assertEquals(0,vt100.getCursorColumn());
- vt100.setCursor(0, 0);
- assertEquals(0,vt100.getCursorLine());
- assertEquals(0,vt100.getCursorColumn());
- vt100.setCursor(1, 2);
- assertEquals(1,vt100.getCursorLine());
- assertEquals(2,vt100.getCursorColumn());
- vt100.setCursor(-1, -2);
- assertEquals(0,vt100.getCursorLine());
- assertEquals(0,vt100.getCursorColumn());
- vt100.setCursor(10, 10);
- assertEquals(2,vt100.getCursorLine());
- assertEquals(3,vt100.getCursorColumn());
- }
-
-}
diff --git a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/AbstractITerminalTextDataTest.java b/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/AbstractITerminalTextDataTest.java
deleted file mode 100644
index 493547a54..000000000
--- a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/AbstractITerminalTextDataTest.java
+++ /dev/null
@@ -1,817 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Michael Scharf (Wind River) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tm.internal.terminal.model;
-import junit.framework.TestCase;
-
-import org.eclipse.tm.terminal.model.ITerminalTextData;
-import org.eclipse.tm.terminal.model.ITerminalTextDataReadOnly;
-import org.eclipse.tm.terminal.model.LineSegment;
-import org.eclipse.tm.terminal.model.Style;
-import org.eclipse.tm.terminal.model.StyleColor;
-
-abstract public class AbstractITerminalTextDataTest extends TestCase {
- abstract protected ITerminalTextData makeITerminalTextData();
-
- protected void setUp() throws Exception {
- try {
- assert false;
- throw new Error("No Assertions! Run this code with assertions enabled! (vmargs: -ea)");
- } catch(AssertionError e) {
- // OK, assertions are enabled!
- }
- super.setUp();
- }
- protected String toSimple(ITerminalTextData term) {
- return TerminalTextTestHelper.toSimple(term);
- }
- protected String toMultiLineText(ITerminalTextDataReadOnly term) {
- return TerminalTextTestHelper.toMultiLineText(term);
- }
-
- protected void fill(ITerminalTextData term, String s) {
- TerminalTextTestHelper.fill(term,s);
- }
-
- protected void fill(ITerminalTextData term, int i, int j, String s) {
- TerminalTextTestHelper.fill(term,i,j,s);
- }
-
- protected void fillSimple(ITerminalTextData term, String s) {
- TerminalTextTestHelper.fillSimple(term, s);
- }
-
-
- /**
- * Used for multi line text
- * @param expected
- * @param actual
- */
- protected void assertEqualsTerm(String expected,String actual) {
- assertEquals(expected, actual);
- }
- /**
- * Used for simple text
- * @param expected
- * @param actual
- */
- protected void assertEqualsSimple(String expected,String actual) {
- assertEquals(-1,actual.indexOf('\n'));
- assertEquals(expected, actual);
- }
- public void testGetWidth() {
- ITerminalTextData term=makeITerminalTextData();
- assertEquals(0, term.getWidth());
- term.setDimensions(term.getHeight(), 10);
- assertEquals(10, term.getWidth());
- term.setDimensions(term.getHeight(), 0);
- assertEquals(0, term.getWidth());
- }
-
- public void testAddLine() {
- String s=
- "111\n" +
- "222\n" +
- "333\n" +
- "444\n" +
- "555";
- ITerminalTextData term=makeITerminalTextData();
- fill(term, s);
- term.setMaxHeight(5);
- term.addLine();
- assertEqualsTerm(
- "222\n" +
- "333\n" +
- "444\n" +
- "555\n" +
- "\000\000\000", toMultiLineText(term));
- }
- public void testCleanLine() {
- String s=
- "111\n" +
- "222\n" +
- "333\n" +
- "444\n" +
- "555";
- ITerminalTextData term=makeITerminalTextData();
- fill(term, s);
- term.cleanLine(0);
- assertEqualsTerm(
- "\000\000\000\n" +
- "222\n" +
- "333\n" +
- "444\n" +
- "555", toMultiLineText(term));
-
- fill(term, s);
- term.cleanLine(4);
- assertEqualsTerm(
- "111\n" +
- "222\n" +
- "333\n" +
- "444\n" +
- "\000\000\000", toMultiLineText(term));
- }
-
- public void testMaxSize() {
- String s=
- "111\n" +
- "222\n" +
- "333\n" +
- "444\n" +
- "555";
- ITerminalTextData term=makeITerminalTextData();
- term.setMaxHeight(8);
- fill(term, s);
- assertEquals(5, term.getHeight());
- assertEquals(8, term.getMaxHeight());
- term.addLine();
- assertEquals(6, term.getHeight());
- assertEqualsTerm(
- "111\n" +
- "222\n" +
- "333\n" +
- "444\n" +
- "555\n" +
- "\000\000\000", toMultiLineText(term));
- term.addLine();
- assertEquals(7, term.getHeight());
- assertEqualsTerm(
- "111\n" +
- "222\n" +
- "333\n" +
- "444\n" +
- "555\n" +
- "\000\000\000\n" +
- "\000\000\000", toMultiLineText(term));
- term.addLine();
- assertEquals(8, term.getHeight());
- assertEqualsTerm(
- "111\n" +
- "222\n" +
- "333\n" +
- "444\n" +
- "555\n" +
- "\000\000\000\n" +
- "\000\000\000\n" +
- "\000\000\000", toMultiLineText(term));
- term.addLine();
- assertEquals(8, term.getHeight());
- assertEqualsTerm(
- "222\n" +
- "333\n" +
- "444\n" +
- "555\n" +
- "\000\000\000\n" +
- "\000\000\000\n" +
- "\000\000\000\n" +
- "\000\000\000", toMultiLineText(term));
- term.addLine();
- assertEquals(8, term.getHeight());
- assertEqualsTerm(
- "333\n" +
- "444\n" +
- "555\n" +
- "\000\000\000\n" +
- "\000\000\000\n" +
- "\000\000\000\n" +
- "\000\000\000\n" +
- "\000\000\000", toMultiLineText(term));
- }
- public void testGetHeight() {
- ITerminalTextData term=makeITerminalTextData();
- assertEquals(0, term.getHeight());
- term.setDimensions(10, term.getWidth());
- assertEquals(10, term.getHeight());
- term.setDimensions(0, term.getWidth());
- assertEquals(0, term.getHeight());
- }
-
- public void testSetDimensions() {
- ITerminalTextData term=makeITerminalTextData();
- assertEquals(0, term.getHeight());
- term.setDimensions(10, 5);
- assertEquals(5, term.getWidth());
- assertEquals(10, term.getHeight());
- term.setDimensions(5, 10);
- assertEquals(10, term.getWidth());
- assertEquals(5, term.getHeight());
- term.setDimensions(15, 0);
- assertEquals(0, term.getWidth());
- assertEquals(15, term.getHeight());
- term.setDimensions(0, 12);
- assertEquals(12, term.getWidth());
- assertEquals(0, term.getHeight());
- term.setDimensions(0, 0);
- assertEquals(0, term.getWidth());
- assertEquals(0, term.getHeight());
- }
- public void testResize() {
- ITerminalTextData term=makeITerminalTextData();
- term.setDimensions(3, 5);
- String s="12345\n" +
- "abcde\n" +
- "ABCDE";
- fill(term,0,0,s);
- assertEqualsTerm(s, toMultiLineText(term));
- term.setDimensions(3, 4);
- assertEqualsTerm(
- "1234\n" +
- "abcd\n" +
- "ABCD", toMultiLineText(term));
- // the columns should be restored
- term.setDimensions(3, 5);
- assertEqualsTerm(
- "12345\n" +
- "abcde\n" +
- "ABCDE", toMultiLineText(term));
- term.setDimensions(3, 6);
- assertEqualsTerm(
- "12345\000\n" +
- "abcde\000\n" +
- "ABCDE\000", toMultiLineText(term));
- term.setChar(0, 5, 'x', null);
- term.setChar(1, 5, 'y', null);
- term.setChar(2, 5, 'z', null);
- assertEqualsTerm(
- "12345x\n" +
- "abcdey\n" +
- "ABCDEz", toMultiLineText(term));
- term.setDimensions(2, 4);
- assertEqualsTerm(
- "1234\n" +
- "abcd", toMultiLineText(term));
- }
-
- public void testResizeFailure() {
- ITerminalTextData term=makeITerminalTextData();
- term.setDimensions(3, 5);
- String s="12345\n" +
- "abcde\n" +
- "ABCDE";
- fill(term,0,0,s);
- assertEqualsTerm(s, toMultiLineText(term));
- try {
- term.setDimensions(-3, 4);
- fail();
- } catch (RuntimeException e) {
- // OK
- }
-// assertEquals(5, term.getWidth());
-// assertEquals(3, term.getHeight());
-// assertEquals(s, toSimpleText(term));
- }
-
- public void testGetLineSegments() {
- Style s1=getDefaultStyle();
- Style s2=s1.setBold(true);
- Style s3=s1.setUnderline(true);
- ITerminalTextData term=makeITerminalTextData();
- term.setDimensions(8, 8);
- LineSegment[] segments;
-
- term.setChars(0, 0,"0123".toCharArray(), s1);
- term.setChars(0, 4,"abcd".toCharArray(), null);
- segments=term.getLineSegments(0, 0, term.getWidth());
- assertEquals(2, segments.length);
- assertSegment(0, "0123", s1, segments[0]);
- assertSegment(4, "abcd", null, segments[1]);
-
-
- segments=term.getLineSegments(0, 4, term.getWidth()-4);
- assertEquals(1, segments.length);
- assertSegment(4, "abcd", null, segments[0]);
-
- segments=term.getLineSegments(0, 3, 2);
- assertEquals(2, segments.length);
- assertSegment(3, "3", s1, segments[0]);
- assertSegment(4, "a", null, segments[1]);
-
- segments=term.getLineSegments(0, 7, 1);
- assertEquals(1, segments.length);
- assertSegment(7, "d", null, segments[0]);
-
- segments=term.getLineSegments(0, 0, 1);
- assertEquals(1, segments.length);
- assertSegment(0, "0", s1, segments[0]);
-
- // line 1
- term.setChars(1, 0,"x".toCharArray(), s1);
- term.setChars(1, 1,"y".toCharArray(), s2);
- term.setChars(1, 2,"z".toCharArray(), s3);
-
- segments=term.getLineSegments(1, 0, term.getWidth());
- assertEquals(4, segments.length);
- assertSegment(0, "x", s1, segments[0]);
- assertSegment(1, "y", s2, segments[1]);
- assertSegment(2, "z", s3, segments[2]);
- assertSegment(3, "\000\000\000\000\000", null, segments[3]);
-
- // line 2
- term.setChars(2, 4,"klm".toCharArray(), s1);
- segments=term.getLineSegments(2, 0, term.getWidth());
- assertEquals(3, segments.length);
- assertSegment(0, "\000\000\000\000", null, segments[0]);
- assertSegment(4, "klm", s1, segments[1]);
- assertSegment(7, "\000", null, segments[2]);
-
- // line 3
- segments=term.getLineSegments(3, 0, term.getWidth());
- assertEquals(1, segments.length);
- assertSegment(0, "\000\000\000\000\000\000\000\000", null, segments[0]);
-
- }
- public void testGetLineSegmentsNull() {
- ITerminalTextData term=makeITerminalTextData();
- term.setDimensions(8, 8);
- LineSegment[] segments=term.getLineSegments(0, 0, term.getWidth());
- assertEquals(1, segments.length);
- }
- public void testGetLineSegmentsOutOfBounds() {
- ITerminalTextData term=makeITerminalTextData();
- term.setDimensions(1, 8);
- term.setChars(0,0,"xx".toCharArray(),null);
- LineSegment[] segments=term.getLineSegments(0, 5, 2);
- assertEquals(1, segments.length);
-
-
- }
- void assertSegment(int col,String text, Style style,LineSegment segment) {
- assertEquals(col, segment.getColumn());
- assertEqualsTerm(text, segment.getText());
- assertEquals(style, segment.getStyle());
-
- }
- public void testGetChar() {
- String s="12345\n" +
- "abcde\n" +
- "ABCDE";
- ITerminalTextData term=makeITerminalTextData();
- fill(term, s);
- assertEquals('1', term.getChar(0,0));
- assertEquals('2', term.getChar(0,1));
- assertEquals('3', term.getChar(0,2));
- assertEquals('4', term.getChar(0,3));
- assertEquals('5', term.getChar(0,4));
- assertEquals('a', term.getChar(1,0));
- assertEquals('b', term.getChar(1,1));
- assertEquals('c', term.getChar(1,2));
- assertEquals('d', term.getChar(1,3));
- assertEquals('e', term.getChar(1,4));
- assertEquals('A', term.getChar(2,0));
- assertEquals('B', term.getChar(2,1));
- assertEquals('C', term.getChar(2,2));
- assertEquals('D', term.getChar(2,3));
- assertEquals('E', term.getChar(2,4));
- try {
- term.getChar(0,-1);
- fail();
- } catch (RuntimeException e) {
- }
- try {
- term.getChar(-1,-1);
- fail();
- } catch (RuntimeException e) {
- }
- try {
- term.getChar(-1,0);
- fail();
- } catch (RuntimeException e) {
- }
- try {
- term.getChar(0,5);
- fail();
- } catch (RuntimeException e) {
- }
- try {
- term.getChar(3,5);
- fail();
- } catch (RuntimeException e) {
- }
- try {
- term.getChar(3,0);
- fail();
- } catch (RuntimeException e) {
- }
- }
-
- public void testGetStyle() {
- ITerminalTextData term=makeITerminalTextData();
- Style style=getDefaultStyle();
- term.setDimensions(6, 3);
- for (int line = 0; line < term.getHeight(); line++) {
- for (int column = 0; column < term.getWidth(); column++) {
- char c=(char)('a'+column+line);
- term.setChar(line, column, c, style.setForground(StyleColor.getStyleColor(""+c)));
- }
- }
- for (int line = 0; line < term.getHeight(); line++) {
- for (int column = 0; column < term.getWidth(); column++) {
- char c=(char)('a'+column+line);
- assertSame(style.setForground(StyleColor.getStyleColor(""+c)), term.getStyle(line, column));
- }
- }
-
- }
-
- protected Style getDefaultStyle() {
- return Style.getStyle(StyleColor.getStyleColor("fg"), StyleColor.getStyleColor("bg"), false, false, false, false);
- }
-
- public void testSetChar() {
- ITerminalTextData term=makeITerminalTextData();
- term.setDimensions(6, 3);
- for (int line = 0; line < term.getHeight(); line++) {
- for (int column = 0; column < term.getWidth(); column++) {
- term.setChar(line, column, (char)('a'+column+line), null);
- }
- }
- for (int line = 0; line < term.getHeight(); line++) {
- for (int column = 0; column < term.getWidth(); column++) {
- char c=(char)('a'+column+line);
- assertEquals(c, term.getChar(line,column));
- }
- }
- assertEqualsTerm(
- "abc\n"
- + "bcd\n"
- + "cde\n"
- + "def\n"
- + "efg\n"
- + "fgh", toMultiLineText(term));
- }
- public void testSetChars() {
- ITerminalTextData term=makeITerminalTextData();
- term.setDimensions(6, 3);
- for (int line = 0; line < term.getHeight(); line++) {
- char[] chars=new char[term.getWidth()];
- for (int column = 0; column < term.getWidth(); column++) {
- chars[column]=(char)('a'+column+line);
- }
- term.setChars(line, 0, chars, null);
- }
- for (int line = 0; line < term.getHeight(); line++) {
- for (int column = 0; column < term.getWidth(); column++) {
- char c=(char)('a'+column+line);
- assertEquals(c, term.getChar(line,column));
- }
- }
- assertEqualsTerm(
- "abc\n"
- + "bcd\n"
- + "cde\n"
- + "def\n"
- + "efg\n"
- + "fgh", toMultiLineText(term));
-
- term.setChars(3, 1, new char[]{'1','2'}, null);
- assertEqualsTerm(
- "abc\n"
- + "bcd\n"
- + "cde\n"
- + "d12\n"
- + "efg\n"
- + "fgh", toMultiLineText(term));
- try {
- // check if we cannot exceed the range
- term.setChars(4, 1, new char[]{'1','2','3','4','5'}, null);
- fail();
- } catch (RuntimeException e) {}
-
- }
- public void testSetCharsLen() {
- ITerminalTextData term=makeITerminalTextData();
- String s= "ZYXWVU\n"
- + "abcdef\n"
- + "ABCDEF";
- fill(term, s);
- char[] chars=new char[]{'1','2','3','4','5','6','7','8'};
- term.setChars(1, 0, chars, 0, 6,null);
- assertEqualsTerm(
- "ZYXWVU\n"
- + "123456\n"
- + "ABCDEF", toMultiLineText(term));
-
- fill(term, s);
- term.setChars(1, 0, chars, 0, 5, null);
- assertEqualsTerm("ZYXWVU\n"
- + "12345f\n"
- + "ABCDEF", toMultiLineText(term));
-
- fill(term, s);
- term.setChars(1, 0, chars, 1, 5, null);
- assertEqualsTerm("ZYXWVU\n"
- + "23456f\n"
- + "ABCDEF", toMultiLineText(term));
-
- fill(term, s);
- term.setChars(1, 1, chars, 1, 4, null);
- assertEqualsTerm("ZYXWVU\n"
- + "a2345f\n"
- + "ABCDEF", toMultiLineText(term));
-
-
-
- fill(term, s);
- term.setChars(1, 2, chars, 3, 4, null);
- assertEqualsTerm("ZYXWVU\n"
- + "ab4567\n"
- + "ABCDEF", toMultiLineText(term));
-
- fill(term, s);
- try {
- term.setChars(1, 0, chars, 7, 10, null);
- fail();
- } catch (RuntimeException e) {}
- fill(term, s);
- try {
- term.setChars(1, -1, chars, 0, 2, null);
- fail();
- } catch (RuntimeException e) {}
- try {
- term.setChars(-1, 1, chars, 0, 2, null);
- fail();
- } catch (RuntimeException e) {}
- try {
- term.setChars(1, 10, chars, 0, 2, null);
- fail();
- } catch (RuntimeException e) {}
- try {
- term.setChars(10, 1, chars, 0, 2, null);
- fail();
- } catch (RuntimeException e) {}
-// assertEquals(s, toSimpleText(term));
- }
- public void testSetCopyInto() {
- ITerminalTextData term=makeITerminalTextData();
- term.setDimensions(3, 5);
- String s="12345\n" +
- "abcde\n" +
- "ABCDE";
- fill(term,0,0,s);
- ITerminalTextData termCopy=makeITerminalTextData();
- termCopy.copy(term);
- assertEqualsTerm(s, toMultiLineText(termCopy));
- assertEqualsTerm(s, toMultiLineText(term));
-
- termCopy.setChar(1, 1, 'X', null);
- assertEqualsTerm(s, toMultiLineText(term));
- term.setDimensions(2, 4);
- assertEquals(5, termCopy.getWidth());
- assertEquals(3, termCopy.getHeight());
-
- assertEqualsTerm("12345\n" +
- "aXcde\n" +
- "ABCDE", toMultiLineText(termCopy));
-
- assertEquals(4, term.getWidth());
- assertEquals(2, term.getHeight());
- }
- public void testSetCopyLines() {
- ITerminalTextData term=makeITerminalTextData();
- String s="012345";
- fillSimple(term, s);
- ITerminalTextData termCopy=makeITerminalTextData();
- String sCopy="abcde";
- fillSimple(termCopy, sCopy);
- termCopy.copyRange(term,0,0,0);
- assertEqualsSimple(s, toSimple(term));
- assertEqualsSimple(sCopy, toSimple(termCopy));
-
- fillSimple(termCopy, sCopy);
- termCopy.copyRange(term,0,0,5);
- assertEqualsSimple(s, toSimple(term));
- assertEqualsSimple("01234", toSimple(termCopy));
-
- fillSimple(termCopy, sCopy);
- termCopy.copyRange(term,0,0,2);
- assertEqualsSimple(s, toSimple(term));
- assertEqualsSimple("01cde", toSimple(termCopy));
-
- fillSimple(termCopy, sCopy);
- termCopy.copyRange(term,0,1,2);
- assertEqualsSimple(s, toSimple(term));
- assertEqualsSimple("a01de", toSimple(termCopy));
-
- fillSimple(termCopy, sCopy);
- termCopy.copyRange(term,1,1,2);
- assertEqualsSimple(s, toSimple(term));
- assertEqualsSimple("a12de", toSimple(termCopy));
-
- fillSimple(termCopy, sCopy);
- termCopy.copyRange(term,1,1,4);
- assertEqualsSimple(s, toSimple(term));
- assertEqualsSimple("a1234", toSimple(termCopy));
-
- fillSimple(termCopy, sCopy);
- termCopy.copyRange(term,2,1,4);
- assertEqualsSimple(s, toSimple(term));
- assertEqualsSimple("a2345", toSimple(termCopy));
-
- try {
- fillSimple(termCopy, sCopy);
- termCopy.copyRange(term,1,1,5);
- fail();
- } catch (RuntimeException e) {}
- try {
- fillSimple(termCopy, sCopy);
- termCopy.copyRange(term,0,0,6);
- fail();
- } catch (RuntimeException e) {}
- try {
- fillSimple(termCopy, sCopy);
- termCopy.copyRange(term,7,0,1);
- fail();
- } catch (RuntimeException e) {}
- try {
- fillSimple(termCopy, sCopy);
- termCopy.copyRange(term,0,7,1);
- fail();
- } catch (RuntimeException e) {}
- }
- public void testCopyLine() {
- ITerminalTextData term=makeITerminalTextData();
- String s=
- "111\n" +
- "222\n" +
- "333\n" +
- "444\n" +
- "555";
- fill(term, s);
- ITerminalTextData dest=makeITerminalTextData();
- String sCopy=
- "aaa\n" +
- "bbb\n" +
- "ccc\n" +
- "ddd\n" +
- "eee";
- fill(dest, sCopy);
- copySelective(dest,term,0,0,new boolean []{true,true,false,false,true});
- assertEqualsTerm(s, toMultiLineText(term));
- assertEqualsTerm(
- "111\n" +
- "222\n" +
- "ccc\n" +
- "ddd\n" +
- "555", toMultiLineText(dest));
-
- fill(dest, sCopy);
- copySelective(dest,term,0,0,new boolean []{true,true,true,true,true});
- assertEqualsTerm(s, toMultiLineText(term));
- assertEqualsTerm(s, toMultiLineText(dest));
-
- fill(dest, sCopy);
- copySelective(dest,term,0,0,new boolean []{false,false,false,false,false});
- assertEqualsTerm(s, toMultiLineText(term));
- assertEqualsTerm(sCopy, toMultiLineText(dest));
- }
- protected void copySelective(ITerminalTextData dest, ITerminalTextData source, int sourceStartLine, int destStartLine, boolean[] linesToCopy) {
- for (int i = 0; i < linesToCopy.length; i++) {
- if(linesToCopy[i]) {
- dest.copyLine(source, i+sourceStartLine, i+destStartLine);
- }
- }
- }
-
- public void testCopyLineWithOffset() {
- ITerminalTextData term=makeITerminalTextData();
- String s=
- "111\n" +
- "222\n" +
- "333\n" +
- "444\n" +
- "555";
- fill(term, s);
- ITerminalTextData dest=makeITerminalTextData();
- String sCopy=
- "aaa\n" +
- "bbb\n" +
- "ccc\n" +
- "ddd\n" +
- "eee";
- fill(dest, sCopy);
- copySelective(dest,term,1,0,new boolean []{true,false,false,true});
- assertEqualsTerm(s, toMultiLineText(term));
- assertEqualsTerm(
- "222\n" +
- "bbb\n" +
- "ccc\n" +
- "555\n" +
- "eee", toMultiLineText(dest));
-
- fill(dest, sCopy);
- copySelective(dest,term,2,0,new boolean []{true,true});
- assertEqualsTerm(s, toMultiLineText(term));
- assertEqualsTerm(
- "333\n" +
- "444\n" +
- "ccc\n" +
- "ddd\n" +
- "eee", toMultiLineText(dest));
-
- fill(dest, sCopy);
- copySelective(dest,term,0,0,new boolean []{true,true,true,true,true});
- assertEqualsTerm(s, toMultiLineText(term));
- assertEqualsTerm(s, toMultiLineText(dest));
-
- fill(dest, sCopy);
- copySelective(dest,term,0,0,new boolean []{false,false,false,false,false});
- assertEqualsTerm(s, toMultiLineText(term));
- assertEqualsTerm(sCopy, toMultiLineText(dest));
- }
- public void testScrollNoop() {
- scrollTest(0,0,0, "012345","012345");
- scrollTest(0,1,0, "012345","012345");
- scrollTest(0,6,0, "012345","012345");
- }
- public void testScrollAll() {
- scrollTest(0,6,1, "012345"," 01234");
- scrollTest(0,6,-1, "012345","12345 ");
- scrollTest(0,6,2, "012345"," 0123");
- scrollTest(0,6,-2, "012345","2345 ");
- }
- public void testScrollNegative() {
- scrollTest(0,2,-1,"012345","1 2345");
- scrollTest(0,1,-1,"012345"," 12345");
- scrollTest(0,6,-1,"012345","12345 ");
- scrollTest(0,6,-6,"012345"," ");
- scrollTest(0,6,-7,"012345"," ");
- scrollTest(0,6,-8,"012345"," ");
- scrollTest(0,6,-2,"012345","2345 ");
- scrollTest(1,1,-1,"012345","0 2345");
- scrollTest(1,1,-1,"012345","0 2345");
- scrollTest(1,2,-1,"012345","02 345");
- scrollTest(5,1,-1,"012345","01234 ");
- scrollTest(5,1,-1,"012345","01234 ");
- }
- public void testScrollNegative2() {
- scrollTest(0,2,-1," 23 "," 23 ");
- scrollTest(0,1,-1," 23 "," 23 ");
- scrollTest(0,6,-1," 23 "," 23 ");
- scrollTest(0,6,-6," 23 "," ");
- scrollTest(0,6,-7," 23 "," ");
- scrollTest(0,6,-8," 23 "," ");
- scrollTest(0,6,-2," 23 ","23 ");
- scrollTest(1,1,-1," 23 "," 23 ");
- scrollTest(1,2,-1," 23 "," 2 3 ");
- scrollTest(5,1,-1," 23 "," 23 ");
- scrollTest(5,1,-1," 23 "," 23 ");
- }
- public void testScrollNegative3() {
- scrollTest(1,5,-7,"012345","0 ");
- }
- public void testScrollPositive2() {
- scrollTest(2,8,20, "0123456789", "01 ");
- }
- public void testScrollPositive() {
- scrollTest(0,2,1, "012345", " 02345");
- scrollTest(0,2,2, "012345", " 2345");
- scrollTest(2,4,2, "012345", "01 23");
- scrollTest(2,4,2, "0123456", "01 236");
- scrollTest(0,7,6, "0123456", " 0");
- scrollTest(0,7,8, "0123456", " ");
- scrollTest(0,7,9, "0123456", " ");
- scrollTest(2,4,2, "0123456", "01 236");
- scrollTest(2,5,3, "0123456789", "01 23789");
- scrollTest(2,7,3, "0123456789", "01 23459");
- scrollTest(2,8,3, "0123456789", "01 23456");
- scrollTest(2,8,5, "0123456789", "01 234");
- scrollTest(2,8,9, "0123456789", "01 ");
- scrollTest(0,10,9,"0123456789", " 0");
- scrollTest(0,6,6, "012345", " ");
- }
- public void testScrollFail() {
- try {
- scrollTest(5,2,-1,"012345","012345");
- fail();
- } catch (RuntimeException e) {
- }
- try {
- scrollTest(0,7,1,"012345"," ");
- fail();
- } catch (RuntimeException e) {
- }
- }
- /**
- * Makes a simple shift test
- * @param line scroll start
- * @param n number of lines to be scrolled
- * @param shift amount of lines to be shifted
- * @param start the original data
- * @param result the expected result
- */
- void scrollTest(int line,int n, int shift, String start,String result) {
- ITerminalTextData term=makeITerminalTextData();
- fillSimple(term,start);
- term.scroll(line, n, shift);
- assertEqualsSimple(result, toSimple(term));
-
- }
-}
diff --git a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/AllTests.java b/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/AllTests.java
deleted file mode 100644
index f0101879f..000000000
--- a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/AllTests.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tm.internal.terminal.model;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- * Internal Terminal Model test cases.
- * Runs in internal model package to allow access to default visible items.
- */
-public class AllTests extends TestCase {
- public AllTests() {
- super(null);
- }
-
- public AllTests(String name) {
- super(name);
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite(AllTests.class.getName());
- suite.addTestSuite(SnapshotChangesTest.class);
- suite.addTestSuite(SynchronizedTerminalTextDataTest.class);
- suite.addTestSuite(TerminalTextDataFastScrollTest.class);
- suite.addTestSuite(TerminalTextDataFastScrollTestMaxHeigth.class);
- suite.addTestSuite(TerminalTextDataPerformanceTest.class);
- suite.addTestSuite(TerminalTextDataSnapshotTest.class);
- suite.addTestSuite(TerminalTextDataSnapshotWindowTest.class);
- suite.addTestSuite(TerminalTextDataStoreTest.class);
- suite.addTestSuite(TerminalTextDataTest.class);
- suite.addTestSuite(TerminalTextDataWindowTest.class);
- return suite;
- }
-
-}
diff --git a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/SnapshotChangesTest.java b/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/SnapshotChangesTest.java
deleted file mode 100644
index 464f0d711..000000000
--- a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/SnapshotChangesTest.java
+++ /dev/null
@@ -1,679 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Michael Scharf (Wind River) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tm.internal.terminal.model;
-
-import org.eclipse.tm.terminal.model.ITerminalTextData;
-
-import junit.framework.TestCase;
-
-public class SnapshotChangesTest extends TestCase {
- /**
- * @param change
- * @param expected a string of 0 and 1 (1 means changed)
- */
- void assertChangedLines(ISnapshotChanges change, String expected) {
- StringBuffer buffer=new StringBuffer();
- for (int line = 0; line < expected.length(); line++) {
- if(change.hasLineChanged(line))
- buffer.append('1');
- else
- buffer.append('0');
- }
- assertEquals(expected, buffer.toString());
- }
-
- public void testSnapshotChanges() {
- SnapshotChanges changes=new SnapshotChanges(1);
- assertEquals(0, changes.getInterestWindowStartLine());
- assertEquals(0, changes.getInterestWindowSize());
- }
- public void testSnapshotChangesWithWindow() {
- SnapshotChanges changes=new SnapshotChanges(2,5);
- assertEquals(2, changes.getInterestWindowStartLine());
- assertEquals(5, changes.getInterestWindowSize());
- }
-
- public void testIsInInterestWindowIntInt() {
- SnapshotChanges changes=new SnapshotChanges(2,5);
- assertFalse(changes.isInInterestWindow(0, 1));
- assertFalse(changes.isInInterestWindow(0, 2));
- assertTrue(changes.isInInterestWindow(0, 3));
- assertTrue(changes.isInInterestWindow(0, 4));
- assertTrue(changes.isInInterestWindow(0, 5));
- assertTrue(changes.isInInterestWindow(0, 6));
- assertTrue(changes.isInInterestWindow(0, 10));
- assertTrue(changes.isInInterestWindow(2, 5));
- assertTrue(changes.isInInterestWindow(6, 0));
- assertTrue(changes.isInInterestWindow(6, 1));
- assertTrue(changes.isInInterestWindow(6, 10));
- assertFalse(changes.isInInterestWindow(7, 0));
- assertFalse(changes.isInInterestWindow(7, 1));
- assertFalse(changes.isInInterestWindow(8, 10));
- }
- public void testIsInInterestWindowIntIntNoWindow() {
- SnapshotChanges changes=new SnapshotChanges(3);
- for (int i = 0; i < 5; i++) {
- for (int j = 0; j < 5; j++) {
- assertTrue(changes.isInInterestWindow(i,j));
- }
- }
- }
-
- public void testIsInInterestWindowInt() {
- SnapshotChanges changes=new SnapshotChanges(3,1);
- assertFalse(changes.isInInterestWindow(0));
- assertFalse(changes.isInInterestWindow(1));
- assertFalse(changes.isInInterestWindow(2));
- assertTrue(changes.isInInterestWindow(3));
- assertFalse(changes.isInInterestWindow(4));
- assertFalse(changes.isInInterestWindow(5));
- }
-
- public void testIsInInterestWindowIntNoWindow() {
- SnapshotChanges changes=new SnapshotChanges(3);
- for (int i = 0; i < 10; i++) {
- assertTrue(changes.isInInterestWindow(i));
- }
- }
-
- public void testFitLineToWindow() {
- SnapshotChanges changes=new SnapshotChanges(2,5);
- assertEquals(2, changes.fitLineToWindow(0));
- assertEquals(2, changes.fitLineToWindow(1));
- assertEquals(2, changes.fitLineToWindow(2));
- assertEquals(3, changes.fitLineToWindow(3));
-
- assertTrue(changes.isInInterestWindow(4));
- assertEquals(4, changes.fitLineToWindow(4));
-
- assertTrue(changes.isInInterestWindow(5));
- assertEquals(5, changes.fitLineToWindow(5));
-
- assertTrue(changes.isInInterestWindow(6));
- assertEquals(6, changes.fitLineToWindow(6));
-
- assertFalse(changes.isInInterestWindow(7));
- // value undefined!
- assertEquals(7, changes.fitLineToWindow(7));
-
- assertFalse(changes.isInInterestWindow(8));
- // value undefined!
- assertEquals(8, changes.fitLineToWindow(8));
- }
-
- public void testFitLineToWindowNoWindow() {
- SnapshotChanges changes=new SnapshotChanges(5);
- assertEquals(0, changes.fitLineToWindow(0));
- assertEquals(1, changes.fitLineToWindow(1));
- assertEquals(2, changes.fitLineToWindow(2));
- assertEquals(3, changes.fitLineToWindow(3));
- assertEquals(4, changes.fitLineToWindow(4));
- assertEquals(5, changes.fitLineToWindow(5));
- assertEquals(6, changes.fitLineToWindow(6));
- assertEquals(7, changes.fitLineToWindow(7));
- }
- public void testFitSizeToWindow() {
- SnapshotChanges changes=new SnapshotChanges(2,3);
- assertFalse(changes.isInInterestWindow(0, 1));
- assertFalse(changes.isInInterestWindow(0, 2));
- assertTrue(changes.isInInterestWindow(0, 3));
- assertEquals(1, changes.fitSizeToWindow(0,3));
- assertEquals(2, changes.fitSizeToWindow(0,4));
- assertEquals(3, changes.fitSizeToWindow(0,5));
- assertEquals(3, changes.fitSizeToWindow(0,6));
- assertEquals(3, changes.fitSizeToWindow(0,7));
- assertEquals(3, changes.fitSizeToWindow(0,8));
- assertEquals(3, changes.fitSizeToWindow(0,9));
- assertEquals(3, changes.fitSizeToWindow(1,9));
- assertEquals(3, changes.fitSizeToWindow(2,9));
- assertEquals(3, changes.fitSizeToWindow(2,3));
- assertEquals(2, changes.fitSizeToWindow(2,2));
- assertEquals(1, changes.fitSizeToWindow(2,1));
- assertEquals(2, changes.fitSizeToWindow(3,9));
- assertEquals(2, changes.fitSizeToWindow(3,2));
- assertEquals(1, changes.fitSizeToWindow(3,1));
- assertEquals(2, changes.fitSizeToWindow(3,2));
- assertEquals(2, changes.fitSizeToWindow(3,3));
- assertEquals(1, changes.fitSizeToWindow(4,1));
- assertEquals(1, changes.fitSizeToWindow(4,2));
- assertFalse(changes.isInInterestWindow(5, 1));
-
- }
- public void testFitSizeToWindowNoWindow() {
- SnapshotChanges changes=new SnapshotChanges(3);
- assertEquals(1, changes.fitSizeToWindow(0,1));
- assertEquals(2, changes.fitSizeToWindow(0,2));
- assertEquals(3, changes.fitSizeToWindow(0,3));
- assertEquals(4, changes.fitSizeToWindow(0,4));
- assertEquals(5, changes.fitSizeToWindow(0,5));
-
- assertEquals(5, changes.fitSizeToWindow(1,5));
- assertEquals(3, changes.fitSizeToWindow(2,3));
- assertEquals(2, changes.fitSizeToWindow(1,2));
- assertEquals(10, changes.fitSizeToWindow(5,10));
- }
-
- public void testMarkLineChanged() {
- SnapshotChanges changes=new SnapshotChanges(2,3);
- assertFalse(changes.hasChanged());
- changes.markLineChanged(0);
- assertFalse(changes.hasChanged());
- changes.markLineChanged(1);
- assertFalse(changes.hasChanged());
- changes.markLineChanged(2);
- assertTrue(changes.hasChanged());
-
- changes=new SnapshotChanges(2,3);
- assertFalse(changes.hasChanged());
- changes.markLineChanged(3);
- assertTrue(changes.hasChanged());
-
- assertLineChange(false,2,3,0);
- assertLineChange(false,2,3,1);
- assertLineChange(true,2,3,2);
- assertLineChange(true,2,3,3);
- assertLineChange(true,2,3,4);
- assertLineChange(false,2,3,5);
- assertLineChange(false,2,3,6);
-
- assertLineChange(true,2,4,5);
- }
- void assertLineChange(boolean expected, int windowStart, int windowSize, int changedLine) {
- SnapshotChanges changes=new SnapshotChanges(windowStart,windowSize);
- assertFalse(changes.hasChanged());
- changes.markLineChanged(changedLine);
- if(expected) {
- assertEquals(changedLine, changes.getFirstChangedLine());
- assertEquals(changedLine, changes.getLastChangedLine());
- } else {
- assertEquals(Integer.MAX_VALUE, changes.getFirstChangedLine());
- assertEquals(-1, changes.getLastChangedLine());
-
- }
- assertEquals(expected,changes.hasChanged());
- for (int i = 0; i < windowStart+windowSize+5; i++) {
- boolean e= i==changedLine && i>=windowStart && i<windowStart+windowSize;
- assertEquals(e, changes.hasLineChanged(i));
- }
-
- }
- public void testMarkLinesChanged() {
- SnapshotChanges changes=new SnapshotChanges(2,3);
- assertFalse(changes.hasChanged());
- assertEquals(Integer.MAX_VALUE, changes.getFirstChangedLine());
- assertEquals(-1, changes.getLastChangedLine());
- changes.markLinesChanged(0, 1);
- assertChangedLines(changes, "00000000000");
- assertFalse(changes.hasChanged());
- assertEquals(Integer.MAX_VALUE, changes.getFirstChangedLine());
- assertEquals(-1, changes.getLastChangedLine());
- changes.markLinesChanged(0, 2);
- assertChangedLines(changes, "00000000000");
- assertFalse(changes.hasChanged());
- assertEquals(Integer.MAX_VALUE, changes.getFirstChangedLine());
- assertEquals(-1, changes.getLastChangedLine());
- changes.markLinesChanged(0, 3);
- assertEquals(2, changes.getFirstChangedLine());
- assertEquals(2, changes.getLastChangedLine());
- assertTrue(changes.hasChanged());
- assertChangedLines(changes, "00100000000");
-
- changes=new SnapshotChanges(2,3);
- changes.markLinesChanged(1, 3);
- assertTrue(changes.hasChanged());
- assertEquals(2, changes.getFirstChangedLine());
- assertEquals(3, changes.getLastChangedLine());
- assertChangedLines(changes, "00110000000");
-
- changes=new SnapshotChanges(2,3);
- changes.markLinesChanged(1, 4);
- assertEquals(2, changes.getFirstChangedLine());
- assertEquals(4, changes.getLastChangedLine());
- assertTrue(changes.hasChanged());
- assertChangedLines(changes, "00111000000");
-
- changes=new SnapshotChanges(2,3);
- changes.markLinesChanged(1, 4);
- assertEquals(2, changes.getFirstChangedLine());
- assertEquals(4, changes.getLastChangedLine());
- assertTrue(changes.hasChanged());
- assertChangedLines(changes, "00111000000");
-
- changes=new SnapshotChanges(2,3);
- changes.markLinesChanged(2, 4);
- assertEquals(2, changes.getFirstChangedLine());
- assertEquals(4, changes.getLastChangedLine());
- assertTrue(changes.hasChanged());
- assertChangedLines(changes, "00111000000");
-
-
- changes=new SnapshotChanges(2,3);
- changes.markLinesChanged(3, 4);
- assertEquals(3, changes.getFirstChangedLine());
- assertEquals(4, changes.getLastChangedLine());
- assertTrue(changes.hasChanged());
- assertChangedLines(changes, "00011000000");
-
- changes=new SnapshotChanges(2,3);
- changes.markLinesChanged(3, 1);
- assertEquals(3, changes.getFirstChangedLine());
- assertEquals(3, changes.getLastChangedLine());
- assertTrue(changes.hasChanged());
- assertChangedLines(changes, "00010000000");
-
- changes=new SnapshotChanges(2,3);
- changes.markLinesChanged(4, 1);
- assertEquals(4, changes.getFirstChangedLine());
- assertEquals(4, changes.getLastChangedLine());
- assertTrue(changes.hasChanged());
- assertChangedLines(changes, "00001000000");
-
- changes=new SnapshotChanges(2,3);
- changes.markLinesChanged(5, 1);
- assertEquals(Integer.MAX_VALUE, changes.getFirstChangedLine());
- assertEquals(-1, changes.getLastChangedLine());
- assertFalse(changes.hasChanged());
- assertChangedLines(changes, "00000000000");
- }
- public void testMarkLinesChangedNoWindow() {
- SnapshotChanges changes=new SnapshotChanges(10);
- assertFalse(changes.hasChanged());
- assertEquals(Integer.MAX_VALUE, changes.getFirstChangedLine());
- assertEquals(-1, changes.getLastChangedLine());
-
- changes.markLinesChanged(0, 1);
- assertTrue(changes.hasChanged());
- assertEquals(0, changes.getFirstChangedLine());
- assertEquals(0, changes.getLastChangedLine());
- assertChangedLines(changes, "1000000000");
-
- changes=new SnapshotChanges(10);
- changes.markLinesChanged(0, 5);
- assertTrue(changes.hasChanged());
- assertEquals(0, changes.getFirstChangedLine());
- assertEquals(4, changes.getLastChangedLine());
- assertChangedLines(changes, "1111100000");
-
- changes=new SnapshotChanges(3);
- changes.markLinesChanged(1, 6);
- assertTrue(changes.hasChanged());
- assertEquals(1, changes.getFirstChangedLine());
- assertEquals(6, changes.getLastChangedLine());
- assertChangedLines(changes, "011");
-
-
- changes=new SnapshotChanges(10);
- changes.markLinesChanged(5, 6);
- assertTrue(changes.hasChanged());
- assertEquals(5, changes.getFirstChangedLine());
- assertEquals(10, changes.getLastChangedLine());
- assertChangedLines(changes, "0000011111");
-
- }
-
- public void testHasChanged() {
- SnapshotChanges changes=new SnapshotChanges(0);
- assertFalse(changes.hasChanged());
- changes=new SnapshotChanges(1);
- assertFalse(changes.hasChanged());
- changes=new SnapshotChanges(1,9);
- assertFalse(changes.hasChanged());
- }
-
- public void testSetAllChanged() {
- SnapshotChanges changes;
- changes=new SnapshotChanges(2,3);
- changes.setAllChanged(10);
- assertEquals(2, changes.getFirstChangedLine());
- assertEquals(4, changes.getLastChangedLine());
- assertTrue(changes.hasChanged());
- assertChangedLines(changes, "00111000000");
-
- changes=new SnapshotChanges(2,3);
- changes.setAllChanged(3);
- assertEquals(2, changes.getFirstChangedLine());
- assertEquals(2, changes.getLastChangedLine());
- assertTrue(changes.hasChanged());
- assertChangedLines(changes, "00111000000");
-
- changes=new SnapshotChanges(2,3);
- changes.setAllChanged(4);
- assertEquals(2, changes.getFirstChangedLine());
- assertEquals(3, changes.getLastChangedLine());
- assertTrue(changes.hasChanged());
- assertChangedLines(changes, "00111000000");
-
- changes=new SnapshotChanges(2,3);
- changes.setAllChanged(5);
- assertEquals(2, changes.getFirstChangedLine());
- assertEquals(4, changes.getLastChangedLine());
- assertTrue(changes.hasChanged());
- assertChangedLines(changes, "00111000000");
-
- changes=new SnapshotChanges(2,3);
- changes.setAllChanged(6);
- assertEquals(2, changes.getFirstChangedLine());
- assertEquals(4, changes.getLastChangedLine());
- assertTrue(changes.hasChanged());
- assertChangedLines(changes, "00111000000");
- }
- public void testSetAllChangedNoWindow() {
- SnapshotChanges changes;
- changes=new SnapshotChanges(5);
- changes.setAllChanged(10);
- assertEquals(0, changes.getFirstChangedLine());
- assertEquals(9, changes.getLastChangedLine());
- assertTrue(changes.hasChanged());
- assertChangedLines(changes, "1111111111");
-
- changes=new SnapshotChanges(5);
- changes.setAllChanged(3);
- assertEquals(0, changes.getFirstChangedLine());
- assertEquals(2, changes.getLastChangedLine());
- assertTrue(changes.hasChanged());
- assertChangedLines(changes, "1111111111");
-
- }
-
- public void testConvertScrollingIntoChanges() {
- SnapshotChanges changes;
- changes=new SnapshotChanges(2,3);
- changes.scroll(0, 4, -1);
- assertTrue(changes.hasChanged());
- assertChangedLines(changes, "000100");
- changes.convertScrollingIntoChanges();
- assertEquals(2, changes.getFirstChangedLine());
- assertEquals(3, changes.getLastChangedLine());
- assertEquals(0, changes.getScrollWindowStartLine());
- assertEquals(0, changes.getScrollWindowSize());
- assertEquals(0, changes.getScrollWindowShift());
- assertChangedLines(changes, "001100");
- }
-
- public void testConvertScrollingIntoChangesNoWindow() {
- SnapshotChanges changes;
- changes=new SnapshotChanges(7);
- changes.scroll(0, 4, -1);
- assertTrue(changes.hasChanged());
- assertChangedLines(changes, "000100");
- changes.convertScrollingIntoChanges();
- assertEquals(0, changes.getFirstChangedLine());
- assertEquals(3, changes.getLastChangedLine());
- assertEquals(0, changes.getScrollWindowStartLine());
- assertEquals(0, changes.getScrollWindowSize());
- assertEquals(0, changes.getScrollWindowShift());
- assertChangedLines(changes, "111100");
- }
- public void testScrollNoWindow() {
- SnapshotChanges changes;
- changes=new SnapshotChanges(7);
- changes.scroll(0, 3, -2);
- assertEquals(1, changes.getFirstChangedLine());
- assertEquals(2, changes.getLastChangedLine());
- assertEquals(0, changes.getScrollWindowStartLine());
- assertEquals(3, changes.getScrollWindowSize());
- assertEquals(-2, changes.getScrollWindowShift());
- assertTrue(changes.hasChanged());
- assertChangedLines(changes, "0110000");
-
- changes=new SnapshotChanges(7);
- changes.scroll(0, 3, -1);
- changes.scroll(0, 3, -1);
- assertEquals(1, changes.getFirstChangedLine());
- assertEquals(2, changes.getLastChangedLine());
- assertEquals(0, changes.getScrollWindowStartLine());
- assertEquals(3, changes.getScrollWindowSize());
- assertEquals(-2, changes.getScrollWindowShift());
- assertTrue(changes.hasChanged());
- assertChangedLines(changes, "0110000");
-
- changes=new SnapshotChanges(7);
- changes.scroll(0, 7, -1);
- changes.scroll(0, 7, -1);
- assertEquals(5, changes.getFirstChangedLine());
- assertEquals(6, changes.getLastChangedLine());
- assertEquals(0, changes.getScrollWindowStartLine());
- assertEquals(7, changes.getScrollWindowSize());
- assertEquals(-2, changes.getScrollWindowShift());
- assertTrue(changes.hasChanged());
- assertChangedLines(changes, "0000011");
-
- // positive scrolls cannot be optimized at the moment
- changes=new SnapshotChanges(7);
- changes.scroll(0, 7, 1);
- changes.scroll(0, 7, 1);
- assertEquals(0, changes.getFirstChangedLine());
- assertEquals(6, changes.getLastChangedLine());
- assertEquals(0, changes.getScrollWindowStartLine());
- assertEquals(0, changes.getScrollWindowSize());
- assertEquals(0, changes.getScrollWindowShift());
- assertTrue(changes.hasChanged());
- assertChangedLines(changes, "1111111");
-
- }
- public void testScroll() {
- SnapshotChanges changes;
- changes=new SnapshotChanges(2,3);
- changes.scroll(0, 7, -1);
- assertEquals(4, changes.getFirstChangedLine());
- assertEquals(4, changes.getLastChangedLine());
- assertEquals(2, changes.getScrollWindowStartLine());
- assertEquals(3, changes.getScrollWindowSize());
- assertEquals(-1, changes.getScrollWindowShift());
- assertTrue(changes.hasChanged());
- assertChangedLines(changes, "0000100000");
-
- changes=new SnapshotChanges(2,3);
- changes.scroll(0, 7, -2);
- assertEquals(3, changes.getFirstChangedLine());
- assertEquals(4, changes.getLastChangedLine());
- assertEquals(2, changes.getScrollWindowStartLine());
- assertEquals(3, changes.getScrollWindowSize());
- assertEquals(-2, changes.getScrollWindowShift());
- assertTrue(changes.hasChanged());
- assertChangedLines(changes, "0001100000");
- }
- public void testScrollNergative() {
- SnapshotChanges changes;
- changes=new SnapshotChanges(2,3);
- changes.scroll(0, 7, -1);
- changes.scroll(0, 7, -1);
- assertEquals(3, changes.getFirstChangedLine());
- assertEquals(4, changes.getLastChangedLine());
- assertEquals(2, changes.getScrollWindowStartLine());
- assertEquals(3, changes.getScrollWindowSize());
- assertEquals(-2, changes.getScrollWindowShift());
- assertTrue(changes.hasChanged());
- assertChangedLines(changes, "0001100000");
-
- }
- public void testScrollPositive() {
- SnapshotChanges changes;
- changes=new SnapshotChanges(2,3);
- changes.scroll(0, 7, 1);
- changes.scroll(0, 7, 1);
- assertEquals(2, changes.getFirstChangedLine());
- assertEquals(4, changes.getLastChangedLine());
- assertEquals(0, changes.getScrollWindowStartLine());
- assertEquals(0, changes.getScrollWindowSize());
- assertEquals(0, changes.getScrollWindowShift());
- assertTrue(changes.hasChanged());
- assertChangedLines(changes, "0011100000");
-
- changes=new SnapshotChanges(2,3);
- changes.scroll(0, 3, 1);
- changes.scroll(0, 3, 1);
- assertEquals(2, changes.getFirstChangedLine());
- assertEquals(2, changes.getLastChangedLine());
- assertEquals(0, changes.getScrollWindowStartLine());
- assertEquals(0, changes.getScrollWindowSize());
- assertEquals(0, changes.getScrollWindowShift());
- assertTrue(changes.hasChanged());
- assertChangedLines(changes, "0010000000");
-
- changes=new SnapshotChanges(2,3);
- changes.scroll(0, 4, 1);
- changes.scroll(0, 4, 1);
- assertEquals(2, changes.getFirstChangedLine());
- assertEquals(3, changes.getLastChangedLine());
- assertEquals(0, changes.getScrollWindowStartLine());
- assertEquals(0, changes.getScrollWindowSize());
- assertEquals(0, changes.getScrollWindowShift());
- assertTrue(changes.hasChanged());
- assertChangedLines(changes, "0011000000");
-
- changes=new SnapshotChanges(2,3);
- changes.scroll(0, 5, 1);
- changes.scroll(0, 5, 1);
- assertEquals(2, changes.getFirstChangedLine());
- assertEquals(4, changes.getLastChangedLine());
- assertEquals(0, changes.getScrollWindowStartLine());
- assertEquals(0, changes.getScrollWindowSize());
- assertEquals(0, changes.getScrollWindowShift());
- assertTrue(changes.hasChanged());
- assertChangedLines(changes, "0011100000");
-
- changes=new SnapshotChanges(2,3);
- changes.scroll(3, 5, 1);
- changes.scroll(3, 5, 1);
- assertEquals(3, changes.getFirstChangedLine());
- assertEquals(4, changes.getLastChangedLine());
- assertEquals(0, changes.getScrollWindowStartLine());
- assertEquals(0, changes.getScrollWindowSize());
- assertEquals(0, changes.getScrollWindowShift());
- assertTrue(changes.hasChanged());
- assertChangedLines(changes, "0001100000");
- }
-
- public void testCopyChangedLines() {
- SnapshotChanges changes;
- changes=new SnapshotChanges(2,3);
- changes.markLineChanged(3);
- ITerminalTextData source=new TerminalTextDataStore();
- TerminalTextTestHelper.fillSimple(source, "01234567890");
- ITerminalTextData dest=new TerminalTextDataStore();
- TerminalTextTestHelper.fillSimple(dest, "abcdefghijk");
-
- changes.copyChangedLines(dest, source);
- assertEquals("abc3efghijk",TerminalTextTestHelper.toSimple(dest));
-
- changes=new SnapshotChanges(2,3);
- changes.setAllChanged(7);
- source=new TerminalTextDataStore();
- TerminalTextTestHelper.fillSimple(source, "01234567890");
- dest=new TerminalTextDataStore();
- TerminalTextTestHelper.fillSimple(dest, "abcdefghijk");
-
- changes.copyChangedLines(dest, source);
- assertEquals("ab234fghijk",TerminalTextTestHelper.toSimple(dest));
-
- changes=new SnapshotChanges(2,3);
- changes.scroll(0,7,-1);
- source=new TerminalTextDataStore();
- TerminalTextTestHelper.fillSimple(source, "01234567890");
- dest=new TerminalTextDataStore();
- TerminalTextTestHelper.fillSimple(dest, "abcdefghijk");
- // only one line has changed! The other lines are scrolled!
- assertChangedLines(changes,"00001000");
- changes.copyChangedLines(dest, source);
- assertEquals("abcd4fghijk",TerminalTextTestHelper.toSimple(dest));
- }
- public void testCopyChangedLinesWithSmallSource() {
- SnapshotChanges changes;
- changes=new SnapshotChanges(2,3);
- changes.markLineChanged(3);
- ITerminalTextData source=new TerminalTextDataStore();
- source.setDimensions(2, 2);
- TerminalTextDataWindow dest=new TerminalTextDataWindow();
- dest.setWindow(2, 2);
- changes.copyChangedLines(dest, source);
- }
- public void testCopyChangedLinesWithSmallSource1() {
- SnapshotChanges changes;
- changes=new SnapshotChanges(2,3);
- changes.markLineChanged(3);
- ITerminalTextData source=new TerminalTextDataStore();
- TerminalTextTestHelper.fillSimple(source, "01");
- ITerminalTextData dest=new TerminalTextDataStore();
- changes.copyChangedLines(dest, source);
- }
-
- public void testSetInterestWindowSize() {
- SnapshotChanges changes;
- changes=new SnapshotChanges(2,3);
- // move the window
- changes.setInterestWindow(3, 3);
- // only one line has changed! The other lines are scrolled!
- assertEquals(3, changes.getScrollWindowStartLine());
- assertEquals(3, changes.getScrollWindowSize());
- assertEquals(-1, changes.getScrollWindowShift());
-
- assertChangedLines(changes,"0000010");
- changes.convertScrollingIntoChanges();
- assertChangedLines(changes,"0001110");
-
- changes=new SnapshotChanges(2,3);
- // move the window
- changes.setInterestWindow(3, 4);
- // only one line has changed! The other lines are scrolled!
- assertEquals(3, changes.getScrollWindowStartLine());
- assertEquals(3, changes.getScrollWindowSize());
- assertEquals(-1, changes.getScrollWindowShift());
-
- assertChangedLines(changes,"0000011");
- changes.convertScrollingIntoChanges();
- assertChangedLines(changes,"0001111");
-
-
- changes=new SnapshotChanges(2,3);
- // move the window
- changes.setInterestWindow(6, 3);
- // cannot scroll
- assertEquals(0, changes.getScrollWindowStartLine());
- assertEquals(0, changes.getScrollWindowSize());
- assertEquals(0, changes.getScrollWindowShift());
- assertChangedLines(changes,"000000111000");
-
- changes=new SnapshotChanges(2,3);
- // expand the window
- changes.setInterestWindow(2, 5);
- // cannot scroll
- assertEquals(0, changes.getScrollWindowStartLine());
- assertEquals(0, changes.getScrollWindowSize());
- assertEquals(0, changes.getScrollWindowShift());
-
- assertChangedLines(changes,"0000011000");
- }
- public void testSetInterestWindowSize2() {
- SnapshotChanges changes;
- changes=new SnapshotChanges(2,3);
- // move the window
- changes.setInterestWindow(1, 3);
- assertChangedLines(changes,"0111000");
-
- changes=new SnapshotChanges(2,3);
- // move the window
- changes.setInterestWindow(1, 4);
- assertChangedLines(changes,"01111000");
-
-
- changes=new SnapshotChanges(2,3);
- // expand the window
- changes.setInterestWindow(6, 3);
- assertChangedLines(changes,"000000111000");
-
- changes=new SnapshotChanges(2,3);
- // expand the window
- changes.setInterestWindow(1, 2);
- assertChangedLines(changes,"0110000");
- }
-
-}
diff --git a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/SynchronizedTerminalTextDataTest.java b/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/SynchronizedTerminalTextDataTest.java
deleted file mode 100644
index 9b07bc7a2..000000000
--- a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/SynchronizedTerminalTextDataTest.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Michael Scharf (Wind River) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tm.internal.terminal.model;
-
-import org.eclipse.tm.terminal.model.ITerminalTextData;
-
-public class SynchronizedTerminalTextDataTest extends AbstractITerminalTextDataTest {
- protected ITerminalTextData makeITerminalTextData() {
- return new SynchronizedTerminalTextData(new TerminalTextData());
- }
-
-}
diff --git a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataFastScrollTest.java b/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataFastScrollTest.java
deleted file mode 100644
index 7379e5410..000000000
--- a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataFastScrollTest.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Michael Scharf (Wind River) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tm.internal.terminal.model;
-
-import org.eclipse.tm.terminal.model.ITerminalTextData;
-
-public class TerminalTextDataFastScrollTest extends AbstractITerminalTextDataTest {
- protected ITerminalTextData makeITerminalTextData() {
- return new TerminalTextDataFastScroll(3);
- }
-
-}
diff --git a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataFastScrollTestMaxHeigth.java b/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataFastScrollTestMaxHeigth.java
deleted file mode 100644
index f0cf227a7..000000000
--- a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataFastScrollTestMaxHeigth.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Michael Scharf (Wind River) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tm.internal.terminal.model;
-
-import org.eclipse.tm.terminal.model.ITerminalTextData;
-
-public class TerminalTextDataFastScrollTestMaxHeigth extends AbstractITerminalTextDataTest {
- protected ITerminalTextData makeITerminalTextData() {
- return new TerminalTextDataFastScroll(1);
- }
-
-}
diff --git a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataPerformanceTest.java b/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataPerformanceTest.java
deleted file mode 100644
index e010e77ab..000000000
--- a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataPerformanceTest.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Michael Scharf (Wind River) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tm.internal.terminal.model;
-
-import junit.framework.TestCase;
-
-import org.eclipse.tm.terminal.model.ITerminalTextData;
-import org.eclipse.tm.terminal.model.ITerminalTextDataSnapshot;
-import org.eclipse.tm.terminal.model.Style;
-import org.eclipse.tm.terminal.model.StyleColor;
-
-public class TerminalTextDataPerformanceTest extends TestCase {
- long TIME=100;
- private void initPerformance(ITerminalTextData term) {
- term.setDimensions(300,200);
- }
- public void testPerformance0() {
- ITerminalTextData term=new TerminalTextData();
- method0(term,"0 ");
- }
- public void testPerformance0a() {
- ITerminalTextData term=new TerminalTextData();
- ITerminalTextDataSnapshot snapshot=term.makeSnapshot();
- method0(term,"0a");
- snapshot.updateSnapshot(true);
- }
- public void testPerformance0b() {
- ITerminalTextData term=new TerminalTextData();
- ITerminalTextDataSnapshot snapshot=term.makeSnapshot();
- N=0;
- snapshot.addListener(new ITerminalTextDataSnapshot.SnapshotOutOfDateListener(){
- public void snapshotOutOfDate(ITerminalTextDataSnapshot snapshot) {
- N++;
- }});
- method0(term,"0b");
- snapshot.updateSnapshot(true);
- }
- private void method0(ITerminalTextData term, String label) {
- Style style=Style.getStyle(StyleColor.getStyleColor("fg"), StyleColor.getStyleColor("bg"), false, false, false, false);
- initPerformance(term);
- String s="This is a test string";
- long n=0;
- long t0=System.currentTimeMillis();
- for (int i = 0; i < 10000000; i++) {
- char c=s.charAt(i%s.length());
- for (int line = 0; line < term.getHeight(); line++) {
- for (int column = 0; column < term.getWidth(); column++) {
- term.setChar(line, column, c, style);
- n++;
- }
- }
- if(System.currentTimeMillis()-t0>TIME) {
- System.out.println(label+" "+(n*1000)/(System.currentTimeMillis()-t0)+" setChar()/sec "+ N);
- break;
- }
- }
- }
- public void testPerformance1() {
- ITerminalTextData term=new TerminalTextData();
- method1(term, "1 ");
- }
- public void testPerformance1a() {
- ITerminalTextData term=new TerminalTextData();
- ITerminalTextDataSnapshot snapshot=term.makeSnapshot();
- method1(term, "1a");
- snapshot.updateSnapshot(true);
- }
- public void testPerformance1b() {
- ITerminalTextData term=new TerminalTextData();
- ITerminalTextDataSnapshot snapshot=term.makeSnapshot();
- N=0;
- snapshot.addListener(new ITerminalTextDataSnapshot.SnapshotOutOfDateListener(){
- public void snapshotOutOfDate(ITerminalTextDataSnapshot snapshot) {
- N++;
- }});
- method1(term, "1b");
- snapshot.updateSnapshot(true);
- }
- private void method1(ITerminalTextData term, String label) {
- Style style=Style.getStyle(StyleColor.getStyleColor("fg"), StyleColor.getStyleColor("bg"), false, false, false, false);
- initPerformance(term);
- String s="This is a test string";
- long n=0;
- long t0=System.currentTimeMillis();
- char[] chars=new char[term.getWidth()];
- for (int i = 0; i < 10000000; i++) {
- for (int j = 0; j < chars.length; j++) {
- chars[j]=s.charAt((i+j)%s.length());
- }
- for (int line = 0; line < term.getHeight(); line++) {
- term.setChars(line, 0, chars, style);
- n+=chars.length;
- }
- if(System.currentTimeMillis()-t0>TIME) {
- System.out.println(label+" "+(n*1000)/(System.currentTimeMillis()-t0)+" setChars()/sec "+ N);
- break;
- }
- }
- }
- public void testPerformance2() {
- TerminalTextData term=new TerminalTextData();
- Style style=Style.getStyle(StyleColor.getStyleColor("fg"), StyleColor.getStyleColor("bg"), false, false, false, false);
- initPerformance(term);
- TerminalTextData copy=new TerminalTextData();
- copy.copy(term);
-
- String s="This is a test string";
- long n=0;
- long t0=System.currentTimeMillis();
- char[] chars=new char[term.getWidth()];
- for (int i = 0; i < 10000000; i++) {
- for (int j = 0; j < chars.length; j++) {
- chars[j]=s.charAt((i+j)%s.length());
- }
- for (int line = 0; line < term.getHeight(); line++) {
- term.setChars(line, 0, chars, 0,1,style);
- copy.copy(term);
- n+=1;
- if(System.currentTimeMillis()-t0>TIME) {
- System.out.println((n*1000)/(System.currentTimeMillis()-t0)+" copy()/sec");
- return;
- }
- }
- }
- }
- public void testPerformance2a() {
- TerminalTextData term=new TerminalTextData();
- ITerminalTextDataSnapshot snapshot=term.makeSnapshot();
- Style style=Style.getStyle(StyleColor.getStyleColor("fg"), StyleColor.getStyleColor("bg"), false, false, false, false);
- initPerformance(term);
- TerminalTextData copy=new TerminalTextData();
- copy.copy(term);
-
- String s="This is a test string";
- long n=0;
- long t0=System.currentTimeMillis();
- char[] chars=new char[term.getWidth()];
- for (int i = 0; i < 10000000; i++) {
- for (int j = 0; j < chars.length; j++) {
- chars[j]=s.charAt((i+j)%s.length());
- }
- for (int line = 0; line < term.getHeight(); line++) {
- term.setChars(line, 0, chars, 0,1,style);
- copy.copy(term);
- n+=1;
- if(System.currentTimeMillis()-t0>TIME) {
- System.out.println((n*1000)/(System.currentTimeMillis()-t0)+" copy()/sec");
- return;
- }
- }
- }
- snapshot.updateSnapshot(true);
- }
- int N=0;
- public void testPerformance2b() {
- TerminalTextData term=new TerminalTextData();
- ITerminalTextDataSnapshot snapshot=term.makeSnapshot();
- N=0;
- snapshot.addListener(new ITerminalTextDataSnapshot.SnapshotOutOfDateListener(){
- public void snapshotOutOfDate(ITerminalTextDataSnapshot snapshot) {
- N++;
- }});
- Style style=Style.getStyle(StyleColor.getStyleColor("fg"), StyleColor.getStyleColor("bg"), false, false, false, false);
- initPerformance(term);
- TerminalTextData copy=new TerminalTextData();
- copy.copy(term);
-
- String s="This is a test string";
- long n=0;
- long t0=System.currentTimeMillis();
- char[] chars=new char[term.getWidth()];
- for (int i = 0; i < 10000000; i++) {
- for (int j = 0; j < chars.length; j++) {
- chars[j]=s.charAt((i+j)%s.length());
- }
- for (int line = 0; line < term.getHeight(); line++) {
- term.setChars(line, 0, chars, 0,1,style);
- copy.copy(term);
- n+=1;
- if(System.currentTimeMillis()-t0>TIME) {
- System.out.println((n*1000)/(System.currentTimeMillis()-t0)+" copy()/sec "+n);
- return;
- }
- }
- }
- snapshot.updateSnapshot(true);
- }
- public void testPerformance3() {
- TerminalTextData term=new TerminalTextData();
- Style style=Style.getStyle(StyleColor.getStyleColor("fg"), StyleColor.getStyleColor("bg"), false, false, false, false);
- initPerformance(term);
- TerminalTextData copy=new TerminalTextData();
- copy.copy(term);
- String s="This is a test string";
- long n=0;
- long t0=System.currentTimeMillis();
- char[] chars=new char[term.getWidth()];
- for (int i = 0; i < 10000000; i++) {
- boolean[] linesToCopy=new boolean[term.getHeight()];
- for (int j = 0; j < chars.length; j++) {
- chars[j]=s.charAt((i+j)%s.length());
- }
- for (int line = 0; line < term.getHeight(); line++) {
- term.setChars(line, 0, chars, 0,1,style);
- linesToCopy[line]=true;
- copy.copyLine(term,0,0);
- linesToCopy[line]=false;
- n+=1;
- if(System.currentTimeMillis()-t0>TIME) {
- System.out.println((n*1000)/(System.currentTimeMillis()-t0)+" copy()/sec");
- return;
- }
- }
- }
- }
-}
diff --git a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataSnapshotTest.java b/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataSnapshotTest.java
deleted file mode 100644
index d6e68ef4e..000000000
--- a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataSnapshotTest.java
+++ /dev/null
@@ -1,1344 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Michael Scharf (Wind River) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tm.internal.terminal.model;
-
-import junit.framework.TestCase;
-
-import org.eclipse.tm.terminal.model.ITerminalTextData;
-import org.eclipse.tm.terminal.model.ITerminalTextDataReadOnly;
-import org.eclipse.tm.terminal.model.ITerminalTextDataSnapshot;
-import org.eclipse.tm.terminal.model.Style;
-import org.eclipse.tm.terminal.model.StyleColor;
-
-public class TerminalTextDataSnapshotTest extends TestCase {
- String toMultiLineText(ITerminalTextDataReadOnly term) {
- return TerminalTextTestHelper.toMultiLineText(term);
- }
-
- protected ITerminalTextData makeITerminalTextData() {
- return new TerminalTextData();
- }
-
-
- public void testTerminalTextDataSnapshot() {
- ITerminalTextData term=makeITerminalTextData();
- String s="12345\n" +
- "abcde\n" +
- "ABCDE\n" +
- "vwxzy\n" +
- "VWXYZ";
- TerminalTextTestHelper.fill(term,s);
-
- ITerminalTextDataSnapshot snapshot=term.makeSnapshot();
- snapshot.updateSnapshot(false);
-
- assertEquals(toMultiLineText(term), toMultiLineText(snapshot));
-
- // new snapshots are fully changed
- assertEquals(0,snapshot.getFirstChangedLine());
- assertEquals(term.getHeight()-1,snapshot.getLastChangedLine());
- for (int line = 0; line <= snapshot.getLastChangedLine(); line++) {
- assertTrue(snapshot.hasLineChanged(line));
- }
- // nothing has scrolled
- assertEquals(0, snapshot.getScrollWindowSize());
- }
-
- public void testDetach() {
- ITerminalTextData term=makeITerminalTextData();
- String s="12345\n" +
- "abcde\n" +
- "ABCDE\n" +
- "vwxzy\n" +
- "VWXYZ";
- TerminalTextTestHelper.fill(term,s);
-
- ITerminalTextDataSnapshot snapshot=term.makeSnapshot();
- snapshot.updateSnapshot(false);
-
- assertEquals(toMultiLineText(term),toMultiLineText(snapshot));
- snapshot.detach();
- // after detach changes to the term has no effect
- term.setChar(0, 0, '?', null);
- assertEquals(s, toMultiLineText(snapshot));
- term.setDimensions(2, 2);
- assertEquals(s, toMultiLineText(snapshot));
- }
- public void testIsOutOfDate() {
- ITerminalTextData term=makeITerminalTextData();
- String s="12345\n" +
- "abcde\n" +
- "ABCDE\n" +
- "vwxzy\n" +
- "VWXYZ";
- TerminalTextTestHelper.fill(term,s);
-
- ITerminalTextDataSnapshot snapshot=term.makeSnapshot();
- assertTrue(snapshot.isOutOfDate());
- snapshot.updateSnapshot(false);
-
- assertFalse(snapshot.isOutOfDate());
-
- // make a change and expect it to be changed
- term.setChar(0, 0, '?', null);
- assertTrue(snapshot.isOutOfDate());
-
- snapshot.updateSnapshot(false);
- assertFalse(snapshot.isOutOfDate());
-
- // make a change and expect it to be changed
- term.setChars(1, 1, new char[]{'?','!','.'},null);
- assertTrue(snapshot.isOutOfDate());
-
- snapshot.updateSnapshot(false);
- assertFalse(snapshot.isOutOfDate());
-
- // scroll
- term.scroll(1, 2, -1);
- assertTrue(snapshot.isOutOfDate());
-
- snapshot.updateSnapshot(false);
- assertFalse(snapshot.isOutOfDate());
-
- // scroll
- term.scroll(1, 2, 1);
- assertTrue(snapshot.isOutOfDate());
-
- snapshot.updateSnapshot(false);
- assertFalse(snapshot.isOutOfDate());
-
- // scroll
- term.scroll(1, 2, -1);
- assertTrue(snapshot.isOutOfDate());
-
- snapshot.updateSnapshot(true);
- assertFalse(snapshot.isOutOfDate());
-
- // scroll
- term.scroll(1, 2, 1);
- assertTrue(snapshot.isOutOfDate());
-
- snapshot.updateSnapshot(true);
- assertFalse(snapshot.isOutOfDate());
-
- // setDimensions
- term.setDimensions(2, 2);
- assertTrue(snapshot.isOutOfDate());
-
- snapshot.updateSnapshot(false);
- assertFalse(snapshot.isOutOfDate());
-
- // setDimensions
- term.setDimensions(20, 20);
- assertTrue(snapshot.isOutOfDate());
-
- snapshot.updateSnapshot(false);
- assertFalse(snapshot.isOutOfDate());
-
- }
- ITerminalTextDataSnapshot snapshot(String text, ITerminalTextData term) {
- TerminalTextTestHelper.fill(term,text);
- ITerminalTextDataSnapshot snapshot=term.makeSnapshot();
- snapshot.updateSnapshot(false);
-
- return snapshot;
-
- }
- public void testUpdateSnapshot() {
- ITerminalTextData term=makeITerminalTextData();
- String s="12345\n" +
- "abcde\n" +
- "ABCDE\n" +
- "vwxzy\n" +
- "VWXYZ";
- TerminalTextTestHelper.fill(term,s);
- String termString=toMultiLineText(term);
- ITerminalTextDataSnapshot snapshot=term.makeSnapshot();
- snapshot.updateSnapshot(false);
-
- assertEquals(termString,toMultiLineText(snapshot));
-
- // make changes and assert that the snapshot has not changed
- // then update the snapshot and expect it to be the
- // same as the changed terminal
-
- // make a change
- term.setChar(0, 0, '?', null);
- assertEquals(termString,toMultiLineText(snapshot));
-
- snapshot.updateSnapshot(false);
- termString=toMultiLineText(term);
- assertEquals(termString,toMultiLineText(snapshot));
-
- // make a change
- term.setChars(1, 1, new char[]{'?','!','.'},null);
- assertEquals(termString,toMultiLineText(snapshot));
-
- snapshot.updateSnapshot(false);
- termString=toMultiLineText(term);
- assertEquals(termString,toMultiLineText(snapshot));
-
- // scroll
- term.scroll(1, 2, -1);
- assertEquals(termString,toMultiLineText(snapshot));
-
- snapshot.updateSnapshot(false);
- termString=toMultiLineText(term);
- assertEquals(termString,toMultiLineText(snapshot));
-
- // scroll
- term.scroll(1, 2, 1);
- assertEquals(termString,toMultiLineText(snapshot));
-
- snapshot.updateSnapshot(false);
- termString=toMultiLineText(term);
- assertEquals(termString,toMultiLineText(snapshot));
-
- // scroll
- term.scroll(1, 2, -1);
- assertEquals(termString,toMultiLineText(snapshot));
-
- snapshot.updateSnapshot(true);
- termString=toMultiLineText(term);
- assertEquals(termString,toMultiLineText(snapshot));
-
- // scroll
- term.scroll(1, 2, 1);
- assertEquals(termString,toMultiLineText(snapshot));
-
- snapshot.updateSnapshot(true);
- termString=toMultiLineText(term);
- assertEquals(termString,toMultiLineText(snapshot));
-
- // set dimensions
- term.setDimensions(2, 2);
- assertEquals(termString,toMultiLineText(snapshot));
-
- snapshot.updateSnapshot(false);
- termString=toMultiLineText(term);
- assertEquals(termString,toMultiLineText(snapshot));
-
- // set dimensions
- term.setDimensions(20, 20);
- assertEquals(termString,toMultiLineText(snapshot));
-
- snapshot.updateSnapshot(false);
- termString=toMultiLineText(term);
- assertEquals(termString,toMultiLineText(snapshot));
- }
-
- public void testMaxSize() {
- String s=
- "111\n" +
- "222\n" +
- "333\n" +
- "444\n" +
- "555";
- ITerminalTextData term=makeITerminalTextData();
- term.setMaxHeight(8);
- TerminalTextTestHelper.fill(term, s);
- ITerminalTextDataSnapshot snapshot=term.makeSnapshot();
- snapshot.updateSnapshot(false);
-
- term.addLine();
- assertTrue(snapshot.isOutOfDate());
- snapshot.updateSnapshot(false);
- assertEquals(toMultiLineText(term), toMultiLineText(snapshot));
-
- term.addLine();
- assertTrue(snapshot.isOutOfDate());
- snapshot.updateSnapshot(false);
- assertEquals(toMultiLineText(term), toMultiLineText(snapshot));
-
- term.addLine();
- assertTrue(snapshot.isOutOfDate());
- snapshot.updateSnapshot(false);
- assertEquals(toMultiLineText(term), toMultiLineText(snapshot));
-
- term.addLine();
- assertTrue(snapshot.isOutOfDate());
- snapshot.updateSnapshot(false);
- assertEquals(toMultiLineText(term), toMultiLineText(snapshot));
-
- term.addLine();
- assertTrue(snapshot.isOutOfDate());
- snapshot.updateSnapshot(false);
- assertEquals(toMultiLineText(term), toMultiLineText(snapshot));
-
- }
-
-
- public void testGetChar() {
- ITerminalTextData term=makeITerminalTextData();
- String s="12345\n" +
- "abcde\n" +
- "ABCDE\n" +
- "vwxzy\n" +
- "VWXYZ";
- TerminalTextTestHelper.fill(term,s);
- ITerminalTextData termUnchanged=makeITerminalTextData();
- TerminalTextTestHelper.fill(termUnchanged,s);
-
- ITerminalTextDataSnapshot snapshot=term.makeSnapshot();
- snapshot.updateSnapshot(false);
-
- for (int line = 0; line < snapshot.getHeight(); line++) {
- for (int column = 0; column < snapshot.getWidth(); column++) {
- assertEquals(term.getChar(line, column),snapshot.getChar(line, column));
- }
- }
- // make a change
- term.setChar(0, 0, '?', null);
- // check against unchanged data
- for (int line = 0; line < snapshot.getHeight(); line++) {
- for (int column = 0; column < snapshot.getWidth(); column++) {
- assertEquals(termUnchanged.getChar(line, column),snapshot.getChar(line, column));
- }
- }
- // update and compare against the terminal
- snapshot.updateSnapshot(true);
- for (int line = 0; line < snapshot.getHeight(); line++) {
- for (int column = 0; column < snapshot.getWidth(); column++) {
- assertEquals(term.getChar(line, column),snapshot.getChar(line, column));
- }
- }
-
- }
-
- public void testGetHeight() {
- ITerminalTextData term=makeITerminalTextData();
- String s="12345\n" +
- "abcde\n" +
- "ABCDE\n" +
- "vwxzy\n" +
- "VWXYZ";
- TerminalTextTestHelper.fill(term,s);
-
- ITerminalTextDataSnapshot snapshot=term.makeSnapshot();
- snapshot.updateSnapshot(false);
-
- int expectedHeight=term.getHeight();
- assertEquals(expectedHeight, snapshot.getHeight());
- term.setDimensions(term.getHeight()-1, term.getWidth());
- assertEquals(expectedHeight, snapshot.getHeight());
-
- //
- snapshot.updateSnapshot(false);
- expectedHeight=term.getHeight();
- assertEquals(expectedHeight, snapshot.getHeight());
- term.setDimensions(term.getHeight()-1, term.getWidth());
- assertEquals(expectedHeight, snapshot.getHeight());
- }
-//
-// public void testGetLineSegments() {
-// fail("Not yet implemented");
-// }
-//
- public void testGetStyle() {
- ITerminalTextData term=makeITerminalTextData();
- Style style=Style.getStyle(StyleColor.getStyleColor("fg"), StyleColor.getStyleColor("bg"), false, false, false, false);
- term.setDimensions(6, 3);
- for (int line = 0; line < term.getHeight(); line++) {
- for (int column = 0; column < term.getWidth(); column++) {
- char c=(char)('a'+column+line);
- term.setChar(line, column, c, style.setForground(StyleColor.getStyleColor(""+c)));
- }
- }
- ITerminalTextDataSnapshot snapshot=term.makeSnapshot();
- snapshot.updateSnapshot(false);
-
-
- for (int line = 0; line < term.getHeight(); line++) {
- for (int column = 0; column < term.getWidth(); column++) {
- char c=(char)('a'+column+line);
- assertSame(style.setForground(StyleColor.getStyleColor(""+c)), snapshot.getStyle(line, column));
- }
- }
-
- }
-
- public void testGetWidth() {
- ITerminalTextData term=makeITerminalTextData();
- String s="12345\n" +
- "abcde\n" +
- "ABCDE\n" +
- "vwxzy\n" +
- "VWXYZ";
- TerminalTextTestHelper.fill(term,s);
-
- ITerminalTextDataSnapshot snapshot=term.makeSnapshot();
- snapshot.updateSnapshot(false);
-
- int expectedWidth=term.getWidth();
- assertEquals(expectedWidth, snapshot.getWidth());
- term.setDimensions(term.getHeight(), term.getWidth()-1);
- assertEquals(expectedWidth, snapshot.getWidth());
-
- //
- snapshot.updateSnapshot(false);
- expectedWidth=term.getWidth();
- assertEquals(expectedWidth, snapshot.getWidth());
- term.setDimensions(term.getHeight(), term.getWidth()-1);
- assertEquals(expectedWidth, snapshot.getWidth());
- }
-
- public void testGetFirstChangedLine() {
- ITerminalTextData term=makeITerminalTextData();
- String s="12345\n" +
- "abcde\n" +
- "ABCDE\n" +
- "vwxzy\n" +
- "VWXYZ";
- ITerminalTextDataSnapshot snapshot=snapshot(s,term);
-
-
- assertEquals(0, snapshot.getFirstChangedLine());
-
- // if nothing has changed the first changed line i height
- snapshot.updateSnapshot(false);
- assertEquals(Integer.MAX_VALUE, snapshot.getFirstChangedLine());
-
- snapshot=snapshot(s,term);
- term.setChar(0, 0, 'x', null);
- snapshot.updateSnapshot(false);
- assertEquals(0, snapshot.getFirstChangedLine());
-
- snapshot=snapshot(s,term);
- term.setChar(3, 0, 'x', null);
- term.setChar(4, 0, 'x', null);
- snapshot.updateSnapshot(false);
- assertEquals(3, snapshot.getFirstChangedLine());
-
- snapshot=snapshot(s,term);
- term.scroll(0, 1, -1);
- snapshot.updateSnapshot(false);
- assertEquals(0, snapshot.getFirstChangedLine());
-
- snapshot=snapshot(s,term);
- term.scroll(2, 2, -1);
- snapshot.updateSnapshot(false);
- assertEquals(2, snapshot.getFirstChangedLine());
-
- // when scrolling the end of the region 'has changed'
- snapshot=snapshot(s,term);
- term.scroll(2, 2, -1);
- snapshot.updateSnapshot(true);
- assertEquals(3, snapshot.getFirstChangedLine());
-
- // when scrolling the end of the region 'has changed'
- snapshot=snapshot(s,term);
- term.scroll(2, 2, -1);
- term.setChar(1, 0, 'x', null);
- snapshot.updateSnapshot(true);
- assertEquals(1, snapshot.getFirstChangedLine());
-
- }
- public void testGetLastChangedLine() {
- ITerminalTextData term=makeITerminalTextData();
- String s="12345\n" +
- "abcde\n" +
- "ABCDE\n" +
- "vwxzy\n" +
- "VWXYZ";
- ITerminalTextDataSnapshot snapshot=snapshot(s,term);
-
-
- assertEquals(4, snapshot.getLastChangedLine());
-
- // if nothing has changed the first changed line i height
- snapshot.updateSnapshot(false);
- assertEquals(-1, snapshot.getLastChangedLine());
-
- snapshot=snapshot(s,term);
- term.setChar(0, 0, 'x', null);
- snapshot.updateSnapshot(false);
- assertEquals(0, snapshot.getLastChangedLine());
-
- snapshot=snapshot(s,term);
- term.cleanLine(1);
- snapshot.updateSnapshot(false);
- assertEquals(1, snapshot.getLastChangedLine());
-
- snapshot=snapshot(s,term);
- term.setChar(3, 0, 'x', null);
- term.setChar(4, 0, 'x', null);
- snapshot.updateSnapshot(false);
- assertEquals(4, snapshot.getLastChangedLine());
-
- snapshot=snapshot(s,term);
- term.scroll(0, 1, -1);
- snapshot.updateSnapshot(false);
- assertEquals(0, snapshot.getLastChangedLine());
-
- snapshot=snapshot(s,term);
- term.scroll(2, 2, -1);
- snapshot.updateSnapshot(false);
- assertEquals(3, snapshot.getLastChangedLine());
-
- // when scrolling the end of the region 'has changed'
- snapshot=snapshot(s,term);
- term.scroll(2, 2, -1);
- snapshot.updateSnapshot(true);
- assertEquals(3, snapshot.getLastChangedLine());
-
- // when scrolling the end of the region 'has changed'
- snapshot=snapshot(s,term);
- term.scroll(2, 2, -1);
- term.setChar(1, 0, 'x', null);
- snapshot.updateSnapshot(true);
- assertEquals(3, snapshot.getLastChangedLine());
-
- }
- /**
- * @param snapshot
- * @param expected a string of 0 and 1 (1 means changed)
- */
- void assertChangedLines(ITerminalTextDataSnapshot snapshot, String expected) {
- assertEquals(expected.length(),snapshot.getHeight());
- StringBuffer buffer=new StringBuffer();
- for (int line = 0; line < expected.length(); line++) {
- if(snapshot.hasLineChanged(line))
- buffer.append('1');
- else
- buffer.append('0');
- }
- assertEquals(expected, buffer.toString());
- }
- public void testHasLineChangedScroll() {
- ITerminalTextData term=makeITerminalTextData();
- String s="00\n" +
- "11\n" +
- "22\n" +
- "33\n" +
- "44\n" +
- "55\n" +
- "66\n" +
- "77\n" +
- "88\n" +
- "99";
- ITerminalTextDataSnapshot snapshot=snapshot(s,term);
-
- term.scroll(2,3,-1);
- snapshot.updateSnapshot(true);
- assertChangedLines(snapshot, "0000100000");
-
- snapshot=snapshot(s,term);
- term.scroll(2,3,-2);
- snapshot.updateSnapshot(true);
- assertChangedLines(snapshot, "0001100000");
-
- snapshot=snapshot(s,term);
- term.scroll(2,4,-1);
- term.scroll(2,4,-1);
- snapshot.updateSnapshot(true);
- assertChangedLines(snapshot, "0000110000");
-
- term.scroll(2,3,1);
- snapshot.updateSnapshot(true);
- assertChangedLines(snapshot, "0011100000");
-
- snapshot=snapshot(s,term);
- term.scroll(2,3,2);
- snapshot.updateSnapshot(true);
- assertChangedLines(snapshot, "0011100000");
-
- snapshot=snapshot(s,term);
- term.scroll(2,4,1);
- term.scroll(2,4,1);
- snapshot.updateSnapshot(true);
- assertChangedLines(snapshot, "0011110000");
-
-
- snapshot=snapshot(s,term);
- term.scroll(2,3,-1);
- snapshot.updateSnapshot(false);
- assertChangedLines(snapshot, "0011100000");
-
- snapshot=snapshot(s,term);
- term.scroll(2,3,-2);
- snapshot.updateSnapshot(false);
- assertChangedLines(snapshot, "0011100000");
-
- snapshot=snapshot(s,term);
- term.scroll(2,4,-1);
- term.scroll(2,4,-1);
- snapshot.updateSnapshot(false);
- assertChangedLines(snapshot, "0011110000");
- }
- public void testMultiScrollWithDifferentSizes() {
- ITerminalTextData term=makeITerminalTextData();
- String s="00\n" +
- "11\n" +
- "22\n" +
- "33\n" +
- "44\n" +
- "55\n" +
- "66\n" +
- "77\n" +
- "88\n" +
- "99";
- ITerminalTextDataSnapshot snapshot;
-
- snapshot=snapshot(s,term);
- term.scroll(2,6,-1);
- term.scroll(2,5,-1);
- snapshot.updateSnapshot(false);
- assertChangedLines(snapshot, "0011111100");
- assertEquals(2, snapshot.getFirstChangedLine());
- assertEquals(7, snapshot.getLastChangedLine());
- assertEquals(0, snapshot.getScrollWindowSize());
- assertEquals(0, snapshot.getScrollWindowStartLine());
- assertEquals(0, snapshot.getScrollWindowShift());
-
- // scrolls with different ranges cause no scroll
- // optimization
- snapshot=snapshot(s,term);
- term.scroll(2,6,-1);
- term.scroll(2,5,-1);
- snapshot.updateSnapshot(true);
- assertChangedLines(snapshot, "0011111100");
- assertEquals(2, snapshot.getFirstChangedLine());
- assertEquals(7, snapshot.getLastChangedLine());
- assertEquals(0, snapshot.getScrollWindowShift());
- assertEquals(0, snapshot.getScrollWindowSize());
- assertEquals(0, snapshot.getScrollWindowStartLine());
- }
- public void testHasLineChanged() {
- ITerminalTextData term=makeITerminalTextData();
- String s="000000\n" +
- "111111\n" +
- "222222\n" +
- "333333\n" +
- "444444\n" +
- "555555\n" +
- "666666\n" +
- "777777\n" +
- "888888\n" +
- "999999";
- ITerminalTextDataSnapshot snapshot;
-
- snapshot=snapshot(s,term);
- term.scroll(2,3,-1);
- term.setChar(7, 0, '.', null);
- snapshot.updateSnapshot(true);
- assertChangedLines(snapshot, "0000100100");
-
- snapshot=snapshot(s,term);
- term.scroll(2,3,-2);
- term.setChar(9, 0, '.', null);
- term.setChars(0, 0, new char[]{'.','!'}, null);
- snapshot.updateSnapshot(true);
- assertChangedLines(snapshot, "1001100001");
-
- snapshot=snapshot(s,term);
- term.scroll(2,4,-1);
- term.scroll(2,4,-1);
- term.setChars(2, 2, new char[]{'.','!','*'},1,1, null);
- snapshot.updateSnapshot(true);
- assertChangedLines(snapshot, "0010110000");
-
- snapshot=snapshot(s,term);
- term.scroll(2,7,-1);
- term.setChar(5, 2, '.', null);
- term.scroll(2,7,-2);
- snapshot.updateSnapshot(true);
- assertChangedLines(snapshot, "0001001110");
-
-
- snapshot=snapshot(s,term);
- term.scroll(2,7,-1);
- term.setChar(5, 2, '.', null);
- term.scroll(2,7,-2);
- snapshot.updateSnapshot(false);
- assertChangedLines(snapshot, "0011111110");
-
- }
-
- public void testScroll() {
- ITerminalTextData term=makeITerminalTextData();
- String s="00\n" +
- "11\n" +
- "22\n" +
- "33\n" +
- "44\n" +
- "55\n" +
- "66\n" +
- "77\n" +
- "88\n" +
- "99";
- ITerminalTextDataSnapshot snapshot=snapshot(s,term);
-
- term.scroll(2,3,-1);
- snapshot.updateSnapshot(true);
- assertEquals(2, snapshot.getScrollWindowStartLine());
- assertEquals(3, snapshot.getScrollWindowSize());
- assertEquals(-1, snapshot.getScrollWindowShift());
- assertEquals(4, snapshot.getFirstChangedLine());
- assertEquals(4, snapshot.getLastChangedLine());
-
- term.scroll(2,3,-2);
- snapshot.updateSnapshot(true);
- assertEquals(2, snapshot.getScrollWindowStartLine());
- assertEquals(3, snapshot.getScrollWindowSize());
- assertEquals(-2, snapshot.getScrollWindowShift());
- assertEquals(3, snapshot.getFirstChangedLine());
- assertEquals(4, snapshot.getLastChangedLine());
-
- term.scroll(2,4,-1);
- term.scroll(2,4,-1);
- snapshot.updateSnapshot(true);
- assertEquals(2, snapshot.getScrollWindowStartLine());
- assertEquals(4, snapshot.getScrollWindowSize());
- assertEquals(-2, snapshot.getScrollWindowShift());
- assertEquals(4, snapshot.getFirstChangedLine());
- assertEquals(5, snapshot.getLastChangedLine());
-
-
- snapshot=snapshot(s,term);
- term.scroll(2,3,-1);
- snapshot.updateSnapshot(false);
- assertEquals(0, snapshot.getScrollWindowStartLine());
- assertEquals(0, snapshot.getScrollWindowSize());
- assertEquals(0, snapshot.getScrollWindowShift());
- assertEquals(2, snapshot.getFirstChangedLine());
- assertEquals(4, snapshot.getLastChangedLine());
-
- }
- public void testDisjointScroll() {
- ITerminalTextData term=makeITerminalTextData();
- String s="000000\n" +
- "111111\n" +
- "222222\n" +
- "333333\n" +
- "444444\n" +
- "555555\n" +
- "666666\n" +
- "777777\n" +
- "888888\n" +
- "999999";
- ITerminalTextDataSnapshot snapshot;
-
- snapshot=snapshot(s,term);
- term.scroll(0,2,-1);
- term.scroll(4,2,-1);
- snapshot.updateSnapshot(true);
- assertChangedLines(snapshot, "1100110000");
- assertEquals(0, snapshot.getScrollWindowStartLine());
- assertEquals(0, snapshot.getScrollWindowSize());
- assertEquals(0, snapshot.getScrollWindowShift());
-
- snapshot=snapshot(s,term);
- term.scroll(0,3,-1);
- term.scroll(2,2,-2);
- snapshot.updateSnapshot(true);
- assertChangedLines(snapshot, "1111000000");
- assertEquals(0, snapshot.getScrollWindowStartLine());
- assertEquals(0, snapshot.getScrollWindowSize());
- assertEquals(0, snapshot.getScrollWindowShift());
-
- snapshot=snapshot(s,term);
- term.scroll(0,3,-1);
- term.scroll(2,2,-2);
- term.scroll(0,3,-1);
- snapshot.updateSnapshot(true);
- assertChangedLines(snapshot, "1111000000");
- assertEquals(0, snapshot.getScrollWindowStartLine());
- assertEquals(0, snapshot.getScrollWindowSize());
- assertEquals(0, snapshot.getScrollWindowShift());
-
- snapshot=snapshot(s,term);
- term.scroll(0,3,-1);
- term.scroll(2,2,-2);
- term.scroll(0,3,-10);
- snapshot.updateSnapshot(true);
- assertChangedLines(snapshot, "1111000000");
- assertEquals(0, snapshot.getScrollWindowStartLine());
- assertEquals(0, snapshot.getScrollWindowSize());
- assertEquals(0, snapshot.getScrollWindowShift());
-
- snapshot=snapshot(s,term);
- term.scroll(1,3,-1);
- term.scroll(1,3,1);
- snapshot.updateSnapshot(true);
- assertChangedLines(snapshot, "0111000000");
- assertEquals(0, snapshot.getScrollWindowStartLine());
- assertEquals(0, snapshot.getScrollWindowSize());
- assertEquals(0, snapshot.getScrollWindowShift());
- }
- public void testResize() {
- ITerminalTextData term=makeITerminalTextData();
- String s="000000\n" +
- "111111\n" +
- "222222\n" +
- "333333";
- ITerminalTextDataSnapshot snapshot;
-
- snapshot=snapshot(s,term);
- term.setDimensions(term.getHeight(), term.getWidth()+1);
- snapshot.updateSnapshot(true);
- assertChangedLines(snapshot, "1111");
- assertEquals(0, snapshot.getFirstChangedLine());
- assertEquals(3, snapshot.getLastChangedLine());
- assertEquals(0, snapshot.getScrollWindowStartLine());
- assertEquals(0, snapshot.getScrollWindowSize());
- assertEquals(0, snapshot.getScrollWindowShift());
-
- snapshot=snapshot(s,term);
- term.setDimensions(term.getHeight()+1, term.getWidth());
- snapshot.updateSnapshot(true);
- assertChangedLines(snapshot, "11111");
- assertEquals(0, snapshot.getFirstChangedLine());
- assertEquals(4, snapshot.getLastChangedLine());
- assertEquals(0, snapshot.getScrollWindowStartLine());
- assertEquals(0, snapshot.getScrollWindowSize());
- assertEquals(0, snapshot.getScrollWindowShift());
-
- snapshot=snapshot(s,term);
- term.setDimensions(term.getHeight()-1, term.getWidth());
- snapshot.updateSnapshot(true);
- assertChangedLines(snapshot, "111");
- assertEquals(0, snapshot.getFirstChangedLine());
- assertEquals(2, snapshot.getLastChangedLine());
- assertEquals(0, snapshot.getScrollWindowStartLine());
- assertEquals(0, snapshot.getScrollWindowSize());
- assertEquals(0, snapshot.getScrollWindowShift());
-
- snapshot=snapshot(s,term);
- term.setDimensions(0, 0);
- snapshot.updateSnapshot(true);
- assertChangedLines(snapshot, "");
- assertEquals(0, snapshot.getFirstChangedLine());
- assertEquals(-1, snapshot.getLastChangedLine());
- assertEquals(0, snapshot.getScrollWindowStartLine());
- assertEquals(0, snapshot.getScrollWindowSize());
- assertEquals(0, snapshot.getScrollWindowShift());
-
- }
- public void testResizeAfterScroll() {
- ITerminalTextData term=makeITerminalTextData();
- String s="000000\n" +
- "111111\n" +
- "222222\n" +
- "333333\n" +
- "444444\n" +
- "555555\n" +
- "666666\n" +
- "777777\n" +
- "888888\n" +
- "999999";
- ITerminalTextDataSnapshot snapshot;
-
- snapshot=snapshot(s,term);
- term.scroll(1,2,-1);
- term.setDimensions(5, 4);
- snapshot.updateSnapshot(true);
- assertChangedLines(snapshot, "11111");
- assertEquals(0, snapshot.getScrollWindowStartLine());
- assertEquals(0, snapshot.getScrollWindowSize());
- assertEquals(0, snapshot.getScrollWindowShift());
-
- snapshot=snapshot(s,term);
- term.scroll(1,2,-1);
- term.setDimensions(7, 2);
- term.scroll(4,2,-1);
- snapshot.updateSnapshot(true);
- assertChangedLines(snapshot, "1111111");
- assertEquals(0, snapshot.getScrollWindowStartLine());
- assertEquals(0, snapshot.getScrollWindowSize());
- assertEquals(0, snapshot.getScrollWindowShift());
- snapshot=snapshot(s,term);
-
- term.scroll(1,2,-1);
- term.setDimensions(term.getHeight(),term.getWidth()+1);
- snapshot.updateSnapshot(true);
- assertChangedLines(snapshot, "1111111111");
- assertEquals(0, snapshot.getScrollWindowStartLine());
- assertEquals(0, snapshot.getScrollWindowSize());
- assertEquals(0, snapshot.getScrollWindowShift());
- }
- public void testScrollAfterResize() {
- ITerminalTextData term=makeITerminalTextData();
- String s="000000\n" +
- "111111\n" +
- "222222\n" +
- "333333\n" +
- "444444\n" +
- "555555\n" +
- "666666\n" +
- "777777\n" +
- "888888\n" +
- "999999";
- ITerminalTextDataSnapshot snapshot;
-
- snapshot=snapshot(s,term);
- term.setDimensions(14, 6);
- term.scroll(0,14,-1);
- snapshot.updateSnapshot(true);
- assertChangedLines(snapshot, "11111111111111");
- assertEquals(0, snapshot.getScrollWindowStartLine());
- assertEquals(0, snapshot.getScrollWindowSize());
- assertEquals(0, snapshot.getScrollWindowShift());
- }
- private final class SnapshotListener implements ITerminalTextDataSnapshot.SnapshotOutOfDateListener {
- int N;
- public void snapshotOutOfDate(ITerminalTextDataSnapshot snapshot) {
- N++;
- }
- public void reset() {
- N=0;
- }
- }
-
- public void testAddListener() {
- ITerminalTextData term=makeITerminalTextData();
- String s="12345\n" +
- "abcde\n" +
- "ABCDE\n" +
- "vwxzy\n" +
- "VWXYZ";
- TerminalTextTestHelper.fill(term,s);
-
- ITerminalTextDataSnapshot snapshot=term.makeSnapshot();
- snapshot.updateSnapshot(false);
-
- SnapshotListener listener=new SnapshotListener();
- snapshot.addListener(listener);
- assertEquals(0, listener.N);
-
- // make a change and expect it to be changed
- term.setChar(0, 0, '?', null);
- assertEquals(1, listener.N);
- term.setChar(1, 1, '?', null);
- assertEquals(1, listener.N);
-
- snapshot.updateSnapshot(false);
- assertEquals(1, listener.N);
- listener.reset();
-
- // make a change and expect it to be changed
- term.setChars(1, 1, new char[]{'?','!','.'},null);
- assertEquals(1, listener.N);
- term.setChars(2, 1, new char[]{'?','!','.'},null);
- assertEquals(1, listener.N);
-
- snapshot.updateSnapshot(false);
- assertEquals(1, listener.N);
- listener.reset();
-
- // scroll
- term.scroll(1, 2, -1);
- assertEquals(1, listener.N);
- term.scroll(1, 2, -1);
- assertEquals(1, listener.N);
-
- snapshot.updateSnapshot(false);
- assertEquals(1, listener.N);
- listener.reset();
-
- // scroll
- term.scroll(1, 2, 1);
- assertEquals(1, listener.N);
- term.scroll(1, 2, 1);
- assertEquals(1, listener.N);
-
- snapshot.updateSnapshot(false);
- assertEquals(1, listener.N);
- listener.reset();
-
- // scroll
- term.scroll(1, 2, -1);
- assertEquals(1, listener.N);
- term.scroll(1, 2, -1);
- assertEquals(1, listener.N);
-
- snapshot.updateSnapshot(false);
- assertEquals(1, listener.N);
- listener.reset();
-
- // scroll
- term.scroll(1, 2, 1);
- assertEquals(1, listener.N);
-
- snapshot.updateSnapshot(false);
- assertEquals(1, listener.N);
- listener.reset();
-
- // setDimensions
- term.setDimensions(2, 2);
- assertEquals(1, listener.N);
-
- snapshot.updateSnapshot(false);
- assertEquals(1, listener.N);
- listener.reset();
-
- // setDimensions
- term.setDimensions(20, 20);
- assertEquals(1, listener.N);
-
- snapshot.updateSnapshot(false);
- assertFalse(snapshot.isOutOfDate());
- }
-
- public void testRemoveListener() {
- ITerminalTextData term=makeITerminalTextData();
- String s="12345\n" +
- "abcde\n" +
- "ABCDE\n" +
- "vwxzy\n" +
- "VWXYZ";
- TerminalTextTestHelper.fill(term,s);
-
- ITerminalTextDataSnapshot snapshot=term.makeSnapshot();
- snapshot.updateSnapshot(false);
-
- SnapshotListener listener1=new SnapshotListener();
- SnapshotListener listener2=new SnapshotListener();
- SnapshotListener listener3=new SnapshotListener();
- snapshot.addListener(listener1);
- snapshot.addListener(listener2);
- snapshot.addListener(listener3);
- assertEquals(0, listener1.N);
-
- // make a change and expect it to be changed
- term.setChar(0, 0, '?', null);
- assertEquals(1, listener1.N);
- assertEquals(1, listener2.N);
- assertEquals(1, listener3.N);
- term.setChar(1, 1, '?', null);
- assertEquals(1, listener1.N);
- assertEquals(1, listener2.N);
- assertEquals(1, listener3.N);
-
- snapshot.updateSnapshot(false);
- assertEquals(1, listener1.N);
- assertEquals(1, listener2.N);
- assertEquals(1, listener3.N);
- listener1.reset();
- listener2.reset();
- listener3.reset();
-
- // make a change and expect it to be changed
- term.setChars(1, 1, new char[]{'?','!','.'},null);
- assertEquals(1, listener1.N);
- assertEquals(1, listener2.N);
- assertEquals(1, listener3.N);
- term.setChars(2, 1, new char[]{'?','!','.'},null);
- assertEquals(1, listener1.N);
- assertEquals(1, listener2.N);
- assertEquals(1, listener3.N);
-
-
- snapshot.updateSnapshot(false);
- assertEquals(1, listener1.N);
- assertEquals(1, listener2.N);
- assertEquals(1, listener3.N);
-
- listener1.reset();
- listener2.reset();
- listener3.reset();
-
- snapshot.removeListener(listener2);
-
- // scroll
- term.scroll(1, 2, -1);
- assertEquals(1, listener1.N);
- assertEquals(0, listener2.N);
- assertEquals(1, listener3.N);
-
- term.scroll(1, 2, -1);
- assertEquals(1, listener1.N);
- assertEquals(0, listener2.N);
- assertEquals(1, listener3.N);
-
-
- snapshot.updateSnapshot(false);
- assertEquals(1, listener1.N);
- assertEquals(0, listener2.N);
- assertEquals(1, listener3.N);
-
- snapshot.addListener(listener2);
- listener1.reset();
- listener2.reset();
- listener3.reset();
-
-
- snapshot.removeListener(listener3);
- // scroll
- term.scroll(1, 2, 1);
- assertEquals(1, listener1.N);
- assertEquals(1, listener2.N);
- assertEquals(0, listener3.N);
-
- term.scroll(1, 2, 1);
- assertEquals(1, listener1.N);
- assertEquals(1, listener2.N);
- assertEquals(0, listener3.N);
-
-
- snapshot.updateSnapshot(false);
- assertEquals(1, listener1.N);
- assertEquals(1, listener2.N);
- assertEquals(0, listener3.N);
-
- snapshot.addListener(listener3);
- listener1.reset();
- listener2.reset();
- listener3.reset();
-
- // add listener multiple times
- snapshot.addListener(listener3);
-
- // scroll
- term.scroll(1, 2, -1);
- assertEquals(1, listener1.N);
- assertEquals(1, listener2.N);
- assertEquals(2, listener3.N);
-
- term.scroll(1, 2, -1);
- assertEquals(1, listener1.N);
- assertEquals(1, listener2.N);
- assertEquals(2, listener3.N);
-
-
- snapshot.updateSnapshot(false);
- assertEquals(1, listener1.N);
- assertEquals(1, listener2.N);
- assertEquals(2, listener3.N);
-
- listener1.reset();
- listener2.reset();
- listener3.reset();
- // remove the duplicate listener
- snapshot.removeListener(listener3);
-
-
- // scroll
- term.scroll(1, 2, 1);
- assertEquals(1, listener1.N);
- assertEquals(1, listener2.N);
- assertEquals(1, listener3.N);
-
-
- snapshot.updateSnapshot(false);
- assertEquals(1, listener1.N);
- assertEquals(1, listener2.N);
- assertEquals(1, listener3.N);
-
- listener1.reset();
- listener2.reset();
- listener3.reset();
-
-
- // setDimensions
- term.setDimensions(2, 2);
- assertEquals(1, listener1.N);
- assertEquals(1, listener2.N);
- assertEquals(1, listener3.N);
-
-
- snapshot.updateSnapshot(false);
- assertEquals(1, listener1.N);
- assertEquals(1, listener2.N);
- assertEquals(1, listener3.N);
-
- listener1.reset();
- listener2.reset();
- listener3.reset();
-
-
- // setDimensions
- term.setDimensions(20, 20);
- assertEquals(1, listener1.N);
- assertEquals(1, listener2.N);
- assertEquals(1, listener3.N);
-
-
- snapshot.updateSnapshot(false);
- assertFalse(snapshot.isOutOfDate());
- }
- public void testWindowOfInterest() {
- ITerminalTextData term=makeITerminalTextData();
- TerminalTextTestHelper.fillSimple(term,"0123456789");
- ITerminalTextDataSnapshot snapshot=term.makeSnapshot();
- snapshot.updateSnapshot(false);
- snapshot.setInterestWindow(7, 4);
- snapshot.setInterestWindow(9, 4);
- snapshot.updateSnapshot(false);
- }
- public void testWindowOfInterest2() {
- ITerminalTextData term=makeITerminalTextData();
- TerminalTextTestHelper.fillSimple(term,"0123456789");
- ITerminalTextDataSnapshot snapshot=term.makeSnapshot();
- snapshot.updateSnapshot(false);
- term.scroll(7, 3,-1);
- snapshot.setInterestWindow(9, 4);
- snapshot.updateSnapshot(false);
- }
- public void testAddLine() {
- ITerminalTextData term=makeITerminalTextData();
- TerminalTextTestHelper.fillSimple(term,"0123456789");
- ITerminalTextDataSnapshot snapshot=term.makeSnapshot();
- term.setMaxHeight(20);
- snapshot.updateSnapshot(false);
- assertEquals(10,term.getHeight());
- assertEquals(20,term.getMaxHeight());
- assertFalse(snapshot.isOutOfDate());
- term.addLine();
- assertTrue(snapshot.isOutOfDate());
- assertEquals(11,term.getHeight());
- assertEquals(10,snapshot.getHeight());
- snapshot.updateSnapshot(false);
- assertEquals(11,term.getHeight());
- assertEquals(11,snapshot.getHeight());
- assertEquals(20,term.getMaxHeight());
-
- term.addLine();
- term.addLine();
- assertEquals(11,snapshot.getHeight());
- assertEquals(13,term.getHeight());
- assertTrue(snapshot.isOutOfDate());
- snapshot.updateSnapshot(false);
- assertEquals(13,snapshot.getHeight());
- assertEquals(13,term.getHeight());
- assertEquals(20,term.getMaxHeight());
- }
- public void testHasDimensionsChanged() {
- ITerminalTextData term=makeITerminalTextData();
- TerminalTextTestHelper.fillSimple(term,"0123456789");
- ITerminalTextDataSnapshot snapshot=term.makeSnapshot();
- term.setMaxHeight(20);
- snapshot.setInterestWindow(3, 4);
- snapshot.updateSnapshot(false);
- assertEquals(10,term.getHeight());
- assertEquals(20,term.getMaxHeight());
- assertFalse(snapshot.isOutOfDate());
- term.addLine();
- assertTrue(snapshot.isOutOfDate());
- assertEquals(11,term.getHeight());
- assertEquals(10,snapshot.getHeight());
- snapshot.updateSnapshot(false);
- assertTrue(snapshot.hasDimensionsChanged());
- assertEquals(11,term.getHeight());
- assertEquals(11,snapshot.getHeight());
- assertEquals(20,term.getMaxHeight());
-
- term.addLine();
- term.addLine();
- assertEquals(11,snapshot.getHeight());
- assertEquals(13,term.getHeight());
- assertTrue(snapshot.isOutOfDate());
- snapshot.updateSnapshot(false);
- assertTrue(snapshot.hasDimensionsChanged());
- assertEquals(13,snapshot.getHeight());
- assertEquals(13,term.getHeight());
- assertEquals(20,term.getMaxHeight());
- }
- public void testCursor() {
- ITerminalTextData term=makeITerminalTextData();
- TerminalTextTestHelper.fillSimple(term,"0123456789");
- ITerminalTextDataSnapshot snapshot=term.makeSnapshot();
- term.setMaxHeight(20);
- snapshot.setInterestWindow(3, 4);
- snapshot.updateSnapshot(false);
- term.setCursorLine(2);
- term.setCursorColumn(1);
- snapshot.updateSnapshot(false);
- assertEquals(2, snapshot.getCursorLine());
- assertEquals(1, snapshot.getCursorColumn());
- term.setCursorLine(3);
- term.setCursorColumn(2);
- snapshot.updateSnapshot(false);
- assertEquals(3, snapshot.getCursorLine());
- assertEquals(2, snapshot.getCursorColumn());
- }
- public void testCursor2() {
- ITerminalTextData term=makeITerminalTextData();
- TerminalTextTestHelper.fillSimple(term,"0123456789");
- ITerminalTextDataSnapshot snapshot=term.makeSnapshot();
- term.setMaxHeight(20);
- snapshot.setInterestWindow(3, 4);
- snapshot.updateSnapshot(false);
- term.setCursorLine(2);
- assertTrue(snapshot.isOutOfDate());
- snapshot.updateSnapshot(false);
- term.setCursorColumn(1);
- assertTrue(snapshot.isOutOfDate());
- }
- public void testHasTerminalChanged() {
- ITerminalTextData term=makeITerminalTextData();
- String s="12345\n" +
- "abcde\n" +
- "ABCDE\n" +
- "vwxzy\n" +
- "VWXYZ";
- TerminalTextTestHelper.fill(term,s);
-
- ITerminalTextDataSnapshot snapshot=term.makeSnapshot();
- assertTrue(snapshot.hasTerminalChanged());
- snapshot.updateSnapshot(false);
-
- assertTrue(snapshot.hasTerminalChanged());
-
- // make a change and expect it to be changed
- term.setChar(0, 0, '?', null);
- snapshot.updateSnapshot(false);
- assertTrue(snapshot.hasTerminalChanged());
-
- // make a change and expect it to be changed
- term.setChars(1, 1, new char[]{'?','!','.'},null);
- snapshot.updateSnapshot(false);
- assertTrue(snapshot.hasTerminalChanged());
-
- // scroll
- term.scroll(1, 2, -1);
- snapshot.updateSnapshot(false);
- assertTrue(snapshot.hasTerminalChanged());
-
- // scroll
- term.scroll(1, 2, 1);
- snapshot.updateSnapshot(false);
- assertTrue(snapshot.hasTerminalChanged());
-
- // scroll
- term.scroll(1, 2, -1);
- snapshot.updateSnapshot(true);
- assertTrue(snapshot.hasTerminalChanged());
-
- // scroll
- term.scroll(1, 2, 1);
- snapshot.updateSnapshot(true);
- assertTrue(snapshot.hasTerminalChanged());
-
- // setDimensions
- term.setDimensions(2, 2);
- snapshot.updateSnapshot(false);
- assertTrue(snapshot.hasTerminalChanged());
-
- // setDimensions
- term.setDimensions(20, 20);
- snapshot.updateSnapshot(false);
- assertTrue(snapshot.hasTerminalChanged());
-
- snapshot.updateSnapshot(false);
- assertFalse(snapshot.hasTerminalChanged());
-
- // window of interest changes should NOT set hasTerminalChanged
- snapshot.updateSnapshot(false);
- snapshot.setInterestWindow(7, 4);
-
- assertFalse(snapshot.hasTerminalChanged());
- }
- public void testGetTerminalTextData() {
- ITerminalTextData term=makeITerminalTextData();
- ITerminalTextDataSnapshot snapshot=term.makeSnapshot();
- assertSame(term, snapshot.getTerminalTextData());
- }
-}
diff --git a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataSnapshotWindowTest.java b/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataSnapshotWindowTest.java
deleted file mode 100644
index 7ce515cc1..000000000
--- a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataSnapshotWindowTest.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Michael Scharf (Wind River) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tm.internal.terminal.model;
-
-import junit.framework.TestCase;
-
-import org.eclipse.tm.terminal.model.ITerminalTextData;
-import org.eclipse.tm.terminal.model.ITerminalTextDataReadOnly;
-import org.eclipse.tm.terminal.model.ITerminalTextDataSnapshot;
-
-public class TerminalTextDataSnapshotWindowTest extends TestCase {
- String toMultiLineText(ITerminalTextDataReadOnly term) {
- return TerminalTextTestHelper.toMultiLineText(term);
- }
- String toSimpleText(ITerminalTextDataReadOnly term) {
- return TerminalTextTestHelper.toSimple(term);
- }
-
- protected ITerminalTextData makeITerminalTextData() {
- return new TerminalTextData();
- }
- ITerminalTextDataSnapshot snapshotSimple(String text, ITerminalTextData term) {
- TerminalTextTestHelper.fillSimple(term,text);
- ITerminalTextDataSnapshot snapshot=term.makeSnapshot();
- return snapshot;
-
- }
- /**
- * @param snapshot
- * @param expected a string of 0 and 1 (1 means changed)
- */
- void assertChangedLines(ITerminalTextDataSnapshot snapshot, String expected) {
- assertEquals(expected.length(),snapshot.getHeight());
- StringBuffer buffer=new StringBuffer();
- for (int line = 0; line < expected.length(); line++) {
- if(snapshot.hasLineChanged(line))
- buffer.append('1');
- else
- buffer.append('0');
- }
- assertEquals(expected, buffer.toString());
- }
-
- public void testSetInterestWindow() {
- ITerminalTextData term=makeITerminalTextData();
- ITerminalTextDataSnapshot snapshot=snapshotSimple("0123456789",term);
- assertEquals(0, snapshot.getInterestWindowStartLine());
- assertEquals(-1, snapshot.getInterestWindowSize());
- snapshot.setInterestWindow(2, 3);
- assertEquals(2, snapshot.getInterestWindowStartLine());
- assertEquals(3, snapshot.getInterestWindowSize());
- snapshot.updateSnapshot(false);
- assertChangedLines(snapshot,"0011100000");
- }
- public void testSetChar() {
- ITerminalTextData term=makeITerminalTextData();
- ITerminalTextDataSnapshot snapshot=snapshotSimple("0123456789",term);
- snapshot.setInterestWindow(2, 3);
- snapshot.updateSnapshot(false);
- assertEquals(" 234 ", toSimpleText(snapshot));
-
- term.setChar(0, 0, 'x', null);
- assertFalse(snapshot.isOutOfDate());
- snapshot.updateSnapshot(false);
- assertChangedLines(snapshot,"0000000000");
-
- term.setChar(1, 0, 'x', null);
- assertFalse(snapshot.isOutOfDate());
-
- term.setChar(2, 0, 'x', null);
- assertTrue(snapshot.isOutOfDate());
- snapshot.updateSnapshot(false);
- assertChangedLines(snapshot,"0010000000");
-
- term.setChar(3, 0, 'x', null);
- assertTrue(snapshot.isOutOfDate());
- snapshot.updateSnapshot(false);
- assertChangedLines(snapshot,"0001000000");
-
- term.setChar(4, 0, 'x', null);
- assertTrue(snapshot.isOutOfDate());
- snapshot.updateSnapshot(false);
- assertChangedLines(snapshot,"0000100000");
-
- term.setChar(5, 0, 'x', null);
- assertFalse(snapshot.isOutOfDate());
-
- term.setChar(6, 0, 'x', null);
- assertFalse(snapshot.isOutOfDate());
-
- for (int i = 0; i < 9; i++) {
- term.setChar(i, 0, (char)('a'+i), null);
- }
- assertTrue(snapshot.isOutOfDate());
- snapshot.updateSnapshot(false);
- assertChangedLines(snapshot,"0011100000");
- }
-
- public void testSetChars() {
- ITerminalTextData term=makeITerminalTextData();
- ITerminalTextDataSnapshot snapshot=snapshotSimple("0123456789",term);
- snapshot.setInterestWindow(2, 3);
- snapshot.updateSnapshot(false);
- assertEquals(" 234 ", toSimpleText(snapshot));
-
- term.setChars(0, 0, "x".toCharArray(), null);
- assertFalse(snapshot.isOutOfDate());
- snapshot.updateSnapshot(false);
- assertChangedLines(snapshot,"0000000000");
-
- term.setChars(1, 0, "x".toCharArray(), null);
- assertFalse(snapshot.isOutOfDate());
-
- term.setChars(2, 0, "x".toCharArray(), null);
- assertTrue(snapshot.isOutOfDate());
- snapshot.updateSnapshot(false);
- assertChangedLines(snapshot,"0010000000");
-
- term.setChars(3, 0, "x".toCharArray(), null);
- assertTrue(snapshot.isOutOfDate());
- snapshot.updateSnapshot(false);
- assertChangedLines(snapshot,"0001000000");
-
- term.setChars(4, 0, "x".toCharArray(), null);
- assertTrue(snapshot.isOutOfDate());
- snapshot.updateSnapshot(false);
- assertChangedLines(snapshot,"0000100000");
-
- term.setChars(5, 0, "x".toCharArray(), null);
- assertFalse(snapshot.isOutOfDate());
-
- term.setChars(6, 0, "x".toCharArray(), null);
- assertFalse(snapshot.isOutOfDate());
- for (int i = 0; i < 9; i++) {
- term.setChars(i, 0, (i+"").toCharArray(), null);
- }
- assertTrue(snapshot.isOutOfDate());
- snapshot.updateSnapshot(false);
- assertChangedLines(snapshot,"0011100000");
- }
- public void testSetChars2() {
- ITerminalTextData term=makeITerminalTextData();
- ITerminalTextDataSnapshot snapshot=snapshotSimple("0123456789",term);
- snapshot.setInterestWindow(2, 3);
- snapshot.updateSnapshot(false);
- assertEquals(" 234 ", toSimpleText(snapshot));
-
- term.setChars(0, 0, "abcdef".toCharArray(),2,1, null);
- assertFalse(snapshot.isOutOfDate());
- snapshot.updateSnapshot(false);
- assertChangedLines(snapshot,"0000000000");
-
- term.setChars(1, 0, "abcdef".toCharArray(),2 ,1, null);
- assertFalse(snapshot.isOutOfDate());
-
- term.setChars(2, 0, "abcdef".toCharArray(),2 ,1, null);
- assertTrue(snapshot.isOutOfDate());
- snapshot.updateSnapshot(false);
- assertChangedLines(snapshot,"0010000000");
-
- term.setChars(3, 0, "abcdef".toCharArray(),2 ,1, null);
- assertTrue(snapshot.isOutOfDate());
- snapshot.updateSnapshot(false);
- assertChangedLines(snapshot,"0001000000");
-
- term.setChars(4, 0, "abcdef".toCharArray(),2 ,1, null);
- assertTrue(snapshot.isOutOfDate());
- snapshot.updateSnapshot(false);
- assertChangedLines(snapshot,"0000100000");
-
- term.setChars(5, 0, "abcdef".toCharArray(),2 ,1, null);
- assertFalse(snapshot.isOutOfDate());
-
- term.setChars(6, 0, "abcdef".toCharArray(),2 ,1, null);
- assertFalse(snapshot.isOutOfDate());
- for (int i = 0; i < 9; i++) {
- term.setChars(i, 0, ("ab"+i+"def").toCharArray(),2 ,1, null);
- }
- assertTrue(snapshot.isOutOfDate());
- snapshot.updateSnapshot(false);
- assertChangedLines(snapshot,"0011100000");
- }
-}
diff --git a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataStoreTest.java b/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataStoreTest.java
deleted file mode 100644
index 743d17792..000000000
--- a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataStoreTest.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Michael Scharf (Wind River) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tm.internal.terminal.model;
-
-import org.eclipse.tm.terminal.model.ITerminalTextData;
-
-public class TerminalTextDataStoreTest extends AbstractITerminalTextDataTest {
- protected ITerminalTextData makeITerminalTextData() {
- return new TerminalTextDataStore();
- }
-
-}
diff --git a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataTest.java b/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataTest.java
deleted file mode 100644
index 457e18d42..000000000
--- a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataTest.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Michael Scharf (Wind River) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tm.internal.terminal.model;
-
-import org.eclipse.tm.terminal.model.ITerminalTextData;
-
-public class TerminalTextDataTest extends AbstractITerminalTextDataTest {
- protected ITerminalTextData makeITerminalTextData() {
- return new TerminalTextData();
- }
-
-}
diff --git a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataWindowTest.java b/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataWindowTest.java
deleted file mode 100644
index 5e739176c..000000000
--- a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataWindowTest.java
+++ /dev/null
@@ -1,481 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Michael Scharf (Wind River) - initial API and implementation
- * Martin Oberhuber (Wind River) - [168197] Fix Terminal for CDC-1.1/Foundation-1.1
- *******************************************************************************/
-package org.eclipse.tm.internal.terminal.model;
-
-import java.util.ArrayList;
-
-import org.eclipse.tm.terminal.model.ITerminalTextData;
-import org.eclipse.tm.terminal.model.LineSegment;
-import org.eclipse.tm.terminal.model.Style;
-import org.eclipse.tm.terminal.model.StyleColor;
-
-public class TerminalTextDataWindowTest extends AbstractITerminalTextDataTest {
- int fOffset;
- int fSize;
- public TerminalTextDataWindowTest() {
- fOffset=2;
- fSize=2;
- }
- protected ITerminalTextData makeITerminalTextData() {
- TerminalTextDataWindow term=new TerminalTextDataWindow();
- term.setWindow(fOffset,fSize);
- return term;
- }
- /**
- * Used for multi line text
- * @param expected
- * @param actual
- */
- protected void assertEqualsTerm(String expected,String actual) {
- assertEquals(stripMultiLine(expected), stripMultiLine(actual));
- }
- private String stripMultiLine(String s) {
- StringBuffer b=new StringBuffer();
- // String[] lines=s.split("\n");
- // <J2ME CDC-1.1 Foundation-1.1 variant>
- ArrayList l = new ArrayList();
- int j = 0;
- for (int k = 0; k < s.length(); k++) {
- if (s.charAt(k) == '\n') {
- l.add(s.substring(j, k));
- j = k;
- }
- }
- j = l.size() - 1;
- while (j >= 0 && "".equals(l.get(j))) {
- j--;
- }
- String[] lines = new String[j + 1];
- while (j >= 0) {
- lines[j] = (String) l.get(j);
- j--;
- }
- // </J2ME CDC-1.1 Foundation-1.1 variant>
- for (int i = 0; i < lines.length; i++) {
- if(i>0)
- b.append("\n"); //$NON-NLS-1$
- if(i>=fOffset && i<fOffset+fSize)
- b.append(lines[i]);
- else
- b.append(new String(new char[lines[i].length()]));
- }
- return b.toString();
- }
- /**
- * Used for simple text
- * @param expected
- * @param actual
- */
- protected void assertEqualsSimple(String expected,String actual) {
- assertEquals(stripSimple(expected), stripSimple(actual));
- }
- String stripSimple(String s) {
- StringBuffer b=new StringBuffer();
- for (int i = 0; i < s.length(); i++) {
- if(i>=fOffset && i<fOffset+fSize)
- b.append(s.charAt(i));
- else
- b.append(' ');
- }
- return b.toString();
- }
- public void testAddLine() {
- String s=
- "111\n" +
- "222\n" +
- "333\n" +
- "444\n" +
- "555";
- ITerminalTextData term=makeITerminalTextData();
- fill(term, s);
- term.addLine();
- assertEqualsTerm(
- "222\n" +
- "333\n" +
- "444\n" +
- "\0\0\0\n" +
- "\000\000\000", toMultiLineText(term));
- }
-
- public void testMaxSize() {
- String s=
- "111\n" +
- "222\n" +
- "333\n" +
- "444\n" +
- "555";
- ITerminalTextData term=makeITerminalTextData();
- term.setMaxHeight(8);
- fill(term, s);
- assertEquals(5, term.getHeight());
- assertEquals(8, term.getMaxHeight());
- term.addLine();
- assertEquals(6, term.getHeight());
- assertEqualsTerm(
- "111\n" +
- "222\n" +
- "333\n" +
- "444\n" +
- "555\n" +
- "\000\000\000", toMultiLineText(term));
- term.addLine();
- assertEquals(7, term.getHeight());
- assertEqualsTerm(
- "111\n" +
- "222\n" +
- "333\n" +
- "444\n" +
- "555\n" +
- "\000\000\000\n" +
- "\000\000\000", toMultiLineText(term));
- term.addLine();
- assertEquals(8, term.getHeight());
- assertEqualsTerm(
- "111\n" +
- "222\n" +
- "333\n" +
- "444\n" +
- "555\n" +
- "\000\000\000\n" +
- "\000\000\000\n" +
- "\000\000\000", toMultiLineText(term));
- term.addLine();
- assertEquals(8, term.getHeight());
- assertEqualsTerm(
- "222\n" +
- "333\n" +
- "444\n" +
- "\000\000\000\n" +
- "\000\000\000\n" +
- "\000\000\000\n" +
- "\000\000\000\n" +
- "\000\000\000", toMultiLineText(term));
- }
-
- public void testGetLineSegments() {
- Style s1=getDefaultStyle();
- Style s2=s1.setBold(true);
- Style s3=s1.setUnderline(true);
- ITerminalTextData term=makeITerminalTextData();
- term.setDimensions(8, 8);
- LineSegment[] segments;
-
- term.setChars(2, 0,"0123".toCharArray(), s1);
- term.setChars(2, 4,"abcd".toCharArray(), null);
- segments=term.getLineSegments(2, 0, term.getWidth());
- assertEquals(2, segments.length);
- assertSegment(0, "0123", s1, segments[0]);
- assertSegment(4, "abcd", null, segments[1]);
-
-
- segments=term.getLineSegments(2, 4, term.getWidth()-4);
- assertEquals(1, segments.length);
- assertSegment(4, "abcd", null, segments[0]);
-
- segments=term.getLineSegments(2, 3, 2);
- assertEquals(2, segments.length);
- assertSegment(3, "3", s1, segments[0]);
- assertSegment(4, "a", null, segments[1]);
-
- segments=term.getLineSegments(2, 7, 1);
- assertEquals(1, segments.length);
- assertSegment(7, "d", null, segments[0]);
-
- segments=term.getLineSegments(2, 0, 1);
- assertEquals(1, segments.length);
- assertSegment(0, "0", s1, segments[0]);
-
- // line 1
- term.setChars(1, 0,"x".toCharArray(), s1);
- term.setChars(1, 1,"y".toCharArray(), s2);
- term.setChars(1, 2,"z".toCharArray(), s3);
-
- segments=term.getLineSegments(1, 0, term.getWidth());
- assertEquals(1, segments.length);
- assertSegment(0, "\000\000\000\000\000\000\000\000", null, segments[0]);
-
- // line 3
- segments=term.getLineSegments(3, 0, term.getWidth());
- assertEquals(1, segments.length);
- assertSegment(0, "\000\000\000\000\000\000\000\000", null, segments[0]);
-
- }
- public void testGetChar() {
- String s="12345\n" +
- "abcde\n" +
- "ABCDE";
- ITerminalTextData term=makeITerminalTextData();
- fill(term, s);
- assertEquals('\000', term.getChar(0,0));
- assertEquals('\000', term.getChar(0,1));
- assertEquals('\000', term.getChar(0,2));
- assertEquals('\000', term.getChar(0,3));
- assertEquals('\000', term.getChar(0,4));
- assertEquals('\000', term.getChar(1,0));
- assertEquals('\000', term.getChar(1,1));
- assertEquals('\000', term.getChar(1,2));
- assertEquals('\000', term.getChar(1,3));
- assertEquals('\000', term.getChar(1,4));
- assertEquals('A', term.getChar(2,0));
- assertEquals('B', term.getChar(2,1));
- assertEquals('C', term.getChar(2,2));
- assertEquals('D', term.getChar(2,3));
- assertEquals('E', term.getChar(2,4));
- }
- public void testGetStyle() {
- ITerminalTextData term=makeITerminalTextData();
- Style style=getDefaultStyle();
- term.setDimensions(6, 3);
- for (int line = 0; line < term.getHeight(); line++) {
- for (int column = 0; column < term.getWidth(); column++) {
- char c=(char)('a'+column+line);
- term.setChar(line, column, c, style.setForground(StyleColor.getStyleColor(""+c)));
- }
- }
- for (int line = 0; line < term.getHeight(); line++) {
- for (int column = 0; column < term.getWidth(); column++) {
- char c=(char)('a'+column+line);
- Style s=null;
- if(line>=fOffset&&line<fOffset+fSize)
- s=style.setForground(StyleColor.getStyleColor(""+c));
- assertSame(s, term.getStyle(line, column));
- }
- }
-
- }
- public void testSetChar() {
- ITerminalTextData term=makeITerminalTextData();
- term.setDimensions(6, 3);
- for (int line = 0; line < term.getHeight(); line++) {
- for (int column = 0; column < term.getWidth(); column++) {
- term.setChar(line, column, (char)('a'+column+line), null);
- }
- }
- for (int line = 0; line < term.getHeight(); line++) {
- for (int column = 0; column < term.getWidth(); column++) {
- char c=0;
- if(line>=fOffset&&line<fOffset+fSize)
- c=(char)('a'+column+line);
- assertEquals(c, term.getChar(line,column));
- }
- }
- assertEqualsTerm(
- "abc\n"
- + "bcd\n"
- + "cde\n"
- + "def\n"
- + "efg\n"
- + "fgh", toMultiLineText(term));
- }
-
- public void testSetChars() {
- ITerminalTextData term=makeITerminalTextData();
- term.setDimensions(6, 3);
- for (int line = 0; line < term.getHeight(); line++) {
- char[] chars=new char[term.getWidth()];
- for (int column = 0; column < term.getWidth(); column++) {
- chars[column]=(char)('a'+column+line);
- }
- term.setChars(line, 0, chars, null);
- }
- for (int line = 0; line < term.getHeight(); line++) {
- for (int column = 0; column < term.getWidth(); column++) {
- char c=0;
- if(line>=fOffset&&line<fOffset+fSize)
- c=(char)('a'+column+line);
- assertEquals(c, term.getChar(line,column));
- }
- }
- assertEqualsTerm(
- "abc\n"
- + "bcd\n"
- + "cde\n"
- + "def\n"
- + "efg\n"
- + "fgh", toMultiLineText(term));
-
- term.setChars(3, 1, new char[]{'1','2'}, null);
- assertEqualsTerm(
- "abc\n"
- + "bcd\n"
- + "cde\n"
- + "d12\n"
- + "efg\n"
- + "fgh", toMultiLineText(term));
- // check if chars are correctly chopped
- term.setChars(4, 1, new char[]{'1','2','3','4','5'}, null);
- assertEqualsTerm(
- "abc\n"
- + "bcd\n"
- + "cde\n"
- + "d12\n"
- + "e12\n"
- + "fgh", toMultiLineText(term));
-
- }
- public void testSetCharsLen() {
- ITerminalTextData term=makeITerminalTextData();
- String s= "ZYXWVU\n"
- + "abcdef\n"
- + "ABCDEF";
- fill(term, s);
- char[] chars=new char[]{'1','2','3','4','5','6','7','8'};
- term.setChars(1, 0, chars, 0, 6,null);
- assertEqualsTerm(
- "ZYXWVU\n"
- + "123456\n"
- + "ABCDEF", toMultiLineText(term));
-
- fill(term, s);
- term.setChars(1, 0, chars, 0, 5, null);
- assertEqualsTerm("ZYXWVU\n"
- + "12345f\n"
- + "ABCDEF", toMultiLineText(term));
-
- fill(term, s);
- term.setChars(1, 0, chars, 1, 5, null);
- assertEqualsTerm("ZYXWVU\n"
- + "23456f\n"
- + "ABCDEF", toMultiLineText(term));
-
- fill(term, s);
- term.setChars(1, 1, chars, 1, 4, null);
- assertEqualsTerm("ZYXWVU\n"
- + "a2345f\n"
- + "ABCDEF", toMultiLineText(term));
-
-
-
- fill(term, s);
- term.setChars(1, 2, chars, 3, 4, null);
- assertEqualsTerm("ZYXWVU\n"
- + "ab4567\n"
- + "ABCDEF", toMultiLineText(term));
-
- fill(term, s);
- }
- public void testSetCopyLines() {
- ITerminalTextData term=new TerminalTextDataStore();
- String s="012345";
- fillSimple(term, s);
- ITerminalTextData termCopy=makeITerminalTextData();
- String sCopy="abcde";
- fillSimple(termCopy, sCopy);
- termCopy.copyRange(term,0,0,0);
- assertEqualsSimple(s, toSimple(term));
- assertEqualsSimple(sCopy, toSimple(termCopy));
-
- fillSimple(termCopy, sCopy);
- termCopy.copyRange(term,0,0,5);
- assertEqualsSimple(s, toSimple(term));
- assertEqualsSimple("01234", toSimple(termCopy));
-
- fillSimple(termCopy, sCopy);
- termCopy.copyRange(term,0,0,2);
- assertEqualsSimple(s, toSimple(term));
- assertEqualsSimple("01cde", toSimple(termCopy));
-
- fillSimple(termCopy, sCopy);
- termCopy.copyRange(term,0,1,2);
- assertEqualsSimple(s, toSimple(term));
- assertEqualsSimple("a01de", toSimple(termCopy));
-
- fillSimple(termCopy, sCopy);
- termCopy.copyRange(term,1,1,2);
- assertEqualsSimple(s, toSimple(term));
- assertEqualsSimple("a12de", toSimple(termCopy));
-
- fillSimple(termCopy, sCopy);
- termCopy.copyRange(term,1,1,4);
- assertEqualsSimple(s, toSimple(term));
- assertEqualsSimple("a1234", toSimple(termCopy));
-
- fillSimple(termCopy, sCopy);
- termCopy.copyRange(term,2,1,4);
- assertEqualsSimple(s, toSimple(term));
- assertEqualsSimple("a2345", toSimple(termCopy));
- }
- public void testScrollNegative() {
- scrollTest(0,2,-1," 23 "," 23 ");
- scrollTest(0,1,-1," 23 "," 23 ");
- scrollTest(0,6,-1," 23 "," 3 ");
- scrollTest(0,6,-6," 23 "," ");
- scrollTest(0,6,-7," 23 "," ");
- scrollTest(0,6,-8," 23 "," ");
- scrollTest(0,6,-2," 23 "," ");
- scrollTest(1,1,-1," 23 "," 23 ");
- scrollTest(1,2,-1," 23 "," 3 ");
- scrollTest(5,1,-1," 23 "," 23 ");
- scrollTest(5,1,-1," 23 "," 23 ");
- }
- public void testScrollAll() {
- scrollTest(0,6,1, " 2345"," 2 ");
- scrollTest(0,6,-1, " 2345"," 3 ");
- scrollTest(0,6,2, " 2345"," ");
- scrollTest(0,6,-2, " 2345"," ");
- }
- public void testCopyLineWithOffset() {
- ITerminalTextData term=makeITerminalTextData();
- String s=
- "111\n" +
- "222\n" +
- "333\n" +
- "444\n" +
- "555";
- fill(term, s);
- ITerminalTextData dest=makeITerminalTextData();
- String sCopy=
- "aaa\n" +
- "bbb\n" +
- "ccc\n" +
- "ddd\n" +
- "eee";
- fill(dest, sCopy);
- copySelective(dest,term,1,0,new boolean []{true,false,false,true});
- assertEqualsTerm(s, toMultiLineText(term));
- assertEqualsTerm(
- "222\n" +
- "bbb\n" +
- "ccc\n" +
- "\00\00\00\n" +
- "eee", toMultiLineText(dest));
-
- fill(dest, sCopy);
- copySelective(dest,term,2,0,new boolean []{true,true});
- assertEqualsTerm(s, toMultiLineText(term));
- assertEqualsTerm(
- "333\n" +
- "444\n" +
- "ccc\n" +
- "ddd\n" +
- "eee", toMultiLineText(dest));
-
- fill(dest, sCopy);
- copySelective(dest,term,0,0,new boolean []{true,true,true,true,true});
- assertEqualsTerm(s, toMultiLineText(term));
- assertEqualsTerm(s, toMultiLineText(dest));
-
- fill(dest, sCopy);
- copySelective(dest,term,0,0,new boolean []{false,false,false,false,false});
- assertEqualsTerm(s, toMultiLineText(term));
- assertEqualsTerm(sCopy, toMultiLineText(dest));
- }
- public void testCopy() {
- ITerminalTextData term=makeITerminalTextData();
- term.setDimensions(3, 1);
- ITerminalTextData data=new TerminalTextData();
- fillSimple(data,"abcd");
- term.copy(data);
-
-
- }
-}
diff --git a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/TerminalTextTestHelper.java b/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/TerminalTextTestHelper.java
deleted file mode 100644
index 95a91f9b3..000000000
--- a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/model/TerminalTextTestHelper.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Michael Scharf (Wind River) - initial API and implementation
- * Martin Oberhuber (Wind River) - [168197] Fix Terminal for CDC-1.1/Foundation-1.1
- *******************************************************************************/
-package org.eclipse.tm.internal.terminal.model;
-
-import org.eclipse.tm.terminal.model.ITerminalTextData;
-import org.eclipse.tm.terminal.model.ITerminalTextDataReadOnly;
-import org.eclipse.tm.terminal.model.Style;
-import org.eclipse.tm.terminal.model.StyleColor;
-
-public class TerminalTextTestHelper {
- static public String toSimple(ITerminalTextDataReadOnly term) {
- return toSimple(toMultiLineText(term));
- }
- static public String toMultiLineText(ITerminalTextDataReadOnly term) {
- StringBuffer buff=new StringBuffer();
- int width=term.getWidth();
- for (int line = 0; line < term.getHeight(); line++) {
- if(line>0)
- buff.append("\n"); //$NON-NLS-1$
- for (int column = 0; column < width; column++) {
- buff.append(term.getChar(line, column));
- }
- }
- return buff.toString();
- }
- static public String toSimple(String str) {
- //return str.replaceAll("\000", " ").replaceAll("\n", "");
- // <J2ME CDC-1.1 Foundation-1.1 variant>
- StringBuffer buf = new StringBuffer(str.length());
- for (int i = 0; i < str.length(); i++) {
- char c = str.charAt(i);
- switch (c) {
- case '\000':
- buf.append(' ');
- break;
- case '\n':
- break;
- default:
- buf.append(c);
- break;
- }
- }
- return buf.toString();
- // </J2ME CDC-1.1 Foundation-1.1 variant>
- }
- /**
- * @param term
- * @param s each character is one line
- */
- static public void fillSimple(ITerminalTextData term, String s) {
- Style style=Style.getStyle(StyleColor.getStyleColor("fg"), StyleColor.getStyleColor("bg"), false, false, false, false);
- term.setDimensions(s.length(), 1);
- for (int i = 0; i < s.length(); i++) {
- char c=s.charAt(i);
- term.setChar(i, 0, c, style.setForground(StyleColor.getStyleColor(""+c)));
- }
- }
- /**
- * @param term
- * @param s lines separated by \n. The terminal will automatically
- * resized to fit the text.
- */
- static public void fill(ITerminalTextData term, String s) {
- int width=0;
- int len=0;
- int height=0;
- for (int i = 0; i < s.length(); i++) {
- char c=s.charAt(i);
- if(c=='\n') {
- width=Math.max(width,len);
- len=0;
- } else {
- if(len==0)
- height++;
- len++;
- }
- }
- width=Math.max(width,len);
- term.setDimensions(height, width);
- fill(term,0,0,s);
- }
-
- static public void fill(ITerminalTextData term, int column, int line, String s) {
- int xx=column;
- int yy=line;
- Style style=Style.getStyle(StyleColor.getStyleColor("fg"), StyleColor.getStyleColor("bg"), false, false, false, false);
- for (int i = 0; i < s.length(); i++) {
- char c=s.charAt(i);
- if(c=='\n') {
- yy++;
- xx=column;
- } else {
- term.setChar(yy, xx, c, style.setForground(StyleColor.getStyleColor(""+c)));
- xx++;
- }
- }
- }
-
-}
diff --git a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/speedtest/SpeedTestConnection.java b/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/speedtest/SpeedTestConnection.java
deleted file mode 100644
index 115435b0f..000000000
--- a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/speedtest/SpeedTestConnection.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Michael Scharf (Wind River) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tm.internal.terminal.speedtest;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl;
-import org.eclipse.tm.internal.terminal.provisional.api.Logger;
-import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
-
-public class SpeedTestConnection extends Thread {
- private static int fgNo;
- private final ITerminalControl fControl;
- private final InputStream fInputStream;
- private final SpeedTestSettings fSettings;
- protected SpeedTestConnection(InputStream inputStream, SpeedTestSettings settings,ITerminalControl control) {
- super("SpeedTestConnection-"+fgNo++);
- fControl = control;
- fInputStream=inputStream;
- fSettings=settings;
- }
- public void run() {
- fControl.setState(TerminalState.CONNECTED);
-
- try {
- readDataForever(fInputStream,fControl.getRemoteToTerminalOutputStream());
- } catch (IOException e) {
- connectFailed(e.getMessage(),e.getMessage());
- }
- // when reading is done, we set the state to closed
- fControl.setState(TerminalState.CLOSED);
- }
- private void connectFailed(String terminalText, String msg) {
- Logger.log(terminalText);
- fControl.displayTextInTerminal(terminalText);
- fControl.setState(TerminalState.CLOSED);
- fControl.setMsg(msg);
- }
- /**
- * Read the data from the input file and display it in the terminal.
- * @param in
- * @throws IOException
- */
- private void readDataForever(InputStream in, OutputStream os) throws IOException {
- long N=0;
- long T=0;
- long tDisplay=0;
- int NCalls=0;
- int bufferSize=fSettings.getBufferSize();
- int throttle=fSettings.getThrottle();
- // read the data
- BufferedReader reader = new BufferedReader(new InputStreamReader(in));
- // read until the thread gets interrupted....
- String info="";
- int n=0;
- byte[] crnl="\r\n".getBytes("UTF-8");
- long t0=System.currentTimeMillis();
- String line=null;
- do {
- line=reader.readLine();
-
- // read some bytes
- if(line!=null) {
- os.write(line.getBytes("UTF-8"));
- os.write(crnl);
- n+=line.length();
- }
- // process at least this number of characters to update the UI
- if(line==null || n>bufferSize) {
- if(throttle>0)
- sleep(throttle);
- // we assume we get ASCII UTF8 bytes
- long t=System.currentTimeMillis();
- T+=t-t0;
- N+=n;
- NCalls++;
- if(t-tDisplay>1000 && T>0) {
- long rate=(1000*N)/T;
- info=rate+" byte/s = "+rate*8+" baud "+"bytes/call="+N/NCalls;
- info=rate+" byte/s with buffer size "+fSettings.getBufferSize();
- setTitle(info);
- tDisplay=System.currentTimeMillis();
- }
- n=0;
- t0=System.currentTimeMillis();
- }
- } while(line!=null);
- }
- private void sleep(int ms) {
- try {
- Thread.sleep(ms);
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- }
- }
- private void setTitle(final String title) {
- Display.getDefault().asyncExec(new Runnable(){
- public void run() {
- fControl.setTerminalTitle(title);
- }});
- }
-
-}
diff --git a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/speedtest/SpeedTestConnector.java b/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/speedtest/SpeedTestConnector.java
deleted file mode 100644
index 88e9b5a5d..000000000
--- a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/speedtest/SpeedTestConnector.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Michael Scharf (Wind River) - initial API and implementation
- * Martin Oberhuber (Wind River) - [225853][api] Provide more default functionality in TerminalConnectorImpl
- *******************************************************************************/
-package org.eclipse.tm.internal.terminal.speedtest;
-
-import java.io.BufferedInputStream;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import org.eclipse.tm.internal.terminal.provisional.api.ISettingsPage;
-import org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore;
-import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl;
-import org.eclipse.tm.internal.terminal.provisional.api.Logger;
-import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
-import org.eclipse.tm.internal.terminal.provisional.api.provider.TerminalConnectorImpl;
-
-public class SpeedTestConnector extends TerminalConnectorImpl {
- final SpeedTestSettings fSettings=new SpeedTestSettings();
- InputStream fInputStream;
- OutputStream fOutputStream;
- SpeedTestConnection fConnection;
- public SpeedTestConnector() {
- }
- synchronized public void connect(ITerminalControl control) {
- super.connect(control);
- fControl.setState(TerminalState.CONNECTING);
- String file=fSettings.getInputFile();
- try {
- fInputStream=new BufferedInputStream(new FileInputStream(file));
- } catch (FileNotFoundException e) {
- disconnect();
- fControl.setMsg(file+": "+e.getLocalizedMessage());
- return;
- }
- fOutputStream=System.out;
- fControl.setTerminalTitle(fSettings.getInputFile());
- fConnection=new SpeedTestConnection(fInputStream,fSettings,fControl);
- fConnection.start();
- }
-
- synchronized public void doDisconnect() {
- if(fConnection!=null){
- fConnection.interrupt();
- fConnection=null;
- }
- if (fInputStream != null) {
- try {
- fInputStream.close();
- } catch (Exception exception) {
- Logger.logException(exception);
- }
- }
- fInputStream=null;
- if (fOutputStream != null) {
- try {
- fOutputStream.close();
- } catch (Exception exception) {
- Logger.logException(exception);
- }
- }
- fOutputStream=null;
- }
- synchronized public InputStream getInputStream() {
- return fInputStream;
- }
-
- synchronized public OutputStream getTerminalToRemoteStream() {
- return fOutputStream;
- }
-
- public String getSettingsSummary() {
- return fSettings.getInputFile();
- }
-
- public void initialize() {
- //throw new RuntimeException("XXX problems\nSpeedTest\nXXX!");
- }
-
- public void load(ISettingsStore store) {
- fSettings.load(store);
- }
-
- public ISettingsPage makeSettingsPage() {
- return new SpeedTestSettingsPage(fSettings);
- }
-
- public void save(ISettingsStore store) {
- fSettings.save(store);
- }
-
- public void setTerminalSize(int newWidth, int newHeight) {
- }
-
-}
diff --git a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/speedtest/SpeedTestSettings.java b/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/speedtest/SpeedTestSettings.java
deleted file mode 100644
index 84f94226c..000000000
--- a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/speedtest/SpeedTestSettings.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Michael Scharf (Wind River) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tm.internal.terminal.speedtest;
-
-
-import org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore;
-
-public class SpeedTestSettings {
- String fInputFile="";
- String fBufferSize="";
- String fThrottle;
- String getInputFile() {
- return fInputFile;
- }
- public String getBufferSizeString() {
- return getBufferSize()+"";
- }
- public void setBufferSizeString(String bufferSize) {
- fBufferSize = bufferSize;
- }
- public int getBufferSize() {
- try {
- return Integer.parseInt(fBufferSize);
- } catch(RuntimeException e) {
- return 1024;
- }
- }
- void setInputFile(String testFile) {
- fInputFile = testFile;
- }
- public void load(ISettingsStore store) {
- fInputFile=store.get("inputFile");
- fBufferSize=store.get("bufferSize");
- fThrottle=store.get("throttle");
- }
- public void save(ISettingsStore store) {
- store.put("inputFile", fInputFile);
- store.put("bufferSize", fBufferSize);
- store.put("throttle", fThrottle);
- }
- public String getThrottleString() {
- return fThrottle;
- }
- public int getThrottle() {
- try {
- return Integer.parseInt(fThrottle);
- } catch(RuntimeException e) {
- return 0;
- }
- }
- public void setThrottleString(String throttle) {
- fThrottle = throttle;
- }
-}
diff --git a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/speedtest/SpeedTestSettingsPage.java b/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/speedtest/SpeedTestSettingsPage.java
deleted file mode 100644
index 1f0c5a234..000000000
--- a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/speedtest/SpeedTestSettingsPage.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Michael Scharf (Wind River) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tm.internal.terminal.speedtest;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.tm.internal.terminal.provisional.api.ISettingsPage;
-
-public class SpeedTestSettingsPage implements ISettingsPage {
- final SpeedTestSettings fSettings;
- Text fInputFile;
- Text fBufferSize;
- private Text fThrottle;
- SpeedTestSettingsPage(SpeedTestSettings settings) {
- fSettings=settings;
- }
- public void createControl(Composite parent) {
- Composite composite = new Composite(parent, SWT.NONE);
- GridLayout gridLayout = new GridLayout(2, false);
-
- composite.setLayout(gridLayout);
- composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- fInputFile=createTextField(composite, "Input File:");//$NON-NLS-1$
- fBufferSize=createTextField(composite, "Buffer Size:");//$NON-NLS-1$
- fThrottle=createTextField(composite, "Throttle:");//$NON-NLS-1$
- loadSettings();
- }
- private Text createTextField(Composite composite, String label) {
- new Label(composite, SWT.RIGHT).setText(label);
- Text text = new Text(composite, SWT.BORDER);
- text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- return text;
- }
-
- public void loadSettings() {
- setText(fInputFile, fSettings.getInputFile());
- setText(fBufferSize, fSettings.getBufferSizeString());
- setText(fThrottle, fSettings.getThrottleString());
- }
- private void setText(Text text, String value) {
- if(value==null)
- value="";
- text.setText(value);
- }
-
- public void saveSettings() {
- fSettings.setInputFile(fInputFile.getText());
- fSettings.setBufferSizeString(fBufferSize.getText());
- fSettings.setThrottleString(fThrottle.getText());
- }
-
- public boolean validateSettings() {
- return true;
- }
-
-}
diff --git a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/terminalcanvas/Main.java b/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/terminalcanvas/Main.java
deleted file mode 100644
index 6dde5a8bf..000000000
--- a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/terminalcanvas/Main.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Michael Scharf (Wind River) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tm.internal.terminal.test.terminalcanvas;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-public class Main {
-
- /**
- * @param args
- */
- public static void main(String[] args) {
- Display display = new Display ();
- Shell shell = new Shell (display);
- shell.setLayout(new FillLayout());
- new TerminalTextCanvas(shell,SWT.NONE);
- shell.setSize (200, 150);
- shell.open ();
- while (!shell.isDisposed ()) {
- if (!display.readAndDispatch ()) display.sleep ();
- }
- display.dispose ();
- }
-
-}
diff --git a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/terminalcanvas/Snippet48.java b/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/terminalcanvas/Snippet48.java
deleted file mode 100644
index 604d8b58b..000000000
--- a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/terminalcanvas/Snippet48.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Michael Scharf (Wind River) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tm.internal.terminal.test.terminalcanvas;
-
-
-/*
- * Canvas example snippet: scroll an image (flicker free, no double buffering)
- *
- * For a list of all SWT example snippets see
- * http://www.eclipse.org/swt/snippets/
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet48 {
-
-public static void main (String [] args) {
- Display display = new Display ();
- Shell shell = new Shell (display);
- shell.setLayout(new FillLayout());
- Image originalImage = null;
- FileDialog dialog = new FileDialog (shell, SWT.OPEN);
- dialog.setText ("Open an image file or cancel");
- String string = dialog.open ();
- if (string != null) {
- originalImage = new Image (display, string);
- }
- final Image image = originalImage;
- final Point origin = new Point (0, 0);
- final Canvas canvas = new Canvas (shell, SWT.NO_BACKGROUND |
- SWT.NO_REDRAW_RESIZE | SWT.V_SCROLL | SWT.H_SCROLL);
- final ScrollBar hBar = canvas.getHorizontalBar ();
- hBar.addListener (SWT.Selection, new Listener () {
- public void handleEvent (Event e) {
- int hSelection = hBar.getSelection ();
- int destX = -hSelection - origin.x;
- Rectangle rect = image.getBounds ();
- canvas.scroll (destX, 0, 0, 0, rect.width, rect.height, false);
- origin.x = -hSelection;
- }
- });
- final ScrollBar vBar = canvas.getVerticalBar ();
- vBar.addListener (SWT.Selection, new Listener () {
- public void handleEvent (Event e) {
- int vSelection = vBar.getSelection ();
- int destY = -vSelection - origin.y;
- Rectangle rect = image.getBounds ();
- canvas.scroll (0, destY, 0, 0, rect.width, rect.height, false);
- origin.y = -vSelection;
- }
- });
- canvas.addListener (SWT.Resize, new Listener () {
- public void handleEvent (Event e) {
- Rectangle rect = image.getBounds ();
- Rectangle client = canvas.getClientArea ();
- hBar.setMaximum (rect.width);
- vBar.setMaximum (rect.height);
- hBar.setThumb (Math.min (rect.width, client.width));
- vBar.setThumb (Math.min (rect.height, client.height));
- int hPage = rect.width - client.width;
- int vPage = rect.height - client.height;
- int hSelection = hBar.getSelection ();
- int vSelection = vBar.getSelection ();
- if (hSelection >= hPage) {
- if (hPage <= 0) hSelection = 0;
- origin.x = -hSelection;
- }
- if (vSelection >= vPage) {
- if (vPage <= 0) vSelection = 0;
- origin.y = -vSelection;
- }
- canvas.redraw ();
- }
- });
- canvas.addListener (SWT.Paint, new Listener () {
- public void handleEvent (Event e) {
- GC gc = e.gc;
- gc.drawImage (image, origin.x, origin.y);
- Rectangle rect = image.getBounds ();
- Rectangle client = canvas.getClientArea ();
- int marginWidth = client.width - rect.width;
- if (marginWidth > 0) {
- gc.fillRectangle (rect.width, 0, marginWidth, client.height);
- }
- int marginHeight = client.height - rect.height;
- if (marginHeight > 0) {
- gc.fillRectangle (0, rect.height, client.width, marginHeight);
- }
- }
- });
- shell.setSize (200, 150);
- shell.open ();
- while (!shell.isDisposed ()) {
- if (!display.readAndDispatch ()) display.sleep ();
- }
- originalImage.dispose();
- display.dispose ();
-}
-
-}
diff --git a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/terminalcanvas/TerminalTextCanvas.java b/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/terminalcanvas/TerminalTextCanvas.java
deleted file mode 100644
index 8996bb966..000000000
--- a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/terminalcanvas/TerminalTextCanvas.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Michael Scharf (Wind River) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tm.internal.terminal.test.terminalcanvas;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Canvas;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.ScrollBar;
-
-public class TerminalTextCanvas extends Canvas {
- Image image;
- Point origin = new Point (0, 0);
- public TerminalTextCanvas(Composite parent, int style) {
- super(parent, SWT.NO_BACKGROUND |
- SWT.NO_REDRAW_RESIZE | SWT.V_SCROLL | SWT.H_SCROLL| style);
- loadImage(parent);
-
- final ScrollBar hBar = getHorizontalBar ();
- hBar.addListener (SWT.Selection, new Listener () {
- public void handleEvent (Event e) {
- int hSelection = hBar.getSelection ();
- int destX = -hSelection - origin.x;
- Rectangle rect = image.getBounds ();
- scroll (destX, 0, 0, 0, rect.width, rect.height, false);
- origin.x = -hSelection;
- }
- });
- final ScrollBar vBar = getVerticalBar ();
- vBar.addListener (SWT.Selection, new Listener () {
- public void handleEvent (Event e) {
- int vSelection = vBar.getSelection ();
- int destY = -vSelection - origin.y;
- Rectangle rect = image.getBounds ();
- scroll (0, destY, 0, 0, rect.width, rect.height, false);
- origin.y = -vSelection;
- }
- });
- addListener (SWT.Resize, new Listener () {
- public void handleEvent (Event e) {
- Rectangle rect = image.getBounds ();
- Rectangle client = getClientArea ();
- hBar.setMaximum (rect.width);
- vBar.setMaximum (rect.height);
- hBar.setThumb (Math.min (rect.width, client.width));
- vBar.setThumb (Math.min (rect.height, client.height));
- int hPage = rect.width - client.width;
- int vPage = rect.height - client.height;
- int hSelection = hBar.getSelection ();
- int vSelection = vBar.getSelection ();
- if (hSelection >= hPage) {
- if (hPage <= 0) hSelection = 0;
- origin.x = -hSelection;
- }
- if (vSelection >= vPage) {
- if (vPage <= 0) vSelection = 0;
- origin.y = -vSelection;
- }
- redraw ();
- }
- });
- addListener (SWT.Paint, new Listener () {
- public void handleEvent (Event e) {
- GC gc = e.gc;
- System.out.println(gc.getClipping()+" "+origin);
- gc.drawImage (image, origin.x, origin.y);
- Rectangle rect = image.getBounds ();
- Rectangle client = getClientArea ();
- int marginWidth = client.width - rect.width;
- if (marginWidth > 0) {
- gc.fillRectangle (rect.width, 0, marginWidth, client.height);
- }
- int marginHeight = client.height - rect.height;
- if (marginHeight > 0) {
- gc.fillRectangle (0, rect.height, client.width, marginHeight);
- }
- }
- });
- }
- private void loadImage(Composite parent) {
- FileDialog dialog = new FileDialog (parent.getShell(), SWT.OPEN);
- dialog.setText ("Open an image file or cancel");
- String string = dialog.open ();
- if (string != null) {
- image = new Image (getDisplay(), string);
- }
- }
-
-}
diff --git a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/terminalcanvas/VirtualCanvas.java b/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/terminalcanvas/VirtualCanvas.java
deleted file mode 100644
index 414622254..000000000
--- a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/terminalcanvas/VirtualCanvas.java
+++ /dev/null
@@ -1,333 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Michael Scharf (Wind River) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tm.internal.terminal.test.terminalcanvas;
-
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Canvas;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.ScrollBar;
-
-/**
- * A <code>Canvas</code> showing a virtual object.
- * Virtual: the extent of the total canvas.
- * Screen: the visible client area in the screen.
- */
-public abstract class VirtualCanvas extends Canvas {
-
- private Rectangle fVirtualBounds = new Rectangle(0,0,0,0);
- private Rectangle fClientArea;
- private GC fPaintGC=null;
- public VirtualCanvas(Composite parent, int style) {
- super(parent, style|SWT.NO_BACKGROUND|SWT.NO_REDRAW_RESIZE);
- fPaintGC= new GC(this);
- addListener(SWT.Paint, new Listener() {
- public void handleEvent(Event event) {
- paint(event.gc);
- }
- });
- addListener(SWT.Resize, new Listener() {
- public void handleEvent(Event event) {
- fClientArea=getClientArea();
- updateViewRectangle();
- }
- });
- getVerticalBar().addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- scrollY((ScrollBar)e.widget);
- postScrollEventHandling(e);
-
- }
-
- });
- getHorizontalBar().addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- scrollX((ScrollBar)e.widget);
- postScrollEventHandling(e);
-
- }
- });
- addDisposeListener(new DisposeListener(){
- public void widgetDisposed(DisposeEvent e) {
- if(fPaintGC!=null){
- fPaintGC.dispose();
- fPaintGC=null;
- }
- }
-
- });
- }
- public void setAutoSelect(boolean on) {
- }
- public boolean hasAutoSelect() {
- return false;
- }
- public void doAutoSelect() {
- }
-
- /** HACK: run an event loop if the scrollbar is dragged...*/
- private void postScrollEventHandling(Event e) {
- if(true&&e.detail==SWT.DRAG) {
- // TODO check if this is always ok???
- // used to process runnables while scrolling
- // This fixes the update problems when scrolling!
- // see: https://bugs.eclipse.org/bugs/show_bug.cgi?id=47582#5
- // TODO investigate:
- // The alternative is to call redraw on the new visible area
- // redraw(expose.x, expose.y, expose.width, expose.height, true);
-
- while (!getDisplay().isDisposed() && getDisplay().readAndDispatch()) {
- // do nothing here...
- }
- }
- }
-
- protected void scrollX(ScrollBar hBar) {
- int hSelection = hBar.getSelection ();
- int destX = -hSelection - fVirtualBounds.x;
- fVirtualBounds.x = -hSelection;
- scrollSmart(destX, 0);
- updateViewRectangle();
- }
- protected void scrollXDelta(int delta) {
- getHorizontalBar().setSelection(-fVirtualBounds.x+delta);
- scrollX(getHorizontalBar());
- }
-
- protected void scrollY(ScrollBar vBar) {
- int vSelection = vBar.getSelection ();
- int destY = -vSelection - fVirtualBounds.y;
- fVirtualBounds.y = -vSelection;
- scrollSmart(0,destY);
- updateViewRectangle();
-
- }
- protected void scrollYDelta(int delta) {
- getVerticalBar().setSelection(-fVirtualBounds.y+delta);
- scrollY(getVerticalBar());
- }
-
-
- private void scrollSmart(int deltaX, int deltaY) {
- Rectangle rect = getBounds();
- scroll (deltaX, deltaY, 0, 0, rect.width, rect.height, false);
- }
-
- protected void revealRect(Rectangle rect) {
- Rectangle visibleRect=getScreenRectInVirtualSpace();
- // scroll the X part
- int deltaX=0;
- if(rect.x<visibleRect.x) {
- deltaX=rect.x-visibleRect.x;
- } else if(visibleRect.x+visibleRect.width<rect.x+rect.width){
- deltaX=(rect.x+rect.width)-(visibleRect.x+visibleRect.width);
- }
- if(deltaX!=0) {
- getHorizontalBar().setSelection(-fVirtualBounds.x+deltaX);
- scrollX(getHorizontalBar());
- }
-
- // scroll the Y part
- int deltaY=0;
- if(rect.y<visibleRect.y){
- deltaY=rect.y-visibleRect.y;
- } else if(visibleRect.y+visibleRect.height<rect.y+rect.height){
- deltaY=(rect.y+rect.height)-(visibleRect.y+visibleRect.height);
-
- }
- if(deltaY!=0) {
- getVerticalBar().setSelection(-fVirtualBounds.y+deltaY);
- scrollY(getVerticalBar());
- }
- }
-
- protected void repaint(Rectangle r) {
- if (fPaintGC!=null) {
- if(inClipping(r,fClientArea)) {
- fPaintGC.setClipping(r);
- paint(fPaintGC);
- }
- }
- }
-
- /**
- * @param gc
- */
- abstract protected void paint(GC gc);
- protected Color getBackgroundColor() {
- return getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND);
- }
- protected void paintUnoccupiedSpace(GC gc, Rectangle clipping) {
- int width=fVirtualBounds.width;
- int height=fVirtualBounds.height;
- int marginWidth = (clipping.x+clipping.width) - width;
- int marginHeight = (clipping.y+clipping.height) - height;
- if(marginWidth>0||marginHeight>0){
- Color bg=getBackground();
- gc.setBackground(getBackgroundColor());
- if (marginWidth > 0) {
- gc.fillRectangle (width, clipping.y, marginWidth, clipping.height);
- }
- if (marginHeight > 0) {
- gc.fillRectangle (clipping.x, height, clipping.width, marginHeight);
- }
- gc.setBackground(bg);
- }
- }
- /**
- * @private
- */
- protected boolean inClipping(Rectangle clipping, Rectangle r) {
- // TODO check if this is OK in all cases (the <=!)
- //
- if(r.x+r.width<=clipping.x)
- return false;
- if(clipping.x+clipping.width<=r.x)
- return false;
- if(r.y+r.height<=clipping.y)
- return false;
- if(clipping.y+clipping.height<=r.y)
- return false;
-
- return true;
- }
- /**
- * @return the screen rect in virtual space (starting with (0,0))
- * of the visible screen. (x,y>=0)
- */
- protected Rectangle getScreenRectInVirtualSpace() {
- return new Rectangle(fClientArea.x-fVirtualBounds.x,fClientArea.y-fVirtualBounds.y,fClientArea.width,fClientArea.height);
- }
- /**
- * @return the rect in virtual space (starting with (0,0))
- * of the visible screen. (x,y>=0)
- */
- protected Rectangle getRectInVirtualSpace(Rectangle r) {
- return new Rectangle(r.x-fVirtualBounds.x,r.y-fVirtualBounds.y,r.width,r.height);
- }
-
- /**
- * Sets the extend of the virtual dieplay ares
- * @param width
- * @param height
- */
- protected void setVirtualExtend(int width, int height) {
- fVirtualBounds.width=width;
- fVirtualBounds.height=height;
- updateScrollbars();
- updateViewRectangle();
- }
- /**
- * sets the scrolling origin. Also sets the scrollbars.
- * Does NOT redraw!
- * Use negative values (move the virtual origin to the top left
- * to see something in the screen (which is located at (0,0))
- * @param x
- * @param y
- */
- protected void setVirtualOrigin(int x, int y) {
- fVirtualBounds.x=x;
- fVirtualBounds.y=y;
- getHorizontalBar().setSelection(x);
- getVerticalBar().setSelection(y);
- updateViewRectangle();
- }
-
- /**
- * @param x
- * @return the virtual coordinate in scree space
- */
- protected int virtualXtoScreen(int x) {
- return x+fVirtualBounds.x;
- }
- protected int virtualYtoScreen(int y) {
- return y+fVirtualBounds.y;
- }
- protected int screenXtoVirtual(int x) {
- return x-fVirtualBounds.x;
- }
- protected int screenYtoVirtual(int y) {
- return y-fVirtualBounds.y;
- }
- /** called when the viewed part is changing */
- private Rectangle fViewRectangle=new Rectangle(0,0,0,0);
- void updateViewRectangle() {
- if(
- fViewRectangle.x==-fVirtualBounds.x
- && fViewRectangle.y==-fVirtualBounds.y
- && fViewRectangle.width==fClientArea.width
- && fViewRectangle.height==fClientArea.height
- )
- return;
- fViewRectangle.x=-fVirtualBounds.x;
- fViewRectangle.y=-fVirtualBounds.y;
- fViewRectangle.width=fClientArea.width;
- fViewRectangle.height=fClientArea.height;
- viewRectangleChanged(fViewRectangle.x,fViewRectangle.y,fViewRectangle.width,fViewRectangle.height);
- }
- protected Rectangle getViewRectangle() {
- return fViewRectangle;
- }
- /**
- * Called when the viewed part has changed.
- * Override when you need this information....
- * Is only called if the values change!
- * @param x visible in virtual space
- * @param y visible in virtual space
- * @param width
- * @param height
- */
- protected void viewRectangleChanged(int x, int y, int width, int height) {
-// System.out.println(x+" "+y+" "+width+" "+height);
- }
- /**
- * @private
- */
- private void updateScrollbars() {
- Point size= getSize();
- Rectangle clientArea= getClientArea();
-
- ScrollBar horizontal= getHorizontalBar();
- if (fVirtualBounds.width <= clientArea.width) {
- // TODO IMPORTANT in ScrollBar.setVisible comment out the line
- // that checks 'isvisible' and returns (at the beginning)
- horizontal.setVisible(false);
- horizontal.setSelection(0);
- } else {
- horizontal.setPageIncrement(clientArea.width - horizontal.getIncrement());
- int max= fVirtualBounds.width + (size.x - clientArea.width);
- horizontal.setMaximum(max);
- horizontal.setThumb(size.x > max ? max : size.x);
- horizontal.setVisible(true);
- }
-
- ScrollBar vertical= getVerticalBar();
- if (fVirtualBounds.height <= clientArea.height) {
- vertical.setVisible(false);
- vertical.setSelection(0);
- } else {
- vertical.setPageIncrement(clientArea.height - vertical.getIncrement());
- int max= fVirtualBounds.height + (size.y - clientArea.height);
- vertical.setMaximum(max);
- vertical.setThumb(size.y > max ? max : size.y);
- vertical.setVisible(true);
- }
- }
-}
-
diff --git a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/ui/AbstractLineOrientedDataSource.java b/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/ui/AbstractLineOrientedDataSource.java
deleted file mode 100644
index f0c297511..000000000
--- a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/ui/AbstractLineOrientedDataSource.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Michael Scharf (Wind River) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tm.internal.terminal.test.ui;
-
-import org.eclipse.tm.terminal.model.ITerminalTextData;
-import org.eclipse.tm.terminal.model.Style;
-
-/**
- * Adds line by line
- *
- */
-abstract class AbstractLineOrientedDataSource implements IDataSource {
- abstract public char[] dataSource();
- abstract public Style getStyle();
-
- abstract public void next();
-
- public int step(ITerminalTextData terminal) {
- next();
- char[] chars=dataSource();
- Style style= getStyle();
- int len;
- // keep the synchronized block short!
- synchronized (terminal) {
- terminal.addLine();
- len=Math.min(terminal.getWidth(),chars.length);
- int line=terminal.getHeight()-1;
- terminal.setChars(line, 0, chars, 0, len, style);
- terminal.setCursorLine(line);
- terminal.setCursorColumn(len-1);
- }
- return len;
- }
-} \ No newline at end of file
diff --git a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/ui/DataReader.java b/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/ui/DataReader.java
deleted file mode 100644
index 6d017f0bd..000000000
--- a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/ui/DataReader.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Michael Scharf (Wind River) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tm.internal.terminal.test.ui;
-
-import org.eclipse.tm.terminal.model.ITerminalTextData;
-
-class DataReader implements Runnable {
- final Thread fThread;
- final IDataSource fDataSource;
- final ITerminalTextData fTerminal;
- volatile boolean fStart;
- volatile boolean fStop;
- volatile int fThrottleTime;
- final IStatus fStatus;
- final String fName;
- DataReader(String name, ITerminalTextData terminal, IDataSource dataSource, IStatus status) {
- fStatus=status;
- fName=name;
- fTerminal=terminal;
- fDataSource=dataSource;
- fThread=new Thread(this,name);
- fThread.setDaemon(true);
- fThread.start();
- }
- public void run() {
- long t0=System.currentTimeMillis()-1;
- long c=0;
- int lines=0;
- while(!Thread.interrupted()) {
- while(!fStart || fStop) {
- sleep(1);
- }
- if(fThrottleTime>0)
- sleep(fThrottleTime);
- // synchronize because we have to be sure the size does not change while
- // we add lines
- int len=fDataSource.step(fTerminal);
- // keep the synchronized block short!
- c+=len;
- lines++;
- if((fThrottleTime>0 || (lines%100==0))&&(System.currentTimeMillis()-t0)>1000) {
- long t=System.currentTimeMillis()-t0;
- final String s=(c*1000)/(t*1024)+"kb/s " + (lines*1000)/t+"lines/sec "+(c*1000*8)/t+" bits/s ";
- fStatus.setStatus(s);
- lines=0;
- t0=System.currentTimeMillis();
- c=0;
- }
- }
- }
- public int getThrottleTime() {
- return fThrottleTime;
- }
- public void setThrottleTime(int throttleTime) {
- fThrottleTime = throttleTime;
- }
- private void sleep(int ms) {
- try {
- Thread.sleep(ms);
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- }
- }
- public boolean isStart() {
- return fStart;
- }
- public void setStart(boolean start) {
- fStart = start;
- }
- public String getName() {
- return fName;
- }
- public boolean isStop() {
- return fStop;
- }
- public void setStop(boolean stop) {
- fStop = stop;
- }
-} \ No newline at end of file
diff --git a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/ui/FastDataSource.java b/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/ui/FastDataSource.java
deleted file mode 100644
index 2ffb33edb..000000000
--- a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/ui/FastDataSource.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Michael Scharf (Wind River) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tm.internal.terminal.test.ui;
-
-import org.eclipse.tm.terminal.model.Style;
-
-final class FastDataSource extends AbstractLineOrientedDataSource {
- char lines[][]=new char[][]{
- "123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 ".toCharArray(),
- "abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi ".toCharArray(),
- };
-
-
- int pos;
-
- public char[] dataSource() {
- return lines[pos%lines.length];
- }
-
- public Style getStyle() {
- return null;
- }
-
- public void next() {
- pos++;
- }
-} \ No newline at end of file
diff --git a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/ui/FileDataSource.java b/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/ui/FileDataSource.java
deleted file mode 100644
index 075393981..000000000
--- a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/ui/FileDataSource.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Michael Scharf (Wind River) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tm.internal.terminal.test.ui;
-
-import java.io.BufferedReader;
-import java.io.FileReader;
-import java.io.IOException;
-
-import org.eclipse.tm.terminal.model.Style;
-import org.eclipse.tm.terminal.model.StyleColor;
-
-/**
- * Reads the file in an infinite loop.
- * Makes lines containing 'x' bold.
- *
- */
-final class FileDataSource extends AbstractLineOrientedDataSource {
- private final String fFile;
-
- BufferedReader reader;
-
- String line;
-
- Style style;
-
- Style styleNormal=Style.getStyle(StyleColor.getStyleColor("black"),StyleColor.getStyleColor("white"));
-
- Style styleBold=styleNormal.setBold(true);
-
- FileDataSource(String file) {
- fFile = file;
- }
-
- public char[] dataSource() {
- return line.toCharArray();
- }
-
- public Style getStyle() {
- return style;
- }
-
- public void next() {
- try {
- if(reader==null)
- reader = new BufferedReader(new FileReader(fFile));
- line=reader.readLine();
- if(line==null) {
- reader.close();
- reader=null;
- // reopen the file
- next();
- return;
- }
- if(line.lastIndexOf('x')>0)
- style=styleBold;
- else
- style=styleNormal;
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
-} \ No newline at end of file
diff --git a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/ui/IDataSource.java b/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/ui/IDataSource.java
deleted file mode 100644
index 938916d80..000000000
--- a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/ui/IDataSource.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Michael Scharf (Wind River) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tm.internal.terminal.test.ui;
-
-import org.eclipse.tm.terminal.model.ITerminalTextData;
-
-interface IDataSource {
- /**
- * @param terminal
- * @return number of characters changed
- */
- int step(ITerminalTextData terminal);
-} \ No newline at end of file
diff --git a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/ui/IStatus.java b/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/ui/IStatus.java
deleted file mode 100644
index d060e779f..000000000
--- a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/ui/IStatus.java
+++ /dev/null
@@ -1,15 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Michael Scharf (Wind River) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tm.internal.terminal.test.ui;
-
-public interface IStatus {
- void setStatus(String message);
-}
diff --git a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/ui/LineCountingDataSource.java b/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/ui/LineCountingDataSource.java
deleted file mode 100644
index 7a3dc3598..000000000
--- a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/ui/LineCountingDataSource.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Michael Scharf (Wind River) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tm.internal.terminal.test.ui;
-
-import org.eclipse.tm.terminal.model.Style;
-import org.eclipse.tm.terminal.model.StyleColor;
-
-final class LineCountingDataSource extends AbstractLineOrientedDataSource {
- Style styleNormal=Style.getStyle(StyleColor.getStyleColor("black"),StyleColor.getStyleColor("red"));
-
- Style styles[]=new Style[] {
- styleNormal,
- styleNormal.setBold(true),
- styleNormal.setForground("blue"),
- styleNormal.setForground("yellow"),
- styleNormal.setBold(true).setUnderline(true),
- styleNormal.setReverse(true),
- styleNormal.setReverse(true).setBold(true),
- styleNormal.setReverse(true).setUnderline(true)
- };
-
- int pos;
-
- public char[] dataSource() {
- return (pos+" 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789").toCharArray();
- }
-
- public Style getStyle() {
- return styles[pos%styles.length];
- }
-
- public void next() {
- pos++;
- }
-} \ No newline at end of file
diff --git a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/ui/RandomDataSource.java b/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/ui/RandomDataSource.java
deleted file mode 100644
index ee002861b..000000000
--- a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/ui/RandomDataSource.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Michael Scharf (Wind River) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tm.internal.terminal.test.ui;
-
-import java.util.Random;
-
-import org.eclipse.tm.terminal.model.ITerminalTextData;
-import org.eclipse.tm.terminal.model.Style;
-import org.eclipse.tm.terminal.model.StyleColor;
-
-public class RandomDataSource implements IDataSource {
- Random fRandom=new Random();
- Style styleNormal=Style.getStyle(StyleColor.getStyleColor("black"),StyleColor.getStyleColor("green"));
- Style styles[]=new Style[] {
- styleNormal,
- styleNormal.setBold(true),
- styleNormal.setForground("red"),
- styleNormal.setForground("yellow"),
- styleNormal.setBold(true).setUnderline(true),
- styleNormal.setReverse(true),
- styleNormal.setReverse(true).setBold(true),
- styleNormal.setReverse(true).setUnderline(true)
- };
-
- public int step(ITerminalTextData terminal) {
- int N=fRandom.nextInt(1000);
- int h=terminal.getHeight();
- int w=terminal.getWidth();
- synchronized (terminal) {
- for (int i = 0; i < N; i++) {
- int line=fRandom.nextInt(h);
- int col=fRandom.nextInt(w);
- char c=(char)('A'+fRandom.nextInt('z'-'A'));
- Style style=styles[fRandom.nextInt(styles.length)];
- terminal.setChar(line, col, c, style);
- }
- }
- return N;
- }
-
-}
diff --git a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/ui/TerminalTextUITest.java b/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/ui/TerminalTextUITest.java
deleted file mode 100644
index 7d9bdf91a..000000000
--- a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/ui/TerminalTextUITest.java
+++ /dev/null
@@ -1,253 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Michael Scharf (Wind River) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tm.internal.terminal.test.ui;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.layout.RowData;
-import org.eclipse.swt.layout.RowLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.tm.internal.terminal.textcanvas.ITextCanvasModel;
-import org.eclipse.tm.internal.terminal.textcanvas.PollingTextCanvasModel;
-import org.eclipse.tm.internal.terminal.textcanvas.TextCanvas;
-import org.eclipse.tm.internal.terminal.textcanvas.TextLineRenderer;
-import org.eclipse.tm.terminal.model.ITerminalTextData;
-import org.eclipse.tm.terminal.model.ITerminalTextDataSnapshot;
-import org.eclipse.tm.terminal.model.TerminalTextDataFactory;
-
-/**
- * adjust columns when table gets resized....
- *
- */
-public class TerminalTextUITest {
- static TextCanvas fgTextCanvas;
- static ITextCanvasModel fgModel;
- static ITerminalTextData fTerminalModel;
- static Label fStatusLabel;
- static volatile int fHeight;
- static volatile int fWidth;
- static DataReader fDataReader;
- static List fDataReaders=new ArrayList();
- private static Text heightText;
- static class Status implements IStatus {
- public void setStatus(final String s) {
- if(!fStatusLabel.isDisposed())
- Display.getDefault().asyncExec(new Runnable(){
- public void run() {
- if(!fStatusLabel.isDisposed())
- fStatusLabel.setText(s);
- }});
- }
-
- }
- public static void main(String[] args) {
- Display display = new Display();
- Shell shell = new Shell(display);
- shell.setLayout(new GridLayout());
- Composite composite=new Composite(shell, SWT.NONE);
- composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- RowLayout layout = new RowLayout(SWT.HORIZONTAL);
- layout.wrap = true;
- layout.fill = false;
- fTerminalModel=TerminalTextDataFactory.makeTerminalTextData();
- fHeight=24;
- fWidth=80;
- fTerminalModel.setDimensions(fHeight, fWidth);
- fTerminalModel.setMaxHeight(fHeight);
- ITerminalTextDataSnapshot snapshot=fTerminalModel.makeSnapshot();
- // TODO how to get the initial size correctly!
- snapshot.updateSnapshot(false);
- fgModel=new PollingTextCanvasModel(snapshot);
- fgTextCanvas=new TextCanvas(shell,fgModel, SWT.NONE,new TextLineRenderer(fgTextCanvas,fgModel));
- fgTextCanvas.setLayoutData(new GridData(GridData.FILL_BOTH));
-
-
- composite.setLayout(layout);
- addAutorevealCursorButton(composite);
- Text maxHeightText = addMaxHeightInput(composite);
- addHeightInput(composite, maxHeightText);
- addWidthText(composite);
- Text throttleText = addThrottleText(composite);
-
- IStatus status=new Status();
- DataReader reader=new DataReader("Line Count",fTerminalModel,new LineCountingDataSource(),status);
- addDataReader(composite, reader);
- reader=new DataReader("Fast",fTerminalModel,new FastDataSource(),status);
- addDataReader(composite, reader);
- reader=new DataReader("Random",fTerminalModel,new RandomDataSource(),status);
- addDataReader(composite, reader);
- for (int i = 0; i < args.length; i++) {
- File file=new File(args[i]);
- reader=new DataReader(file.getName(),fTerminalModel,new VT100DataSource(args[i]),status);
- addDataReader(composite, reader);
- }
- addStopAllButton(composite, reader);
-
- fStatusLabel=new Label(shell,SWT.NONE);
- fStatusLabel.setLayoutData(new GridData(250,15));
- throttleText.setText("100");
- setThrottleForAll(100);
-
- if(args.length==0)
- addLabel(composite, "[Files can be added via commandline]");
- shell.setSize(600,300);
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- display.dispose();
- }
- private static Text addMaxHeightInput(Composite composite) {
- addLabel(composite, "maxHeight:");
- final Text maxHeightText=new Text(composite,SWT.BORDER);
- setLayoutData(maxHeightText,30);
- maxHeightText.addModifyListener(new ModifyListener(){
- public void modifyText(ModifyEvent e) {
- synchronized (fTerminalModel) {
- int height=textToInt(maxHeightText);
- if(height<1)
- return;
- if(fTerminalModel.getHeight()>height) {
- fTerminalModel.scroll(0, fTerminalModel.getHeight(), height-fTerminalModel.getHeight());
- fTerminalModel.setDimensions(height,fTerminalModel.getWidth());
- heightText.setText(height+"");
- }
- fTerminalModel.setMaxHeight(height);
- }
- }
- });
- maxHeightText.setText(fHeight+"");
- return maxHeightText;
- }
- private static void addHeightInput(Composite composite, final Text maxHeightText) {
- addLabel(composite,"heigth:");
- heightText=new Text(composite,SWT.BORDER);
- setLayoutData(heightText,30);
- heightText.addModifyListener(new ModifyListener(){
- public void modifyText(ModifyEvent e) {
- synchronized (fTerminalModel) {
- int height=textToInt(heightText);
- if(height<1)
- return;
- maxHeightText.setText(""+height);
- fTerminalModel.setDimensions(height,fTerminalModel.getWidth());
- fTerminalModel.setMaxHeight(height);
- }
- }
- });
- heightText.setText(fHeight+"");
- }
- private static Text addWidthText(Composite composite) {
- addLabel(composite,"width:");
- final Text widthText=new Text(composite,SWT.BORDER);
- setLayoutData(widthText,30);
- widthText.addModifyListener(new ModifyListener(){
- public void modifyText(ModifyEvent e) {
- synchronized (fTerminalModel) {
- int width=textToInt(widthText);
- if(width>1)
- fTerminalModel.setDimensions(fTerminalModel.getHeight(), width);
- }
- }
- });
- widthText.setText(fWidth+"");
- return widthText;
- }
- private static Text addThrottleText(Composite composite) {
- addLabel(composite,"throttle:");
- final Text throttleText=new Text(composite,SWT.BORDER);
- setLayoutData(throttleText,30);
- throttleText.addModifyListener(new ModifyListener(){
- public void modifyText(ModifyEvent e) {
- synchronized (fTerminalModel) {
- int throttle=textToInt(throttleText);
- setThrottleForAll(throttle);
- }
- }});
- return throttleText;
- }
- private static void addStopAllButton(Composite composite, DataReader reader) {
- final Button stopAllButton=new Button(composite,SWT.CHECK);
- stopAllButton.setText("Stop ALL");
- stopAllButton.addSelectionListener(new SelectionAdapter(){
-
- public void widgetSelected(SelectionEvent e) {
- boolean stop=stopAllButton.getSelection();
- for (Iterator iterator = fDataReaders.iterator(); iterator.hasNext();) {
- DataReader reader = (DataReader) iterator.next();
- reader.setStop(stop);
-
- }}});
- stopAllButton.setSelection(reader.isStart());
- }
- private static void addAutorevealCursorButton(Composite composite) {
- final Button button=new Button(composite,SWT.CHECK);
- button.setText("ScrollLock");
- button.addSelectionListener(new SelectionAdapter(){
- public void widgetSelected(SelectionEvent e) {
- boolean scrollLock=button.getSelection();
- fgTextCanvas.setScrollLock(scrollLock);
- }
- });
- button.setSelection(fgTextCanvas.isScrollLock());
- }
- private static void addLabel(Composite composite,String message) {
- Label label;
- label=new Label(composite, SWT.NONE);
- label.setText(message);
- }
- private static void addDataReader(Composite composite, final DataReader reader) {
- fDataReaders.add(reader);
- final Button button=new Button(composite,SWT.CHECK);
- button.setText(reader.getName());
- button.addSelectionListener(new SelectionAdapter(){
-
- public void widgetSelected(SelectionEvent e) {
- reader.setStart(button.getSelection());
- }});
- button.setSelection(reader.isStart());
-
- }
- static private void setThrottleForAll(int throttle) {
- for (Iterator iterator = fDataReaders.iterator(); iterator.hasNext();) {
- DataReader reader = (DataReader) iterator.next();
- reader.setThrottleTime(throttle);
- }
- }
- static void setLayoutData(Control c,int width) {
- c.setLayoutData(new RowData(width,-1));
- }
- static int textToInt(Text text) {
- try {
- return Integer.valueOf(text.getText()).intValue();
- } catch (Exception ex) {
- return 0;
- }
- }
-}
-
diff --git a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/ui/VT100DataSource.java b/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/ui/VT100DataSource.java
deleted file mode 100644
index 69e66b8af..000000000
--- a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/ui/VT100DataSource.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Michael Scharf (Wind River) - initial API and implementation
- * Martin Oberhuber (Wind River) - [204796] Terminal should allow setting the encoding to use
- *******************************************************************************/
-package org.eclipse.tm.internal.terminal.test.ui;
-
-import java.io.ByteArrayOutputStream;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.Reader;
-import java.io.UnsupportedEncodingException;
-
-import org.eclipse.tm.internal.terminal.control.impl.ITerminalControlForText;
-import org.eclipse.tm.internal.terminal.emulator.VT100Emulator;
-import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector;
-import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
-import org.eclipse.tm.terminal.model.ITerminalTextData;
-
-/**
- * Reads the file in an infinite loop.
- * Makes lines containing 'x' bold.
- *
- */
-final class VT100DataSource implements IDataSource {
- VT100Emulator fEmulator;
- volatile int fAvailable;
- volatile int fRead;
- private final String fFile;
-
- VT100DataSource(String file) {
- fFile=file;
- }
- class InfiniteFileInputStream extends InputStream {
- public InfiniteFileInputStream() {
- try {
- fInputStream=new FileInputStream(fFile);
- } catch (FileNotFoundException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- public int available() throws IOException {
- return fAvailable;
- }
- private InputStream fInputStream;
- public int read() throws IOException {
- throw new IOException();
- }
- public int read(byte[] b, int off, int len) throws IOException {
- while(fAvailable==0) {
- try {
- Thread.sleep(1);
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- }
- }
- len=fAvailable;
- int n=fInputStream.read(b, off, len);
- if(n<=0) {
- fInputStream.close();
- fInputStream=new FileInputStream(fFile);
- n=fInputStream.read(b, off, len);
- }
- fAvailable-=n;
- return n;
- }
-
- }
- void init(ITerminalTextData terminal) {
- final Reader reader;
- try {
- reader = new InputStreamReader(new InfiniteFileInputStream(), "ISO-8859-1"); //$NON-NLS-1$
- } catch (UnsupportedEncodingException e) {
- throw new RuntimeException(e);
- }
- fEmulator=new VT100Emulator(terminal,new ITerminalControlForText() {
-
- public void disconnectTerminal() {
- // TODO Auto-generated method stub
-
- }
-
- public OutputStream getOutputStream() {
- return new ByteArrayOutputStream();
- }
-
- public TerminalState getState() {
- return TerminalState.CONNECTED;
- }
-
- public ITerminalConnector getTerminalConnector() {
- return null;
- }
-
- public void setState(TerminalState state) {
- }
-
- public void setTerminalTitle(String title) {
- }
- }, reader);
- }
- public int step(ITerminalTextData terminal) {
- synchronized(terminal) {
- if(fEmulator==null) {
- init(terminal);
-// fEmulator.setDimensions(48, 132);
- fEmulator.setDimensions(24, 80);
- fEmulator.setCrAfterNewLine(true);
-
- }
- fAvailable=80;
- fEmulator.processText();
- }
- return 80;
- }
-}
diff --git a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/textcanvas/PipedInputStreamPerformanceTest.java b/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/textcanvas/PipedInputStreamPerformanceTest.java
deleted file mode 100644
index dd105f603..000000000
--- a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/textcanvas/PipedInputStreamPerformanceTest.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Michael Scharf (Wind River) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tm.internal.terminal.textcanvas;
-
-import java.io.OutputStream;
-
-public class PipedInputStreamPerformanceTest {
-
- /**
- * @param args
- * @throws InterruptedException
- */
- public static void main(String[] args) throws InterruptedException {
- runPerformanceTest();
- runPerformanceTest();
- }
-
- private static void runPerformanceTest() throws InterruptedException {
- PipedInputStream in=new PipedInputStream(1024);
- OutputStream out=in.getOutputStream();
- PipedStreamTest.runPipe("",in, out,100);
- }
-
-}
diff --git a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/textcanvas/PipedStreamTest.java b/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/textcanvas/PipedStreamTest.java
deleted file mode 100644
index 11e7ecfeb..000000000
--- a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/textcanvas/PipedStreamTest.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Michael Scharf (Wind River) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tm.internal.terminal.textcanvas;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-
-class PipedStreamTest {
- static class ReadThread extends Thread implements Runnable {
-
- InputStream pi = null;
-
- OutputStream po = null;
-
- ReadThread(String process, InputStream pi, OutputStream po) {
- this.pi = pi;
- this.po = po;
- setDaemon(true);
- }
-
- public void run() {
- byte[] buffer = new byte[2048];
- int bytes_read;
- try {
- for (;;) {
- bytes_read = pi.read(buffer);
- if (bytes_read == -1) {
- po.close();
- pi.close();
- return;
- }
- po.write(buffer, 0, bytes_read);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- }
- static class FakeInputStream extends InputStream {
- int N;
- FakeInputStream(int n) {
- N=n;
- }
- public int read(byte[] b, int off, int len) throws IOException {
- if(N==0)
- return -1;
- int n=Math.min(len,N);
- for (int i = off; i < off+n; i++) {
- b[i]='x';
- }
- N-=n;
- return n;
- }
- public int read() throws IOException {
- throw new UnsupportedOperationException();
- }
- /*
- * available has to be implemented!
- */
- public int available() throws IOException {
- return N;
- }
- }
- static class FakeOutputStream extends OutputStream {
- long N;
- public void write(int b) throws IOException {
- throw new UnsupportedOperationException();
- }
- public void write(byte[] b, int off, int len) throws IOException {
- N+=len;
- }
- }
- public static void main(String[] args) throws IOException, InterruptedException {
- while(true) {
- runSunTest();
- runMyTest();
- }
- }
- private static void runSunTest() throws IOException, InterruptedException {
- java.io.PipedInputStream in = new java.io.PipedInputStream();
- OutputStream out = new java.io.PipedOutputStream(in);
- runPipe("Sun ",in, out,10);
- }
- private static void runMyTest() throws IOException, InterruptedException {
- PipedInputStream in=new PipedInputStream(4*1024);
- OutputStream out=in.getOutputStream();
- runPipe("My ",in, out,99);
- }
- public static void runPipe(String what,InputStream writeIn, OutputStream readOut,int N) throws InterruptedException {
- FakeInputStream in=new FakeInputStream(N*1000*1000);
- FakeOutputStream out=new FakeOutputStream();
- ReadThread rt = new ReadThread("reader", in , readOut);
- ReadThread wt = new ReadThread("writer", writeIn, out);
- long t0=System.currentTimeMillis();
- rt.start();
- wt.start();
- wt.join();
- long t=System.currentTimeMillis();
- long n=out.N;
- System.out.println(what+n + " byte in " +(t-t0)+" ms -> "+(1000*n)/((t-t0+1)*1024)+" kb/sec");
- }
-}
diff --git a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/terminal/model/AllTests.java b/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/terminal/model/AllTests.java
deleted file mode 100644
index 257c92a3a..000000000
--- a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/terminal/model/AllTests.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tm.terminal.model;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- * Public Terminal Model test cases.
- * Runs in internal model package to allow access to default visible items.
- */
-public class AllTests extends TestCase {
- public AllTests() {
- super(null);
- }
-
- public AllTests(String name) {
- super(name);
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite(AllTests.class.getName());
- suite.addTestSuite(StyleColorTest.class);
- suite.addTestSuite(StyleTest.class);
- return suite;
- }
-
-}
diff --git a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/terminal/model/StyleColorTest.java b/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/terminal/model/StyleColorTest.java
deleted file mode 100644
index e641c74d7..000000000
--- a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/terminal/model/StyleColorTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Michael Scharf (Wind River) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tm.terminal.model;
-
-import junit.framework.TestCase;
-
-public class StyleColorTest extends TestCase {
-
-
- public void testEqualsObject() {
- assertEquals(StyleColor.getStyleColor("foo"),StyleColor.getStyleColor("foo"));
- assertFalse(StyleColor.getStyleColor("foox").equals(StyleColor.getStyleColor("foo")));
- }
-
- public void testSameObject() {
- assertSame(StyleColor.getStyleColor("foo"),StyleColor.getStyleColor("foo"));
- assertNotSame(StyleColor.getStyleColor("foox"),StyleColor.getStyleColor("foo"));
- }
-
- public void testToString() {
- assertEquals("xxx", StyleColor.getStyleColor("xxx").toString());
- }
-
- public void testGetName() {
- assertEquals("xxx", StyleColor.getStyleColor("xxx").getName());
- }
-
-}
diff --git a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/terminal/model/StyleTest.java b/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/terminal/model/StyleTest.java
deleted file mode 100644
index 9f0cd7517..000000000
--- a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/terminal/model/StyleTest.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Michael Scharf (Wind River) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tm.terminal.model;
-
-import junit.framework.TestCase;
-
-public class StyleTest extends TestCase {
- final StyleColor c1=StyleColor.getStyleColor("c1");
- final StyleColor c2=StyleColor.getStyleColor("c2");
- final StyleColor c3=StyleColor.getStyleColor("c3");
-
- public void testGetStyle() {
- Style s1=Style.getStyle(c1, c2, true, false, true, false);
- Style s2=Style.getStyle(c1, c2, true, false, true, false);
- assertEquals(s1,s2);
- assertSame(s1,s2);
- s1=s1.setBlink(!s1.isBlink());
- assertNotSame(s1,s2);
- assertFalse(s1.equals(s2));
- s1=s1.setBlink(!s1.isBlink());
- assertSame(s1,s2);
- }
-
- public void testSetForground() {
- Style s1=Style.getStyle(c1, c2, true, false, true, false);
- Style s2=s1;
- s2=s1.setForground(c3);
- assertNotSame(s1,s2);
- assertFalse(s1.equals(s2));
- assertSame(s2.getForground(), c3);
- assertSame(s1.getForground(), c1);
- assertSame(s1.getBackground(), c2);
- assertSame(s2.getBackground(), c2);
- s2=s2.setForground(c1);
- assertSame(s1, s2);
- }
-
- public void testSetBackground() {
- Style s1=Style.getStyle(c1, c2, true, false, true, false);
- Style s2=s1;
- s2=s1.setBackground(c3);
- assertNotSame(s1,s2);
- assertFalse(s1.equals(s2));
- assertSame(s2.getForground(), c1);
- assertSame(s1.getForground(), c1);
- assertSame(s1.getBackground(), c2);
- assertSame(s2.getBackground(), c3);
- s2=s2.setBackground(c2);
- assertSame(s1, s2);
- }
-
- public void testSetBold() {
- Style s1=getDefaultStyle();
- Style s2=s1;
- assertSame(s1,s2);
- assertFalse(s2.isBold());
- s2=s2.setBold(true);
- assertNotSame(s1,s2);
- assertTrue(s2.isBold());
- s2=s2.setBold(false);
- assertSame(s1,s2);
- assertFalse(s2.isBold());
- }
-
- public void testSetBlink() {
- Style s1=getDefaultStyle();
- Style s2=s1;
- assertSame(s1,s2);
- assertFalse(s2.isBlink());
- s2=s2.setBlink(true);
- assertNotSame(s1,s2);
- assertTrue(s2.isBlink());
- s2=s2.setBlink(false);
- assertSame(s1,s2);
- assertFalse(s2.isBlink());
- }
-
- public void testSetUnderline() {
- Style s1=getDefaultStyle();
- Style s2=s1;
- assertSame(s1,s2);
- assertFalse(s2.isUnderline());
- s2=s2.setUnderline(true);
- assertNotSame(s1,s2);
- assertTrue(s2.isUnderline());
- s2=s2.setUnderline(false);
- assertSame(s1,s2);
- assertFalse(s2.isUnderline());
- }
-
- public void testSetReverse() {
- Style s1=getDefaultStyle();
- Style s2=s1;
- assertSame(s1,s2);
- assertFalse(s2.isReverse());
- s2=s2.setReverse(true);
- assertNotSame(s1,s2);
- assertTrue(s2.isReverse());
- s2=s2.setReverse(false);
- assertSame(s1,s2);
- assertFalse(s2.isReverse());
- }
-
- private Style getDefaultStyle() {
- return Style.getStyle(c1, c2, false, false, false, false);
- }
-
-}
diff --git a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/terminal/test/AutomatedPluginTests.java b/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/terminal/test/AutomatedPluginTests.java
deleted file mode 100644
index 9ca272e28..000000000
--- a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/terminal/test/AutomatedPluginTests.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.tm.terminal.test;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- * Master Test Suite to run all Terminal plug-in tests.
- */
-public class AutomatedPluginTests extends TestCase {
- /**
- * Call each AllTests class from each of the test packages.
- */
- public static Test suite() {
- TestSuite suite = new TestSuite(AutomatedPluginTests.class.getName());
- suite.addTestSuite(org.eclipse.tm.internal.terminal.connector.TerminalConnectorPluginTest.class);
- return suite;
- }
-
-}
diff --git a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/terminal/test/AutomatedTests.java b/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/terminal/test/AutomatedTests.java
deleted file mode 100644
index 5b8ca6bb9..000000000
--- a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/terminal/test/AutomatedTests.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tm.terminal.test;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- * Master test suite to run all terminal unit tests.
- */
-public class AutomatedTests extends TestCase {
-
- public static final String PI_TERMINAL_TESTS = "org.eclipse.tm.terminal.test"; //$NON-NLS-1$
-
- public AutomatedTests() {
- super(null);
- }
-
- public AutomatedTests(String name) {
- super(name);
- }
-
- /**
- * Call each AllTests class from each of the test packages.
- */
- public static Test suite() {
- TestSuite suite = new TestSuite(AutomatedTests.class.getName());
- suite.addTest(org.eclipse.tm.internal.terminal.emulator.AllTests.suite());
- suite.addTest(org.eclipse.tm.internal.terminal.model.AllTests.suite());
- suite.addTest(org.eclipse.tm.terminal.model.AllTests.suite());
- return suite;
- }
-}
diff --git a/terminal/org.eclipse.tm.terminal.test/teamConfig/Terminal All Unit Tests.launch b/terminal/org.eclipse.tm.terminal.test/teamConfig/Terminal All Unit Tests.launch
deleted file mode 100644
index fd2e3ebb9..000000000
--- a/terminal/org.eclipse.tm.terminal.test/teamConfig/Terminal All Unit Tests.launch
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
-<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
-<listEntry value="/org.eclipse.tm.terminal.test/src"/>
-</listAttribute>
-<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
-<listEntry value="2"/>
-</listAttribute>
-<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value="=org.eclipse.tm.terminal.test/src"/>
-<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
-<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
-<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
-<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value=""/>
-<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.tm.terminal.test"/>
-<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-ea"/>
-</launchConfiguration>
diff --git a/terminal/org.eclipse.tm.terminal.test/teamConfig/Terminal Plugin Tests.launch b/terminal/org.eclipse.tm.terminal.test/teamConfig/Terminal Plugin Tests.launch
deleted file mode 100644
index 5def47264..000000000
--- a/terminal/org.eclipse.tm.terminal.test/teamConfig/Terminal Plugin Tests.launch
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<launchConfiguration type="org.eclipse.pde.ui.JunitLaunchConfig">
-<booleanAttribute key="append.args" value="true"/>
-<booleanAttribute key="askclear" value="false"/>
-<booleanAttribute key="automaticAdd" value="true"/>
-<booleanAttribute key="automaticValidate" value="false"/>
-<stringAttribute key="bootstrap" value=""/>
-<stringAttribute key="checked" value="[NONE]"/>
-<booleanAttribute key="clearConfig" value="true"/>
-<booleanAttribute key="clearws" value="true"/>
-<booleanAttribute key="clearwslog" value="false"/>
-<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/pde-junit"/>
-<booleanAttribute key="default" value="true"/>
-<booleanAttribute key="includeOptional" value="true"/>
-<stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/>
-<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
-<listEntry value="/org.eclipse.tm.terminal.test/src/org/eclipse/tm/terminal/test/AutomatedPluginTests.java"/>
-</listAttribute>
-<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
-<listEntry value="1"/>
-</listAttribute>
-<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
-<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
-<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
-<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
-<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
-<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.tm.terminal.test.AutomatedPluginTests"/>
-<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl}"/>
-<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.tm.terminal.test"/>
-<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
-<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-ea"/>
-<stringAttribute key="pde.version" value="3.3"/>
-<stringAttribute key="product" value="org.eclipse.sdk.ide"/>
-<booleanAttribute key="show_selected_only" value="false"/>
-<booleanAttribute key="tracing" value="false"/>
-<booleanAttribute key="useDefaultConfig" value="true"/>
-<booleanAttribute key="useDefaultConfigArea" value="false"/>
-<booleanAttribute key="useProduct" value="true"/>
-</launchConfiguration>
diff --git a/terminal/org.eclipse.tm.terminal.test/test.xml b/terminal/org.eclipse.tm.terminal.test/test.xml
deleted file mode 100644
index bbb992759..000000000
--- a/terminal/org.eclipse.tm.terminal.test/test.xml
+++ /dev/null
@@ -1,91 +0,0 @@
-<?xml version="1.0"?>
-
-<!--
-Run post build tests.
-Not yet complete.
-Needs to be updated and tested for org.eclipse.tm.terminal
--->
-
-<project name="testsuite" default="run" basedir=".">
- <!-- The property ${eclipse-home} should be passed into this script -->
- <!-- Set a meaningful default value for when it is not. -->
- <property name="eclipse-home" value="${basedir}/../../"/>
-
- <!-- sets the properties eclipse-home, and library-file -->
- <property name="plugin-name" value="org.eclipse.tm.terminal.test"/>
- <property name="library-file" value="${eclipse-home}/plugins/org.eclipse.test/library.xml"/>
-
- <!-- This target holds all initialization code that needs to be done for -->
- <!-- all tests that are to be run. Initialization for individual tests -->
- <!-- should be done within the body of the suite target. -->
- <target name="init">
- <tstamp/>
- <delete>
- <fileset dir="${eclipse-home}" includes="org.eclipse.tm.terminal.test.*.xml"/>
- </delete>
- </target>
-
- <!-- This target defines the tests that need to be run. -->
- <target name="suite">
- <property name="location" value="${eclipse-home}/terminal_test_workspace"/>
- <delete dir="${location}" quiet="true"/>
- <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}">
- <property name="data-dir" value="${location}"/>
- <property name="plugin-name" value="${plugin-name}"/>
- <property name="classname" value="org.eclipse.tm.terminal.test.AutomatedTests"/>
- <property name="extraVMargs" value="-ea"/>
- </ant>
-
- <!-- UI Tests: Commented out until access to default visible methods works
- <ant target="ui-test" antfile="${library-file}" dir="${eclipse-home}">
- <property name="data-dir" value="${session-folder}"/>
- <property name="plugin-name" value="${plugin-name}"/>
- <property name="classname"
- value="org.eclipse.ui.tests.api.SessionRestoreTest"/>
- </ant>
- -->
-
- <!--
- <property name="sniff-folder"
- value="${eclipse-home}/ui_sniff_folder"/>
- <delete dir="${sniff-folder}" quiet="true"/>
- <ant target="ui-test" antfile="${library-file}" dir="${eclipse-home}">
- <property name="data-dir" value="${sniff-folder}"/>
- <property name="plugin-name" value="${plugin-name}"/>
- <property name="classname"
- value="org.eclipse.ui.tests.UiTestSuite"/>
-
- </ant>
-
- <property name="jface-sniff-folder"
- value="${eclipse-home}/jface_sniff_folder"/>
- <delete dir="${jface-sniff-folder}" quiet="true"/>
- <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}">
- <property name="data-dir" value="${jface-sniff-folder}"/>
- <property name="plugin-name" value="${plugin-name}"/>
- <property name="classname"
- value="org.eclipse.jface.tests.viewers.AllTests"/>
- </ant>
- -->
-
- </target>
-
- <!-- This target holds code to cleanup the testing environment after the tests -->
- <!-- have been run. You can use this to delete temporary files that are created. -->
- <target name="cleanup">
- </target>
-
- <!-- This target runs the test suite. Any actions that need to happen after all -->
- <!-- the tests have been run should go here. -->
- <target name="run" depends="init,suite,cleanup">
- <ant target="collect" antfile="${library-file}" dir="${eclipse-home}">
- <property name="includes" value="org.eclipse.rse.*.xml"/>
- <property name="output-file" value="${plugin-name}.xml"/>
- </ant>
- </target>
-
- <!-- This target runs the performance test suites. -->
- <target name="performance">
- </target>
-
-</project>

Back to the top