-
Notifications
You must be signed in to change notification settings - Fork 804
Fix drawing tests for the new TAEF world and fix OS X tests. #1948
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,21 @@ | |
| #import "CGContextInternal.h" | ||
| #endif | ||
|
|
||
| #ifdef TARGET_OS_MAC | ||
| #define LOG_TEST_FILE(...) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no record property?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nah, not necessary to record the property in an xml file we don't generate for a platform we don't want to diff on :)
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fair. Would be useful to move this macro to TestFramework for the benefit of other tests? In reply to: 100652177 [](ancestors = 100652177) |
||
| #else | ||
| #define LOG_TEST_FILE(...) WEX::Logging::Log::File(__VA_ARGS__) | ||
| std::wstring _CFStringToWString(CFStringRef string) { | ||
| const UniChar* characters16 = CFStringGetCharactersPtr(string); | ||
| if (characters16) { | ||
| return {characters16, characters16 + CFStringGetLength(string)}; | ||
| } | ||
|
|
||
| static std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter; | ||
| return converter.from_bytes(CFStringGetCStringPtr(string, kCFStringEncodingUTF8)); | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add a newline before this guy? I was confused what the log test thing did until I realized this was separate. |
||
| #endif | ||
|
|
||
| static const CGSize g_defaultCanvasSize{ 512.f, 256.f }; | ||
|
|
||
| template <typename TComparator> | ||
|
|
@@ -34,7 +49,7 @@ CGSize testing::DrawTest<TComparator>::CanvasSize() { | |
| } | ||
|
|
||
| template <typename TComparator> | ||
| void testing::DrawTest<TComparator>::SetUp() { | ||
| void testing::DrawTest<TComparator>::PreDraw() { | ||
| CGSize size = CanvasSize(); | ||
|
|
||
| auto deviceColorSpace = woc::MakeStrongCF<CGColorSpaceRef>(CGColorSpaceCreateDeviceRGB()); | ||
|
|
@@ -69,7 +84,7 @@ CFStringRef testing::DrawTest<TComparator>::CreateOutputFilename() { | |
| } | ||
|
|
||
| template <typename TComparator> | ||
| void testing::DrawTest<TComparator>::TearDown() { | ||
| void testing::DrawTest<TComparator>::PostDraw() { | ||
| CGContextRef context = GetDrawingContext(); | ||
|
|
||
| #if WINOBJC // Validate that the results are correct even under batched drawing from _CGContextPushBegin/PopEndDraw | ||
|
|
@@ -133,10 +148,12 @@ void testing::DrawTest<TComparator>::TearDown() { | |
|
|
||
| _WriteCFDataToFile(encodedDeltaImageData.get(), deltaFilename.get()); | ||
|
|
||
| LOG_TEST_PROPERTY("expectedImage", CFStringGetCStringPtr(referenceFilename.get(), kCFStringEncodingUTF8)); | ||
| LOG_TEST_PROPERTY("actualImage", CFStringGetCStringPtr(outputPath.get(), kCFStringEncodingUTF8)); | ||
| LOG_TEST_PROPERTY("deltaImage", CFStringGetCStringPtr(deltaFilename.get(), kCFStringEncodingUTF8)); | ||
| LOG_TEST_FILE(_CFStringToWString(referenceFilename).c_str()); | ||
| LOG_TEST_FILE(_CFStringToWString(outputPath).c_str()); | ||
| LOG_TEST_FILE(_CFStringToWString(deltaFilename).c_str()); | ||
| } | ||
| } else if (drawingConfig->GetMode() == DrawingTestMode::Generate) { | ||
| LOG_TEST_FILE(_CFStringToWString(outputPath).c_str()); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -150,6 +167,11 @@ void testing::DrawTest<TComparator>::TestBody() { | |
| // Nothing. | ||
| } | ||
|
|
||
| template <typename TComparator> | ||
| void testing::DrawTest<TComparator>::Draw() { | ||
| // Nothing. | ||
| } | ||
|
|
||
| template <typename TComparator> | ||
| CGContextRef testing::DrawTest<TComparator>::GetDrawingContext() { | ||
| return _context.get(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1377,9 +1377,9 @@ internal::CartesianProductHolder10<Generator1, Generator2, Generator3, | |
|
|
||
|
|
||
|
|
||
| # define TEST_P(test_case_name, test_name) \ | ||
| # define GTEST_TEST_P_(test_case_name, test_name, test_fixture_name) \ | ||
| class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \ | ||
| : public test_case_name { \ | ||
| : public test_fixture_name { \ | ||
| public: \ | ||
| GTEST_TEST_CLASS_NAME_(test_case_name, test_name)() {} \ | ||
| virtual void TestBody(); \ | ||
|
|
@@ -1406,6 +1406,8 @@ internal::CartesianProductHolder10<Generator1, Generator2, Generator3, | |
| GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::AddToRegistry(); \ | ||
| void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody() | ||
|
|
||
| # define TEST_P(test_case_name, test_name) GTEST_TEST_P_(test_case_name, test_name, test_case_name) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Just so I understand this, you are modifying the gtest api to have another level of indirection here so we can do the interstitial doodad?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yep!
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thank you |
||
|
|
||
| // The optional last argument to INSTANTIATE_TEST_CASE_P allows the user | ||
| // to specify a function or functor that generates custom test name suffixes | ||
| // based on the test parameters. The function should accept one argument of | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,8 +20,19 @@ | |
| #include <Foundation/Foundation.h> | ||
| #endif | ||
|
|
||
| #ifndef IF_NOT_EXISTS_BEGIN | ||
| #ifdef _MSC_VER | ||
| #define IF_NOT_EXISTS_BEGIN(name) __if_not_exists(name) { | ||
| #define IF_NOT_EXISTS_END } | ||
| #else | ||
| #define IF_NOT_EXISTS_BEGIN(name) | ||
| #define IF_NOT_EXISTS_END | ||
| #endif | ||
| #endif | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. solid. |
||
|
|
||
| #if TARGET_OS_MAC | ||
| #include "gtest-api.h" | ||
| #include <mach-o/dyld.h> | ||
| #else | ||
| #include "test-api.h" | ||
| #endif | ||
|
|
@@ -229,23 +240,23 @@ class ObjCTest : public ::testing::Test { | |
| #define boolean Boolean | ||
| #endif | ||
|
|
||
| __if_not_exists(GetCurrentTestDirectory) { | ||
| IF_NOT_EXISTS_BEGIN(GetCurrentTestDirectory) | ||
| static std::string GetCurrentTestDirectory() { | ||
| std::string tempBuffer; | ||
| uint32_t maxPath = _MAX_PATH; | ||
| uint32_t maxPath = PATH_MAX; | ||
| tempBuffer.resize(maxPath); | ||
| _NSGetExecutablePath(&tempBuffer[0], &maxPath); | ||
| return tempBuffer.substr(0, tempBuffer.find_last_of('/')).c_str(); | ||
| } | ||
| } | ||
| IF_NOT_EXISTS_END | ||
|
|
||
| __if_not_exists(GetTestFullName) { | ||
| IF_NOT_EXISTS_BEGIN(GetTestFullName) | ||
| static std::string GetTestFullName() { | ||
| return std::string(::testing::UnitTest::GetInstance()->current_test_info()->test_case_name()) + "." + | ||
| ::testing::UnitTest::GetInstance()->current_test_info()->name(); | ||
| } | ||
| } | ||
| IF_NOT_EXISTS_END | ||
|
|
||
| #ifndef LOG_TEST_PROPERTY | ||
| #define LOG_TEST_PROPERTY(key, value) RecordProperty(key, value) | ||
| #endif | ||
| #endif | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! much cleaner.