Skip to content

Commit c98a4d7

Browse files
committed
feat: window color indicator on timer window + adding some tests
1 parent 448e5c3 commit c98a4d7

File tree

3 files changed

+78
-10
lines changed

3 files changed

+78
-10
lines changed

DebuggingSpy-Browser-Tests/DSRecordBrowserPresenterTest.class.st

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,10 @@ DSRecordBrowserPresenterTest >> testGetWindowColorFrom [
219219

220220
| record |
221221
record := DSWindowRecord new toolInfo: (DSToolInfo new toolClass: StDebugger).
222-
self assert: (browser getWindowColorFrom: record) equals: DSWindowRecord debuggerColor.
222+
self assert: (browser getWindowColorFrom: record) equals: StDebugger windowColor.
223223

224224
record toolInfo toolClass: DSRecordBrowserPresenter.
225-
self assert: (browser getWindowColorFrom: record) equals: DSWindowRecord defaultColor
225+
self assert: (browser getWindowColorFrom: record) equals: DSRecordBrowserPresenter defaultWindowColor
226226
]
227227

228228
{ #category : 'tests' }

DebuggingSpy-Browser-Tests/DSTimerWindowTest.class.st

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ DSTimerWindowTest >> setUp [
2222
timerWindow := DSTimerWindow new.
2323
]
2424

25+
{ #category : 'tests' }
26+
DSTimerWindowTest >> testBuildLayout [
27+
"buildLayout has been already called from initialize"
28+
29+
self assert: ({ 'timerMorph'. 'currentTimeMorph'. 'lastEventMorph'. 'windowColorIndicator' } allSatisfy: [ :slotName |
30+
(timerWindow readSlotNamed: slotName) isNotNil ]).
31+
32+
self assert: timerWindow submorphs size equals: 6
33+
]
34+
2535
{ #category : 'tests' }
2636
DSTimerWindowTest >> testCurrentTimeMorph [
2737

@@ -59,6 +69,17 @@ DSTimerWindowTest >> testGetFormattedNameFrom [
5969
self assert: (timerWindow getFormattedNameFrom: DSBrowseRecord new) equals: 'Browse (DSTimerWindowTest)'
6070
]
6171

72+
{ #category : 'tests' }
73+
DSTimerWindowTest >> testGetRecordColorFrom [
74+
75+
| toolInfo |
76+
toolInfo := DSToolInfo new toolClass: StPlayground.
77+
78+
self assert: (timerWindow getRecordColorFrom: DSAbstractEventRecord new) equals: DSRecordBrowserPresenter defaultWindowColor.
79+
80+
self assert: (timerWindow getRecordColorFrom: (DSMouseEventRecord new toolInfo: toolInfo)) equals: StPlayground windowColor
81+
]
82+
6283
{ #category : 'tests' }
6384
DSTimerWindowTest >> testGetToolInfoFor [
6485

@@ -104,6 +125,25 @@ DSTimerWindowTest >> testStartTimer [
104125
DSSpy recordingSession: false
105126
]
106127

128+
{ #category : 'tests' }
129+
DSTimerWindowTest >> testUpdatePosition [
130+
131+
| newPosition |
132+
newPosition := self currentWorld extent - timerWindow extent - timerWindow margin
133+
- (0 @ self currentWorld taskbars first extent y).
134+
135+
timerWindow updatePosition.
136+
self assert: timerWindow position equals: newPosition
137+
]
138+
139+
{ #category : 'tests' }
140+
DSTimerWindowTest >> testWindowColorIndicator [
141+
142+
timerWindow writeSlotNamed: 'windowColorIndicator' value: nil.
143+
self assert: timerWindow windowColorIndicator isNotNil.
144+
self assert: (timerWindow readSlotNamed: 'windowColorIndicator') isNotNil
145+
]
146+
107147
{ #category : 'layout' }
108148
DSTimerWindowTest >> timerMorph [
109149
"Returns the window's timerMorph."

DebuggingSpy-Browser/DSTimerWindow.class.st

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ Class {
99
'startTime',
1010
'currentTimeMorph',
1111
'lastEventMorph',
12-
'lastToolInfo'
12+
'lastToolInfo',
13+
'windowColorIndicator'
1314
],
1415
#category : 'DebuggingSpy-Browser',
1516
#package : 'DebuggingSpy-Browser'
@@ -22,8 +23,10 @@ DSTimerWindow >> buildLayout [
2223
timerMorph := self timerMorph.
2324
currentTimeMorph := self currentTimeMorph.
2425
lastEventMorph := self lastEventMorph.
26+
windowColorIndicator := self windowColorIndicator.
2527

2628
self
29+
addMorph: windowColorIndicator;
2730
addMorph: lastEventMorph;
2831
addMorph: self recordingIcon;
2932
addMorph: timerMorph;
@@ -43,7 +46,7 @@ DSTimerWindow >> currentTimeMorph [
4346

4447
^ StringMorph new
4548
contents: Time now print24;
46-
position: 325 @ 6
49+
position: 335 @ 6
4750
]
4851

4952
{ #category : 'timer' }
@@ -67,6 +70,17 @@ DSTimerWindow >> getFormattedNameFrom: aRecord [
6770
^ formattedEventName
6871
]
6972

73+
{ #category : 'accessing' }
74+
DSTimerWindow >> getRecordColorFrom: aRecord [
75+
"Returns the toolInfo's window corresponding color, or default color otherwise."
76+
77+
| toolInfo |
78+
toolInfo := self getToolInfoFor: aRecord.
79+
toolInfo ifNil: [ ^ DSRecordBrowserPresenter defaultWindowColor ].
80+
81+
^ toolInfo toolClass windowColor
82+
]
83+
7084
{ #category : 'accessing' }
7185
DSTimerWindow >> getToolInfoFor: aRecord [
7286
"Returns the record's toolInfo if possible, else returns the last used toolInfo (which can be nil)."
@@ -121,14 +135,18 @@ DSTimerWindow >> lastEventMorph [
121135
^ lastEventMorph ifNil: [
122136
lastEventMorph := StringMorph new
123137
contents: 'No last record';
124-
position: 5 @ 6 ]
138+
height: 15;
139+
position: 15 @ 6 ]
125140
]
126141

127142
{ #category : 'accessing' }
128143
DSTimerWindow >> lastRecord: aRecord [
129144
"Updates the last record text on the window."
130145

131-
lastEventMorph contents: (self getFormattedNameFrom: aRecord)
146+
lastEventMorph contents: (self getFormattedNameFrom: aRecord).
147+
windowColorIndicator
148+
backgroundColor: (self getRecordColorFrom: aRecord);
149+
contents: ' ' "so we force the redraw"
132150
]
133151

134152
{ #category : 'accessing' }
@@ -172,14 +190,14 @@ DSTimerWindow >> recordingIcon [
172190

173191
^ ImageMorph new
174192
image: (self iconNamed: #glamorousRedCircle);
175-
position: 250 @ 7;
193+
position: 260 @ 7;
176194
yourself
177195
]
178196

179197
{ #category : 'accessing' }
180198
DSTimerWindow >> size [
181199

182-
^ 400 @ 30
200+
^ 410 @ 30
183201
]
184202

185203
{ #category : 'accessing' }
@@ -210,7 +228,7 @@ DSTimerWindow >> stopButton [
210228
label: (IconicListItemMorph new icon: (self iconNamed: #stop));
211229
model: self;
212230
actionSelector: #stopTimer;
213-
position: 375 @ 4;
231+
position: 385 @ 4;
214232
yourself
215233
]
216234

@@ -227,7 +245,7 @@ DSTimerWindow >> timerMorph [
227245

228246
^ StringMorph new
229247
contents: '00:00:00';
230-
position: 265 @ 6
248+
position: 275 @ 6
231249
]
232250

233251
{ #category : 'private - layout' }
@@ -236,3 +254,13 @@ DSTimerWindow >> updatePosition [
236254

237255
self position: self currentWorld extent - self extent - self margin - (0 @ self currentWorld taskbars first extent y)
238256
]
257+
258+
{ #category : 'layout' }
259+
DSTimerWindow >> windowColorIndicator [
260+
261+
^ windowColorIndicator ifNil: [
262+
windowColorIndicator := StringMorph new
263+
contents: ' ';
264+
height: 15;
265+
position: 5 @ 6 ]
266+
]

0 commit comments

Comments
 (0)