Implement QAudioDeviceInfo operator==/!=

Compares some of the useful parts, but perhaps should be made more
tolerant.

Also refactored the auto test to properly skip if there are no
(output) devices, rather than manually skip.

Task-number: QTBUG-13723
Change-Id: I3b83f87a440a83f4237fa119a23009bc99e7626a
Reviewed-by: Jonas Rabbe <jonas.rabbe@nokia.com>
Reviewed-by: Dmytro Poplavskiy <dmytro.poplavskiy@nokia.com>
This commit is contained in:
Michael Goddard
2012-01-23 11:52:42 +10:00
committed by Qt by Nokia
parent 7d826e38e7
commit 01e7cb9950
3 changed files with 115 additions and 105 deletions

View File

@@ -186,7 +186,31 @@ QAudioDeviceInfo& QAudioDeviceInfo::operator=(const QAudioDeviceInfo &other)
}
/*!
Returns whether this QAudioDeviceInfo object holds a device definition.
Returns true if this QAudioDeviceInfo class represents the
same audio device as \a other.
*/
bool QAudioDeviceInfo::operator ==(const QAudioDeviceInfo &other) const
{
if (d == other.d)
return true;
if (d->realm == other.d->realm
&& d->mode == other.d->mode
&& d->handle == other.d->handle
&& deviceName() == other.deviceName())
return true;
}
/*!
Returns true if this QAudioDeviceInfo class represents a
different audio device than \a other
*/
bool QAudioDeviceInfo::operator !=(const QAudioDeviceInfo &other) const
{
return !operator==(other);
}
/*!
Returns whether this QAudioDeviceInfo object holds a valid device definition.
*/
bool QAudioDeviceInfo::isNull() const
{

View File

@@ -76,6 +76,9 @@ public:
QAudioDeviceInfo& operator=(const QAudioDeviceInfo& other);
bool operator==(const QAudioDeviceInfo &other) const;
bool operator!=(const QAudioDeviceInfo &other) const;
bool isNull() const;
QString deviceName() const;