Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.

Commit 133070a

Browse files
ilcatoaentinger
authored andcommitted
Added decode unit test for CloudTelevision
1 parent 8d894c7 commit 133070a

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

test/src/test_decode.cpp

+30
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "types/automation/CloudSmartPlug.h"
2323
#include "types/automation/CloudSwitch.h"
2424
#include "types/automation/CloudTemperature.h"
25+
#include "types/automation/CloudTelevision.h"
2526

2627
/**************************************************************************************
2728
TEST CODE
@@ -191,6 +192,35 @@ SCENARIO("Arduino Cloud Properties are decoded", "[ArduinoCloudThing::decode]")
191192

192193
/************************************************************************************/
193194

195+
WHEN("A Television property is changed via CBOR message") {
196+
GIVEN("CloudProtocol::V2") {
197+
ArduinoCloudThing thing;
198+
thing.begin();
199+
200+
CloudTelevision tv_test = CloudTelevision(false, 0, false, PlaybackCommands::Stop, InputValue::AUX1, 0);
201+
202+
203+
thing.addPropertyReal(tv_test, "test", Permission::ReadWrite);
204+
205+
/* [{0: "test:swi", 4: true},{0: "test:vol", 2: 50},{0: "test:mut", 2: false},{0: "test:pbc", 2: 3},{0: "test:inp", 2: 55},{0: "test:cha", 2: 7}] = 86 A2 00 68 74 65 73 74 3A 73 77 69 04 F5 A2 00 68 74 65 73 74 3A 76 6F 6C 02 18 32 A2 00 68 74 65 73 74 3A 6D 75 74 02 F4 A2 00 68 74 65 73 74 3A 70 62 63 02 03 A2 00 68 74 65 73 74 3A 69 6E 70 02 18 37 A2 00 68 74 65 73 74 3A 63 68 61 02 07 */
206+
uint8_t const payload[] = {0x86, 0xA2, 0x00, 0x68, 0x74, 0x65, 0x73, 0x74, 0x3A, 0x73, 0x77, 0x69, 0x04, 0xF5, 0xA2, 0x00, 0x68, 0x74, 0x65, 0x73, 0x74, 0x3A, 0x76, 0x6F, 0x6C, 0x02, 0x18, 0x32, 0xA2, 0x00, 0x68, 0x74, 0x65, 0x73, 0x74, 0x3A, 0x6D, 0x75, 0x74, 0x02, 0xF4, 0xA2, 0x00, 0x68, 0x74, 0x65, 0x73, 0x74, 0x3A, 0x70, 0x62, 0x63, 0x02, 0x03, 0xA2, 0x00, 0x68, 0x74, 0x65, 0x73, 0x74, 0x3A, 0x69, 0x6E, 0x70, 0x02, 0x18, 0x37, 0xA2, 0x00, 0x68, 0x74, 0x65, 0x73, 0x74, 0x3A, 0x63, 0x68, 0x61, 0x02, 0x07 };
207+
thing.decode(payload, sizeof(payload) / sizeof(uint8_t));
208+
209+
Television tv_compare = Television(true, 50, false, PlaybackCommands::Play, InputValue::TV, 7);
210+
Television value_tv_test = tv_test.getValue();
211+
bool verify = (value_tv_test == tv_compare);
212+
REQUIRE(verify);
213+
REQUIRE(value_tv_test.swi == tv_compare.swi);
214+
REQUIRE(value_tv_test.vol == tv_compare.vol);
215+
REQUIRE(value_tv_test.mut == tv_compare.mut);
216+
REQUIRE(value_tv_test.pbc == tv_compare.pbc);
217+
REQUIRE(value_tv_test.inp == tv_compare.inp);
218+
REQUIRE(value_tv_test.cha == tv_compare.cha);
219+
}
220+
}
221+
222+
/************************************************************************************/
223+
194224
WHEN("A DimmedLight property is changed via CBOR message") {
195225
GIVEN("CloudProtocol::V2") {
196226
ArduinoCloudThing thing;

0 commit comments

Comments
 (0)