mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 00:03:03 +04:00
Adding test support for WINRT
This commit is contained in:
@@ -4054,7 +4054,7 @@ enum GTestColor {
|
||||
COLOR_YELLOW
|
||||
};
|
||||
|
||||
#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE
|
||||
#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE && !defined WINRT
|
||||
|
||||
// Returns the character attribute for the given color.
|
||||
WORD GetColorAttribute(GTestColor color) {
|
||||
@@ -4122,7 +4122,7 @@ static void ColoredPrintf(GTestColor color, const char* fmt, ...) {
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
|
||||
#if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_SYMBIAN || GTEST_OS_ZOS || GTEST_OS_IOS
|
||||
#if GTEST_OS_WINDOWS_MOBILE || WINRT || GTEST_OS_SYMBIAN || GTEST_OS_ZOS || GTEST_OS_IOS
|
||||
const bool use_color = false;
|
||||
#else
|
||||
static const bool in_color_mode =
|
||||
@@ -4137,7 +4137,7 @@ static void ColoredPrintf(GTestColor color, const char* fmt, ...) {
|
||||
return;
|
||||
}
|
||||
|
||||
#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE
|
||||
#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE && !defined WINRT
|
||||
const HANDLE stdout_handle = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
|
||||
// Gets the current text color.
|
||||
@@ -5320,7 +5320,7 @@ void UnitTest::AddTestPartResult(
|
||||
// with another testing framework) and specify the former on the
|
||||
// command line for debugging.
|
||||
if (GTEST_FLAG(break_on_failure)) {
|
||||
#if GTEST_OS_WINDOWS
|
||||
#if GTEST_OS_WINDOWS && !defined WINRT
|
||||
// Using DebugBreak on Windows allows gtest to still break into a debugger
|
||||
// when a failure happens and both the --gtest_break_on_failure and
|
||||
// the --gtest_catch_exceptions flags are specified.
|
||||
@@ -5398,7 +5398,7 @@ int UnitTest::Run() {
|
||||
// process. In either case the user does not want to see pop-up dialogs
|
||||
// about crashes - they are expected.
|
||||
if (impl()->catch_exceptions() || in_death_test_child_process) {
|
||||
# if !GTEST_OS_WINDOWS_MOBILE
|
||||
# if !GTEST_OS_WINDOWS_MOBILE && !defined WINRT
|
||||
// SetErrorMode doesn't exist on CE.
|
||||
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOALIGNMENTFAULTEXCEPT |
|
||||
SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX);
|
||||
@@ -7110,6 +7110,7 @@ bool DeathTestImpl::Passed(bool status_ok) {
|
||||
}
|
||||
|
||||
# if GTEST_OS_WINDOWS
|
||||
#ifndef WINRT
|
||||
// WindowsDeathTest implements death tests on Windows. Due to the
|
||||
// specifics of starting new processes on Windows, death tests there are
|
||||
// always threadsafe, and Google Test considers the
|
||||
@@ -7301,6 +7302,7 @@ DeathTest::TestRole WindowsDeathTest::AssumeRole() {
|
||||
set_spawned(true);
|
||||
return OVERSEE_TEST;
|
||||
}
|
||||
#endif
|
||||
# else // We are not on Windows.
|
||||
|
||||
// ForkingDeathTest provides implementations for most of the abstract
|
||||
@@ -7711,10 +7713,14 @@ bool DefaultDeathTestFactory::Create(const char* statement, const RE* regex,
|
||||
}
|
||||
|
||||
# if GTEST_OS_WINDOWS
|
||||
|
||||
if (GTEST_FLAG(death_test_style) == "threadsafe" ||
|
||||
GTEST_FLAG(death_test_style) == "fast") {
|
||||
#ifndef WINRT
|
||||
*test = new WindowsDeathTest(statement, regex, file, line);
|
||||
#else
|
||||
printf("DeathTest is not supported on winrt!\n");
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
# else
|
||||
@@ -7758,6 +7764,7 @@ static void SplitString(const ::std::string& str, char delimiter,
|
||||
}
|
||||
|
||||
# if GTEST_OS_WINDOWS
|
||||
#ifndef WINRT
|
||||
// Recreates the pipe and event handles from the provided parameters,
|
||||
// signals the event, and returns a file descriptor wrapped around the pipe
|
||||
// handle. This function is called in the child process only.
|
||||
@@ -7823,6 +7830,7 @@ int GetStatusFileDescriptor(unsigned int parent_process_id,
|
||||
|
||||
return write_fd;
|
||||
}
|
||||
#endif
|
||||
# endif // GTEST_OS_WINDOWS
|
||||
|
||||
// Returns a newly created InternalRunDeathTestFlag object with fields
|
||||
@@ -7840,7 +7848,7 @@ InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag() {
|
||||
int write_fd = -1;
|
||||
|
||||
# if GTEST_OS_WINDOWS
|
||||
|
||||
#ifndef WINRT
|
||||
unsigned int parent_process_id = 0;
|
||||
size_t write_handle_as_size_t = 0;
|
||||
size_t event_handle_as_size_t = 0;
|
||||
@@ -7857,6 +7865,7 @@ InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag() {
|
||||
write_fd = GetStatusFileDescriptor(parent_process_id,
|
||||
write_handle_as_size_t,
|
||||
event_handle_as_size_t);
|
||||
#endif
|
||||
# else
|
||||
|
||||
if (fields.size() != 4
|
||||
@@ -7974,7 +7983,7 @@ static bool IsPathSeparator(char c) {
|
||||
|
||||
// Returns the current working directory, or "" if unsuccessful.
|
||||
FilePath FilePath::GetCurrentDir() {
|
||||
#if GTEST_OS_WINDOWS_MOBILE
|
||||
#if GTEST_OS_WINDOWS_MOBILE || WINRT
|
||||
// Windows CE doesn't have a current directory, so we just return
|
||||
// something reasonable.
|
||||
return FilePath(kCurrentDirectoryString);
|
||||
@@ -8765,6 +8774,7 @@ class CapturedStream {
|
||||
public:
|
||||
// The ctor redirects the stream to a temporary file.
|
||||
explicit CapturedStream(int fd) : fd_(fd), uncaptured_fd_(dup(fd)) {
|
||||
#ifndef WINRT
|
||||
# if GTEST_OS_WINDOWS
|
||||
char temp_dir_path[MAX_PATH + 1] = { '\0' }; // NOLINT
|
||||
char temp_file_path[MAX_PATH + 1] = { '\0' }; // NOLINT
|
||||
@@ -8810,6 +8820,7 @@ class CapturedStream {
|
||||
fflush(NULL);
|
||||
dup2(captured_fd, fd_);
|
||||
close(captured_fd);
|
||||
#endif
|
||||
}
|
||||
|
||||
~CapturedStream() {
|
||||
|
||||
Reference in New Issue
Block a user