Started rewriting video_engine tests to use GUnit.

- Added comments to the new test.
- Added a new mode to the vie_auto_test binary. It is now possible to pass --automated to it to make it run noninteractively. - To be precise, it will run everything that has been rewritten as GUnit tests, which currently is one "test suite" in the binary.

BUG=
TEST=

Review URL: http://webrtc-codereview.appspot.com/168002
Patch from Patrik Hoglund <phoglund@webrtc.org>.

git-svn-id: http://webrtc.googlecode.com/svn/trunk@666 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
mflodman@webrtc.org 2011-09-29 12:24:13 +00:00
parent 5045f671d0
commit 5eec6cf29a
7 changed files with 213 additions and 43 deletions

View File

@ -0,0 +1,89 @@
/*
* Copyright (c) 2011 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
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
/*
* This file contains the "standard" suite of integration tests, implemented
* as a GUnit test. This file is a part of the effort to try to automate all
* tests in this section of the code. Currently, this code makes no attempt
* to verify any video output - it only checks for direct errors.
*/
#include "gtest/gtest.h"
#include "vie_autotest.h"
#include "vie_autotest_window_manager_interface.h"
#include "vie_window_creator.h"
namespace {
class ViEStandardIntegrationTest: public testing::Test {
public:
static void SetUpTestCase() {
window_creator_ = new ViEWindowCreator();
ViEAutoTestWindowManagerInterface* window_manager =
window_creator_->CreateTwoWindows();
// Create the test cases
tests_ = new ViEAutoTest(window_manager->GetWindow1(),
window_manager->GetWindow2());
}
static void TearDownTestCase() {
window_creator_->TerminateWindows();
delete tests_;
delete window_creator_;
}
protected:
static ViEWindowCreator* window_creator_;
static ViEAutoTest* tests_;
};
TEST_F(ViEStandardIntegrationTest, RunsBaseStandardTestWithoutErrors) {
ASSERT_EQ(0, tests_->ViEBaseStandardTest());
}
TEST_F(ViEStandardIntegrationTest, RunsCaptureTestWithoutErrors) {
ASSERT_EQ(0, tests_->ViECaptureStandardTest());
}
TEST_F(ViEStandardIntegrationTest, RunsCodecTestWithoutErrors) {
ASSERT_EQ(0, tests_->ViECodecStandardTest());
}
TEST_F(ViEStandardIntegrationTest, RunsEncryptionTestWithoutErrors) {
ASSERT_EQ(0, tests_->ViEEncryptionStandardTest());
}
TEST_F(ViEStandardIntegrationTest, RunsFileTestWithoutErrors) {
ASSERT_EQ(0, tests_->ViEFileStandardTest());
}
TEST_F(ViEStandardIntegrationTest, RunsImageProcessTestWithoutErrors) {
ASSERT_EQ(0, tests_->ViEImageProcessStandardTest());
}
TEST_F(ViEStandardIntegrationTest, RunsNetworkTestWithoutErrors) {
ASSERT_EQ(0, tests_->ViENetworkStandardTest());
}
TEST_F(ViEStandardIntegrationTest, RunsRenderTestWithoutErrors) {
ASSERT_EQ(0, tests_->ViERenderStandardTest());
}
TEST_F(ViEStandardIntegrationTest, RunsRtpRctpTestWithoutErrors) {
ASSERT_EQ(0, tests_->ViERtpRtcpStandardTest());
}
ViEAutoTest* ViEStandardIntegrationTest::tests_ = NULL;
ViEWindowCreator* ViEStandardIntegrationTest::window_creator_ = NULL;
}

View File

@ -0,0 +1,62 @@
/*
* Copyright (c) 2011 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
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "vie_window_creator.h"
#include "vie_autotest_main.h"
#include "vie_codec.h"
#include "voe_codec.h"
#if defined(WIN32)
#include "vie_autotest_windows.h"
#include <tchar.h>
#include <ShellAPI.h> //ShellExecute
#elif defined(WEBRTC_MAC_INTEL)
#if defined(COCOA_RENDERING)
#include "vie_autotest_mac_cocoa.h"
#elif defined(CARBON_RENDERING)
#include "vie_autotest_mac_carbon.h"
#endif
#elif defined(WEBRTC_LINUX)
#include "vie_autotest_linux.h"
#endif
ViEWindowCreator::ViEWindowCreator() {
// Create platform dependent render windows.
window_manager_ = new ViEAutoTestWindowManager();
}
ViEWindowCreator::~ViEWindowCreator() {
delete window_manager_;
}
ViEAutoTestWindowManagerInterface*
ViEWindowCreator::CreateTwoWindows() {
#if (defined(_WIN32))
TCHAR window1Title[1024] = _T("ViE Autotest Window 1");
TCHAR window2Title[1024] = _T("ViE Autotest Window 2");
#else
char window1Title[1024] = "ViE Autotest Window 1";
char window2Title[1024] = "ViE Autotest Window 2";
#endif
AutoTestRect window1Size(352, 288, 600, 100);
AutoTestRect window2Size(352, 288, 1000, 100);
window_manager_->CreateWindows(window1Size, window2Size, window1Title,
window2Title);
window_manager_->SetTopmostWindow();
return window_manager_;
}
void ViEWindowCreator::TerminateWindows() {
window_manager_->TerminateWindows();
}

View File

@ -0,0 +1,32 @@
/*
* Copyright (c) 2011 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
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef SRC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_HELPERS_VIE_WINDOW_CREATOR_H_
#define SRC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_HELPERS_VIE_WINDOW_CREATOR_H_
class ViEAutoTestWindowManagerInterface;
class ViEWindowCreator {
public:
ViEWindowCreator();
virtual ~ViEWindowCreator();
// The pointer returned here will still be owned by this object.
// Only use it to retrieve the created windows.
ViEAutoTestWindowManagerInterface* CreateTwoWindows();
// Terminates windows opened by CreateTwoWindows, which must
// have been called before this method.
void TerminateWindows();
private:
ViEAutoTestWindowManagerInterface* window_manager_;
};
#endif // SRC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_HELPERS_VIE_WINDOW_CREATOR_H_

View File

@ -12,6 +12,9 @@
// vie_autotest_linux.cc
//
#include "gtest/gtest.h"
#include <string>
#include "vie_autotest_linux.h"
#include "vie_autotest_defines.h"
@ -144,10 +147,18 @@ bool ViEAutoTestWindowManager::SetTopmostWindow()
return 0;
}
int main()
int main(int argc, char** argv)
{
// This command-line flag is a transitory solution until we
// managed to rewrite all tests to GUnit tests. This flag is
// currently only supported in Linux.
if (argc == 2 && std::string(argv[1]) == "--automated") {
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
// Default: run in classic interactive mode.
ViEAutoTestMain autoTest;
autoTest.UseAnswerFile("answers.txt");
return autoTest.BeginOSIndependentTesting();
}

View File

@ -13,25 +13,11 @@
*
*/
#include "vie_autotest.h"
#include "vie_autotest_defines.h"
#include "vie_autotest_main.h"
#include "vie_codec.h"
#include "voe_codec.h"
#include "vie_window_creator.h"
#include "vie_autotest_window_manager_interface.h"
#if defined(WIN32)
#include "vie_autotest_windows.h"
#include <tchar.h>
#include <ShellAPI.h> //ShellExecute
#elif defined(WEBRTC_MAC_INTEL)
#if defined(COCOA_RENDERING)
#include "vie_autotest_mac_cocoa.h"
#elif defined(CARBON_RENDERING)
#include "vie_autotest_mac_carbon.h"
#endif
#elif defined(WEBRTC_LINUX)
#include "vie_autotest_linux.h"
#endif
#include "vie_autotest.h"
#include "vie_autotest_main.h"
ViEAutoTestMain::ViEAutoTestMain() :
_answers(),
@ -42,23 +28,10 @@ ViEAutoTestMain::ViEAutoTestMain() :
bool ViEAutoTestMain::BeginOSIndependentTesting()
{
// Create platform dependent render windows
// Create the windows
ViEWindowCreator windowCreator;
ViEAutoTestWindowManagerInterface* windowManager =
new ViEAutoTestWindowManager();
#if (defined(_WIN32))
TCHAR window1Title[1024] = _T("ViE Autotest Window 1");
TCHAR window2Title[1024] = _T("ViE Autotest Window 2");
#else
char window1Title[1024] = "ViE Autotest Window 1";
char window2Title[1024] = "ViE Autotest Window 2";
#endif
AutoTestRect window1Size(352, 288, 600, 100);
AutoTestRect window2Size(352, 288, 1000, 100);
windowManager->CreateWindows(window1Size, window2Size, window1Title,
window2Title);
windowManager->SetTopmostWindow();
windowCreator.CreateTwoWindows();
// Create the test cases
ViEAutoTest vieAutoTest(windowManager->GetWindow1(),
@ -289,7 +262,7 @@ bool ViEAutoTestMain::BeginOSIndependentTesting()
}
} while (testType != 0);
windowManager->TerminateWindows();
windowCreator.TerminateWindows();
if (testErrors)
{
@ -306,8 +279,6 @@ bool ViEAutoTestMain::BeginOSIndependentTesting()
while ((c = getchar()) != '\n' && c != EOF)
/* discard */;
delete windowManager;
return true;
}

View File

@ -230,15 +230,12 @@ int ViEAutoTestWindowManager::ViEDestroyWindow(HWND& hwnd)
bool ViEAutoTestWindowManager::SetTopmostWindow()
{
// meant to put terminal window on top
// Meant to put terminal window on top
return true;
}
int main(int argc, char* argv[])
{
ViEAutoTestMain autoTest;
if (argc > 1)
{

View File

@ -41,10 +41,12 @@
'<(webrtc_root)/modules/modules.gyp:video_render_module',
'<(webrtc_root)/modules/modules.gyp:video_capture_module',
'<(webrtc_root)/voice_engine/voice_engine.gyp:voice_engine_core',
'<(webrtc_root)/../testing/gtest.gyp:gtest',
'video_engine_core',
],
'include_dirs': [
'interface/',
'helpers/',
'../../interface',
'../../source',
'../../../../modules/video_capture/main/source/',
@ -66,6 +68,12 @@
'interface/vie_autotest_window_manager_interface.h',
'interface/vie_autotest_windows.h',
# Helper classes
'helpers/vie_window_creator.cc',
# New, fully automated tests
'automated/vie_standard_integration_test.cc',
# Platform independent
'source/tb_capture_device.cc',
'source/tb_external_transport.cc',