mirror of
https://github.com/esphome/esphome.git
synced 2026-11-03 19:57:35 +00:00
[microphone] Test the deprecated vector data callback
This commit is contained in:
1 parent
f2c3174cb7
commit
af8b53e8c4
1 file changed
+15
@@ -1,7 +1,11 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
// The deprecation warning for vector callbacks is reported inside microphone.h. Remove in 2027.5.0.
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#include "esphome/components/microphone/automation.h"
|
||||
#include "esphome/components/microphone/microphone.h"
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
@@ -74,4 +78,15 @@ TEST(MicrophoneDataCallbacks, DataTriggerPassesACopy) {
|
||||
EXPECT_EQ(data, SAMPLES);
|
||||
}
|
||||
|
||||
// Remove in 2027.5.0 with the deprecated vector callbacks; nothing else in the tree compiles that adapter
|
||||
TEST(MicrophoneDataCallbacks, DeprecatedVectorCallbackGetsData) {
|
||||
TestMicrophone mic;
|
||||
std::vector<uint8_t> data;
|
||||
mic.add_data_callback([&](const std::vector<uint8_t> &x) { data = x; });
|
||||
|
||||
std::vector<uint8_t> buffer = SAMPLES;
|
||||
mic.publish(buffer, STEREO_48K, 0);
|
||||
EXPECT_EQ(data, SAMPLES);
|
||||
}
|
||||
|
||||
} // namespace esphome::microphone::testing
|
||||
Reference in new issue
Block a user