@@ -752,6 +752,7 @@ TEST_F(ControlBlocksTest, WaitImpl)
752752
753753 std::chrono::steady_clock::time_point startTime (std::chrono::milliseconds (1000 ));
754754 EXPECT_CALL (clock, currentSteadyTime ()).Times (2 ).WillRepeatedly (Return (startTime));
755+ EXPECT_CALL (m_engineMock, requestRedraw ());
755756 vm.run ();
756757
757758 ASSERT_EQ (vm.registerCount (), 0 );
@@ -901,8 +902,10 @@ TEST_F(ControlBlocksTest, CreateCloneOfImpl)
901902 vm.setFunctions (functions);
902903 vm.setConstValues (constValues);
903904
905+ Sprite *clone1;
904906 EXPECT_CALL (m_engineMock, targetAt (4 )).WillOnce (Return (&sprite));
905- EXPECT_CALL (m_engineMock, initClone).Times (1 );
907+ EXPECT_CALL (m_engineMock, initClone).WillOnce (SaveArg<0 >(&clone1));
908+ EXPECT_CALL (m_engineMock, requestRedraw ());
906909
907910 vm.setBytecode (bytecode1);
908911 vm.run ();
@@ -911,6 +914,7 @@ TEST_F(ControlBlocksTest, CreateCloneOfImpl)
911914 ASSERT_EQ (sprite.allChildren ().size (), 1 );
912915
913916 EXPECT_CALL (m_engineMock, initClone).Times (1 );
917+ EXPECT_CALL (m_engineMock, requestRedraw ());
914918
915919 vm.setBytecode (bytecode2);
916920 vm.run ();
@@ -919,9 +923,11 @@ TEST_F(ControlBlocksTest, CreateCloneOfImpl)
919923 ASSERT_EQ (sprite.allChildren ().size (), 2 );
920924 ASSERT_EQ (sprite.children (), sprite.allChildren ());
921925
926+ Sprite *clone3;
922927 EXPECT_CALL (m_engineMock, findTarget).WillOnce (Return (4 ));
923928 EXPECT_CALL (m_engineMock, targetAt (4 )).WillOnce (Return (&sprite));
924- EXPECT_CALL (m_engineMock, initClone).Times (1 );
929+ EXPECT_CALL (m_engineMock, initClone).WillOnce (SaveArg<0 >(&clone3));
930+ EXPECT_CALL (m_engineMock, requestRedraw ());
925931
926932 vm.setBytecode (bytecode3);
927933 vm.run ();
@@ -931,13 +937,17 @@ TEST_F(ControlBlocksTest, CreateCloneOfImpl)
931937 ASSERT_EQ (sprite.children (), sprite.allChildren ());
932938
933939 EXPECT_CALL (m_engineMock, initClone).Times (1 );
940+ EXPECT_CALL (m_engineMock, requestRedraw ());
934941
935942 vm.setBytecode (bytecode4);
936943 vm.run ();
937944
938945 ASSERT_EQ (vm.registerCount (), 0 );
939946 ASSERT_EQ (sprite.allChildren ().size (), 4 );
940947 ASSERT_EQ (sprite.children (), sprite.allChildren ());
948+
949+ EXPECT_CALL (m_engineMock, deinitClone (clone1));
950+ EXPECT_CALL (m_engineMock, deinitClone (clone3));
941951}
942952
943953TEST_F (ControlBlocksTest, StartAsClone)
@@ -980,13 +990,15 @@ TEST_F(ControlBlocksTest, DeleteThisCloneImpl)
980990
981991 Sprite *clone;
982992 EXPECT_CALL (m_engineMock, initClone (_)).WillOnce (SaveArg<0 >(&clone));
993+ EXPECT_CALL (m_engineMock, requestRedraw ());
983994 sprite.clone ();
984995 ASSERT_TRUE (clone);
985996
986997 VirtualMachine vm (clone, &m_engineMock, nullptr );
987998 vm.setFunctions (functions);
988999
9891000 EXPECT_CALL (m_engineMock, stopTarget (clone, nullptr )).Times (1 );
1001+ EXPECT_CALL (m_engineMock, deinitClone (clone)).Times (2 ); // TODO: Is there a double-free?
9901002
9911003 vm.setBytecode (bytecode);
9921004 vm.run ();
0 commit comments