The ScriptBuilder class is used to build Scratch scripts in unit tests.
More...
#include <scratchcpp/test/scriptbuilder.h>
|
| | ScriptBuilder (IExtension *extension, IEngine *engine, std::shared_ptr< Target > target, bool createHatBlock=true) |
| |
| | ScriptBuilder (const ScriptBuilder &)=delete |
| |
| | ~ScriptBuilder () |
| |
| void | addBlock (std::shared_ptr< Block > block) |
| |
| void | addBlock (const std::string &opcode) |
| |
| void | captureBlockReturnValue () |
| |
| void | addValueInput (const std::string &name, const Value &value) |
| |
| void | addNullInput (const std::string &name) |
| |
| void | addObscuredInput (const std::string &name, std::shared_ptr< Block > valueBlock) |
| |
| void | addNullObscuredInput (const std::string &name) |
| |
| void | addDropdownInput (const std::string &name, const std::string &selectedValue) |
| |
| void | addDropdownField (const std::string &name, const std::string &selectedValue) |
| |
| void | addEntityInput (const std::string &name, const std::string &entityName, InputValue::Type entityType, std::shared_ptr< Entity > entity) |
| |
| void | addEntityField (const std::string &name, std::shared_ptr< Entity > entity) |
| |
| Block * | currentBlock () |
| |
| std::shared_ptr< Block > | takeBlock () |
| |
| void | build () |
| |
| void | run () |
| |
| List * | capturedValues () const |
| |
The ScriptBuilder class is used to build Scratch scripts in unit tests.
◆ ScriptBuilder() [1/2]
| ScriptBuilder::ScriptBuilder |
( |
IExtension * | extension, |
|
|
IEngine * | engine, |
|
|
std::shared_ptr< Target > | target, |
|
|
bool | createHatBlock = true ) |
◆ ScriptBuilder() [2/2]
| libscratchcpp::test::ScriptBuilder::ScriptBuilder |
( |
const ScriptBuilder & | | ) |
|
|
delete |
◆ ~ScriptBuilder()
| ScriptBuilder::~ScriptBuilder |
( |
| ) |
|
◆ addBlock() [1/2]
| void ScriptBuilder::addBlock |
( |
const std::string & | opcode | ) |
|
Adds a block with the given opcode to the script.
◆ addBlock() [2/2]
| void ScriptBuilder::addBlock |
( |
std::shared_ptr< Block > | block | ) |
|
Adds the given block to the script.
◆ addDropdownField()
| void ScriptBuilder::addDropdownField |
( |
const std::string & | name, |
|
|
const std::string & | selectedValue ) |
Adds a dropdown field to the current block.
◆ addDropdownInput()
| void ScriptBuilder::addDropdownInput |
( |
const std::string & | name, |
|
|
const std::string & | selectedValue ) |
Adds a dropdown menu input to the current block.
◆ addEntityField()
| void ScriptBuilder::addEntityField |
( |
const std::string & | name, |
|
|
std::shared_ptr< Entity > | entity ) |
Adds a field pointing to an entity (variable, list, broadcast, etc.)
◆ addEntityInput()
| void ScriptBuilder::addEntityInput |
( |
const std::string & | name, |
|
|
const std::string & | entityName, |
|
|
InputValue::Type | entityType, |
|
|
std::shared_ptr< Entity > | entity ) |
Adds an input pointing to an entity (variable, list, broadcast, etc.)
◆ addNullInput()
| void ScriptBuilder::addNullInput |
( |
const std::string & | name | ) |
|
Adds a null input (zero) to the current block.
◆ addNullObscuredInput()
| void ScriptBuilder::addNullObscuredInput |
( |
const std::string & | name | ) |
|
Adds an input obscured by a block which returns zero to the current block.
◆ addObscuredInput()
| void ScriptBuilder::addObscuredInput |
( |
const std::string & | name, |
|
|
std::shared_ptr< Block > | valueBlock ) |
Adds an input obscured by the given block to the current block.
◆ addValueInput()
| void ScriptBuilder::addValueInput |
( |
const std::string & | name, |
|
|
const Value & | value ) |
Adds a simple input with a value to the current block.
◆ build()
| void ScriptBuilder::build |
( |
| ) |
|
Builds and compiles the script.
◆ buildMultiple()
| void ScriptBuilder::buildMultiple |
( |
const std::vector< ScriptBuilder * > & | builders | ) |
|
|
static |
Builds multiple scripts using the given script builders.
- Note
- Using run() on any of the script builders will result in all scripts without a custom hat block being called. Use this only with a single when flag clicked block.
-
Return value capturing is not supported when building multiple scripts.
◆ captureBlockReturnValue()
| void ScriptBuilder::captureBlockReturnValue |
( |
| ) |
|
Captures the return value of the created reporter block. It can be retrieved using capturedValues() later.
◆ capturedValues()
| List * ScriptBuilder::capturedValues |
( |
| ) |
const |
Returns the list of captured block return values.
◆ currentBlock()
| Block * ScriptBuilder::currentBlock |
( |
| ) |
|
Returns the current block (can be used e. g. with a custom Compiler instance).
The script is automatically built to set the compile function of the block.
- Note
- This method is not intended for building scripts, use build() for that.
◆ run()
| void ScriptBuilder::run |
( |
| ) |
|
◆ takeBlock()
| std::shared_ptr< Block > ScriptBuilder::takeBlock |
( |
| ) |
|
Removes the current block from the script and returns it. Can be used in inputs later.
The documentation for this class was generated from the following files: