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>
|
||||
|
||||
class ViEAutoTestWindowManager: public ViEAutoTestWindowManagerInterface
|
||||
{
|
||||
public:
|
||||
ViEAutoTestWindowManager();
|
||||
virtual ~ViEAutoTestWindowManager();
|
||||
virtual void* GetWindow1();
|
||||
virtual void* GetWindow2();
|
||||
virtual int CreateWindows(AutoTestRect window1Size,
|
||||
AutoTestRect window2Size, void* window1Title,
|
||||
void* window2Title);
|
||||
virtual int TerminateWindows();
|
||||
virtual bool SetTopmostWindow();
|
||||
class ViEAutoTestWindowManager: public ViEAutoTestWindowManagerInterface {
|
||||
public:
|
||||
ViEAutoTestWindowManager();
|
||||
virtual ~ViEAutoTestWindowManager() {}
|
||||
virtual void* GetWindow1();
|
||||
virtual void* GetWindow2();
|
||||
virtual int CreateWindows(AutoTestRect window1Size,
|
||||
AutoTestRect window2Size,
|
||||
void* window1Title,
|
||||
void* window2Title);
|
||||
virtual int TerminateWindows();
|
||||
virtual bool SetTopmostWindow();
|
||||
|
||||
private:
|
||||
CocoaRenderView* _cocoaRenderView1;
|
||||
CocoaRenderView* _cocoaRenderView2;
|
||||
private:
|
||||
CocoaRenderView* _cocoaRenderView1;
|
||||
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
|
||||
|
||||
#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 {
|
||||
public:
|
||||
ViEAutoTestMain();
|
||||
bool BeginOSIndependentTesting();
|
||||
bool GetAnswer(int index, std::string* answer);
|
||||
int AskUserForTestCase();
|
||||
bool GetNextAnswer(std::string& answer);
|
||||
bool IsUsingAnswerFile();
|
||||
bool UseAnswerFile(const char* fileName);
|
||||
|
||||
// Runs the test according to the specified arguments.
|
||||
// Pass in --automated to run in automated mode; interactive
|
||||
// mode is default. All usual googletest flags also apply.
|
||||
int RunTests(int argc, char** argv);
|
||||
|
||||
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_;
|
||||
|
||||
static const int kInvalidChoice = -1;
|
||||
|
||||
// Starts interactive mode.
|
||||
bool RunInteractiveMode();
|
||||
// Prompts the user for a specific test method in the provided test case.
|
||||
// Returns 0 on success, nonzero otherwise.
|
||||
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
|
||||
// [min_allowed, max_allowed]. Returns kInvalidChoice on failure.
|
||||
int AskUserForNumber(int min_allowed, int max_allowed);
|
||||
|
||||
@@ -93,10 +93,11 @@ bool FindSpecificCodec(webrtc::VideoCodecType of_type,
|
||||
webrtc::ViECodec* codec_interface,
|
||||
webrtc::VideoCodec* result) {
|
||||
|
||||
memset(result, 1, sizeof(webrtc::VideoCodec));
|
||||
memset(result, 0, sizeof(webrtc::VideoCodec));
|
||||
|
||||
for (int i = 0; i < codec_interface->NumberOfCodecs(); i++) {
|
||||
webrtc::VideoCodec codec;
|
||||
memset(&codec, 0, sizeof(webrtc::VideoCodec));
|
||||
if (codec_interface->GetCodec(i, codec) != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -150,15 +150,6 @@ void ViEAutoTest::ViECaptureStandardTest()
|
||||
ViETest::Log("Found capture device %s\nUnique name %s", deviceName,
|
||||
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
|
||||
int numberOfCapabilities =
|
||||
devInfo->NumberOfCapabilities(deviceUniqueName);
|
||||
|
||||
@@ -15,16 +15,12 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "gflags/gflags.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "vie_autotest_defines.h"
|
||||
#include "vie_autotest_main.h"
|
||||
#include "engine_configurations.h"
|
||||
#include "critical_section_wrapper.h"
|
||||
#include "thread_wrapper.h"
|
||||
|
||||
DEFINE_bool(automated, false, "Run Video engine tests in noninteractive mode.");
|
||||
|
||||
ViEAutoTestWindowManager::ViEAutoTestWindowManager()
|
||||
: _hdsp1(NULL),
|
||||
_hdsp2(NULL) {
|
||||
@@ -138,24 +134,6 @@ bool ViEAutoTestWindowManager::SetTopmostWindow() {
|
||||
}
|
||||
|
||||
int main(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
|
||||
ViEAutoTestMain autoTest;
|
||||
autoTest.UseAnswerFile("answers.txt");
|
||||
result = autoTest.BeginOSIndependentTesting();
|
||||
}
|
||||
|
||||
ViETest::Terminate();
|
||||
return result;
|
||||
ViEAutoTestMain auto_test;
|
||||
return auto_test.RunTests(argc, argv);
|
||||
}
|
||||
|
||||
@@ -329,7 +329,8 @@ else
|
||||
|
||||
-(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];
|
||||
|
||||
ViEAutoTestMain autoTest;
|
||||
|
||||
@@ -16,140 +16,115 @@
|
||||
#include "vie_autotest.h"
|
||||
#include "vie_autotest_main.h"
|
||||
|
||||
ViEAutoTestWindowManager::ViEAutoTestWindowManager() :
|
||||
_cocoaRenderView1(nil), _cocoaRenderView2(nil)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ViEAutoTestWindowManager::~ViEAutoTestWindowManager()
|
||||
{
|
||||
if (_cocoaRenderView1)
|
||||
{
|
||||
[ _cocoaRenderView1 release];
|
||||
}
|
||||
if(_cocoaRenderView2)
|
||||
{
|
||||
[_cocoaRenderView2 release];
|
||||
}
|
||||
ViEAutoTestWindowManager::ViEAutoTestWindowManager()
|
||||
: _cocoaRenderView1(nil), _cocoaRenderView2(nil) {
|
||||
}
|
||||
|
||||
int ViEAutoTestWindowManager::CreateWindows(AutoTestRect window1Size,
|
||||
AutoTestRect window2Size,
|
||||
void* window1Title,
|
||||
void* window2Title)
|
||||
{
|
||||
void* window2Title) {
|
||||
NSRect outWindow1Frame = NSMakeRect(window1Size.origin.x,
|
||||
window1Size.origin.y,
|
||||
window1Size.size.width,
|
||||
window1Size.size.height);
|
||||
NSWindow* outWindow1 = [[NSWindow alloc] initWithContentRect:outWindow1Frame
|
||||
styleMask:NSTitledWindowMask
|
||||
backing:NSBackingStoreBuffered defer:NO];
|
||||
[outWindow1 orderOut:nil];
|
||||
outWindow1_ = [[NSWindow alloc] initWithContentRect:outWindow1Frame
|
||||
styleMask:NSTitledWindowMask
|
||||
backing:NSBackingStoreBuffered defer:NO];
|
||||
[outWindow1_ orderOut:nil];
|
||||
NSRect cocoaRenderView1Frame = NSMakeRect(0, 0, window1Size.size.width,
|
||||
window1Size.size.height);
|
||||
_cocoaRenderView1 = [[CocoaRenderView alloc]
|
||||
initWithFrame:cocoaRenderView1Frame];
|
||||
[[outWindow1 contentView] addSubview:(NSView*)_cocoaRenderView1];
|
||||
[outWindow1 setTitle:[NSString stringWithFormat:@"%s", window1Title]];
|
||||
[outWindow1 makeKeyAndOrderFront:NSApp];
|
||||
[[outWindow1_ contentView] addSubview:(NSView*)_cocoaRenderView1];
|
||||
[outWindow1_ setTitle:[NSString stringWithFormat:@"%s", window1Title]];
|
||||
[outWindow1_ makeKeyAndOrderFront:NSApp];
|
||||
|
||||
NSRect outWindow2Frame = NSMakeRect(window2Size.origin.x,
|
||||
window2Size.origin.y,
|
||||
window2Size.size.width,
|
||||
window2Size.size.height);
|
||||
NSWindow* outWindow2 = [[NSWindow alloc] initWithContentRect:outWindow2Frame
|
||||
styleMask:NSTitledWindowMask
|
||||
backing:NSBackingStoreBuffered defer:NO];
|
||||
[outWindow2 orderOut:nil];
|
||||
outWindow2_ = [[NSWindow alloc] initWithContentRect:outWindow2Frame
|
||||
styleMask:NSTitledWindowMask
|
||||
backing:NSBackingStoreBuffered defer:NO];
|
||||
[outWindow2_ orderOut:nil];
|
||||
NSRect cocoaRenderView2Frame = NSMakeRect(0, 0, window2Size.size.width,
|
||||
window2Size.size.height);
|
||||
_cocoaRenderView2 = [[CocoaRenderView alloc]
|
||||
initWithFrame:cocoaRenderView2Frame];
|
||||
[[outWindow2 contentView] addSubview:(NSView*)_cocoaRenderView2];
|
||||
[outWindow2 setTitle:[NSString stringWithFormat:@"%s", window2Title]];
|
||||
[outWindow2 makeKeyAndOrderFront:NSApp];
|
||||
[[outWindow2_ contentView] addSubview:(NSView*)_cocoaRenderView2];
|
||||
[outWindow2_ setTitle:[NSString stringWithFormat:@"%s", window2Title]];
|
||||
[outWindow2_ makeKeyAndOrderFront:NSApp];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ViEAutoTestWindowManager::TerminateWindows()
|
||||
{
|
||||
int ViEAutoTestWindowManager::TerminateWindows() {
|
||||
[outWindow1_ close];
|
||||
[outWindow2_ close];
|
||||
return 0;
|
||||
}
|
||||
|
||||
void* ViEAutoTestWindowManager::GetWindow1()
|
||||
{
|
||||
void* ViEAutoTestWindowManager::GetWindow1() {
|
||||
return _cocoaRenderView1;
|
||||
}
|
||||
|
||||
void* ViEAutoTestWindowManager::GetWindow2()
|
||||
{
|
||||
void* ViEAutoTestWindowManager::GetWindow2() {
|
||||
return _cocoaRenderView2;
|
||||
}
|
||||
|
||||
bool ViEAutoTestWindowManager::SetTopmostWindow()
|
||||
{
|
||||
bool ViEAutoTestWindowManager::SetTopmostWindow() {
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int argc, const char * argv[])
|
||||
{
|
||||
int main(int argc, char * argv[]) {
|
||||
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
[NSApplication sharedApplication];
|
||||
|
||||
int result = 0;
|
||||
#if defined(MAC_COCOA_USE_NSRUNLOOP)
|
||||
// we have to run the test in a secondary thread because we need to run a
|
||||
// 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
|
||||
[[NSRunLoop mainRunLoop]run];
|
||||
AutoTestClass* tests = [[AutoTestClass alloc] init];
|
||||
|
||||
[tests setArgc:argc argv:argv];
|
||||
[NSThread detachNewThreadSelector:@selector(autoTestWithArg:)
|
||||
toTarget:tests withObject:nil];
|
||||
// Process OS events. Blocking call.
|
||||
[[NSRunLoop mainRunLoop]run];
|
||||
|
||||
result = [tests result];
|
||||
|
||||
#else
|
||||
|
||||
ViEAutoTestMain autoTest;
|
||||
int success = autoTest.BeginOSIndependentTesting();
|
||||
result = autoTest.RunTests(argc, argv);
|
||||
|
||||
#endif
|
||||
[pool release];
|
||||
[pool release];
|
||||
return result;
|
||||
}
|
||||
|
||||
@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];
|
||||
|
||||
ViEAutoTestMain autoTest;
|
||||
ViEAutoTestMain auto_test;
|
||||
|
||||
if(NSOrderedSame != [answerFile compare:@""])
|
||||
{
|
||||
char answerFileUTF8[1024] = "";
|
||||
strcpy(answerFileUTF8, (char*)[answerFileUTF8 UTF8]);
|
||||
autoTest.UseAnswerFile(answerFileUTF8);
|
||||
}
|
||||
|
||||
int success = autoTest.BeginOSIndependentTesting();
|
||||
result_ = auto_test.RunTests(argc_, argv_);
|
||||
|
||||
[pool release];
|
||||
return;
|
||||
}
|
||||
|
||||
- (int)result {
|
||||
return result_;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
|
||||
@@ -10,20 +10,19 @@
|
||||
|
||||
#include "vie_autotest_main.h"
|
||||
|
||||
#include "gflags/gflags.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "vie_autotest.h"
|
||||
#include "vie_autotest_window_manager_interface.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 kExtendedTest = "ViEExtendedIntegrationTest";
|
||||
static const std::string kApiTest = "ViEApiIntegrationTest";
|
||||
|
||||
ViEAutoTestMain::ViEAutoTestMain()
|
||||
: answers_(),
|
||||
answers_count_(0),
|
||||
use_answer_file_() {
|
||||
|
||||
ViEAutoTestMain::ViEAutoTestMain() {
|
||||
index_to_test_method_map_[1] = "RunsBaseTestWithoutErrors";
|
||||
index_to_test_method_map_[2] = "RunsCaptureTestWithoutErrors";
|
||||
index_to_test_method_map_[3] = "RunsCodecTestWithoutErrors";
|
||||
@@ -35,6 +34,27 @@ ViEAutoTestMain::ViEAutoTestMain()
|
||||
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 choice;
|
||||
std::string answer;
|
||||
@@ -44,7 +64,7 @@ int ViEAutoTestMain::AskUserForTestCase() {
|
||||
ViETest::Log("\t 0. Go back to previous menu.");
|
||||
|
||||
// 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;
|
||||
for (iterator = index_to_test_method_map_.begin();
|
||||
iterator != index_to_test_method_map_.end();
|
||||
@@ -62,11 +82,6 @@ int ViEAutoTestMain::AskUserForTestCase() {
|
||||
|
||||
int ViEAutoTestMain::AskUserForNumber(int min_allowed, int max_allowed) {
|
||||
int result;
|
||||
if (use_answer_file_) {
|
||||
assert(0 && "Answer files are not implemented");
|
||||
return kInvalidChoice;
|
||||
}
|
||||
|
||||
if (scanf("%d", &result) <= 0) {
|
||||
ViETest::Log("\nPlease enter a number instead, then hit enter.");
|
||||
getchar();
|
||||
@@ -113,7 +128,7 @@ int ViEAutoTestMain::RunSpecialTestCase(int choice) {
|
||||
ViEAutoTest vieAutoTest(windowManager->GetWindow1(),
|
||||
windowManager->GetWindow2());
|
||||
|
||||
int errors = 0;
|
||||
int errors;
|
||||
switch (choice) {
|
||||
case 7: errors = vieAutoTest.ViELoopbackCall(); break;
|
||||
case 8: errors = vieAutoTest.ViECustomCall(); break;
|
||||
@@ -124,8 +139,7 @@ int ViEAutoTestMain::RunSpecialTestCase(int choice) {
|
||||
return errors;
|
||||
}
|
||||
|
||||
bool ViEAutoTestMain::BeginOSIndependentTesting() {
|
||||
|
||||
bool ViEAutoTestMain::RunInteractiveMode() {
|
||||
ViETest::Log(" ============================== ");
|
||||
ViETest::Log(" WebRTC ViE 3.x Autotest ");
|
||||
ViETest::Log(" ============================== \n");
|
||||
@@ -172,47 +186,3 @@ bool ViEAutoTestMain::BeginOSIndependentTesting() {
|
||||
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_;
|
||||
*/
|
||||
}
|
||||
|
||||
460
src/video_engine/test/auto_test/source/vie_autotest_windows.cc
Normal file → Executable file
460
src/video_engine/test/auto_test/source/vie_autotest_windows.cc
Normal file → Executable file
@@ -1,246 +1,214 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
//
|
||||
// vie_autotest_windows.cc
|
||||
//
|
||||
|
||||
#include "vie_autotest_windows.h"
|
||||
|
||||
#include "vie_autotest_defines.h"
|
||||
#include "vie_autotest_main.h"
|
||||
|
||||
#include "engine_configurations.h"
|
||||
#include "critical_section_wrapper.h"
|
||||
#include "thread_wrapper.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#ifdef _DEBUG
|
||||
//#include "vld.h"
|
||||
#endif
|
||||
|
||||
// Disable Visual studio warnings
|
||||
// 'this' : used in base member initializer list
|
||||
#pragma warning(disable: 4355)
|
||||
// new behavior: elements of array 'XXX' will be default initialized
|
||||
#pragma warning(disable: 4351)
|
||||
|
||||
LRESULT CALLBACK ViEAutoTestWinProc(HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
LPARAM lParam)
|
||||
{
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage( WM_QUIT);
|
||||
break;
|
||||
case WM_COMMAND:
|
||||
break;
|
||||
}
|
||||
return DefWindowProc(hWnd, uMsg, wParam, lParam);
|
||||
}
|
||||
|
||||
ViEAutoTestWindowManager::ViEAutoTestWindowManager() :
|
||||
_window1(NULL),
|
||||
_window2(NULL),
|
||||
_terminate(false),
|
||||
_eventThread(*webrtc::ThreadWrapper::CreateThread(EventProcess, this,
|
||||
webrtc::kNormalPriority,
|
||||
"ViEAutotestEventThread")),
|
||||
_crit(*webrtc::CriticalSectionWrapper::CreateCriticalSection()),
|
||||
_hwnd1(NULL),
|
||||
_hwnd2(NULL),
|
||||
_hwnd1Size(),
|
||||
_hwnd2Size(),
|
||||
_hwnd1Title(),
|
||||
_hwnd2Title()
|
||||
{
|
||||
}
|
||||
|
||||
ViEAutoTestWindowManager::~ViEAutoTestWindowManager()
|
||||
{
|
||||
if (_hwnd1)
|
||||
{
|
||||
ViEDestroyWindow(_hwnd1);
|
||||
}
|
||||
if (_hwnd2)
|
||||
{
|
||||
ViEDestroyWindow(_hwnd1);
|
||||
}
|
||||
delete &_crit;
|
||||
}
|
||||
|
||||
void* ViEAutoTestWindowManager::GetWindow1()
|
||||
{
|
||||
return _window1;
|
||||
}
|
||||
|
||||
void* ViEAutoTestWindowManager::GetWindow2()
|
||||
{
|
||||
return _window2;
|
||||
}
|
||||
|
||||
int ViEAutoTestWindowManager::CreateWindows(AutoTestRect window1Size,
|
||||
AutoTestRect window2Size,
|
||||
void* window1Title,
|
||||
void* window2Title)
|
||||
{
|
||||
_hwnd1Size.Copy(window1Size);
|
||||
_hwnd2Size.Copy(window2Size);
|
||||
memcpy(_hwnd1Title, window1Title, TITLE_LENGTH);
|
||||
memcpy(_hwnd2Title, window2Title, TITLE_LENGTH);
|
||||
|
||||
unsigned int tId = 0;
|
||||
_eventThread.Start(tId);
|
||||
|
||||
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();
|
||||
|
||||
//ViECreateWindow(_hwnd1, 352, 288, 600, 100, "ViE Autotest Window 1");
|
||||
//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();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int ViEAutoTestWindowManager::ViECreateWindow(HWND &hwndMain, int xPos,
|
||||
int yPos, int width, int height,
|
||||
TCHAR* className)
|
||||
{
|
||||
HINSTANCE hinst = GetModuleHandle(0);
|
||||
WNDCLASSEX wcx;
|
||||
wcx.hInstance = hinst;
|
||||
wcx.lpszClassName = className;
|
||||
wcx.lpfnWndProc = (WNDPROC) ViEAutoTestWinProc;
|
||||
wcx.style = CS_DBLCLKS;
|
||||
wcx.hIcon = LoadIcon(NULL, IDI_APPLICATION);
|
||||
wcx.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
|
||||
wcx.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wcx.lpszMenuName = NULL;
|
||||
wcx.cbSize = sizeof(WNDCLASSEX);
|
||||
wcx.cbClsExtra = 0;
|
||||
wcx.cbWndExtra = 0;
|
||||
wcx.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
|
||||
|
||||
// Register our window class with the operating system.
|
||||
// If there is an error, exit program.
|
||||
ViETest::TestError(RegisterClassEx(&wcx) != NULL,
|
||||
"Could not register autotest window");
|
||||
|
||||
// Create the main window.
|
||||
hwndMain = CreateWindowEx(0, // no extended styles
|
||||
className, // class name
|
||||
className, // window name
|
||||
WS_OVERLAPPED | WS_THICKFRAME,// overlapped window
|
||||
xPos, // horizontal position
|
||||
yPos, // vertical position
|
||||
width, // width
|
||||
height, // height
|
||||
(HWND) NULL, // no parent or owner window
|
||||
(HMENU) NULL, // class menu used
|
||||
hinst, // instance handle
|
||||
NULL); // no window creation data
|
||||
|
||||
if (!hwndMain)
|
||||
{
|
||||
int error = GetLastError();
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Show the window using the flag specified by the program
|
||||
// that started the application, and send the application
|
||||
// a WM_PAINT message.
|
||||
|
||||
ShowWindow(hwndMain, SW_SHOWDEFAULT);
|
||||
UpdateWindow(hwndMain);
|
||||
|
||||
::SetWindowPos(hwndMain, HWND_TOP, xPos, yPos, width, height,
|
||||
SWP_FRAMECHANGED);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ViEAutoTestWindowManager::ViEDestroyWindow(HWND& hwnd)
|
||||
{
|
||||
::DestroyWindow(hwnd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool ViEAutoTestWindowManager::SetTopmostWindow()
|
||||
{
|
||||
// Meant to put terminal window on top
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
ViEAutoTestMain autoTest;
|
||||
if (argc > 1)
|
||||
{
|
||||
autoTest.UseAnswerFile(argv[1]);
|
||||
}
|
||||
return autoTest.BeginOSIndependentTesting();
|
||||
|
||||
}
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
//
|
||||
// vie_autotest_windows.cc
|
||||
//
|
||||
|
||||
#include "vie_autotest_windows.h"
|
||||
|
||||
#include "vie_autotest_defines.h"
|
||||
#include "vie_autotest_main.h"
|
||||
|
||||
#include "engine_configurations.h"
|
||||
#include "critical_section_wrapper.h"
|
||||
#include "thread_wrapper.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#ifdef _DEBUG
|
||||
//#include "vld.h"
|
||||
#endif
|
||||
|
||||
// Disable Visual studio warnings
|
||||
// 'this' : used in base member initializer list
|
||||
#pragma warning(disable: 4355)
|
||||
// new behavior: elements of array 'XXX' will be default initialized
|
||||
#pragma warning(disable: 4351)
|
||||
|
||||
LRESULT CALLBACK ViEAutoTestWinProc(HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
LPARAM lParam) {
|
||||
switch (uMsg) {
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage( WM_QUIT);
|
||||
break;
|
||||
case WM_COMMAND:
|
||||
break;
|
||||
}
|
||||
return DefWindowProc(hWnd, uMsg, wParam, lParam);
|
||||
}
|
||||
|
||||
ViEAutoTestWindowManager::ViEAutoTestWindowManager()
|
||||
: _window1(NULL),
|
||||
_window2(NULL),
|
||||
_terminate(false),
|
||||
_eventThread(*webrtc::ThreadWrapper::CreateThread(
|
||||
EventProcess, this, webrtc::kNormalPriority,
|
||||
"ViEAutotestEventThread")),
|
||||
_crit(*webrtc::CriticalSectionWrapper::CreateCriticalSection()),
|
||||
_hwnd1(NULL),
|
||||
_hwnd2(NULL),
|
||||
_hwnd1Size(),
|
||||
_hwnd2Size(),
|
||||
_hwnd1Title(),
|
||||
_hwnd2Title() {
|
||||
}
|
||||
|
||||
ViEAutoTestWindowManager::~ViEAutoTestWindowManager() {
|
||||
if (_hwnd1) {
|
||||
ViEDestroyWindow(_hwnd1);
|
||||
}
|
||||
if (_hwnd2) {
|
||||
ViEDestroyWindow(_hwnd1);
|
||||
}
|
||||
delete &_crit;
|
||||
}
|
||||
|
||||
void* ViEAutoTestWindowManager::GetWindow1() {
|
||||
return _window1;
|
||||
}
|
||||
|
||||
void* ViEAutoTestWindowManager::GetWindow2() {
|
||||
return _window2;
|
||||
}
|
||||
|
||||
int ViEAutoTestWindowManager::CreateWindows(AutoTestRect window1Size,
|
||||
AutoTestRect window2Size,
|
||||
void* window1Title,
|
||||
void* window2Title) {
|
||||
_hwnd1Size.Copy(window1Size);
|
||||
_hwnd2Size.Copy(window2Size);
|
||||
memcpy(_hwnd1Title, window1Title, TITLE_LENGTH);
|
||||
memcpy(_hwnd2Title, window2Title, TITLE_LENGTH);
|
||||
|
||||
unsigned int tId = 0;
|
||||
_eventThread.Start(tId);
|
||||
|
||||
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();
|
||||
|
||||
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 yPos, int width, int height,
|
||||
TCHAR* className) {
|
||||
HINSTANCE hinst = GetModuleHandle(0);
|
||||
WNDCLASSEX wcx;
|
||||
wcx.hInstance = hinst;
|
||||
wcx.lpszClassName = className;
|
||||
wcx.lpfnWndProc = (WNDPROC) ViEAutoTestWinProc;
|
||||
wcx.style = CS_DBLCLKS;
|
||||
wcx.hIcon = LoadIcon(NULL, IDI_APPLICATION);
|
||||
wcx.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
|
||||
wcx.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wcx.lpszMenuName = NULL;
|
||||
wcx.cbSize = sizeof(WNDCLASSEX);
|
||||
wcx.cbClsExtra = 0;
|
||||
wcx.cbWndExtra = 0;
|
||||
wcx.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
|
||||
|
||||
RegisterClassEx(&wcx);
|
||||
|
||||
// Create the main window.
|
||||
hwndMain = CreateWindowEx(0, // no extended styles
|
||||
className, // class name
|
||||
className, // window name
|
||||
WS_OVERLAPPED | WS_THICKFRAME, // overlapped window
|
||||
xPos, // horizontal position
|
||||
yPos, // vertical position
|
||||
width, // width
|
||||
height, // height
|
||||
(HWND) NULL, // no parent or owner window
|
||||
(HMENU) NULL, // class menu used
|
||||
hinst, // instance handle
|
||||
NULL); // no window creation data
|
||||
|
||||
if (!hwndMain) {
|
||||
int error = GetLastError();
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Show the window using the flag specified by the program
|
||||
// that started the application, and send the application
|
||||
// a WM_PAINT message.
|
||||
ShowWindow(hwndMain, SW_SHOWDEFAULT);
|
||||
UpdateWindow(hwndMain);
|
||||
|
||||
::SetWindowPos(hwndMain, HWND_TOP, xPos, yPos, width, height,
|
||||
SWP_FRAMECHANGED);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ViEAutoTestWindowManager::ViEDestroyWindow(HWND& hwnd) {
|
||||
::DestroyWindow(hwnd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool ViEAutoTestWindowManager::SetTopmostWindow() {
|
||||
// Meant to put terminal window on top
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
ViEAutoTestMain auto_test;
|
||||
return auto_test.RunTests(argc, argv);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user