Skip to content

Commit

Permalink
Added new UT cases for Argo WREM2
Browse files Browse the repository at this point in the history
From captures in issue crankyoldgit#2133 (confirmed valid by the OP)

Signed-off-by: Mateusz Bronk <[email protected]>
  • Loading branch information
mbronk committed Aug 31, 2024
1 parent 6461a31 commit 95e5bc4
Showing 1 changed file with 129 additions and 13 deletions.
142 changes: 129 additions & 13 deletions test/ir_Argo_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ TEST(TestArgoACClass, MessageConstructon) {
auto actual = ac.getRaw();
EXPECT_THAT(std::vector<uint8_t>(actual, actual + static_cast<uint8_t>(
ceil(static_cast<float>(kArgoBits) / 8.0))),
::testing::ElementsAreArray(expected));
::testing::ElementsAreArray(expected));
EXPECT_EQ(
"Model: 1 (WREM2), Power: On, Mode: 0 (Cool), Fan: 0 (Auto), Temp: 20C, "
"Sensor Temp: 21C, Max: On, IFeel: On, Night: On",
Expand Down Expand Up @@ -1516,20 +1516,34 @@ TEST(TestDecodeArgo, Issue2133_90bit_message) {
///
struct ArgoE2ETestParam {
const std::vector<uint16_t> rawDataInput;
const uint8_t expectedEncodedSizeBytes;
const uint8_t expectedEncodedSizeBits;
const std::vector<uint8_t> expectedEncodedValue;
const std::string expectedString;
const argo_ac_remote_model_t expectedModel;

ArgoE2ETestParam(std::vector<uint16_t> _raw, uint8_t _encSizeBits,
std::vector<uint8_t> _encValue, std::string _str,
argo_ac_remote_model_t _model)
: rawDataInput(_raw), expectedEncodedSizeBits(_encSizeBits),
expectedEncodedValue(_encValue), expectedString(_str),
expectedModel(_model) {}

ArgoE2ETestParam(std::vector<uint16_t> _raw, uint8_t _encSize,
ArgoE2ETestParam(std::vector<uint16_t> _raw, uint8_t _encSizeBytes,
std::vector<uint8_t> _encValue, std::string _str)
: rawDataInput(_raw), expectedEncodedSizeBytes(_encSize),
expectedEncodedValue(_encValue), expectedString(_str) {}
: ArgoE2ETestParam(_raw, _encSizeBytes * 8, _encValue, _str,
argo_ac_remote_model_t::SAC_WREM3) {}

inline uint16_t getExpectedEncodedSizeBytes() const {
return static_cast<int>(ceil(static_cast<float>(
expectedEncodedSizeBits) / 8.0));
}

friend std::ostream& operator<<(std::ostream& os, const ArgoE2ETestParam& v) {
return os << "rawDataInput: " << ::testing::PrintToString(v.rawDataInput)
<< "\n\texpectedEncodedSize: "
<< static_cast<int>(v.expectedEncodedSizeBytes)
<< "[B]" << "\n\texpectedEncodedValue: 0x"
<< static_cast<int>(v.expectedEncodedSizeBits)
<< "[b] (" << v.getExpectedEncodedSizeBytes() << "[B])"
<< "\n\texpectedEncodedValue: 0x"
<< bytesToHexString(v.expectedEncodedValue) << "\n\texpectedString: "
<< v.expectedString;
}
Expand All @@ -1553,13 +1567,20 @@ TEST_P(TestArgoE2E, RealExampleCommands) {

ASSERT_TRUE(irrecv.decode(&irsend.capture));
EXPECT_EQ(decode_type_t::ARGO, irsend.capture.decode_type);
ASSERT_TRUE(IRArgoAC_WREM3::isValidWrem3Message(irsend.capture.state,
irsend.capture.bits, true));

EXPECT_EQ(GetParam().expectedEncodedSizeBytes * 8, irsend.capture.bits);
if (GetParam().expectedModel == argo_ac_remote_model_t::SAC_WREM3) {
ASSERT_TRUE(IRArgoAC_WREM3::isValidWrem3Message(irsend.capture.state,
irsend.capture.bits, true));
} else if (GetParam().expectedEncodedSizeBits != kArgoShortBits) {
ASSERT_TRUE(IRArgoAC::validChecksum(irsend.capture.state,
ceil(static_cast<float>(
irsend.capture.bits) / 8.0)));
}

EXPECT_EQ(GetParam().expectedEncodedSizeBits, irsend.capture.bits);

std::vector<uint8_t> stateActual(irsend.capture.state, irsend.capture.state
+ GetParam().expectedEncodedSizeBytes);
+ GetParam().getExpectedEncodedSizeBytes());
EXPECT_THAT(stateActual, ::testing::ElementsAreArray(
GetParam().expectedEncodedValue));

Expand Down Expand Up @@ -1651,8 +1672,103 @@ INSTANTIATE_TEST_CASE_P(
},
kArgo3ConfigStateLength,
std::vector<uint8_t> { 0xCB, 0x0C, 0x4A, 0x21 },
"Config[CH#0]: Model: 2 (WREM3), Key: 12, Value: 74")),
"Config[CH#0]: Model: 2 (WREM3), Key: 12, Value: 74"),


//////
// WREM2 test cases
//////
ArgoE2ETestParam(
std::vector<uint16_t> {
6390, 3192, 430, 848, 424, 852, 432, 2124, 424, 2132, 426, 850, 422,
2134, 424, 852, 432, 2124, 424, 2132, 426, 852, 432, 2122, 424, 852,
432, 2124, 424, 2132, 426, 2130, 428, 2126, 432, 846, 426, 850, 422,
854, 430, 848, 426, 850, 432, 844, 428, 850, 424, 2130, 426, 2128, 430,
848, 426, 852, 432, 2122, 424, 2132, 426, 850, 422, 854, 430, 2126, 432,
844, 430, 2126, 432, 2124, 424, 852, 430, 848, 426, 850, 424, 854, 428,
848, 424, 852, 432, 844, 430, 848, 424, 852, 432, 846, 428, 2128, 430,
2124, 434, 2122, 424, 852, 432, 846, 428, 850, 424, 854, 430, 846, 426,
850, 422, 854, 430, 848, 426, 2130, 430, 2126, 430, 2124, 422, 2132,
426, 2130, 428, 2126, 430, 2124, 422, 2132, 426, 2128, 430, 2126, 432,
2124, 424, 2130, 426, 2128, 430, 848, 426, 852, 432, 844, 428, 848, 424,
852, 432, 846, 428, 850, 424, 854, 430, 846, 426, 850, 434, 844, 430,
848, 424, 2130, 428, 850, 424, 854, 430, 846, 426, 850, 422, 854, 430,
848, 426, 2128, 428, 2128, 430
},
kArgoBits,
std::vector<uint8_t> { 0xAC, 0xF5, 0x80, 0x99, 0x06, 0xE0, 0x00, 0xFF,
0x1F, 0x00, 0x02, 0x03 },
"Model: 1 (WREM2), Power: Off, Mode: 0 (Cool), Fan: 3 (Max), Temp: 10C, "
"Sensor Temp: 24C, Max: Off, IFeel: Off, Night: Off",
argo_ac_remote_model_t::SAC_WREM2),


ArgoE2ETestParam(
std::vector<uint16_t> {
6420, 3164, 426, 850, 422, 854, 462, 2092, 432, 2122, 424, 852, 432,
2124, 422, 854, 462, 2092, 434, 2122, 458, 820, 454, 2102, 424, 854,
430, 2126, 454, 2100, 458, 2096, 428, 2126, 432, 846, 460, 816, 424,
854, 464, 814, 426, 852, 432, 844, 430, 848, 490, 2066, 426, 2128, 452,
826, 458, 818, 454, 2100, 458, 2098, 462, 816, 422, 854, 452, 2102, 456,
822, 462, 2092, 454, 2100, 458, 820, 454, 824, 460, 816, 456, 820, 452,
824, 460, 818, 422, 854, 462, 814, 458, 818, 454, 822, 428, 2126, 454,
2102, 456, 2098, 458, 818, 432, 844, 462, 816, 458, 820, 454, 824, 460,
816, 458, 820, 452, 824, 426, 2128, 462, 2092, 454, 2102, 456, 2098,
458, 2096, 462, 2092, 454, 2102, 456, 2098, 426, 2128, 464, 2092, 456,
2100, 456, 2098, 460, 2094, 452, 824, 460, 818, 456, 820, 462, 814, 458,
818, 454, 824, 460, 816, 456, 820, 452, 2102, 456, 822, 462, 816, 458,
820, 454, 2102, 424, 854, 452, 824, 460, 818, 456, 822, 462, 814, 458,
2098, 460, 2094, 454, 2102, 424
},
kArgoBits,
std::vector<uint8_t> { 0xAC, 0xF5, 0x80, 0x99, 0x06, 0xE0, 0x00, 0xFF,
0x1F, 0x20, 0x82, 0x03 },
"Model: 1 (WREM2), Power: On, Mode: 0 (Cool), Fan: 3 (Max), Temp: 10C, "
"Sensor Temp: 24C, Max: Off, IFeel: Off, Night: Off",
argo_ac_remote_model_t::SAC_WREM2),


ArgoE2ETestParam(
std::vector<uint16_t> {
6388, 3196, 428, 850, 424, 852, 430, 2124, 424, 2132, 426, 852, 432,
2124, 424, 854, 430, 2124, 422, 2132, 426, 852, 434, 2122, 424, 852,
432, 2124, 422, 2134, 424, 2130, 428, 2126, 432, 846, 428, 850, 422,
854, 430, 848, 426, 852, 432, 844, 428, 848, 424, 2130, 428, 2128, 430,
848, 424, 852, 432, 2124, 424, 2132, 426, 850, 422, 854, 430, 2126, 432,
846, 428, 2128, 430, 2124, 422, 854, 428, 848, 424, 852, 432, 846, 428,
850, 424, 854, 430, 846, 426, 850, 422, 854, 430, 848, 426, 2130, 428,
2128, 430, 2124, 422, 854, 484, 794, 424, 852, 432, 844, 428, 850, 424,
852, 430, 846, 426, 850, 422, 2132, 426, 2130, 428, 2126, 430, 2124,
422, 2132, 426, 2130, 428, 2126, 430, 2124, 434, 2122, 426, 2130, 428,
2126, 430, 2124, 434, 2122, 424, 852, 432, 844, 428, 850, 422, 854, 430,
846, 426, 852, 432, 844, 428, 848, 424, 2130, 428, 848, 424, 2132, 426,
852, 432, 2122, 424, 852, 432, 846, 428, 850, 424, 854, 430, 846, 426,
2128, 430, 2126, 432, 846, 428
},
kArgoBits,
std::vector<uint8_t> { 0xAC, 0xF5, 0x80, 0x99, 0x06, 0xE0, 0x00, 0xFF,
0x1F, 0xA0, 0x82, 0x01 },
"Model: 1 (WREM2), Power: On, Mode: 0 (Cool), Fan: 3 (Max), Temp: 10C, "
"Sensor Temp: 24C, Max: Off, IFeel: On, Night: Off",
argo_ac_remote_model_t::SAC_WREM2),



ArgoE2ETestParam(
std::vector<uint16_t> {
6388, 3194, 430, 848, 426, 852, 432, 2122, 424, 2130, 428, 850, 424,
2132, 426, 850, 434, 2122, 424, 2130, 426, 850, 424, 2132, 426, 852,
422, 2132, 424, 2130, 428, 2128, 430, 2124, 422, 854, 430, 2126, 434,
844, 428, 2126, 432, 846, 426, 2128, 430, 846, 426, 2130, 428, 2126,
432, 2122, 424, 854, 432, 2124, 424, 854, 430, 846, 426, 2130, 428,
848, 424
},
kArgoShortBits,
std::vector<uint8_t> { 0xAC, 0xF5, 0xAA, 0x4B },
"Model: 1 (WREM2), Sensor Temp: 25C",
argo_ac_remote_model_t::SAC_WREM2)),
[](const testing::TestParamInfo<ArgoE2ETestParam>& info) {
return bytesToHexString(info.param.expectedEncodedValue);
return irutils::modelToStr(decode_type_t::ARGO, info.param.expectedModel)
+ "_" + bytesToHexString(info.param.expectedEncodedValue);
}
);

0 comments on commit 95e5bc4

Please sign in to comment.