Index: media/audio/audio_unittest_utils.h |
diff --git a/media/audio/audio_unittest_utils.h b/media/audio/audio_unittest_utils.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d6e0d5d3e1bf1df4a0ed10138d499c13c62d9471 |
--- /dev/null |
+++ b/media/audio/audio_unittest_utils.h |
@@ -0,0 +1,25 @@ |
+#include "base/command_line.h" |
+#include "base/logging.h" |
+#include "media/base/media_switches.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+// Use in tests to either skip or fail a test when the system is missing a |
+// required audio device or library. If the |kRequireAudioHardwareForTesting| |
+// flag is set, missing requirements will cause the test to fail. Otherwise it |
+// will be skipped. |
+#define CAN_RUN_AUDIO_TEST_IF(requirements_satisfied) \ |
DaleCurtis
2015/02/09 21:21:31
Hmm, naming feels odd. What about something like:
watk
2015/02/09 22:03:57
Much better, thanks
|
+ do { \ |
+ bool satisfied = requirements_satisfied; \ |
DaleCurtis
2015/02/09 21:21:31
Most of this should be moved into a static functio
watk
2015/02/09 22:03:57
Done.
|
+ bool fail_if_unsatisfied = \ |
+ base::CommandLine::ForCurrentProcess()->HasSwitch( \ |
+ switches::kRequireAudioHardwareForTesting); \ |
+ const char* message = \ |
+ "Requirement(s) not satisfied (" #requirements_satisfied ")"; \ |
+ if (fail_if_unsatisfied && !satisfied) { \ |
+ FAIL() << message; \ |
+ } \ |
+ if (!satisfied) { \ |
+ LOG(WARNING) << "Skipping test: " << message; \ |
+ return; \ |
+ } \ |
+ } while (false) |