SCComponentTestCase


SeasideTesting-Core

Comment:



Hierarchy:

ProtoObject
Object
TestCase
SCComponentTestCase

Summary:

instance variables:

app browser debugging handler pseudomain responseSema

methods:

instance class
Running accessing answering application component private request/response Testing

Detail:

instance variables:

app
inferredType:
UndefinedObject
browser
InitialValue:
a SCBrowserSimulator
inferredType:
SCBrowserSimulator
debugging
inferredType:
UndefinedObject
handler
inferredType:
UndefinedObject
pseudomain
inferredType:
UndefinedObject
responseSema
InitialValue:
a Semaphore()
inferredType:
Semaphore

instance methods:

Running
debug

	self resources
		do: [:res | res isAvailable
				ifFalse: [^ res signalInitializationError]].
	[(self class selector: testSelector) makeDebugging; runCase]
		sunitEnsure: [self resources
				do: [:each | each reset]]
makeDebugging

	debugging _ true
run: aResult

	debugging _ false.
	^super run: aResult
runCaseAsFailure: aSemaphore
 
	self makeDebugging.
	super runCaseAsFailure: aSemaphore
tearDown

	self removeApplication.

accessing
browser

	^ browser
		ifNil: [browser _ SCBrowserSimulator new
			responseSemaphore: self responseSemaphore;
			yourself]
isDebugging

	^debugging
session

	^ pseudomain storedSession

answering
answer

	| checker |
	checker _ pseudomain answerChecker.
	^checker hasAnswer
		ifTrue: [checker answerValue]
		ifFalse: [self error: 'Component did not answer.']
componentAnswered

	^ pseudomain answerChecker hasAnswer
componentAnswered: value
 
	| checker |
	checker := pseudomain answerChecker.
	^checker hasAnswer and: [checker answerValue = value]

application
configureApplicationForComponent: aComponentClass
 
	app preferenceAt: #deploymentMode put: true.
	pseudomain _ SCTestingPseudomain new.
	app preferenceAt: #mainClass put: pseudomain.
	handler _ SCTestErrorHandler new.
	handler case: self.
	app preferenceAt: #errorHandler put: handler
newApplicationWithRootClass: aComponentClass
 
	app := SCTesterApplication path: aComponentClass name.
	app configuration 
		addAncestor: WARenderLoopConfiguration localConfiguration.
	app preferenceAt: #rootComponent put: aComponentClass.
	WADispatcher default registerEntryPoint: app at: aComponentClass name.
	self configureApplicationForComponent: aComponentClass.
	^app
newApplicationWithRootClass: aComponentClass initializeWith: aBlock

	app := SCTesterApplication path: aComponentClass name.
	app configuration 
		addAncestor: WARenderLoopConfiguration localConfiguration.
	app preferenceAt: #rootComponent put: aComponentClass.
	WADispatcher default registerEntryPoint: app at: aComponentClass name.
	self configureApplicationForComponent: aComponentClass.
	pseudomain initializeComponentWith: aBlock.
	^app
removeApplication

	WADispatcher default removeEntryPoint: app.
responseSemaphore

	^ responseSema
		ifNil: [responseSema _ Semaphore new]

component
component

	^pseudomain component
frontMostComponent

	^ pseudomain component visiblePresentersDo: [:each |
		each isDecoration ifFalse: [^each]]

private
checkResponseForDebugging: response
 
	| a finalResponse |
	finalResponse _ response.
	self isDebugging
		ifTrue: [a _ response anchorWithLabel: 'Debug' ifNone: [^finalResponse].
			[finalResponse _ self followAnchor: a] fork.
			self halt: 'Browser waiting for response, proceed when you''re done debugging.'].
	^ finalResponse
errorOccurred: e
 
	self isDebugging
		ifFalse: [self error: 'An error occured during request processing']

request/response
back

	^self browser back
backAndRefresh

	self back.
	^self refresh
establishSession

	^ self checkResponseForDebugging:  (self browser establishSessionAtBase: app baseUrl asString)
followAnchor: anAnchor
 
	| response |
	response _ self browser followAnchor: anAnchor.
	^self checkResponseForDebugging: response
lastResponse

	^self browser lastResponse
refresh

	^self browser refresh
submitForm: form pressingButton: button
 
	| response |
	response _ self browser submitForm: form pressingButton: button.
	^self checkResponseForDebugging: response

class methods:

Testing
isAbstract

	"Override to true if a TestCase subclass is Abstract and should not have
	TestCase instances built from it"

	^self sunitName = #SCComponentTestCase

^top


- made by Dandelion -