Refactoring audio_device_test_api for gtest and execution on all platforms.
All the code that was previously in one single function is now broken up into 44 gtest tests. The creation of the Audio Device is done once (SetUpTestCase) and the audio device is initialized before each test (SetUp) and terminated after each test (TearDown). Doing this, the things that execute are basically the same since the test was structured as different sections separated by these calls: TEST(audioDevice->Terminate() == 0); TEST(audioDevice->Init() == 0); I also cleaned up some unused helper functions and removed old test macros when replacing them by gtest macros. The parts that are failing for Mac and Windows are excluded using #ifdef. Separate issues are filed for this code to be fixed. Formatting is updated to follow the WebRTC style guide. BUG=None. TEST=audio_device_test_api in Debug+Release on Linux, Mac and Windows. Test run audio_device_test_func on Linux. Review URL: https://webrtc-codereview.appspot.com/437002 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1861 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
8012474552
commit
67fdd70e1b
@ -173,7 +173,7 @@
|
||||
},
|
||||
],
|
||||
# Exclude the test targets when building with chromium.
|
||||
'conditions': [
|
||||
'conditions': [
|
||||
['build_with_chromium==0', {
|
||||
'targets': [
|
||||
{
|
||||
@ -182,6 +182,8 @@
|
||||
'dependencies': [
|
||||
'audio_device',
|
||||
'webrtc_utility',
|
||||
'<(webrtc_root)/../test/test.gyp:test_support_main',
|
||||
'<(webrtc_root)/../testing/gtest.gyp:gtest',
|
||||
'<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:system_wrappers',
|
||||
],
|
||||
'sources': [
|
||||
@ -198,6 +200,7 @@
|
||||
'<(webrtc_root)/common_audio/common_audio.gyp:resampler',
|
||||
'<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:system_wrappers',
|
||||
'<(webrtc_root)/../test/test.gyp:test_support',
|
||||
'<(webrtc_root)/../testing/gtest.gyp:gtest',
|
||||
],
|
||||
'sources': [
|
||||
'../test/audio_device_test_func.cc',
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
||||
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
@ -11,8 +11,8 @@
|
||||
#ifndef WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_TEST_DEFINES_H
|
||||
#define WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_TEST_DEFINES_H
|
||||
|
||||
#include "common_types.h"
|
||||
#include "audio_device.h"
|
||||
#include "common_types.h"
|
||||
#include "process_thread.h"
|
||||
#include "trace.h"
|
||||
|
||||
@ -34,14 +34,10 @@
|
||||
#define TEST_LOG_ERROR(...) fprintf(stderr, __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
static int testCount = 0;
|
||||
static int errorCount = 0;
|
||||
static int warningCount = 0;
|
||||
|
||||
#define RESET_TEST \
|
||||
do { \
|
||||
testCount = 0; \
|
||||
errorCount = 0; \
|
||||
warningCount = 0; \
|
||||
} while(0) \
|
||||
|
||||
@ -53,52 +49,19 @@ static int warningCount = 0;
|
||||
|
||||
#define WARNING(expr) \
|
||||
do { \
|
||||
testCount++; \
|
||||
if (!(expr)) { \
|
||||
TEST_LOG_ERROR("WARNING #%d: at line %i\n\n", \
|
||||
warningCount+1, __LINE__); \
|
||||
TEST_LOG_ERROR("WARNING #%d: at line %i\n\n", \
|
||||
warningCount+1, __LINE__); \
|
||||
warningCount++; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define TEST(expr) \
|
||||
do { \
|
||||
testCount++; \
|
||||
if (!(expr)) { \
|
||||
PRINT_ERR_MSG("Assertion failed: " #expr "\n\n"); \
|
||||
errorCount++; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define TEST_ERR(expr, err) \
|
||||
do { \
|
||||
testCount++; \
|
||||
if (!(expr)) { \
|
||||
PRINT_ERR_MSG("Assertion failed: " #expr "\n\n"); \
|
||||
errorCount++; \
|
||||
} \
|
||||
if (audioDevice->LastError() != err) { \
|
||||
PRINT_ERR_MSG("Assertion failed: " #err "\n\n"); \
|
||||
errorCount++; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define PRINT_TEST_RESULTS \
|
||||
do { \
|
||||
TEST_LOG("\n>> %i tests completed <<\n", testCount); \
|
||||
if (errorCount > 0) { \
|
||||
TEST_LOG(">> %i FAILED! <<\n\n", errorCount); \
|
||||
} \
|
||||
else if (warningCount > 0) \
|
||||
{ \
|
||||
TEST_LOG(">> ALL PASSED (with %d warnings) <<\n\n", \
|
||||
warningCount); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
TEST_LOG(">> ALL PASSED <<\n\n"); \
|
||||
if (warningCount > 0) \
|
||||
{ \
|
||||
TEST_LOG(">> %d warnings <<\n\n", \
|
||||
warningCount); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
@ -107,9 +70,7 @@ static int warningCount = 0;
|
||||
// For Android, they are defined in API test only (since both
|
||||
// API and Func tests are built into the same lib).
|
||||
// For other, they are defined in both API test and Func test.
|
||||
char* GetFilename(char* filename);
|
||||
const char* GetFilename(const char* filename);
|
||||
char* GetResource(char* resource);
|
||||
const char* GetResource(const char* resource);
|
||||
|
||||
#endif // WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_TEST_DEFINES_H
|
||||
|
@ -43,8 +43,6 @@ int func_test(int sel)
|
||||
TEST_LOG("=========================================\n\n");
|
||||
|
||||
// Initialize the counters here to get rid of "unused variables" warnings.
|
||||
testCount = 0;
|
||||
errorCount = 0;
|
||||
warningCount = 0;
|
||||
|
||||
FuncTestManager funcMgr;
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user