blink1-lib  1.0.0
fake_blink1_lib Namespace Reference

Testing library namespace. More...

Functions

void CLEAR_ALL ()
 
bool ALL_DEVICES_FREED ()
 
void SET_BLINK1_VERSION (int version)
 
void SET_BLINK1_SUCCESSFUL_OPERATION (bool op)
 
void SET_BLINK1_SUCCESSFUL_INIT (bool init)
 
void SET_BLINK1_VID (int _vid)
 
void SET_BLINK1_PID (int _pid)
 
void SET_CACHE_INDEX (int index)
 
void SET_SERIAL (std::string serial)
 
void SET_IS_MK2 (bool mk2)
 
bool SUCCESS (blink1_device *dev)
 
blink1_lib::RGB GET_RGB (long n)
 
void SET_RGB (blink1_lib::RGB rgb, long n)
 
uint16_t GET_FADE_MILLIS (long n)
 
void SET_FADE_MILLIS (uint16_t fadeMillis, long n)
 
blink1_lib::PatternLineN GET_PATTERN_LINE (long pos)
 
void SET_PATTERN_LINE (blink1_lib::PatternLineN line, long pos)
 
blink1_lib::PlayState GET_PLAY_STATE ()
 
void SET_PLAY_STATE (blink1_lib::PlayState state)
 

Detailed Description

Testing library namespace.

This library simulates blink(1) devices for use in testing. It keeps track of each device opened by the application, but for simplicity each one maps to the same simulated device. For example, setting LED 1 to red on device 1 and then reading the color of LED 1 on device 2 will return red, despite device 2 not having the color set.

Additional functions provided in this namespace allow for controlling the simulated device in ways that are not normally possible.

Function Documentation

◆ ALL_DEVICES_FREED()

bool fake_blink1_lib::ALL_DEVICES_FREED ( )

Indicates whether there are any blink(1) devices still connected to the application. Whenever a blink1_lib::Blink1Device goes out of scope, the corresponding device should be disconnected, so this can be used to determine whether any devices are still in scope.

Returns
true if all blink(1) devices have been properly closed and freed, false otherwise

◆ CLEAR_ALL()

void fake_blink1_lib::CLEAR_ALL ( )

Resets all features of the simulated blink(1) device to their default values. LEDs are cleared and all devices are removed. This function should be in the teardown for your test cases.

◆ GET_FADE_MILLIS()

uint16_t fake_blink1_lib::GET_FADE_MILLIS ( long  n)

Gets the fadeMillis value that was used in the last call to either blink1_lib::Blink1Device::fadeToRGB or blink1_lib::Blink1Device::fadeToRGBN for the LED at index n.

◆ GET_PATTERN_LINE()

blink1_lib::PatternLineN fake_blink1_lib::GET_PATTERN_LINE ( long  pos)

Reads the pattern line set by blink1_lib::Blink1Device::writePatternLineN at position pos.

◆ GET_PLAY_STATE()

blink1_lib::PlayState fake_blink1_lib::GET_PLAY_STATE ( )

Gets the value of the play state, bypassing the need to have a device and read from it.

◆ GET_RGB()

blink1_lib::RGB fake_blink1_lib::GET_RGB ( long  n)

Returns the color of simulated LED n.

◆ SET_BLINK1_PID()

void fake_blink1_lib::SET_BLINK1_PID ( int  _pid)

Sets the value that will be read by blink1_lib::Blink1Device::pid(). The default value is 0.

◆ SET_BLINK1_SUCCESSFUL_INIT()

void fake_blink1_lib::SET_BLINK1_SUCCESSFUL_INIT ( bool  init)

Sets whether attempting to open a new blink(1) device should succeed or not. The default value is false.

◆ SET_BLINK1_SUCCESSFUL_OPERATION()

void fake_blink1_lib::SET_BLINK1_SUCCESSFUL_OPERATION ( bool  op)

Sets whether operations that can fail should succeed or not. By default, all operations will fail - functions returning optionals will have empty results, functions that return bools will return false, etc.

◆ SET_BLINK1_VERSION()

void fake_blink1_lib::SET_BLINK1_VERSION ( int  version)

Sets the value that will be read by blink1_lib::Blink1Device::getVersion(). The default value is 0.

◆ SET_BLINK1_VID()

void fake_blink1_lib::SET_BLINK1_VID ( int  _vid)

Sets the value that will be read by blink1_lib::Blink1Device::vid(). The default value is 0.

◆ SET_CACHE_INDEX()

void fake_blink1_lib::SET_CACHE_INDEX ( int  index)

Sets the value that will be read by blink1_lib::Blink1Device::getCacheIndex(). The default value is 0.

◆ SET_FADE_MILLIS()

void fake_blink1_lib::SET_FADE_MILLIS ( uint16_t  fadeMillis,
long  n 
)

Sets the most recent fadeMillis value for LED n.

◆ SET_IS_MK2()

void fake_blink1_lib::SET_IS_MK2 ( bool  mk2)

Sets the value that will be read by blink1_lib::Blink1Device::isMk2(). The default value is false.

◆ SET_PATTERN_LINE()

void fake_blink1_lib::SET_PATTERN_LINE ( blink1_lib::PatternLineN  line,
long  pos 
)

Sets the pattern line at position pos to line.

◆ SET_PLAY_STATE()

void fake_blink1_lib::SET_PLAY_STATE ( blink1_lib::PlayState  state)

Sets the value that will be read by blink1_lib::Blink1Device::readPlayState().

◆ SET_RGB()

void fake_blink1_lib::SET_RGB ( blink1_lib::RGB  rgb,
long  n 
)

Sets the color of simulated LED n to rgb.

◆ SET_SERIAL()

void fake_blink1_lib::SET_SERIAL ( std::string  serial)

Sets the value that will be read by blink1_lib::Blink1Device::getSerial(). The default value is "".

◆ SUCCESS()

bool fake_blink1_lib::SUCCESS ( blink1_device *  dev)

For internal use.