vie_auto_test may now be run in automated mode on all three platforms.
Fixed chrash bug on Mac, but there are still crash bugs since a couple weeks back. These will have to be fixed separately. Removed dialogs from capture tests on Windows. Removed some dead code related to answer files. Added the last Windows fixes. Fixed the Mac vie_auto_test runner - it will now run on Mac again. It will still crash randomly on codec and rtcp tests though. Fixed compilation error. Got patch to commit on Mac. Temp commit on mac BUG= TEST= Review URL: http://webrtc-codereview.appspot.com/292011 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1087 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@@ -22,31 +22,37 @@
|
|||||||
|
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
class ViEAutoTestWindowManager: public ViEAutoTestWindowManagerInterface
|
class ViEAutoTestWindowManager: public ViEAutoTestWindowManagerInterface {
|
||||||
{
|
public:
|
||||||
public:
|
ViEAutoTestWindowManager();
|
||||||
ViEAutoTestWindowManager();
|
virtual ~ViEAutoTestWindowManager() {}
|
||||||
virtual ~ViEAutoTestWindowManager();
|
virtual void* GetWindow1();
|
||||||
virtual void* GetWindow1();
|
virtual void* GetWindow2();
|
||||||
virtual void* GetWindow2();
|
virtual int CreateWindows(AutoTestRect window1Size,
|
||||||
virtual int CreateWindows(AutoTestRect window1Size,
|
AutoTestRect window2Size,
|
||||||
AutoTestRect window2Size, void* window1Title,
|
void* window1Title,
|
||||||
void* window2Title);
|
void* window2Title);
|
||||||
virtual int TerminateWindows();
|
virtual int TerminateWindows();
|
||||||
virtual bool SetTopmostWindow();
|
virtual bool SetTopmostWindow();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CocoaRenderView* _cocoaRenderView1;
|
CocoaRenderView* _cocoaRenderView1;
|
||||||
CocoaRenderView* _cocoaRenderView2;
|
CocoaRenderView* _cocoaRenderView2;
|
||||||
|
NSWindow* outWindow1_;
|
||||||
|
NSWindow* outWindow2_;
|
||||||
};
|
};
|
||||||
|
|
||||||
@interface AutoTestClass : NSObject
|
@interface AutoTestClass : NSObject {
|
||||||
{
|
int argc_;
|
||||||
|
char** argv_;
|
||||||
|
int result_;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)autoTestWithArg:(NSString*)answerFile;
|
-(void)setArgc:(int)argc argv:(char**)argv;
|
||||||
|
-(int) result;
|
||||||
|
-(void)autoTestWithArg:(NSObject*)ignored;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#endif // WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_VIE_AUTOTEST_MAC_COCOA_H_
|
#endif // WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_VIE_AUTOTEST_MAC_COCOA_H_
|
||||||
#endif // COCOA_RENDERING
|
#endif // COCOA_RENDERING
|
||||||
|
|||||||
@@ -17,25 +17,24 @@
|
|||||||
class ViEAutoTestMain {
|
class ViEAutoTestMain {
|
||||||
public:
|
public:
|
||||||
ViEAutoTestMain();
|
ViEAutoTestMain();
|
||||||
bool BeginOSIndependentTesting();
|
|
||||||
bool GetAnswer(int index, std::string* answer);
|
// Runs the test according to the specified arguments.
|
||||||
int AskUserForTestCase();
|
// Pass in --automated to run in automated mode; interactive
|
||||||
bool GetNextAnswer(std::string& answer);
|
// mode is default. All usual googletest flags also apply.
|
||||||
bool IsUsingAnswerFile();
|
int RunTests(int argc, char** argv);
|
||||||
bool UseAnswerFile(const char* fileName);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string answers_[1024];
|
|
||||||
int answers_count_;
|
|
||||||
int answers_index_;
|
|
||||||
bool use_answer_file_;
|
|
||||||
std::map<int, std::string> index_to_test_method_map_;
|
std::map<int, std::string> index_to_test_method_map_;
|
||||||
|
|
||||||
static const int kInvalidChoice = -1;
|
static const int kInvalidChoice = -1;
|
||||||
|
|
||||||
|
// Starts interactive mode.
|
||||||
|
bool RunInteractiveMode();
|
||||||
// Prompts the user for a specific test method in the provided test case.
|
// Prompts the user for a specific test method in the provided test case.
|
||||||
// Returns 0 on success, nonzero otherwise.
|
// Returns 0 on success, nonzero otherwise.
|
||||||
int RunSpecificTestCaseIn(const std::string test_case_name);
|
int RunSpecificTestCaseIn(const std::string test_case_name);
|
||||||
|
// Asks the user for a particular test case to run.
|
||||||
|
int AskUserForTestCase();
|
||||||
// Retrieves a number from the user in the interval
|
// Retrieves a number from the user in the interval
|
||||||
// [min_allowed, max_allowed]. Returns kInvalidChoice on failure.
|
// [min_allowed, max_allowed]. Returns kInvalidChoice on failure.
|
||||||
int AskUserForNumber(int min_allowed, int max_allowed);
|
int AskUserForNumber(int min_allowed, int max_allowed);
|
||||||
|
|||||||
@@ -93,10 +93,11 @@ bool FindSpecificCodec(webrtc::VideoCodecType of_type,
|
|||||||
webrtc::ViECodec* codec_interface,
|
webrtc::ViECodec* codec_interface,
|
||||||
webrtc::VideoCodec* result) {
|
webrtc::VideoCodec* result) {
|
||||||
|
|
||||||
memset(result, 1, sizeof(webrtc::VideoCodec));
|
memset(result, 0, sizeof(webrtc::VideoCodec));
|
||||||
|
|
||||||
for (int i = 0; i < codec_interface->NumberOfCodecs(); i++) {
|
for (int i = 0; i < codec_interface->NumberOfCodecs(); i++) {
|
||||||
webrtc::VideoCodec codec;
|
webrtc::VideoCodec codec;
|
||||||
|
memset(&codec, 0, sizeof(webrtc::VideoCodec));
|
||||||
if (codec_interface->GetCodec(i, codec) != 0) {
|
if (codec_interface->GetCodec(i, codec) != 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -150,15 +150,6 @@ void ViEAutoTest::ViECaptureStandardTest()
|
|||||||
ViETest::Log("Found capture device %s\nUnique name %s", deviceName,
|
ViETest::Log("Found capture device %s\nUnique name %s", deviceName,
|
||||||
deviceUniqueName);
|
deviceUniqueName);
|
||||||
|
|
||||||
// not supported on MAC (is part of capture capabilities)
|
|
||||||
#if !defined(WEBRTC_LINUX) && !defined(WEBRTC_MAC_INTEL)
|
|
||||||
EXPECT_EQ(0,
|
|
||||||
ViE.capture->ShowCaptureSettingsDialogBox(
|
|
||||||
(char*) deviceUniqueName,
|
|
||||||
(unsigned int) (strlen((char*) deviceUniqueName)),
|
|
||||||
"WebRTCViECapture StandardTest"));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(WEBRTC_MAC_INTEL) // these functions will return -1
|
#if !defined(WEBRTC_MAC_INTEL) // these functions will return -1
|
||||||
int numberOfCapabilities =
|
int numberOfCapabilities =
|
||||||
devInfo->NumberOfCapabilities(deviceUniqueName);
|
devInfo->NumberOfCapabilities(deviceUniqueName);
|
||||||
|
|||||||
@@ -15,16 +15,12 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "gflags/gflags.h"
|
|
||||||
#include "gtest/gtest.h"
|
|
||||||
#include "vie_autotest_defines.h"
|
#include "vie_autotest_defines.h"
|
||||||
#include "vie_autotest_main.h"
|
#include "vie_autotest_main.h"
|
||||||
#include "engine_configurations.h"
|
#include "engine_configurations.h"
|
||||||
#include "critical_section_wrapper.h"
|
#include "critical_section_wrapper.h"
|
||||||
#include "thread_wrapper.h"
|
#include "thread_wrapper.h"
|
||||||
|
|
||||||
DEFINE_bool(automated, false, "Run Video engine tests in noninteractive mode.");
|
|
||||||
|
|
||||||
ViEAutoTestWindowManager::ViEAutoTestWindowManager()
|
ViEAutoTestWindowManager::ViEAutoTestWindowManager()
|
||||||
: _hdsp1(NULL),
|
: _hdsp1(NULL),
|
||||||
_hdsp2(NULL) {
|
_hdsp2(NULL) {
|
||||||
@@ -138,24 +134,6 @@ bool ViEAutoTestWindowManager::SetTopmostWindow() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
// Initialize logging
|
ViEAutoTestMain auto_test;
|
||||||
ViETest::Init();
|
return auto_test.RunTests(argc, argv);
|
||||||
// Initialize the testing framework
|
|
||||||
testing::InitGoogleTest(&argc, argv);
|
|
||||||
// Parse remaining flags:
|
|
||||||
google::ParseCommandLineFlags(&argc, &argv, true);
|
|
||||||
|
|
||||||
int result;
|
|
||||||
if (FLAGS_automated) {
|
|
||||||
// Run in automated mode
|
|
||||||
result = RUN_ALL_TESTS();
|
|
||||||
} else {
|
|
||||||
// Run in interactive mode
|
|
||||||
ViEAutoTestMain autoTest;
|
|
||||||
autoTest.UseAnswerFile("answers.txt");
|
|
||||||
result = autoTest.BeginOSIndependentTesting();
|
|
||||||
}
|
|
||||||
|
|
||||||
ViETest::Terminate();
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -329,7 +329,8 @@ else
|
|||||||
|
|
||||||
-(void)autoTestWithArg:(NSString*)answerFile;
|
-(void)autoTestWithArg:(NSString*)answerFile;
|
||||||
{
|
{
|
||||||
|
// TODO(phoglund): Rewrite this file to work with the new way of running
|
||||||
|
// vie_auto_test. The file doesn't seem to be used at the moment though.
|
||||||
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
|
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
|
||||||
|
|
||||||
ViEAutoTestMain autoTest;
|
ViEAutoTestMain autoTest;
|
||||||
|
|||||||
@@ -16,140 +16,115 @@
|
|||||||
#include "vie_autotest.h"
|
#include "vie_autotest.h"
|
||||||
#include "vie_autotest_main.h"
|
#include "vie_autotest_main.h"
|
||||||
|
|
||||||
ViEAutoTestWindowManager::ViEAutoTestWindowManager() :
|
ViEAutoTestWindowManager::ViEAutoTestWindowManager()
|
||||||
_cocoaRenderView1(nil), _cocoaRenderView2(nil)
|
: _cocoaRenderView1(nil), _cocoaRenderView2(nil) {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
ViEAutoTestWindowManager::~ViEAutoTestWindowManager()
|
|
||||||
{
|
|
||||||
if (_cocoaRenderView1)
|
|
||||||
{
|
|
||||||
[ _cocoaRenderView1 release];
|
|
||||||
}
|
|
||||||
if(_cocoaRenderView2)
|
|
||||||
{
|
|
||||||
[_cocoaRenderView2 release];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ViEAutoTestWindowManager::CreateWindows(AutoTestRect window1Size,
|
int ViEAutoTestWindowManager::CreateWindows(AutoTestRect window1Size,
|
||||||
AutoTestRect window2Size,
|
AutoTestRect window2Size,
|
||||||
void* window1Title,
|
void* window1Title,
|
||||||
void* window2Title)
|
void* window2Title) {
|
||||||
{
|
|
||||||
NSRect outWindow1Frame = NSMakeRect(window1Size.origin.x,
|
NSRect outWindow1Frame = NSMakeRect(window1Size.origin.x,
|
||||||
window1Size.origin.y,
|
window1Size.origin.y,
|
||||||
window1Size.size.width,
|
window1Size.size.width,
|
||||||
window1Size.size.height);
|
window1Size.size.height);
|
||||||
NSWindow* outWindow1 = [[NSWindow alloc] initWithContentRect:outWindow1Frame
|
outWindow1_ = [[NSWindow alloc] initWithContentRect:outWindow1Frame
|
||||||
styleMask:NSTitledWindowMask
|
styleMask:NSTitledWindowMask
|
||||||
backing:NSBackingStoreBuffered defer:NO];
|
backing:NSBackingStoreBuffered defer:NO];
|
||||||
[outWindow1 orderOut:nil];
|
[outWindow1_ orderOut:nil];
|
||||||
NSRect cocoaRenderView1Frame = NSMakeRect(0, 0, window1Size.size.width,
|
NSRect cocoaRenderView1Frame = NSMakeRect(0, 0, window1Size.size.width,
|
||||||
window1Size.size.height);
|
window1Size.size.height);
|
||||||
_cocoaRenderView1 = [[CocoaRenderView alloc]
|
_cocoaRenderView1 = [[CocoaRenderView alloc]
|
||||||
initWithFrame:cocoaRenderView1Frame];
|
initWithFrame:cocoaRenderView1Frame];
|
||||||
[[outWindow1 contentView] addSubview:(NSView*)_cocoaRenderView1];
|
[[outWindow1_ contentView] addSubview:(NSView*)_cocoaRenderView1];
|
||||||
[outWindow1 setTitle:[NSString stringWithFormat:@"%s", window1Title]];
|
[outWindow1_ setTitle:[NSString stringWithFormat:@"%s", window1Title]];
|
||||||
[outWindow1 makeKeyAndOrderFront:NSApp];
|
[outWindow1_ makeKeyAndOrderFront:NSApp];
|
||||||
|
|
||||||
NSRect outWindow2Frame = NSMakeRect(window2Size.origin.x,
|
NSRect outWindow2Frame = NSMakeRect(window2Size.origin.x,
|
||||||
window2Size.origin.y,
|
window2Size.origin.y,
|
||||||
window2Size.size.width,
|
window2Size.size.width,
|
||||||
window2Size.size.height);
|
window2Size.size.height);
|
||||||
NSWindow* outWindow2 = [[NSWindow alloc] initWithContentRect:outWindow2Frame
|
outWindow2_ = [[NSWindow alloc] initWithContentRect:outWindow2Frame
|
||||||
styleMask:NSTitledWindowMask
|
styleMask:NSTitledWindowMask
|
||||||
backing:NSBackingStoreBuffered defer:NO];
|
backing:NSBackingStoreBuffered defer:NO];
|
||||||
[outWindow2 orderOut:nil];
|
[outWindow2_ orderOut:nil];
|
||||||
NSRect cocoaRenderView2Frame = NSMakeRect(0, 0, window2Size.size.width,
|
NSRect cocoaRenderView2Frame = NSMakeRect(0, 0, window2Size.size.width,
|
||||||
window2Size.size.height);
|
window2Size.size.height);
|
||||||
_cocoaRenderView2 = [[CocoaRenderView alloc]
|
_cocoaRenderView2 = [[CocoaRenderView alloc]
|
||||||
initWithFrame:cocoaRenderView2Frame];
|
initWithFrame:cocoaRenderView2Frame];
|
||||||
[[outWindow2 contentView] addSubview:(NSView*)_cocoaRenderView2];
|
[[outWindow2_ contentView] addSubview:(NSView*)_cocoaRenderView2];
|
||||||
[outWindow2 setTitle:[NSString stringWithFormat:@"%s", window2Title]];
|
[outWindow2_ setTitle:[NSString stringWithFormat:@"%s", window2Title]];
|
||||||
[outWindow2 makeKeyAndOrderFront:NSApp];
|
[outWindow2_ makeKeyAndOrderFront:NSApp];
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ViEAutoTestWindowManager::TerminateWindows()
|
int ViEAutoTestWindowManager::TerminateWindows() {
|
||||||
{
|
[outWindow1_ close];
|
||||||
|
[outWindow2_ close];
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* ViEAutoTestWindowManager::GetWindow1()
|
void* ViEAutoTestWindowManager::GetWindow1() {
|
||||||
{
|
|
||||||
return _cocoaRenderView1;
|
return _cocoaRenderView1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* ViEAutoTestWindowManager::GetWindow2()
|
void* ViEAutoTestWindowManager::GetWindow2() {
|
||||||
{
|
|
||||||
return _cocoaRenderView2;
|
return _cocoaRenderView2;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ViEAutoTestWindowManager::SetTopmostWindow()
|
bool ViEAutoTestWindowManager::SetTopmostWindow() {
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, const char * argv[])
|
int main(int argc, char * argv[]) {
|
||||||
{
|
|
||||||
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
|
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
|
||||||
|
|
||||||
[NSApplication sharedApplication];
|
[NSApplication sharedApplication];
|
||||||
|
|
||||||
|
int result = 0;
|
||||||
#if defined(MAC_COCOA_USE_NSRUNLOOP)
|
#if defined(MAC_COCOA_USE_NSRUNLOOP)
|
||||||
// we have to run the test in a secondary thread because we need to run a
|
AutoTestClass* tests = [[AutoTestClass alloc] init];
|
||||||
// runloop, which blocks
|
|
||||||
if (argc > 1)
|
|
||||||
{
|
|
||||||
AutoTestClass * autoTestClass = [[AutoTestClass alloc]init];
|
|
||||||
[NSThread detachNewThreadSelector:@selector(autoTestWithArg:)
|
|
||||||
toTarget:autoTestClass withObject:[NSString stringWithFormat:@"%s",
|
|
||||||
argv[1]]];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
AutoTestClass* autoTestClass = [[AutoTestClass alloc]init];
|
|
||||||
[NSThread detachNewThreadSelector:@selector(autoTestWithArg:)
|
|
||||||
toTarget:autoTestClass withObject:nil];
|
|
||||||
}
|
|
||||||
|
|
||||||
// process OS events. Blocking call
|
[tests setArgc:argc argv:argv];
|
||||||
[[NSRunLoop mainRunLoop]run];
|
[NSThread detachNewThreadSelector:@selector(autoTestWithArg:)
|
||||||
|
toTarget:tests withObject:nil];
|
||||||
|
// Process OS events. Blocking call.
|
||||||
|
[[NSRunLoop mainRunLoop]run];
|
||||||
|
|
||||||
|
result = [tests result];
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
ViEAutoTestMain autoTest;
|
ViEAutoTestMain autoTest;
|
||||||
int success = autoTest.BeginOSIndependentTesting();
|
result = autoTest.RunTests(argc, argv);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
[pool release];
|
[pool release];
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@implementation AutoTestClass
|
@implementation AutoTestClass
|
||||||
|
|
||||||
-(void)autoTestWithArg:(NSString*)answerFile
|
- (void)setArgc:(int)argc argv:(char**)argv {
|
||||||
{
|
argc_ = argc;
|
||||||
|
argv_ = argv;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)autoTestWithArg:(NSObject*)ignored {
|
||||||
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
|
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
|
||||||
|
|
||||||
ViEAutoTestMain autoTest;
|
ViEAutoTestMain auto_test;
|
||||||
|
|
||||||
if(NSOrderedSame != [answerFile compare:@""])
|
result_ = auto_test.RunTests(argc_, argv_);
|
||||||
{
|
|
||||||
char answerFileUTF8[1024] = "";
|
|
||||||
strcpy(answerFileUTF8, (char*)[answerFileUTF8 UTF8]);
|
|
||||||
autoTest.UseAnswerFile(answerFileUTF8);
|
|
||||||
}
|
|
||||||
|
|
||||||
int success = autoTest.BeginOSIndependentTesting();
|
|
||||||
|
|
||||||
[pool release];
|
[pool release];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (int)result {
|
||||||
|
return result_;
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -10,20 +10,19 @@
|
|||||||
|
|
||||||
#include "vie_autotest_main.h"
|
#include "vie_autotest_main.h"
|
||||||
|
|
||||||
|
#include "gflags/gflags.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
#include "vie_autotest.h"
|
||||||
#include "vie_autotest_window_manager_interface.h"
|
#include "vie_autotest_window_manager_interface.h"
|
||||||
#include "vie_window_creator.h"
|
#include "vie_window_creator.h"
|
||||||
#include "vie_autotest.h"
|
|
||||||
|
DEFINE_bool(automated, false, "Run Video engine tests in noninteractive mode.");
|
||||||
|
|
||||||
static const std::string kStandardTest = "ViEStandardIntegrationTest";
|
static const std::string kStandardTest = "ViEStandardIntegrationTest";
|
||||||
static const std::string kExtendedTest = "ViEExtendedIntegrationTest";
|
static const std::string kExtendedTest = "ViEExtendedIntegrationTest";
|
||||||
static const std::string kApiTest = "ViEApiIntegrationTest";
|
static const std::string kApiTest = "ViEApiIntegrationTest";
|
||||||
|
|
||||||
ViEAutoTestMain::ViEAutoTestMain()
|
ViEAutoTestMain::ViEAutoTestMain() {
|
||||||
: answers_(),
|
|
||||||
answers_count_(0),
|
|
||||||
use_answer_file_() {
|
|
||||||
|
|
||||||
index_to_test_method_map_[1] = "RunsBaseTestWithoutErrors";
|
index_to_test_method_map_[1] = "RunsBaseTestWithoutErrors";
|
||||||
index_to_test_method_map_[2] = "RunsCaptureTestWithoutErrors";
|
index_to_test_method_map_[2] = "RunsCaptureTestWithoutErrors";
|
||||||
index_to_test_method_map_[3] = "RunsCodecTestWithoutErrors";
|
index_to_test_method_map_[3] = "RunsCodecTestWithoutErrors";
|
||||||
@@ -35,6 +34,27 @@ ViEAutoTestMain::ViEAutoTestMain()
|
|||||||
index_to_test_method_map_[9] = "RunsRtpRtcpTestWithoutErrors";
|
index_to_test_method_map_[9] = "RunsRtpRtcpTestWithoutErrors";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ViEAutoTestMain::RunTests(int argc, char** argv) {
|
||||||
|
// Initialize logging.
|
||||||
|
ViETest::Init();
|
||||||
|
// Initialize the testing framework.
|
||||||
|
testing::InitGoogleTest(&argc, argv);
|
||||||
|
// Parse remaining flags:
|
||||||
|
google::ParseCommandLineFlags(&argc, &argv, true);
|
||||||
|
|
||||||
|
int result;
|
||||||
|
if (FLAGS_automated) {
|
||||||
|
// Run in automated mode.
|
||||||
|
result = RUN_ALL_TESTS();
|
||||||
|
} else {
|
||||||
|
// Run in interactive mode.
|
||||||
|
result = RunInteractiveMode();
|
||||||
|
}
|
||||||
|
|
||||||
|
ViETest::Terminate();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
int ViEAutoTestMain::AskUserForTestCase() {
|
int ViEAutoTestMain::AskUserForTestCase() {
|
||||||
int choice;
|
int choice;
|
||||||
std::string answer;
|
std::string answer;
|
||||||
@@ -44,7 +64,7 @@ int ViEAutoTestMain::AskUserForTestCase() {
|
|||||||
ViETest::Log("\t 0. Go back to previous menu.");
|
ViETest::Log("\t 0. Go back to previous menu.");
|
||||||
|
|
||||||
// Print all test method choices. Assumes that map sorts on its key.
|
// Print all test method choices. Assumes that map sorts on its key.
|
||||||
int last_valid_choice = 0;
|
int last_valid_choice;
|
||||||
std::map<int, std::string>::const_iterator iterator;
|
std::map<int, std::string>::const_iterator iterator;
|
||||||
for (iterator = index_to_test_method_map_.begin();
|
for (iterator = index_to_test_method_map_.begin();
|
||||||
iterator != index_to_test_method_map_.end();
|
iterator != index_to_test_method_map_.end();
|
||||||
@@ -62,11 +82,6 @@ int ViEAutoTestMain::AskUserForTestCase() {
|
|||||||
|
|
||||||
int ViEAutoTestMain::AskUserForNumber(int min_allowed, int max_allowed) {
|
int ViEAutoTestMain::AskUserForNumber(int min_allowed, int max_allowed) {
|
||||||
int result;
|
int result;
|
||||||
if (use_answer_file_) {
|
|
||||||
assert(0 && "Answer files are not implemented");
|
|
||||||
return kInvalidChoice;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (scanf("%d", &result) <= 0) {
|
if (scanf("%d", &result) <= 0) {
|
||||||
ViETest::Log("\nPlease enter a number instead, then hit enter.");
|
ViETest::Log("\nPlease enter a number instead, then hit enter.");
|
||||||
getchar();
|
getchar();
|
||||||
@@ -113,7 +128,7 @@ int ViEAutoTestMain::RunSpecialTestCase(int choice) {
|
|||||||
ViEAutoTest vieAutoTest(windowManager->GetWindow1(),
|
ViEAutoTest vieAutoTest(windowManager->GetWindow1(),
|
||||||
windowManager->GetWindow2());
|
windowManager->GetWindow2());
|
||||||
|
|
||||||
int errors = 0;
|
int errors;
|
||||||
switch (choice) {
|
switch (choice) {
|
||||||
case 7: errors = vieAutoTest.ViELoopbackCall(); break;
|
case 7: errors = vieAutoTest.ViELoopbackCall(); break;
|
||||||
case 8: errors = vieAutoTest.ViECustomCall(); break;
|
case 8: errors = vieAutoTest.ViECustomCall(); break;
|
||||||
@@ -124,8 +139,7 @@ int ViEAutoTestMain::RunSpecialTestCase(int choice) {
|
|||||||
return errors;
|
return errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ViEAutoTestMain::BeginOSIndependentTesting() {
|
bool ViEAutoTestMain::RunInteractiveMode() {
|
||||||
|
|
||||||
ViETest::Log(" ============================== ");
|
ViETest::Log(" ============================== ");
|
||||||
ViETest::Log(" WebRTC ViE 3.x Autotest ");
|
ViETest::Log(" WebRTC ViE 3.x Autotest ");
|
||||||
ViETest::Log(" ============================== \n");
|
ViETest::Log(" ============================== \n");
|
||||||
@@ -172,47 +186,3 @@ bool ViEAutoTestMain::BeginOSIndependentTesting() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ViEAutoTestMain::GetAnswer(int index, std::string* answer) {
|
|
||||||
if (!use_answer_file_ || index > answers_count_) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
*answer = answers_[index];
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ViEAutoTestMain::IsUsingAnswerFile() {
|
|
||||||
return use_answer_file_;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO(unknown): implement?
|
|
||||||
bool ViEAutoTestMain::UseAnswerFile(const char* fileName) {
|
|
||||||
return false;
|
|
||||||
/*
|
|
||||||
use_answer_file_ = false;
|
|
||||||
|
|
||||||
ViETest::Log("Opening answer file: %s...", fileName);
|
|
||||||
|
|
||||||
ifstream answerFile(fileName);
|
|
||||||
if(!answerFile)
|
|
||||||
{
|
|
||||||
ViETest::Log("failed! X(\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
answers_count_ = 1;
|
|
||||||
answers_index_ = 1;
|
|
||||||
char lineContent[128] = "";
|
|
||||||
while(!answerFile.eof())
|
|
||||||
{
|
|
||||||
answerFile.getline(lineContent, 128);
|
|
||||||
answers_[answers_Count++] = string(lineContent);
|
|
||||||
}
|
|
||||||
answerFile.close();
|
|
||||||
|
|
||||||
cout << "Success :)" << endl << endl;
|
|
||||||
|
|
||||||
use_answer_file_ = true;
|
|
||||||
|
|
||||||
return use_answer_file_;
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|||||||
316
src/video_engine/test/auto_test/source/vie_autotest_windows.cc
Normal file → Executable file
316
src/video_engine/test/auto_test/source/vie_autotest_windows.cc
Normal file → Executable file
@@ -34,213 +34,181 @@
|
|||||||
#pragma warning(disable: 4351)
|
#pragma warning(disable: 4351)
|
||||||
|
|
||||||
LRESULT CALLBACK ViEAutoTestWinProc(HWND hWnd, UINT uMsg, WPARAM wParam,
|
LRESULT CALLBACK ViEAutoTestWinProc(HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||||
LPARAM lParam)
|
LPARAM lParam) {
|
||||||
{
|
switch (uMsg) {
|
||||||
switch (uMsg)
|
case WM_DESTROY:
|
||||||
{
|
PostQuitMessage( WM_QUIT);
|
||||||
case WM_DESTROY:
|
break;
|
||||||
PostQuitMessage( WM_QUIT);
|
case WM_COMMAND:
|
||||||
break;
|
break;
|
||||||
case WM_COMMAND:
|
}
|
||||||
break;
|
return DefWindowProc(hWnd, uMsg, wParam, lParam);
|
||||||
}
|
|
||||||
return DefWindowProc(hWnd, uMsg, wParam, lParam);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ViEAutoTestWindowManager::ViEAutoTestWindowManager() :
|
ViEAutoTestWindowManager::ViEAutoTestWindowManager()
|
||||||
_window1(NULL),
|
: _window1(NULL),
|
||||||
_window2(NULL),
|
_window2(NULL),
|
||||||
_terminate(false),
|
_terminate(false),
|
||||||
_eventThread(*webrtc::ThreadWrapper::CreateThread(EventProcess, this,
|
_eventThread(*webrtc::ThreadWrapper::CreateThread(
|
||||||
webrtc::kNormalPriority,
|
EventProcess, this, webrtc::kNormalPriority,
|
||||||
"ViEAutotestEventThread")),
|
"ViEAutotestEventThread")),
|
||||||
_crit(*webrtc::CriticalSectionWrapper::CreateCriticalSection()),
|
_crit(*webrtc::CriticalSectionWrapper::CreateCriticalSection()),
|
||||||
_hwnd1(NULL),
|
_hwnd1(NULL),
|
||||||
_hwnd2(NULL),
|
_hwnd2(NULL),
|
||||||
_hwnd1Size(),
|
_hwnd1Size(),
|
||||||
_hwnd2Size(),
|
_hwnd2Size(),
|
||||||
_hwnd1Title(),
|
_hwnd1Title(),
|
||||||
_hwnd2Title()
|
_hwnd2Title() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ViEAutoTestWindowManager::~ViEAutoTestWindowManager()
|
ViEAutoTestWindowManager::~ViEAutoTestWindowManager() {
|
||||||
{
|
if (_hwnd1) {
|
||||||
if (_hwnd1)
|
ViEDestroyWindow(_hwnd1);
|
||||||
{
|
}
|
||||||
ViEDestroyWindow(_hwnd1);
|
if (_hwnd2) {
|
||||||
}
|
ViEDestroyWindow(_hwnd1);
|
||||||
if (_hwnd2)
|
}
|
||||||
{
|
delete &_crit;
|
||||||
ViEDestroyWindow(_hwnd1);
|
|
||||||
}
|
|
||||||
delete &_crit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void* ViEAutoTestWindowManager::GetWindow1()
|
void* ViEAutoTestWindowManager::GetWindow1() {
|
||||||
{
|
return _window1;
|
||||||
return _window1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void* ViEAutoTestWindowManager::GetWindow2()
|
void* ViEAutoTestWindowManager::GetWindow2() {
|
||||||
{
|
return _window2;
|
||||||
return _window2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ViEAutoTestWindowManager::CreateWindows(AutoTestRect window1Size,
|
int ViEAutoTestWindowManager::CreateWindows(AutoTestRect window1Size,
|
||||||
AutoTestRect window2Size,
|
AutoTestRect window2Size,
|
||||||
void* window1Title,
|
void* window1Title,
|
||||||
void* window2Title)
|
void* window2Title) {
|
||||||
{
|
_hwnd1Size.Copy(window1Size);
|
||||||
_hwnd1Size.Copy(window1Size);
|
_hwnd2Size.Copy(window2Size);
|
||||||
_hwnd2Size.Copy(window2Size);
|
memcpy(_hwnd1Title, window1Title, TITLE_LENGTH);
|
||||||
memcpy(_hwnd1Title, window1Title, TITLE_LENGTH);
|
memcpy(_hwnd2Title, window2Title, TITLE_LENGTH);
|
||||||
memcpy(_hwnd2Title, window2Title, TITLE_LENGTH);
|
|
||||||
|
|
||||||
unsigned int tId = 0;
|
unsigned int tId = 0;
|
||||||
_eventThread.Start(tId);
|
_eventThread.Start(tId);
|
||||||
|
|
||||||
do
|
do {
|
||||||
{
|
|
||||||
_crit.Enter();
|
|
||||||
if (_window1 != NULL)
|
|
||||||
break;
|
|
||||||
_crit.Leave();
|
|
||||||
AutoTestSleep(10);
|
|
||||||
} while (true);
|
|
||||||
_crit.Leave();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ViEAutoTestWindowManager::TerminateWindows()
|
|
||||||
{
|
|
||||||
_eventThread.SetNotAlive();
|
|
||||||
|
|
||||||
_terminate = true;
|
|
||||||
if (_eventThread.Stop())
|
|
||||||
{
|
|
||||||
_crit.Enter();
|
|
||||||
delete &_eventThread;
|
|
||||||
_crit.Leave();
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ViEAutoTestWindowManager::EventProcess(void* obj)
|
|
||||||
{
|
|
||||||
return static_cast<ViEAutoTestWindowManager*> (obj)->EventLoop();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ViEAutoTestWindowManager::EventLoop()
|
|
||||||
{
|
|
||||||
_crit.Enter();
|
_crit.Enter();
|
||||||
|
if (_window1 != NULL) {
|
||||||
//ViECreateWindow(_hwnd1, 352, 288, 600, 100, "ViE Autotest Window 1");
|
break;
|
||||||
//ViECreateWindow(_hwnd2, 352, 288, 1000, 100, "ViE Autotest Window 2");
|
|
||||||
|
|
||||||
ViECreateWindow(_hwnd1, _hwnd1Size.origin.x, _hwnd1Size.origin.y,
|
|
||||||
_hwnd1Size.size.width, _hwnd1Size.size.height, _hwnd1Title);
|
|
||||||
ViECreateWindow(_hwnd2, _hwnd2Size.origin.x, _hwnd2Size.origin.y,
|
|
||||||
_hwnd2Size.size.width, _hwnd2Size.size.height, _hwnd2Title);
|
|
||||||
|
|
||||||
_window1 = (void*) _hwnd1;
|
|
||||||
_window2 = (void*) _hwnd2;
|
|
||||||
MSG msg;
|
|
||||||
while (!_terminate)
|
|
||||||
{
|
|
||||||
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
|
|
||||||
{
|
|
||||||
TranslateMessage(&msg);
|
|
||||||
DispatchMessage(&msg);
|
|
||||||
}
|
|
||||||
_crit.Leave();
|
|
||||||
AutoTestSleep(10);
|
|
||||||
_crit.Enter();
|
|
||||||
}
|
}
|
||||||
ViEDestroyWindow(_hwnd1);
|
|
||||||
ViEDestroyWindow(_hwnd2);
|
|
||||||
_crit.Leave();
|
_crit.Leave();
|
||||||
|
AutoTestSleep(10);
|
||||||
|
} while (true);
|
||||||
|
_crit.Leave();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
int ViEAutoTestWindowManager::TerminateWindows() {
|
||||||
|
_eventThread.SetNotAlive();
|
||||||
|
|
||||||
|
_terminate = true;
|
||||||
|
if (_eventThread.Stop()) {
|
||||||
|
_crit.Enter();
|
||||||
|
delete &_eventThread;
|
||||||
|
_crit.Leave();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ViEAutoTestWindowManager::EventProcess(void* obj) {
|
||||||
|
return static_cast<ViEAutoTestWindowManager*> (obj)->EventLoop();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ViEAutoTestWindowManager::EventLoop() {
|
||||||
|
_crit.Enter();
|
||||||
|
|
||||||
|
ViECreateWindow(_hwnd1, _hwnd1Size.origin.x, _hwnd1Size.origin.y,
|
||||||
|
_hwnd1Size.size.width, _hwnd1Size.size.height, _hwnd1Title);
|
||||||
|
ViECreateWindow(_hwnd2, _hwnd2Size.origin.x, _hwnd2Size.origin.y,
|
||||||
|
_hwnd2Size.size.width, _hwnd2Size.size.height, _hwnd2Title);
|
||||||
|
|
||||||
|
_window1 = (void*) _hwnd1;
|
||||||
|
_window2 = (void*) _hwnd2;
|
||||||
|
MSG msg;
|
||||||
|
while (!_terminate) {
|
||||||
|
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
|
||||||
|
TranslateMessage(&msg);
|
||||||
|
DispatchMessage(&msg);
|
||||||
|
}
|
||||||
|
_crit.Leave();
|
||||||
|
AutoTestSleep(10);
|
||||||
|
_crit.Enter();
|
||||||
|
}
|
||||||
|
ViEDestroyWindow(_hwnd1);
|
||||||
|
ViEDestroyWindow(_hwnd2);
|
||||||
|
_crit.Leave();
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ViEAutoTestWindowManager::ViECreateWindow(HWND &hwndMain, int xPos,
|
int ViEAutoTestWindowManager::ViECreateWindow(HWND &hwndMain, int xPos,
|
||||||
int yPos, int width, int height,
|
int yPos, int width, int height,
|
||||||
TCHAR* className)
|
TCHAR* className) {
|
||||||
{
|
HINSTANCE hinst = GetModuleHandle(0);
|
||||||
HINSTANCE hinst = GetModuleHandle(0);
|
WNDCLASSEX wcx;
|
||||||
WNDCLASSEX wcx;
|
wcx.hInstance = hinst;
|
||||||
wcx.hInstance = hinst;
|
wcx.lpszClassName = className;
|
||||||
wcx.lpszClassName = className;
|
wcx.lpfnWndProc = (WNDPROC) ViEAutoTestWinProc;
|
||||||
wcx.lpfnWndProc = (WNDPROC) ViEAutoTestWinProc;
|
wcx.style = CS_DBLCLKS;
|
||||||
wcx.style = CS_DBLCLKS;
|
wcx.hIcon = LoadIcon(NULL, IDI_APPLICATION);
|
||||||
wcx.hIcon = LoadIcon(NULL, IDI_APPLICATION);
|
wcx.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
|
||||||
wcx.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
|
wcx.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||||
wcx.hCursor = LoadCursor(NULL, IDC_ARROW);
|
wcx.lpszMenuName = NULL;
|
||||||
wcx.lpszMenuName = NULL;
|
wcx.cbSize = sizeof(WNDCLASSEX);
|
||||||
wcx.cbSize = sizeof(WNDCLASSEX);
|
wcx.cbClsExtra = 0;
|
||||||
wcx.cbClsExtra = 0;
|
wcx.cbWndExtra = 0;
|
||||||
wcx.cbWndExtra = 0;
|
wcx.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
|
||||||
wcx.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
|
|
||||||
|
|
||||||
// Register our window class with the operating system.
|
RegisterClassEx(&wcx);
|
||||||
// If there is an error, exit program.
|
|
||||||
ViETest::TestError(RegisterClassEx(&wcx) != NULL,
|
|
||||||
"Could not register autotest window");
|
|
||||||
|
|
||||||
// Create the main window.
|
// Create the main window.
|
||||||
hwndMain = CreateWindowEx(0, // no extended styles
|
hwndMain = CreateWindowEx(0, // no extended styles
|
||||||
className, // class name
|
className, // class name
|
||||||
className, // window name
|
className, // window name
|
||||||
WS_OVERLAPPED | WS_THICKFRAME,// overlapped window
|
WS_OVERLAPPED | WS_THICKFRAME, // overlapped window
|
||||||
xPos, // horizontal position
|
xPos, // horizontal position
|
||||||
yPos, // vertical position
|
yPos, // vertical position
|
||||||
width, // width
|
width, // width
|
||||||
height, // height
|
height, // height
|
||||||
(HWND) NULL, // no parent or owner window
|
(HWND) NULL, // no parent or owner window
|
||||||
(HMENU) NULL, // class menu used
|
(HMENU) NULL, // class menu used
|
||||||
hinst, // instance handle
|
hinst, // instance handle
|
||||||
NULL); // no window creation data
|
NULL); // no window creation data
|
||||||
|
|
||||||
if (!hwndMain)
|
if (!hwndMain) {
|
||||||
{
|
int error = GetLastError();
|
||||||
int error = GetLastError();
|
return -1;
|
||||||
return -1;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Show the window using the flag specified by the program
|
// Show the window using the flag specified by the program
|
||||||
// that started the application, and send the application
|
// that started the application, and send the application
|
||||||
// a WM_PAINT message.
|
// a WM_PAINT message.
|
||||||
|
ShowWindow(hwndMain, SW_SHOWDEFAULT);
|
||||||
|
UpdateWindow(hwndMain);
|
||||||
|
|
||||||
ShowWindow(hwndMain, SW_SHOWDEFAULT);
|
::SetWindowPos(hwndMain, HWND_TOP, xPos, yPos, width, height,
|
||||||
UpdateWindow(hwndMain);
|
SWP_FRAMECHANGED);
|
||||||
|
|
||||||
::SetWindowPos(hwndMain, HWND_TOP, xPos, yPos, width, height,
|
return 0;
|
||||||
SWP_FRAMECHANGED);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ViEAutoTestWindowManager::ViEDestroyWindow(HWND& hwnd)
|
int ViEAutoTestWindowManager::ViEDestroyWindow(HWND& hwnd) {
|
||||||
{
|
::DestroyWindow(hwnd);
|
||||||
::DestroyWindow(hwnd);
|
return 0;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ViEAutoTestWindowManager::SetTopmostWindow()
|
bool ViEAutoTestWindowManager::SetTopmostWindow() {
|
||||||
{
|
// Meant to put terminal window on top
|
||||||
// Meant to put terminal window on top
|
return true;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[]) {
|
||||||
{
|
ViEAutoTestMain auto_test;
|
||||||
ViEAutoTestMain autoTest;
|
return auto_test.RunTests(argc, argv);
|
||||||
if (argc > 1)
|
|
||||||
{
|
|
||||||
autoTest.UseAnswerFile(argv[1]);
|
|
||||||
}
|
|
||||||
return autoTest.BeginOSIndependentTesting();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user