1/*
2 *  Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 *
4 *  Use of this source code is governed by a BSD-style license
5 *  that can be found in the LICENSE file in the root of the source
6 *  tree. An additional intellectual property rights grant can be found
7 *  in the file PATENTS.  All contributing project authors may
8 *  be found in the AUTHORS file in the root of the source tree.
9 */
10
11#ifndef WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_TEST_DEFINES_H
12#define WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_TEST_DEFINES_H
13
14#include "webrtc/common_types.h"
15#include "webrtc/modules/audio_device/include/audio_device.h"
16#include "webrtc/modules/utility/interface/process_thread.h"
17#include "webrtc/system_wrappers/interface/trace.h"
18
19#ifdef _WIN32
20#define MACRO_DEFAULT_DEVICE AudioDeviceModule::kDefaultDevice
21#define MACRO_DEFAULT_COMMUNICATION_DEVICE AudioDeviceModule::kDefaultCommunicationDevice
22#else
23#define MACRO_DEFAULT_DEVICE 0
24#define MACRO_DEFAULT_COMMUNICATION_DEVICE 0
25#endif
26
27#ifdef ANDROID
28#include <android/log.h>
29#define LOG_TAG "WebRtc ADM TEST"
30#define TEST_LOG(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
31#define TEST_LOG_ERROR(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
32#else
33#define TEST_LOG printf
34#define TEST_LOG_ERROR(...) fprintf(stderr, __VA_ARGS__)
35#endif
36
37static int warningCount = 0;
38
39#define RESET_TEST                                              \
40    do {                                                        \
41        warningCount = 0;                                       \
42    } while(0)                                                  \
43
44#define PRINT_ERR_MSG(msg)                                      \
45    do {                                                        \
46        TEST_LOG_ERROR("Error at line %i of %s\n%s",            \
47            __LINE__, __FILE__, msg);                           \
48    } while(0)
49
50#define WARNING(expr)                                           \
51    do {                                                        \
52        if (!(expr)) {                                          \
53            TEST_LOG_ERROR("WARNING #%d: at line %i\n\n",       \
54                           warningCount+1, __LINE__);           \
55            warningCount++;                                     \
56        }                                                       \
57    } while(0)
58
59#define PRINT_TEST_RESULTS                                      \
60    do {                                                        \
61        if (warningCount > 0)                                   \
62        {                                                       \
63            TEST_LOG(">> %d warnings <<\n\n",                   \
64                     warningCount);                             \
65        }                                                       \
66    } while(0)
67
68// Helper functions
69// For iPhone, they are defined in iPhone specific test code.
70// For Android, they are defined in API test only (since both
71//   API and Func tests are built into the same lib).
72// For other, they are defined in both API test and Func test.
73const char* GetFilename(const char* filename);
74const char* GetResource(const char* resource);
75
76#endif  // WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_TEST_DEFINES_H
77