Adding back platform specific renderer to video loopback test.
BUG=3039 TEST=locally on Mac and Win, video_loopback test R=pbos@webrtc.org Review URL: https://webrtc-codereview.appspot.com/10689004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@6339 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
0d523eea83
commit
eae7924836
@ -10,15 +10,20 @@
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "webrtc/test/run_test.h"
|
||||
|
||||
// Converting a C++ function pointer to an Objective-C block.
|
||||
typedef void(^TestBlock)();
|
||||
TestBlock functionToBlock(void(*function)()) {
|
||||
return [^(void) { function(); } copy];
|
||||
}
|
||||
|
||||
// Class calling the test function on the platform specific thread.
|
||||
@interface TestRunner : NSObject {
|
||||
BOOL running_;
|
||||
int testResult_;
|
||||
}
|
||||
- (void)runAllTests:(NSObject *)ignored;
|
||||
- (void)runAllTests:(TestBlock)ignored;
|
||||
- (BOOL)running;
|
||||
- (int)result;
|
||||
@end
|
||||
|
||||
@implementation TestRunner
|
||||
@ -30,9 +35,9 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)runAllTests:(NSObject *)ignored {
|
||||
- (void)runAllTests:(TestBlock)testBlock {
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
testResult_ = RUN_ALL_TESTS();
|
||||
testBlock();
|
||||
running_ = NO;
|
||||
[pool release];
|
||||
}
|
||||
@ -40,33 +45,30 @@
|
||||
- (BOOL)running {
|
||||
return running_;
|
||||
}
|
||||
|
||||
- (int)result {
|
||||
return testResult_;
|
||||
}
|
||||
@end
|
||||
|
||||
namespace webrtc {
|
||||
namespace test {
|
||||
|
||||
int RunAllTests() {
|
||||
void RunTest(void(*test)()) {
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
[NSApplication sharedApplication];
|
||||
|
||||
// Convert the function pointer to an Objective-C block and call on a
|
||||
// separate thread, to avoid blocking the main thread.
|
||||
TestRunner *testRunner = [[TestRunner alloc] init];
|
||||
TestBlock testBlock = functionToBlock(test);
|
||||
[NSThread detachNewThreadSelector:@selector(runAllTests:)
|
||||
toTarget:testRunner
|
||||
withObject:nil];
|
||||
withObject:testBlock];
|
||||
|
||||
NSRunLoop *runLoop = [NSRunLoop currentRunLoop];
|
||||
while ([testRunner running] &&
|
||||
[runLoop runMode:NSDefaultRunLoopMode
|
||||
beforeDate:[NSDate distantFuture]]);
|
||||
|
||||
int result = [testRunner result];
|
||||
[testRunner release];
|
||||
[pool release];
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace test
|
@ -7,13 +7,16 @@
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
#include "webrtc/test/run_test.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
namespace webrtc {
|
||||
namespace test {
|
||||
|
||||
int RunAllTests() {
|
||||
return RUN_ALL_TESTS();
|
||||
void RunTest(void(*test)()) {
|
||||
(*test)();
|
||||
}
|
||||
|
||||
} // namespace test
|
@ -7,19 +7,16 @@
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
#ifndef WEBRTC_VIDEO_ENGINE_TEST_COMMON_TEST_RUNNER_H_
|
||||
#define WEBRTC_VIDEO_ENGINE_TEST_COMMON_TEST_RUNNER_H_
|
||||
#ifndef WEBRTC_TEST_RUN_TEST_H
|
||||
#define WEBRTC_TEST_RUN_TEST_H
|
||||
|
||||
namespace webrtc {
|
||||
namespace test {
|
||||
|
||||
// Blocks until the user presses enter.
|
||||
void PressEnterToContinue();
|
||||
// Running a test function on a separate thread, if required by the OS.
|
||||
void RunTest(void(*test)());
|
||||
|
||||
// Performs platform-dependent initializations and calls gtest's
|
||||
// RUN_ALL_TESTS().
|
||||
int RunAllTests();
|
||||
} // namespace test
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_VIDEO_ENGINE_TEST_COMMON_TEST_RUNNER_H_
|
||||
#endif // WEBRTC_TEST_RUN_TEST_H
|
@ -11,7 +11,6 @@
|
||||
#include "gflags/gflags.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "webrtc/test/field_trial.h"
|
||||
#include "webrtc/test/run_tests.h"
|
||||
#include "webrtc/test/testsupport/fileutils.h"
|
||||
|
||||
DEFINE_string(force_fieldtrials, "",
|
||||
@ -29,5 +28,5 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
webrtc::test::SetExecutablePath(argv[0]);
|
||||
webrtc::test::InitFieldTrialsFromString(FLAGS_force_fieldtrials);
|
||||
return webrtc::test::RunAllTests();
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
@ -31,12 +31,9 @@
|
||||
'frame_generator_capturer.cc',
|
||||
'frame_generator_capturer.h',
|
||||
'mock_transport.h',
|
||||
'null_platform_renderer.cc',
|
||||
'null_transport.cc',
|
||||
'null_transport.h',
|
||||
'rtp_rtcp_observer.h',
|
||||
'run_tests.cc',
|
||||
'run_tests.h',
|
||||
'run_loop.cc',
|
||||
'run_loop.h',
|
||||
'statistics.cc',
|
||||
@ -45,12 +42,71 @@
|
||||
'vcm_capturer.h',
|
||||
'video_capturer.cc',
|
||||
'video_capturer.h',
|
||||
'win/run_loop_win.cc',
|
||||
],
|
||||
'conditions': [
|
||||
['OS=="win"', {
|
||||
'sources!': [
|
||||
'run_loop.cc',
|
||||
],
|
||||
}],
|
||||
],
|
||||
'dependencies': [
|
||||
'<(DEPTH)/testing/gtest.gyp:gtest',
|
||||
'<(DEPTH)/third_party/gflags/gflags.gyp:gflags',
|
||||
'<(webrtc_root)/modules/modules.gyp:video_capture_module',
|
||||
'<(webrtc_root)/modules/modules.gyp:media_file',
|
||||
'<(webrtc_root)/test/test.gyp:frame_generator',
|
||||
'<(webrtc_root)/test/test.gyp:test_support',
|
||||
],
|
||||
},
|
||||
{
|
||||
'target_name': 'webrtc_test_renderer',
|
||||
'type': 'static_library',
|
||||
'sources': [
|
||||
'gl/gl_renderer.cc',
|
||||
'gl/gl_renderer.h',
|
||||
'linux/glx_renderer.cc',
|
||||
'linux/glx_renderer.h',
|
||||
'linux/video_renderer_linux.cc',
|
||||
'mac/video_renderer_mac.h',
|
||||
'mac/video_renderer_mac.mm',
|
||||
'null_platform_renderer.cc',
|
||||
'video_renderer.cc',
|
||||
'video_renderer.h',
|
||||
'win/d3d_renderer.cc',
|
||||
'win/d3d_renderer.h',
|
||||
],
|
||||
'conditions': [
|
||||
['OS=="linux"', {
|
||||
'sources!': [
|
||||
'null_platform_renderer.cc',
|
||||
],
|
||||
}],
|
||||
['OS=="mac"', {
|
||||
'sources!': [
|
||||
'null_platform_renderer.cc',
|
||||
],
|
||||
}],
|
||||
['OS!="linux" and OS!="mac"', {
|
||||
'sources!' : [
|
||||
'gl/gl_renderer.cc',
|
||||
'gl/gl_renderer.h',
|
||||
],
|
||||
}],
|
||||
['OS=="win"', {
|
||||
'sources!': [
|
||||
'null_platform_renderer.cc',
|
||||
],
|
||||
}],
|
||||
],
|
||||
'dependencies': [
|
||||
'<(DEPTH)/testing/gtest.gyp:gtest',
|
||||
'<(webrtc_root)/modules/modules.gyp:video_capture_module',
|
||||
'<(webrtc_root)/modules/modules.gyp:media_file',
|
||||
'<(webrtc_root)/test/test.gyp:frame_generator',
|
||||
'<(webrtc_root)/test/test.gyp:test_support',
|
||||
],
|
||||
# TODO(pbos): As far as I can tell these are dependencies from
|
||||
# video_render and they should really not be here. This target provides
|
||||
# no platform-specific rendering.
|
||||
'direct_dependent_settings': {
|
||||
'conditions': [
|
||||
['OS=="linux"', {
|
||||
@ -68,25 +124,47 @@
|
||||
['OS=="mac"', {
|
||||
'xcode_settings' : {
|
||||
'OTHER_LDFLAGS' : [
|
||||
'-framework Foundation',
|
||||
'-framework AppKit',
|
||||
'-framework Cocoa',
|
||||
'-framework OpenGL',
|
||||
'-framework CoreVideo',
|
||||
'-framework CoreAudio',
|
||||
'-framework AudioToolbox',
|
||||
],
|
||||
},
|
||||
}],
|
||||
],
|
||||
},
|
||||
'dependencies': [
|
||||
'<(DEPTH)/testing/gtest.gyp:gtest',
|
||||
'<(webrtc_root)/modules/modules.gyp:video_capture_module',
|
||||
'<(webrtc_root)/modules/modules.gyp:media_file',
|
||||
'<(webrtc_root)/test/test.gyp:frame_generator',
|
||||
'<(webrtc_root)/test/test.gyp:test_support',
|
||||
},
|
||||
{
|
||||
# This target is only needed since the video render module builds platform
|
||||
# specific code and depends on these libraries. This target should be
|
||||
# removed as soon as the new video API doesn't depend on the module.
|
||||
# TODO(mflodman) Remove this target as described above.
|
||||
'target_name': 'webrtc_test_video_render_dependencies',
|
||||
'type': 'static_library',
|
||||
'direct_dependent_settings': {
|
||||
'conditions': [
|
||||
['OS=="linux"', {
|
||||
'libraries': [
|
||||
'-lXext',
|
||||
'-lX11',
|
||||
'-lGL',
|
||||
],
|
||||
}],
|
||||
['OS=="android"', {
|
||||
'libraries' : [
|
||||
'-lGLESv2', '-llog',
|
||||
],
|
||||
}],
|
||||
['OS=="mac"', {
|
||||
'xcode_settings' : {
|
||||
'OTHER_LDFLAGS' : [
|
||||
'-framework Cocoa',
|
||||
'-framework OpenGL',
|
||||
'-framework CoreVideo',
|
||||
],
|
||||
},
|
||||
}],
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
'conditions': [
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include "webrtc/test/encoder_settings.h"
|
||||
#include "webrtc/test/fake_encoder.h"
|
||||
#include "webrtc/test/run_loop.h"
|
||||
#include "webrtc/test/run_tests.h"
|
||||
#include "webrtc/test/run_test.h"
|
||||
#include "webrtc/test/video_capturer.h"
|
||||
#include "webrtc/test/video_renderer.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
@ -127,6 +127,6 @@ int main(int argc, char* argv[]) {
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
google::ParseCommandLineFlags(&argc, &argv, true);
|
||||
|
||||
webrtc::Loopback();
|
||||
webrtc::test::RunTest(webrtc::Loopback);
|
||||
return 0;
|
||||
}
|
||||
|
@ -20,12 +20,23 @@
|
||||
'target_name': 'video_loopback',
|
||||
'type': 'executable',
|
||||
'sources': [
|
||||
'test/mac/run_test.mm',
|
||||
'test/run_test.cc',
|
||||
'test/run_test.h',
|
||||
'video/loopback.cc',
|
||||
],
|
||||
'conditions': [
|
||||
['OS=="mac"', {
|
||||
'sources!': [
|
||||
'test/run_test.cc',
|
||||
],
|
||||
}],
|
||||
],
|
||||
'dependencies': [
|
||||
'<(DEPTH)/testing/gtest.gyp:gtest',
|
||||
'<(DEPTH)/third_party/gflags/gflags.gyp:gflags',
|
||||
'test/webrtc_test_common.gyp:webrtc_test_common',
|
||||
'test/webrtc_test_common.gyp:webrtc_test_renderer',
|
||||
'<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:field_trial_default',
|
||||
'webrtc',
|
||||
],
|
||||
@ -47,6 +58,7 @@
|
||||
'test/metrics.gyp:metrics',
|
||||
'test/webrtc_test_common.gyp:webrtc_test_common',
|
||||
'test/test.gyp:test_main',
|
||||
'test/webrtc_test_common.gyp:webrtc_test_video_render_dependencies',
|
||||
'webrtc',
|
||||
],
|
||||
'conditions': [
|
||||
@ -74,6 +86,7 @@
|
||||
'modules/modules.gyp:rtp_rtcp',
|
||||
'test/webrtc_test_common.gyp:webrtc_test_common',
|
||||
'test/test.gyp:test_main',
|
||||
'test/webrtc_test_common.gyp:webrtc_test_video_render_dependencies',
|
||||
'webrtc',
|
||||
],
|
||||
'conditions': [
|
||||
|
Loading…
Reference in New Issue
Block a user