audio_unittest_util.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334
  1. // Copyright 2015 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef MEDIA_AUDIO_AUDIO_UNITTEST_UTIL_H_
  5. #define MEDIA_AUDIO_AUDIO_UNITTEST_UTIL_H_
  6. #include "testing/gtest/include/gtest/gtest.h"
  7. namespace media {
  8. // Use in tests to either skip or fail a test when the system is missing a
  9. // required audio device or library. If the --require-audio-hardware-for-testing
  10. // flag is set, missing requirements will cause the test to fail. Otherwise it
  11. // will be skipped.
  12. #define ABORT_AUDIO_TEST_IF_NOT(requirements_satisfied) \
  13. do { \
  14. bool fail = false; \
  15. if (ShouldAbortAudioTest(requirements_satisfied, #requirements_satisfied, \
  16. &fail)) { \
  17. if (fail) \
  18. FAIL(); \
  19. else \
  20. return; \
  21. } \
  22. } while (false)
  23. bool ShouldAbortAudioTest(bool requirements_satisfied,
  24. const char* requirements_expression,
  25. bool* should_fail);
  26. } // namespace media
  27. #endif // MEDIA_AUDIO_AUDIO_UNITTEST_UTIL_H_