-
Notifications
You must be signed in to change notification settings - Fork 2
Feat/recordbrowser #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: P14
Are you sure you want to change the base?
Changes from all commits
d0dad6b
8b1479c
23ec5e0
486cfed
f911360
ea04d1d
f31aa6c
0f39f0e
a8720ec
9f3f530
5321071
819f0b0
1af3591
c3b5de3
5cd5eb8
70a8d12
a44b70a
0ae7e5c
305073b
318ba65
9f8477e
fa08e33
e5a6b5c
8ad83d9
a7d8bbc
9838a45
bece7be
23ded92
11e058a
9fd34a5
c41e740
d7c4d3b
4cf47b1
ebc3aba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
nicolasp025 marked this conversation as resolved.
Show resolved
Hide resolved
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,264 @@ | ||
| Class { | ||
| #name : 'DSRecordBrowserTest', | ||
| #superclass : 'TestCase', | ||
| #instVars : [ | ||
| 'browser', | ||
| 'logger' | ||
| ], | ||
| #category : 'DebuggingSpy-Browser-Tests', | ||
| #package : 'DebuggingSpy-Browser-Tests' | ||
| } | ||
|
|
||
| { #category : 'helpers' } | ||
| DSRecordBrowserTest >> filesPresenter [ | ||
|
|
||
| ^ browser presenterAt: #fileListPresenter | ||
| ] | ||
|
|
||
| { #category : 'helpers' } | ||
| DSRecordBrowserTest >> generateRecordsFile [ | ||
| "Generates a file of random records and returns its file reference." | ||
|
|
||
| | recordFileRef writeStream randomNbOfRecords | | ||
| randomNbOfRecords := Random new nextInteger: 10. | ||
|
|
||
| recordFileRef := self temporaryDirectory / ('ds-spy-test-' , UUID new asString). | ||
| recordFileRef ensureCreateFile. | ||
| writeStream := recordFileRef writeStream. | ||
|
|
||
| writeStream nextPut: $[. | ||
|
|
||
| 1 to: randomNbOfRecords do: [ :index | | ||
| writeStream nextPutAll: (STON toString: (self getRecordForIndex: index)). | ||
|
|
||
| index = randomNbOfRecords ifFalse: [ | ||
| writeStream nextPut: $,. | ||
| writeStream crlf ] ]. | ||
|
|
||
| writeStream nextPut: $]. | ||
|
|
||
| writeStream close. | ||
|
|
||
| ^ recordFileRef | ||
| ] | ||
|
|
||
| { #category : 'helpers' } | ||
| DSRecordBrowserTest >> getRecordForIndex: aNumber [ | ||
| "Generates a record with specified number as dateTime (in seconds) and as windowId" | ||
|
|
||
| ^ self recordClass new | ||
| dateTime: (DateAndTime fromSeconds: aNumber); | ||
| windowId: aNumber; | ||
| yourself | ||
| ] | ||
|
|
||
| { #category : 'helpers' } | ||
| DSRecordBrowserTest >> recordClass [ | ||
|
|
||
| ^ DSMouseEnterWindowRecord | ||
| ] | ||
|
Comment on lines
+55
to
+59
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand this method, it seems to be useless
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It returns the class of records that would be generated in the (DSRecordBrowserTest >> getRecordForIndex: ) method, we could have used any random class of record but some of them may need additional attributes to be defined. This method is also used in tests when we want to filter a class of records |
||
|
|
||
| { #category : 'helpers' } | ||
| DSRecordBrowserTest >> recordsFilterPresenter [ | ||
|
|
||
| ^ browser presenterAt: #recordsFilter | ||
| ] | ||
|
|
||
| { #category : 'helpers' } | ||
| DSRecordBrowserTest >> recordsTablePresenter [ | ||
|
|
||
| ^ browser presenterAt: #recordsTablePresenter | ||
| ] | ||
|
|
||
| { #category : 'running' } | ||
| DSRecordBrowserTest >> setUp [ | ||
|
|
||
| super setUp. | ||
| browser := DSRecordBrowser new | ||
| ] | ||
|
|
||
| { #category : 'running' } | ||
| DSRecordBrowserTest >> tearDown [ | ||
|
|
||
| DSRecordBrowser resetBrowser. | ||
| super tearDown | ||
| ] | ||
|
|
||
| { #category : 'tests' } | ||
| DSRecordBrowserTest >> testAddFile [ | ||
|
|
||
| | fileRef | | ||
| fileRef := self generateRecordsFile. | ||
|
|
||
| browser addFile: fileRef. | ||
| self assert: browser files size equals: 1. | ||
| self assert: self filesPresenter items size equals: 1. | ||
|
|
||
| self assert: self filesPresenter selectedItem equals: fileRef | ||
| ] | ||
|
|
||
| { #category : 'tests' } | ||
| DSRecordBrowserTest >> testAddFileWhenAlreadyInList [ | ||
|
|
||
| | fileRef | | ||
| fileRef := self generateRecordsFile. | ||
|
|
||
| browser addFile: fileRef. | ||
| browser addFile: fileRef. | ||
| self assert: browser files size equals: 1. | ||
| self assert: self filesPresenter items size equals: 1. | ||
| self assert: self filesPresenter selectedItem equals: fileRef | ||
| ] | ||
|
|
||
| { #category : 'tests' } | ||
| DSRecordBrowserTest >> testBrowserEmpty [ | ||
nicolasp025 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| self assertEmpty: browser files. | ||
| self assert: self filesPresenter items size equals: 0. | ||
| self assert: self filesPresenter selectedItem equals: nil. | ||
|
|
||
| ] | ||
|
|
||
| { #category : 'tests' } | ||
| DSRecordBrowserTest >> testClosingBrowser [ | ||
|
|
||
| DSRecordBrowser toggleBrowser. | ||
| DSRecordBrowser toggleBrowser. | ||
| self deny: DSRecordBrowser uniqueInstance window isOpen | ||
| ] | ||
|
|
||
| { #category : 'tests' } | ||
| DSRecordBrowserTest >> testCreatingAndOpeningBrowser [ | ||
|
|
||
| DSRecordBrowser toggleBrowser. | ||
| self assert: DSRecordBrowser uniqueInstance window isOpen. | ||
| DSRecordBrowser toggleBrowser | ||
| ] | ||
|
|
||
| { #category : 'tests' } | ||
| DSRecordBrowserTest >> testFilteringAClassOfRecords [ | ||
|
|
||
| | fileRef history | | ||
| fileRef := self generateRecordsFile. | ||
| history := browser getHistoryFrom: fileRef. | ||
|
|
||
| browser addFile: fileRef. | ||
| self assert: self recordsTablePresenter roots size equals: history records size. | ||
|
|
||
| self recordsFilterPresenter sourceList selectItem: self recordClass. | ||
| self recordsFilterPresenter addSelected. | ||
|
|
||
| self assert: self recordsTablePresenter roots size equals: 0 "Since there is only one type of records in the generated file" | ||
| ] | ||
|
|
||
| { #category : 'tests' } | ||
| DSRecordBrowserTest >> testFilteringAllRecords [ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that, for this test, it will be interessing to have an example file with different type of record (as you want to filter records). |
||
|
|
||
| | fileRef history | | ||
| fileRef := self generateRecordsFile. | ||
| history := browser getHistoryFrom: fileRef. | ||
|
|
||
| browser addFile: fileRef. | ||
| self assert: self recordsTablePresenter roots size equals: history records size. | ||
|
|
||
| self recordsFilterPresenter addAll. | ||
| self assert: self recordsTablePresenter roots size equals: 0 | ||
| ] | ||
|
|
||
| { #category : 'tests' } | ||
| DSRecordBrowserTest >> testGetHistoryFrom [ | ||
|
|
||
| | fileRef | | ||
| fileRef := self generateRecordsFile. | ||
| self assert: (browser getHistoryFrom: fileRef) class equals: DSRecordHistory | ||
| ] | ||
|
|
||
| { #category : 'tests' } | ||
| DSRecordBrowserTest >> testGetRecordColorAssociationsFrom [ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test is not clear for me, can you explain it?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By the way, as you want to check that different colors appears in your presenter, it will be interesting to have different type of records in your testing file
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test is meant to verify that each association contains a record and the correct associated color. In that case, each record will be associated with the default color since we didn't defined any window for them, considering the color relies on the window and not the record. I think that test is useful because it happened that for any obscure reason (that has been fixed), the colors may be not corresponding so I think we better verifying it. |
||
|
|
||
| | fileRef history colorAssociations | | ||
| fileRef := self generateRecordsFile. | ||
| history := browser getHistoryFrom: fileRef. | ||
| colorAssociations := browser getRecordColorAssociationsFrom: history windows. | ||
|
|
||
| history windows do: [ :window | | ||
| window events do: [ :record | | ||
| self assert: (colorAssociations anySatisfy: [ :association | | ||
| association key = record and: association value = (browser getWindowColorFrom: window) ]) ] ] | ||
nicolasp025 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ] | ||
|
|
||
| { #category : 'tests' } | ||
| DSRecordBrowserTest >> testRemoveFile [ | ||
nicolasp025 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| | fileRef1 fileRef2 | | ||
| fileRef1 := self generateRecordsFile. | ||
| fileRef2 := self generateRecordsFile. | ||
|
|
||
| browser addFile: fileRef1. | ||
| browser addFile: fileRef2. | ||
| browser removeFile: fileRef1. | ||
|
|
||
| self assert: browser files size equals: 1. | ||
| self assert: self filesPresenter items size equals: 1. | ||
| self assert: self filesPresenter selectedItem equals: fileRef2 | ||
| ] | ||
|
|
||
| { #category : 'tests' } | ||
| DSRecordBrowserTest >> testRemoveLastFile [ | ||
|
|
||
| | fileRef1 | | ||
| fileRef1 := self generateRecordsFile. | ||
|
|
||
| browser addFile: fileRef1. | ||
| browser removeFile: fileRef1. | ||
|
|
||
| self assert: browser files size equals: 0. | ||
| self assert: self filesPresenter items size equals: 0. | ||
| self assert: self filesPresenter selectedItem equals: nil | ||
| ] | ||
|
|
||
| { #category : 'tests' } | ||
| DSRecordBrowserTest >> testStartRecording [ | ||
|
|
||
| self assert: browser recorderWindow isNil. | ||
| self deny: DSRecordRegistry autoSerialize. | ||
| self deny: DSSpy recordingSession. | ||
|
|
||
| browser startRecording. | ||
| self assert: DSSpy recordingSession. | ||
| self assert: DSRecordRegistry autoSerialize. | ||
| self deny: browser recorderWindow isNil. | ||
|
|
||
| browser stopRecording | ||
nicolasp025 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ] | ||
nicolasp025 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| { #category : 'tests' } | ||
| DSRecordBrowserTest >> testUpdateRecordsTable [ | ||
|
|
||
| | fileRef history presenterMock | | ||
| fileRef := self generateRecordsFile. | ||
| history := browser getHistoryFrom: fileRef. | ||
| presenterMock := MockObject new on: #selectedItem respond: fileRef. | ||
| browser updateRecordsTable: presenterMock. | ||
|
|
||
| self recordsTablePresenter roots do: [ :association | | ||
| self assert: (history records anySatisfy: [ :record | record uuid = association key uuid ]) ] | ||
| ] | ||
|
|
||
| { #category : 'tests' } | ||
| DSRecordBrowserTest >> testUpdateRecordsTableWhenAddingFile [ | ||
|
|
||
| | fileRef history | | ||
| fileRef := self generateRecordsFile. | ||
| history := browser getHistoryFrom: fileRef. | ||
|
|
||
| browser addFile: fileRef. | ||
|
|
||
| self assert: self recordsTablePresenter roots size equals: history records size | ||
| ] | ||
|
|
||
| { #category : 'helpers' } | ||
| DSRecordBrowserTest >> timelinePresenter [ | ||
|
|
||
| ^ browser presenterAt: #graphicTimeline | ||
| ] | ||
nicolasp025 marked this conversation as resolved.
Show resolved
Hide resolved
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe you can add a |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,51 @@ | ||||||
| Class { | ||||||
| #name : 'DSRecorderWindowTest', | ||||||
nicolasp025 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| #superclass : 'TestCase', | ||||||
| #instVars : [ | ||||||
| 'window' | ||||||
| ], | ||||||
| #category : 'DebuggingSpy-Browser-Tests', | ||||||
| #package : 'DebuggingSpy-Browser-Tests' | ||||||
| } | ||||||
|
|
||||||
| { #category : 'running' } | ||||||
| DSRecorderWindowTest >> setUp [ | ||||||
| super setUp. | ||||||
|
|
||||||
| window := DSTimerWindow new. | ||||||
nicolasp025 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| ] | ||||||
|
|
||||||
| { #category : 'tests' } | ||||||
| DSRecorderWindowTest >> testEmptyTimerWindow [ | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| self assert: (Time readFrom: self timerMorph contents readStream) seconds equals: 0 | ||||||
| ] | ||||||
|
|
||||||
| { #category : 'tests' } | ||||||
| DSRecorderWindowTest >> testTimeNow [ | ||||||
nicolasp025 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
|
||||||
| self assert: (Time readFrom: self timeNowMorph contents readStream) asSeconds equals: Time now asSeconds | ||||||
| ] | ||||||
|
|
||||||
| { #category : 'tests' } | ||||||
| DSRecorderWindowTest >> testTimer [ | ||||||
nicolasp025 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
|
||||||
| window startTimer. | ||||||
| (Delay forMilliseconds: 1000) wait. | ||||||
| window stopTimer. | ||||||
| self assert: window elapsedTime equals: 1 | ||||||
| ] | ||||||
|
|
||||||
| { #category : 'layout' } | ||||||
| DSRecorderWindowTest >> timeNowMorph [ | ||||||
| "Returns the window's timeNowMorph" | ||||||
|
|
||||||
| ^ window readSlot: (DSTimerWindow slotNamed: #timeNowMorph) | ||||||
| ] | ||||||
|
|
||||||
| { #category : 'layout' } | ||||||
| DSRecorderWindowTest >> timerMorph [ | ||||||
| "Returns the window's timerMorph." | ||||||
|
|
||||||
| ^ window readSlot: (DSTimerWindow slotNamed: #timerMorph) | ||||||
| ] | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Package { #name : 'DebuggingSpy-Browser-Tests' } |
Uh oh!
There was an error while loading. Please reload this page.