@@ -403,6 +403,36 @@ TEST_F(LooksBlocksTest, ChangeEffectBy)
403403
404404static void initEffects ()
405405{
406+ // Create and register fake graphics effects
407+ auto colorEffect = std::make_shared<GraphicsEffectMock>();
408+ auto fisheyeEffect = std::make_shared<GraphicsEffectMock>();
409+ auto whirlEffect = std::make_shared<GraphicsEffectMock>();
410+ auto pixelateEffect = std::make_shared<GraphicsEffectMock>();
411+ auto mosaicEffect = std::make_shared<GraphicsEffectMock>();
412+ auto brightnessEffect = std::make_shared<GraphicsEffectMock>();
413+ auto ghostEffect = std::make_shared<GraphicsEffectMock>();
414+
415+ EXPECT_CALL (*colorEffect, name ()).WillOnce (Return (" color" ));
416+ ScratchConfiguration::registerGraphicsEffect (colorEffect);
417+
418+ EXPECT_CALL (*fisheyeEffect, name ()).WillOnce (Return (" fisheye" ));
419+ ScratchConfiguration::registerGraphicsEffect (fisheyeEffect);
420+
421+ EXPECT_CALL (*whirlEffect, name ()).WillOnce (Return (" whirl" ));
422+ ScratchConfiguration::registerGraphicsEffect (whirlEffect);
423+
424+ EXPECT_CALL (*pixelateEffect, name ()).WillOnce (Return (" pixelate" ));
425+ ScratchConfiguration::registerGraphicsEffect (pixelateEffect);
426+
427+ EXPECT_CALL (*mosaicEffect, name ()).WillOnce (Return (" mosaic" ));
428+ ScratchConfiguration::registerGraphicsEffect (mosaicEffect);
429+
430+ EXPECT_CALL (*brightnessEffect, name ()).WillOnce (Return (" brightness" ));
431+ ScratchConfiguration::registerGraphicsEffect (brightnessEffect);
432+
433+ EXPECT_CALL (*ghostEffect, name ()).WillOnce (Return (" ghost" ));
434+ ScratchConfiguration::registerGraphicsEffect (ghostEffect);
435+
406436 LooksBlocks::m_colorEffect = ScratchConfiguration::getGraphicsEffect (" color" );
407437 LooksBlocks::m_fisheyeEffect = ScratchConfiguration::getGraphicsEffect (" fisheye" );
408438 LooksBlocks::m_whirlEffect = ScratchConfiguration::getGraphicsEffect (" whirl" );
@@ -412,6 +442,17 @@ static void initEffects()
412442 LooksBlocks::m_ghostEffect = ScratchConfiguration::getGraphicsEffect (" ghost" );
413443}
414444
445+ static void removeEffects ()
446+ {
447+ ScratchConfiguration::removeGraphicsEffect (" color" );
448+ ScratchConfiguration::removeGraphicsEffect (" fisheye" );
449+ ScratchConfiguration::removeGraphicsEffect (" whirl" );
450+ ScratchConfiguration::removeGraphicsEffect (" pixelate" );
451+ ScratchConfiguration::removeGraphicsEffect (" mosaic" );
452+ ScratchConfiguration::removeGraphicsEffect (" brightness" );
453+ ScratchConfiguration::removeGraphicsEffect (" ghost" );
454+ }
455+
415456TEST_F (LooksBlocksTest, ChangeEffectByImpl)
416457{
417458 static unsigned int bytecode1[] = { vm::OP_START, vm::OP_CONST, 0 , vm::OP_CONST, 1 , vm::OP_EXEC, 0 , vm::OP_HALT };
@@ -466,9 +507,8 @@ TEST_F(LooksBlocksTest, ChangeEffectByImpl)
466507 sprite.setGraphicsEffectValue (ScratchConfiguration::getGraphicsEffect (" brightness" ), -0.01 );
467508 sprite.setGraphicsEffectValue (ScratchConfiguration::getGraphicsEffect (" ghost" ), 45.78 );
468509
469- // TODO: Uncomment commented lines (#283, #284, #285, #286, #287, #288, #289)
470510 // color
471- /* vm.reset();
511+ vm.reset ();
472512 vm.setBytecode (bytecode3);
473513 vm.run ();
474514
@@ -481,7 +521,7 @@ TEST_F(LooksBlocksTest, ChangeEffectByImpl)
481521 vm.run ();
482522
483523 ASSERT_EQ (vm.registerCount (), 0 );
484- ASSERT_EQ(sprite.graphicsEffectValue(ScratchConfiguration::getGraphicsEffect("fisheye")), -6.15);
524+ ASSERT_EQ (std::round ( sprite.graphicsEffectValue (ScratchConfiguration::getGraphicsEffect (" fisheye" )) * 100 ) / 100 , -6.15 );
485525
486526 // whirl
487527 vm.reset ();
@@ -513,15 +553,17 @@ TEST_F(LooksBlocksTest, ChangeEffectByImpl)
513553 vm.run ();
514554
515555 ASSERT_EQ (vm.registerCount (), 0 );
516- ASSERT_EQ(sprite.graphicsEffectValue(ScratchConfiguration::getGraphicsEffect("brightness")), -8.55);
556+ ASSERT_EQ (std::round ( sprite.graphicsEffectValue (ScratchConfiguration::getGraphicsEffect (" brightness" )) * 100 ) / 100 , -8.55 );
517557
518558 // ghost
519559 vm.reset ();
520560 vm.setBytecode (bytecode9);
521561 vm.run ();
522562
523563 ASSERT_EQ (vm.registerCount (), 0 );
524- ASSERT_EQ(sprite.graphicsEffectValue(ScratchConfiguration::getGraphicsEffect("ghost")), 45.79);*/
564+ ASSERT_EQ (sprite.graphicsEffectValue (ScratchConfiguration::getGraphicsEffect (" ghost" )), 45.79 );
565+
566+ removeEffects ();
525567}
526568
527569TEST_F (LooksBlocksTest, SetEffectTo)
@@ -741,9 +783,8 @@ TEST_F(LooksBlocksTest, SetEffectToImpl)
741783 sprite.setGraphicsEffectValue (ScratchConfiguration::getGraphicsEffect (" brightness" ), -0.01 );
742784 sprite.setGraphicsEffectValue (ScratchConfiguration::getGraphicsEffect (" ghost" ), 45.78 );
743785
744- // TODO: Uncomment commented lines (#283, #284, #285, #286, #287, #288, #289)
745786 // color
746- /* vm.reset();
787+ vm.reset ();
747788 vm.setBytecode (bytecode3);
748789 vm.run ();
749790
@@ -796,7 +837,9 @@ TEST_F(LooksBlocksTest, SetEffectToImpl)
796837 vm.run ();
797838
798839 ASSERT_EQ (vm.registerCount (), 0 );
799- ASSERT_EQ(sprite.graphicsEffectValue(ScratchConfiguration::getGraphicsEffect("ghost")), 0.01);*/
840+ ASSERT_EQ (sprite.graphicsEffectValue (ScratchConfiguration::getGraphicsEffect (" ghost" )), 0.01 );
841+
842+ removeEffects ();
800843}
801844
802845TEST_F (LooksBlocksTest, ClearGraphicEffects)
0 commit comments