The Trunk: ToolBuilder-SUnit-cwp.16.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: ToolBuilder-SUnit-cwp.16.mcz

commits-2
Colin Putney uploaded a new version of ToolBuilder-SUnit to project The Trunk:
http://source.squeak.org/trunk/ToolBuilder-SUnit-cwp.16.mcz

==================== Summary ====================

Name: ToolBuilder-SUnit-cwp.16
Author: cwp
Time: 5 November 2011, 3:24:49.747 pm
UUID: 1cc3fc65-636c-4a2b-84a3-6700a8e15f0b
Ancestors: ToolBuilder-SUnit-cmm.15

Introduced a state dictionary to WidgetStub. This lets us simulate a widget more easily and correctly: we maintain local state for thinks like button labels or list contents, so that we don't query the model unless something changes,  like a real widget would do.

=============== Diff against ToolBuilder-SUnit-cmm.15 ===============

Item was changed:
  WidgetStub subclass: #ButtonStub
+ instanceVariableNames: ''
- instanceVariableNames: 'enabled'
  classVariableNames: ''
  poolDictionaries: ''
  category: 'ToolBuilder-SUnit'!

Item was changed:
  ----- Method: ButtonStub>>color (in category 'simulating') -----
  color
+ ^ state at: #color!
- ^ self model perform: spec color!

Item was removed:
- ----- Method: ButtonStub>>eventAccessors (in category 'events') -----
- eventAccessors
- ^ #(label color state enabled)!

Item was changed:
  ----- Method: ButtonStub>>isEnabled (in category 'simulating') -----
  isEnabled
+ ^ state at: #enabled!
- enabled ifNil: [enabled := spec model perform: spec enabled].
- ^ enabled!

Item was added:
+ ----- Method: ButtonStub>>isPressed (in category 'simulating') -----
+ isPressed
+ ^ state at: #state!

Item was added:
+ ----- Method: ButtonStub>>label (in category 'simulating') -----
+ label
+ ^ state at: #label!

Item was added:
+ ----- Method: ButtonStub>>stateVariables (in category 'events') -----
+ stateVariables
+ ^ #(label color state enabled)!

Item was changed:
  WidgetStub subclass: #CompositeStub
+ instanceVariableNames: ''
- instanceVariableNames: 'children'
  classVariableNames: ''
  poolDictionaries: ''
  category: 'ToolBuilder-SUnit'!

Item was changed:
  ----- Method: CompositeStub>>children (in category 'accessing') -----
  children
+ ^ state at: #children!
- ^children!

Item was changed:
  ----- Method: CompositeStub>>children: (in category 'accessing') -----
  children: anObject
+ state at: #children put: anObject!
- children := anObject!

Item was removed:
- ----- Method: CompositeStub>>eventAccessors (in category 'accessing') -----
- eventAccessors
- ^ #(children)!

Item was added:
+ ----- Method: CompositeStub>>stateVariables (in category 'accessing') -----
+ stateVariables
+ ^ #(children)!

Item was changed:
  ----- Method: CompositeStub>>widgetNamed: (in category 'accessing') -----
  widgetNamed: aString
  self name = aString
  ifTrue: [^ self]
+ ifFalse: [self children do: [:ea | (ea widgetNamed: aString) ifNotNil: [:w | ^ w]]].
- ifFalse: [children do: [:ea | (ea widgetNamed: aString) ifNotNil: [:w | ^ w]]].
  ^ nil!

Item was removed:
- ----- Method: ListStub>>eventAccessors (in category 'events') -----
- eventAccessors
- ^ #(list getIndex setIndex getSelected setSelected menu keyPress autoDeselect)!

Item was changed:
  WidgetStub subclass: #TextStub
+ instanceVariableNames: ''
- instanceVariableNames: 'text'
  classVariableNames: ''
  poolDictionaries: ''
  category: 'ToolBuilder-SUnit'!

Item was changed:
  ----- Method: TextStub>>accept: (in category 'simulating') -----
  accept: aString
+ state at: #getText put: aString.
  ^ self model perform: spec setText with: aString asText!

Item was changed:
  ----- Method: TextStub>>color (in category 'simulating') -----
  color
+ ^ state at: #color!
- ^ self model perform: spec color!

Item was removed:
- ----- Method: TextStub>>eventAccessors (in category 'events') -----
- eventAccessors
- ^ #(setText selection menu color)!

Item was removed:
- ----- Method: TextStub>>refresh (in category 'events') -----
- refresh
- self refreshText!

Item was removed:
- ----- Method: TextStub>>refreshText (in category 'events') -----
- refreshText
- text := self model perform: spec getText!

Item was added:
+ ----- Method: TextStub>>stateVariables (in category 'events') -----
+ stateVariables
+ ^ #(color selection getText)!

Item was changed:
  ----- Method: TextStub>>text (in category 'simulating') -----
  text
+ ^ state at: #getText!
- ^ text!

Item was removed:
- ----- Method: TextStub>>update: (in category 'events') -----
- update: aSymbol
- aSymbol = spec getText ifTrue: [^ self refreshText].
- super update: aSymbol!

Item was removed:
- ----- Method: TreeStub>>eventAccessors (in category 'events') -----
- eventAccessors
- ^ #(roots getSelectedPath setSelected getChildren hasChildren label icon help menu keyPress)!

Item was changed:
  Object subclass: #WidgetStub
+ instanceVariableNames: 'spec state'
- instanceVariableNames: 'spec'
  classVariableNames: ''
  poolDictionaries: ''
  category: 'ToolBuilder-SUnit'!

Item was removed:
- ----- Method: WidgetStub>>eventAccessors (in category 'events') -----
- eventAccessors
- ^ #()!

Item was changed:
  ----- Method: WidgetStub>>refresh (in category 'events') -----
+ refresh
+ self stateVariables do: [:var | self refresh: var]!
- refresh!

Item was added:
+ ----- Method: WidgetStub>>refresh: (in category 'events') -----
+ refresh: var
+ | value |
+ value := spec perform: var.
+ self refresh: var with: value!

Item was added:
+ ----- Method: WidgetStub>>refresh:with: (in category 'events') -----
+ refresh: var with: value
+ state
+ at: var
+ put: (value isSymbol
+ ifTrue: [spec model perform: value]
+ ifFalse: [value])!

Item was changed:
  ----- Method: WidgetStub>>setSpec: (in category 'initialize-release') -----
  setSpec: aSpec
+ state := IdentityDictionary new.
  spec := aSpec.
  spec model addDependent: self.
  self refresh.!

Item was added:
+ ----- Method: WidgetStub>>stateVariables (in category 'events') -----
+ stateVariables
+ ^ #()!

Item was changed:
  ----- Method: WidgetStub>>update: (in category 'events') -----
+ update: aSymbol
+
+ self stateVariables do:
+ [:var |
+ (spec perform: var) == aSymbol ifTrue:
+ [self refresh: var with: aSymbol.
+ ^ self]]!
- update: aSelector
- | recognized |
- recognized := self eventAccessors collect: [:ea | spec perform: ea].
- (recognized includes: aSelector)
- ifTrue: [spec model perform: aSelector]!

Item was removed:
- ----- Method: WindowStub>>eventAccessors (in category 'events') -----
- eventAccessors
- ^ super eventAccessors, #(label)!

Item was added:
+ ----- Method: WindowStub>>stateVariables (in category 'events') -----
+ stateVariables
+ ^ super stateVariables, #(label)!