Skip to content

Commit

Permalink
Free all Mock Tele Clients and hence receive loops and cores (#416)
Browse files Browse the repository at this point in the history
* allows freeing MockTeleClients and make sure that they are freed

* add comment to MockTeleClient explaining why it should be freed

* remove mockCore from TCTMMocks
  • Loading branch information
rsommerfeld authored Jun 26, 2021
1 parent c015d8f commit 8ab9159
Show file tree
Hide file tree
Showing 29 changed files with 55 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ testMessageShouldNotNotify
| chat |

chat := TCCChat newFromChatEvent: (TCTMMocks mockChatEventMutedFor: 42).
self assert: false equals: ((TCTMMocks mockMessageFor: chat) shouldNotify).
self assert: false equals: ((TCTMMocks mockMessageIn: chat with: self core) shouldNotify).
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ testMessageShouldNotify
| chat |

chat := TCCChat newFromChatEvent: (TCTMMocks mockChatEventMutedFor: 0).
self assert: true equals: ((TCTMMocks mockMessageFor: chat) shouldNotify).
self assert: true equals: ((TCTMMocks mockMessageIn: chat with: self core) shouldNotify).
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"class" : {
},
"instance" : {
"testMessageShouldNotNotify" : "per 6/18/2021 09:28",
"testMessageShouldNotify" : "per 6/18/2021 09:28" } }
"testMessageShouldNotNotify" : "RS 6/25/2021 13:03",
"testMessageShouldNotify" : "RS 6/25/2021 13:03" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
running
tearDown

self core freeClient.
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
"core" : "TR 6/13/2021 15:00",
"core:" : "TR 6/13/2021 14:54",
"mockTeleClient" : "RS 6/6/2021 11:28",
"setUp" : "per 6/15/2021 08:23" } }
"setUp" : "per 6/15/2021 08:23",
"tearDown" : "RS 6/25/2021 12:40" } }
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
A TCTCMockTeleClient is a TeleClient that simulates a connection to tdlib. You can manually register events on request types by using onRequestType:respond:.
A TCTCMockTeleClient is a TeleClient that simulates a connection to tdlib. You can manually register events on request types by using onRequestType:respond:.
When used by a core, the MockTeleClient should be freed to ensure that the core eventLoops will terminate.
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
library calls
free
free

self freed: true.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
freed: aBoolean

freed := aBoolean
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
freed

^ freed
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ initialize-release
initialize

self responseQueue: LinkedList new.
self requestResponses: Dictionary new.
self requestResponses: Dictionary new.
self freed: false.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
accessing
isAlive

^ true
^ self freed not
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
"addExtraAttribute:to:" : "RS 6/6/2021 12:29",
"appendResponsesToRequest:" : "RS 6/6/2021 12:33",
"execute:" : "RS 6/3/2021 11:49",
"free" : "JB 6/7/2021 11:40",
"initialize" : "RS 6/6/2021 12:21",
"isAlive" : "RS 6/3/2021 12:09",
"free" : "RS 6/25/2021 12:30",
"freed" : "RS 6/25/2021 12:28",
"freed:" : "RS 6/25/2021 12:28",
"initialize" : "RS 6/25/2021 12:28",
"isAlive" : "RS 6/25/2021 12:33",
"logIn" : "JB 6/7/2021 09:13",
"onRequestType:respond:" : "RS 6/6/2021 12:20",
"onRequestType:respondAll:" : "RS 6/6/2021 12:22",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
],
"classvars" : [
],
"commentStamp" : "JB 6/7/2021 09:35",
"commentStamp" : "RS 6/25/2021 13:08",
"instvars" : [
"created",
"freed",
"responseQueue",
"requestResponses" ],
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
message
mockMessageFor: aChat
mockMessageIn: aChat with: aCore

^ TCCMessage newFromMessageEvent: (self mockMessageJsonFrom: aChat id)
in: aChat
with: self mockCore
with: aCore
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,16 @@
"mockBasicGroupFullInfoJson" : "per 6/10/2021 19:41",
"mockChatEventMutedFor:" : "per 6/18/2021 09:20",
"mockChats" : "TR 5/27/2021 19:55",
"mockCore" : "TR 6/13/2021 15:45",
"mockImageData" : "pk 6/19/2021 18:18",
"mockImageForm" : "pk 6/19/2021 18:10",
"mockImageId" : "pk 6/19/2021 17:22",
"mockImagePath" : "pk 6/19/2021 18:06",
"mockImageResponseJson" : "pk 6/19/2021 18:21",
"mockMembers" : "per 6/15/2021 08:25",
"mockMessage" : "per 6/10/2021 19:30",
"mockMessageDate" : "RS 6/6/2021 11:42",
"mockMessageEventFrom:" : "RS 5/23/2021 17:56",
"mockMessageFor:" : "per 6/18/2021 09:28",
"mockMessageID" : "pk 5/19/2021 11:36",
"mockMessageIn:with:" : "RS 6/25/2021 13:02",
"mockMessageJsonFrom:" : "per 6/10/2021 19:30",
"mockMessageText" : "pk 5/19/2021 11:38",
"mockMessageWith:" : "6/13/2021 15:37:31",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ testMessageColorsDifferentForIncomingOutgoing

| incomingMessage outgoingMessage |

outgoingMessage := TCTMMocks mockMessage.
incomingMessage := TCTMMocks mockMessage.
outgoingMessage := TCTMMocks mockMessageWith: self core.
incomingMessage := TCTMMocks mockMessageWith: self core.

outgoingMessage isOutgoing: true.
incomingMessage isOutgoing: false.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ testMessageContainsDate

| message |

message := TCTMMocks mockMessage.
message := TCTMMocks mockMessageWith: self core.
message date: message date asUTC.

self wantsToTest: (TCUMessage newFromTCCMessage: message).
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
testing
testMessageContainsMessageSender

self wantsToTest: (TCUMessage newFromTCCMessage: TCTMMocks mockMessage).
self wantsToTest: (TCUMessage newFromTCCMessage: (TCTMMocks mockMessageWith: self core)).
self assertReading: TCTMMocks mockUser1 fullName in: self subject.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
testing
testMessageContainsMessageText

self wantsToTest: (TCUMessage newFromTCCMessage: TCTMMocks mockMessage).
self wantsToTest: (TCUMessage newFromTCCMessage: (TCTMMocks mockMessageWith: self core)).
self assertReading: TCTMMocks mockMessageText in: self subject.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ testMessageShrinksCorrectly

| message messageMorph |

message := TCTMMocks mockMessage.
message := TCTMMocks mockMessageWith: self core.
messageMorph := TCUMessage newFromTCCMessage: message.

self forceSaveScreenshotOf: messageMorph as: 'testMessageShrinksCorrectly' in: self class defaultTestResultPath.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
},
"instance" : {
"expectedSqueak5_2Failures" : "RS 6/6/2021 15:43",
"testMessageColorsDifferentForIncomingOutgoing" : "pk 6/11/2021 10:28",
"testMessageContainsDate" : "pk 6/11/2021 10:28",
"testMessageContainsMessageSender" : "TR 6/13/2021 15:46",
"testMessageContainsMessageText" : "pk 6/11/2021 10:28",
"testMessageShrinksCorrectly" : "pk 6/13/2021 11:04" } }
"testMessageColorsDifferentForIncomingOutgoing" : "RS 6/25/2021 13:04",
"testMessageContainsDate" : "RS 6/25/2021 13:04",
"testMessageContainsMessageSender" : "RS 6/25/2021 13:04",
"testMessageContainsMessageText" : "RS 6/25/2021 13:04",
"testMessageShrinksCorrectly" : "RS 6/25/2021 13:04" } }
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ testing
testMutedNotificationNotVisible

| message |
message := TCTMMocks mockMessage.
message := TCTMMocks mockMessageWith: self core.
message chat: TCTMMocks mockMutedPrivateChat.
TCUMain basicNew newMessageReceived: message.
self deny: ((Project current world submorphOfClass: TCUNotification) notNil).
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
testing
testNotificationContainsSender

self wantsToTest: (TCUNotification newWithMessage: TCTMMocks mockMessage).
self wantsToTest: (TCUNotification newWithMessage: (TCTMMocks mockMessageWith: self core)).
self assertReading: TCTMMocks mockUser1 fullName in: self subject.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ testing
testUnmutedNotificationVisible

| message |
message := TCTMMocks mockMessage.
message := TCTMMocks mockMessageWith: self core.
message chat: TCTMMocks mockPrivateChat.
TCUMain basicNew newMessageReceived: message.
1 seconds wait.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"class" : {
},
"instance" : {
"testMutedNotificationNotVisible" : "per 6/18/2021 09:35",
"testMutedNotificationNotVisible" : "RS 6/25/2021 13:05",
"testNotificationConstructor" : "TR 6/13/2021 15:45",
"testNotificationContainsMessage" : "JB 6/7/2021 09:28",
"testNotificationContainsSender" : "per 6/10/2021 19:31",
"testNotificationContainsSender" : "RS 6/25/2021 13:05",
"testNotificationHidesPrivateChatTitle" : "TR 6/13/2021 15:46",
"testNotificationShowsGroupChatTitle" : "TR 6/13/2021 15:46",
"testUnmutedNotificationVisible" : "per 6/18/2021 09:35" } }
"testUnmutedNotificationVisible" : "RS 6/25/2021 13:05" } }
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
running
tearDown

self deleteMorphs.
self deleteMorphs.
self core freeClient.
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@
"seeing:in:" : "per 6/15/2021 09:29",
"setUp" : "TR 6/13/2021 15:39",
"takeScreenshotOf:" : "JB 5/24/2021 16:21",
"tearDown" : "JB 5/24/2021 17:42",
"tearDown" : "RS 6/25/2021 12:38",
"waitUntil:" : "RS 6/6/2021 13:00" } }

0 comments on commit 8ab9159

Please sign in to comment.