Skip to content

Commit bb4a212

Browse files
committed
Rewrite looks_changeeffectby test
1 parent 2931363 commit bb4a212

File tree

1 file changed

+68
-71
lines changed

1 file changed

+68
-71
lines changed

test/blocks/looks_blocks_test.cpp

Lines changed: 68 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -316,95 +316,92 @@ TEST_F(LooksBlocksTest, Hide)
316316
}
317317
}
318318

319-
TEST_F(LooksBlocksTest, ChangeEffectBy)
319+
TEST_F(LooksBlocksTest, ChangeEffectBy_Color)
320320
{
321-
// Color
322-
{
323-
auto stage = std::make_shared<Stage>();
324-
stage->setEngine(m_engine);
321+
auto stage = std::make_shared<Stage>();
322+
stage->setEngine(m_engine);
325323

326-
ScriptBuilder builder(m_extension.get(), m_engine, stage);
327-
IGraphicsEffect *effect = ScratchConfiguration::getGraphicsEffect("COLOR");
328-
ASSERT_TRUE(effect);
324+
ScriptBuilder builder(m_extension.get(), m_engine, stage);
325+
IGraphicsEffect *effect = ScratchConfiguration::getGraphicsEffect("COLOR");
326+
ASSERT_TRUE(effect);
329327

330-
builder.addBlock("looks_changeeffectby");
331-
builder.addDropdownField("EFFECT", "COLOR");
332-
builder.addValueInput("CHANGE", 45.2);
333-
auto block = builder.currentBlock();
328+
builder.addBlock("looks_changeeffectby");
329+
builder.addDropdownField("EFFECT", "COLOR");
330+
builder.addValueInput("CHANGE", 45.2);
331+
auto block = builder.currentBlock();
334332

335-
Compiler compiler(m_engine, stage.get());
336-
auto code = compiler.compile(block);
337-
Script script(stage.get(), block, m_engine);
338-
script.setCode(code);
339-
Thread thread(stage.get(), m_engine, &script);
333+
Compiler compiler(m_engine, stage.get());
334+
auto code = compiler.compile(block);
335+
Script script(stage.get(), block, m_engine);
336+
script.setCode(code);
337+
Thread thread(stage.get(), m_engine, &script);
340338

341-
stage->setGraphicsEffectValue(effect, 86.84);
342-
thread.run();
343-
ASSERT_EQ(std::round(stage->graphicsEffectValue(effect) * 100) / 100, 132.04);
344-
}
339+
stage->setGraphicsEffectValue(effect, 86.84);
340+
thread.run();
341+
ASSERT_EQ(std::round(stage->graphicsEffectValue(effect) * 100) / 100, 132.04);
342+
}
345343

346-
// Brightness
347-
{
348-
auto stage = std::make_shared<Stage>();
349-
stage->setEngine(m_engine);
344+
TEST_F(LooksBlocksTest, ChangeEffectBy_Brightness)
345+
{
346+
auto stage = std::make_shared<Stage>();
347+
stage->setEngine(m_engine);
350348

351-
ScriptBuilder builder(m_extension.get(), m_engine, stage);
352-
IGraphicsEffect *effect = ScratchConfiguration::getGraphicsEffect("BRIGHTNESS");
353-
ASSERT_TRUE(effect);
349+
ScriptBuilder builder(m_extension.get(), m_engine, stage);
350+
IGraphicsEffect *effect = ScratchConfiguration::getGraphicsEffect("BRIGHTNESS");
351+
ASSERT_TRUE(effect);
354352

355-
builder.addBlock("looks_changeeffectby");
356-
builder.addDropdownField("EFFECT", "BRIGHTNESS");
357-
builder.addValueInput("CHANGE", 12.05);
358-
auto block = builder.currentBlock();
353+
builder.addBlock("looks_changeeffectby");
354+
builder.addDropdownField("EFFECT", "BRIGHTNESS");
355+
builder.addValueInput("CHANGE", 12.05);
356+
auto block = builder.currentBlock();
359357

360-
Compiler compiler(m_engine, stage.get());
361-
auto code = compiler.compile(block);
362-
Script script(stage.get(), block, m_engine);
363-
script.setCode(code);
364-
Thread thread(stage.get(), m_engine, &script);
358+
Compiler compiler(m_engine, stage.get());
359+
auto code = compiler.compile(block);
360+
Script script(stage.get(), block, m_engine);
361+
script.setCode(code);
362+
Thread thread(stage.get(), m_engine, &script);
365363

366-
thread.run();
367-
ASSERT_EQ(std::round(stage->graphicsEffectValue(effect) * 100) / 100, 12.05);
368-
}
364+
thread.run();
365+
ASSERT_EQ(std::round(stage->graphicsEffectValue(effect) * 100) / 100, 12.05);
366+
}
369367

370-
// Ghost
371-
{
372-
auto stage = std::make_shared<Stage>();
373-
stage->setEngine(m_engine);
368+
TEST_F(LooksBlocksTest, ChangeEffectBy_Ghost)
369+
{
370+
auto stage = std::make_shared<Stage>();
371+
stage->setEngine(m_engine);
374372

375-
ScriptBuilder builder(m_extension.get(), m_engine, stage);
376-
IGraphicsEffect *effect = ScratchConfiguration::getGraphicsEffect("GHOST");
377-
ASSERT_TRUE(effect);
373+
ScriptBuilder builder(m_extension.get(), m_engine, stage);
374+
IGraphicsEffect *effect = ScratchConfiguration::getGraphicsEffect("GHOST");
375+
ASSERT_TRUE(effect);
378376

379-
builder.addBlock("looks_changeeffectby");
380-
builder.addDropdownField("EFFECT", "GHOST");
381-
builder.addValueInput("CHANGE", -8.06);
382-
auto block = builder.currentBlock();
377+
builder.addBlock("looks_changeeffectby");
378+
builder.addDropdownField("EFFECT", "GHOST");
379+
builder.addValueInput("CHANGE", -8.06);
380+
auto block = builder.currentBlock();
383381

384-
Compiler compiler(m_engine, stage.get());
385-
auto code = compiler.compile(block);
386-
Script script(stage.get(), block, m_engine);
387-
script.setCode(code);
388-
Thread thread(stage.get(), m_engine, &script);
382+
Compiler compiler(m_engine, stage.get());
383+
auto code = compiler.compile(block);
384+
Script script(stage.get(), block, m_engine);
385+
script.setCode(code);
386+
Thread thread(stage.get(), m_engine, &script);
389387

390-
stage->setGraphicsEffectValue(effect, 13.12);
391-
thread.run();
392-
ASSERT_EQ(std::round(stage->graphicsEffectValue(effect) * 100) / 100, 5.06);
393-
}
388+
stage->setGraphicsEffectValue(effect, 13.12);
389+
thread.run();
390+
ASSERT_EQ(std::round(stage->graphicsEffectValue(effect) * 100) / 100, 5.06);
391+
}
394392

395-
// Invalid
396-
{
397-
auto stage = std::make_shared<Stage>();
398-
stage->setEngine(m_engine);
393+
TEST_F(LooksBlocksTest, ChangeEffectBy_Invalid)
394+
{
395+
auto stage = std::make_shared<Stage>();
396+
stage->setEngine(m_engine);
399397

400-
ScriptBuilder builder(m_extension.get(), m_engine, stage);
401-
builder.addBlock("looks_changeeffectby");
402-
builder.addDropdownField("EFFECT", "INVALID");
403-
builder.addValueInput("CHANGE", 8.3);
398+
ScriptBuilder builder(m_extension.get(), m_engine, stage);
399+
builder.addBlock("looks_changeeffectby");
400+
builder.addDropdownField("EFFECT", "INVALID");
401+
builder.addValueInput("CHANGE", 8.3);
404402

405-
builder.build();
406-
builder.run();
407-
}
403+
builder.build();
404+
builder.run();
408405
}
409406

410407
TEST_F(LooksBlocksTest, SetEffectTo_Fisheye)

0 commit comments

Comments
 (0)