summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp38
1 files changed, 24 insertions, 14 deletions
diff --git a/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp b/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp
index eec2b10d..cfdd9355 100644
--- a/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp
+++ b/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp
@@ -709,11 +709,12 @@ TEST_IO_STREAM(GetBufferSize,
709 ASSERT_GE(extract(stream->getBufferSize()), 709 ASSERT_GE(extract(stream->getBufferSize()),
710 extract(stream->getFrameSize()))); 710 extract(stream->getFrameSize())));
711 711
712template <class Property, class CapabilityGetter, class Getter, class Setter> 712template <class Property, class CapabilityGetter>
713static void testCapabilityGetter(const string& name, IStream* stream, 713static void testCapabilityGetter(const string& name, IStream* stream,
714 Property currentValue,
715 CapabilityGetter capablityGetter, 714 CapabilityGetter capablityGetter,
716 Getter getter, Setter setter) { 715 Return<Property> (IStream::*getter)(),
716 Return<Result> (IStream::*setter)(Property),
717 bool currentMustBeSupported = true) {
717 hidl_vec<Property> capabilities; 718 hidl_vec<Property> capabilities;
718 ASSERT_OK((stream->*capablityGetter)(returnIn(capabilities))); 719 ASSERT_OK((stream->*capablityGetter)(returnIn(capabilities)));
719 if (capabilities.size() == 0) { 720 if (capabilities.size() == 0) {
@@ -724,16 +725,24 @@ static void testCapabilityGetter(const string& name, IStream* stream,
724 doc::partialTest(name + " is not supported"); 725 doc::partialTest(name + " is not supported");
725 return; 726 return;
726 }; 727 };
727 // TODO: This code has never been tested on a hal that supports 728
728 // getSupportedSampleRates 729 if (currentMustBeSupported) {
729 EXPECT_NE(std::find(capabilities.begin(), capabilities.end(), currentValue), 730 Property currentValue = extract((stream->*getter)());
730 capabilities.end()) 731 EXPECT_NE(std::find(capabilities.begin(), capabilities.end(), currentValue),
731 << "current " << name << " is not in the list of the supported ones " 732 capabilities.end())
732 << toString(capabilities); 733 << "current " << name << " is not in the list of the supported ones "
734 << toString(capabilities);
735 }
733 736
734 // Check that all declared supported values are indeed supported 737 // Check that all declared supported values are indeed supported
735 for (auto capability : capabilities) { 738 for (auto capability : capabilities) {
736 ASSERT_OK((stream->*setter)(capability)); 739 auto ret = (stream->*setter)(capability);
740 ASSERT_TRUE(ret.isOk());
741 if (ret == Result::NOT_SUPPORTED) {
742 doc::partialTest("Setter is not supported");
743 return;
744 }
745 ASSERT_OK(ret);
737 ASSERT_EQ(capability, extract((stream->*getter)())); 746 ASSERT_EQ(capability, extract((stream->*getter)()));
738 } 747 }
739} 748}
@@ -741,15 +750,17 @@ static void testCapabilityGetter(const string& name, IStream* stream,
741TEST_IO_STREAM(SupportedSampleRate, 750TEST_IO_STREAM(SupportedSampleRate,
742 "Check that the stream sample rate is declared as supported", 751 "Check that the stream sample rate is declared as supported",
743 testCapabilityGetter("getSupportedSampleRate", stream.get(), 752 testCapabilityGetter("getSupportedSampleRate", stream.get(),
744 extract(stream->getSampleRate()),
745 &IStream::getSupportedSampleRates, 753 &IStream::getSupportedSampleRates,
746 &IStream::getSampleRate, 754 &IStream::getSampleRate,
747 &IStream::setSampleRate)) 755 &IStream::setSampleRate,
756 // getSupportedSampleRate returns the native sampling rates,
757 // (the sampling rates that can be played without resampling)
758 // but other sampling rates can be supported by the HAL.
759 false))
748 760
749TEST_IO_STREAM(SupportedChannelMask, 761TEST_IO_STREAM(SupportedChannelMask,
750 "Check that the stream channel mask is declared as supported", 762 "Check that the stream channel mask is declared as supported",
751 testCapabilityGetter("getSupportedChannelMask", stream.get(), 763 testCapabilityGetter("getSupportedChannelMask", stream.get(),
752 extract(stream->getChannelMask()),
753 &IStream::getSupportedChannelMasks, 764 &IStream::getSupportedChannelMasks,
754 &IStream::getChannelMask, 765 &IStream::getChannelMask,
755 &IStream::setChannelMask)) 766 &IStream::setChannelMask))
@@ -757,7 +768,6 @@ TEST_IO_STREAM(SupportedChannelMask,
757TEST_IO_STREAM(SupportedFormat, 768TEST_IO_STREAM(SupportedFormat,
758 "Check that the stream format is declared as supported", 769 "Check that the stream format is declared as supported",
759 testCapabilityGetter("getSupportedFormat", stream.get(), 770 testCapabilityGetter("getSupportedFormat", stream.get(),
760 extract(stream->getFormat()),
761 &IStream::getSupportedFormats, 771 &IStream::getSupportedFormats,
762 &IStream::getFormat, &IStream::setFormat)) 772 &IStream::getFormat, &IStream::setFormat))
763 773