From 6b6d0bbbc06bad4180968c5063b7ac96001bb2aa Mon Sep 17 00:00:00 2001 From: Yichen Yao Date: Mon, 9 Sep 2019 12:18:20 -0700 Subject: [PATCH] Put desktop unit tests into namespaces. (#3098) * Put desktop unit tests into namespaces. * Change files * Small fix for position of "clang-format on" --- ...2019-09-06-16-42-33-AddNamespaceToUts.json | 8 + vnext/Desktop.ABITests/MemoryTrackerTests.cpp | 123 +++---- .../AsyncStorageManagerTest.cpp | 8 + vnext/Desktop.UnitTests/AsyncStorageTest.cpp | 4 + .../Desktop.UnitTests/BaseWebSocketTests.cpp | 162 +++++----- vnext/Desktop.UnitTests/BytecodeUnitTests.cpp | 4 + .../LayoutAnimationTests.cpp | 305 +++++++++--------- .../MemoryMappedBufferTests.cpp | 4 + .../StringConversionTest_Desktop.cpp | 4 + .../Desktop.UnitTests/UIManagerModuleTest.cpp | 4 + .../UnicodeConversionTest.cpp | 4 + .../Desktop.UnitTests/UnicodeTestStrings.cpp | 4 + vnext/Desktop.UnitTests/UnicodeTestStrings.h | 4 + vnext/Desktop.UnitTests/UtilsTest.cpp | 175 +++++----- .../WebSocketJSExecutorTest.cpp | 22 +- .../Desktop.UnitTests/WebSocketModuleTest.cpp | 4 + vnext/Desktop.UnitTests/WebSocketTest.cpp | 85 ++--- 17 files changed, 515 insertions(+), 409 deletions(-) create mode 100644 change/react-native-windows-2019-09-06-16-42-33-AddNamespaceToUts.json diff --git a/change/react-native-windows-2019-09-06-16-42-33-AddNamespaceToUts.json b/change/react-native-windows-2019-09-06-16-42-33-AddNamespaceToUts.json new file mode 100644 index 0000000000..a2327716e7 --- /dev/null +++ b/change/react-native-windows-2019-09-06-16-42-33-AddNamespaceToUts.json @@ -0,0 +1,8 @@ +{ + "type": "prerelease", + "comment": "Put desktop unit tests into namespaces.", + "packageName": "react-native-windows", + "email": "yicyao@microsoft.com", + "commit": "376450bff685ade93b719d1ba5cd0d8d290eefb2", + "date": "2019-09-06T23:42:33.841Z" +} \ No newline at end of file diff --git a/vnext/Desktop.ABITests/MemoryTrackerTests.cpp b/vnext/Desktop.ABITests/MemoryTrackerTests.cpp index 194f8822c7..b939f2ef0c 100644 --- a/vnext/Desktop.ABITests/MemoryTrackerTests.cpp +++ b/vnext/Desktop.ABITests/MemoryTrackerTests.cpp @@ -13,82 +13,87 @@ using namespace winrt::facebook::react; namespace ABITests { -TEST_CLASS(MemoryTrackerTests){ +// We turn clang format off here because it does not work with some of the +// test macros. +// clang-format off - TEST_METHOD(Handler_AddedAndRemoved){ - init_apartment(winrt::apartment_type::single_threaded); -IMessageQueue callbackMessageQueue = ::winrt::make(); -MemoryTracker tracker{callbackMessageQueue}; +TEST_CLASS(MemoryTrackerTests) { -uint32_t registrationToken = tracker.AddThresholdHandler( - /* threshold */ 100, - /* minCallbackIntervalInMilliseconds */ 100, - [](uint64_t currentUsage) {}); -Assert::IsTrue(tracker.RemoveThresholdHandler(registrationToken)); -} // namespace ABITests + TEST_METHOD(Handler_AddedAndRemoved){ + init_apartment(winrt::apartment_type::single_threaded); + IMessageQueue callbackMessageQueue = ::winrt::make(); + MemoryTracker tracker{callbackMessageQueue}; -TEST_METHOD(CurrentMemoryUsage_ReturnsInitialValue) { - init_apartment(winrt::apartment_type::single_threaded); - IMessageQueue callbackMessageQueue = ::winrt::make(); - MemoryTracker tracker{callbackMessageQueue}; + uint32_t registrationToken = tracker.AddThresholdHandler( + /* threshold */ 100, + /* minCallbackIntervalInMilliseconds */ 100, + [](uint64_t currentUsage) {}); + Assert::IsTrue(tracker.RemoveThresholdHandler(registrationToken)); + } - tracker.Initialize(1000); - Assert::AreEqual( - 1000ull, tracker.CurrentMemoryUsage(), L"CurrentMemoryUsage"); -} + TEST_METHOD(CurrentMemoryUsage_ReturnsInitialValue) { + init_apartment(winrt::apartment_type::single_threaded); + IMessageQueue callbackMessageQueue = ::winrt::make(); + MemoryTracker tracker{callbackMessageQueue}; -TEST_METHOD(PeakMemoryUsage_ReturnsInitialValue) { - init_apartment(winrt::apartment_type::single_threaded); - IMessageQueue callbackMessageQueue = ::winrt::make(); - MemoryTracker tracker{callbackMessageQueue}; + tracker.Initialize(1000); + Assert::AreEqual( + 1000ull, tracker.CurrentMemoryUsage(), L"CurrentMemoryUsage"); + } - tracker.Initialize(1000); - Assert::AreEqual(1000ull, tracker.PeakMemoryUsage(), L"PeakMemoryUsage"); -} + TEST_METHOD(PeakMemoryUsage_ReturnsInitialValue) { + init_apartment(winrt::apartment_type::single_threaded); + IMessageQueue callbackMessageQueue = ::winrt::make(); + MemoryTracker tracker{callbackMessageQueue}; -TEST_METHOD(ThresholdHandler_Called) { - init_apartment(winrt::apartment_type::single_threaded); + tracker.Initialize(1000); + Assert::AreEqual(1000ull, tracker.PeakMemoryUsage(), L"PeakMemoryUsage"); + } - DWORD testThreadId = GetCurrentThreadId(); + TEST_METHOD(ThresholdHandler_Called) { + init_apartment(winrt::apartment_type::single_threaded); - auto manualMessageQueue = std::make_shared( - ControllableMessageQueueThread::Mode::ManualDispatch); + DWORD testThreadId = GetCurrentThreadId(); - IMessageQueue callbackMessageQueue = - ::winrt::make(manualMessageQueue); - MemoryTracker tracker{callbackMessageQueue}; + auto manualMessageQueue = std::make_shared( + ControllableMessageQueueThread::Mode::ManualDispatch); - tracker.Initialize(500); + IMessageQueue callbackMessageQueue = + ::winrt::make(manualMessageQueue); + MemoryTracker tracker{callbackMessageQueue}; - std::vector actualCallbacks; - DWORD callbackThreadId; - uint32_t registrationToken = tracker.AddThresholdHandler( - /* threshold */ 1000, - /* minCallbackIntervalInMilliseconds */ 100, - [&actualCallbacks, &callbackThreadId](uint64_t currentUsage) { - actualCallbacks.push_back(currentUsage); - callbackThreadId = GetCurrentThreadId(); - }); + tracker.Initialize(500); - tracker.OnAllocation(1000); + std::vector actualCallbacks; + DWORD callbackThreadId; + uint32_t registrationToken = tracker.AddThresholdHandler( + /* threshold */ 1000, + /* minCallbackIntervalInMilliseconds */ 100, + [&actualCallbacks, &callbackThreadId](uint64_t currentUsage) { + actualCallbacks.push_back(currentUsage); + callbackThreadId = GetCurrentThreadId(); + }); - // allow the callback to get dispatched - Assert::IsTrue( - manualMessageQueue->DispatchOne(std::chrono::milliseconds(500))); - Assert::IsTrue(manualMessageQueue->IsEmpty()); + tracker.OnAllocation(1000); - Assert::AreEqual( - 1500ull, tracker.CurrentMemoryUsage(), L"CurrentMemoryUsage"); - Assert::AreEqual(1500ull, tracker.PeakMemoryUsage(), L"PeakMemoryUsage"); + // allow the callback to get dispatched + Assert::IsTrue( + manualMessageQueue->DispatchOne(std::chrono::milliseconds(500))); + Assert::IsTrue(manualMessageQueue->IsEmpty()); - Assert::AreEqual(static_cast(1), actualCallbacks.size()); - Assert::AreEqual(1500ull, actualCallbacks[0]); + Assert::AreEqual( + 1500ull, tracker.CurrentMemoryUsage(), L"CurrentMemoryUsage"); + Assert::AreEqual(1500ull, tracker.PeakMemoryUsage(), L"PeakMemoryUsage"); - Assert::AreNotEqual(testThreadId, callbackThreadId); + Assert::AreEqual(static_cast(1), actualCallbacks.size()); + Assert::AreEqual(1500ull, actualCallbacks[0]); - Assert::IsTrue(tracker.RemoveThresholdHandler(registrationToken)); -} -} -; + Assert::AreNotEqual(testThreadId, callbackThreadId); + + Assert::IsTrue(tracker.RemoveThresholdHandler(registrationToken)); + } +}; + +// clange-format on } // namespace ABITests diff --git a/vnext/Desktop.UnitTests/AsyncStorageManagerTest.cpp b/vnext/Desktop.UnitTests/AsyncStorageManagerTest.cpp index fc65aaf86e..1d270b0103 100644 --- a/vnext/Desktop.UnitTests/AsyncStorageManagerTest.cpp +++ b/vnext/Desktop.UnitTests/AsyncStorageManagerTest.cpp @@ -14,6 +14,8 @@ using namespace facebook::react; using namespace Microsoft::VisualStudio::CppUnitTestFramework; +namespace { + std::vector returnedValues; std::condition_variable_any cv; std::recursive_mutex m; @@ -55,6 +57,10 @@ void throwLastErrorMessage() { throw std::exception(errorMessageBuffer); } +} // namespace + +namespace Microsoft::React::Test { + TEST_CLASS(AsyncStorageManagerTest) { const WCHAR *m_storageFileName = L"testdomain"; @@ -266,3 +272,5 @@ TEST_CLASS(AsyncStorageManagerTest) { lock.unlock(); } }; + +} // namespace Microsoft::React::Test diff --git a/vnext/Desktop.UnitTests/AsyncStorageTest.cpp b/vnext/Desktop.UnitTests/AsyncStorageTest.cpp index 1740a3e897..75b7adee3d 100644 --- a/vnext/Desktop.UnitTests/AsyncStorageTest.cpp +++ b/vnext/Desktop.UnitTests/AsyncStorageTest.cpp @@ -8540,6 +8540,8 @@ KVPair NewLinesAndBackSlashes = { using namespace facebook::react; using namespace Microsoft::VisualStudio::CppUnitTestFramework; +namespace Microsoft::React::Test { + TEST_CLASS(AsyncStorageTest) { public: const WCHAR *m_storageFileName = L"testdomain"; @@ -8825,3 +8827,5 @@ TEST_CLASS(AsyncStorageTest) { kvStorage->clear(); } }; + +} // namespace Microsoft::React::Test diff --git a/vnext/Desktop.UnitTests/BaseWebSocketTests.cpp b/vnext/Desktop.UnitTests/BaseWebSocketTests.cpp index b6bb924379..4291160b74 100644 --- a/vnext/Desktop.UnitTests/BaseWebSocketTests.cpp +++ b/vnext/Desktop.UnitTests/BaseWebSocketTests.cpp @@ -16,99 +16,109 @@ using std::make_unique; using std::promise; using std::string; +namespace Microsoft::React::Test { + using CloseCode = IWebSocket::CloseCode; using Error = IWebSocket::Error; +// We turn clang format off here because it does not work with some of the +// test macros. +// clang-format off + TEST_CLASS(BaseWebSocketTest){ - BEGIN_TEST_CLASS_ATTRIBUTE() TEST_CLASS_ATTRIBUTE(L"Ignore", L"true") - END_TEST_CLASS_ATTRIBUTE() + BEGIN_TEST_CLASS_ATTRIBUTE() + TEST_CLASS_ATTRIBUTE(L"Ignore", L"true") + END_TEST_CLASS_ATTRIBUTE() - TEST_METHOD(CreateAndSetHandlers){ - auto ws = make_unique(Url("ws://localhost")); + TEST_METHOD(CreateAndSetHandlers){ + auto ws = make_unique(Url("ws://localhost")); -Assert::IsFalse(nullptr == ws); -ws->SetOnConnect([]() {}); -ws->SetOnPing([]() {}); -ws->SetOnSend([](size_t length) {}); -ws->SetOnMessage([](size_t length, const string &buffer) {}); -ws->SetOnClose([](CloseCode, const string &) {}); -ws->SetOnError([](const Error &error) {}); -} + Assert::IsFalse(nullptr == ws); + ws->SetOnConnect([]() {}); + ws->SetOnPing([]() {}); + ws->SetOnSend([](size_t length) {}); + ws->SetOnMessage([](size_t length, const string &buffer) {}); + ws->SetOnClose([](CloseCode, const string &) {}); + ws->SetOnError([](const Error &error) {}); + } -TEST_METHOD(ConnectSucceeds) { - string errorMessage; - bool connected = false; - auto ws = make_unique(Url("ws://localhost")); - ws->SetOnError([&errorMessage](Error err) { errorMessage = err.Message; }); - ws->SetOnConnect([&connected]() { connected = true; }); + TEST_METHOD(ConnectSucceeds) { + string errorMessage; + bool connected = false; + auto ws = make_unique(Url("ws://localhost")); + ws->SetOnError([&errorMessage](Error err) { errorMessage = err.Message; }); + ws->SetOnConnect([&connected]() { connected = true; }); - ws->Connect({}, {}); - ws->Close(CloseCode::Normal, {}); + ws->Connect({}, {}); + ws->Close(CloseCode::Normal, {}); - Assert::AreEqual({}, errorMessage); - Assert::IsTrue(connected); -} + Assert::AreEqual({}, errorMessage); + Assert::IsTrue(connected); + } -TEST_METHOD(ConnectFails) { - string errorMessage; - bool connected = false; - auto ws = make_unique(Url("ws://localhost")); - ws->SetOnError([&errorMessage](Error err) { errorMessage = err.Message; }); - ws->SetOnConnect([&connected]() { connected = true; }); - ws->SetConnectResult([]() -> error_code { - return make_error_code(errc::state_not_recoverable); - }); + TEST_METHOD(ConnectFails) { + string errorMessage; + bool connected = false; + auto ws = make_unique(Url("ws://localhost")); + ws->SetOnError([&errorMessage](Error err) { errorMessage = err.Message; }); + ws->SetOnConnect([&connected]() { connected = true; }); + ws->SetConnectResult([]() -> error_code { + return make_error_code(errc::state_not_recoverable); + }); - ws->Connect({}, {}); - ws->Close(CloseCode::Normal, {}); + ws->Connect({}, {}); + ws->Close(CloseCode::Normal, {}); - Assert::AreNotEqual({}, errorMessage); - Assert::IsFalse(connected); -} + Assert::AreNotEqual({}, errorMessage); + Assert::IsFalse(connected); + } -BEGIN_TEST_METHOD_ATTRIBUTE(HandshakeFails) -TEST_IGNORE() -END_TEST_METHOD_ATTRIBUTE() -TEST_METHOD(HandshakeFails) { - string errorMessage; - bool connected = false; - auto ws = make_unique(Url("ws://localhost")); - ws->SetOnError([&errorMessage](Error err) { errorMessage = err.Message; }); - ws->SetOnConnect([&connected]() { connected = true; }); - ws->SetHandshakeResult([](string, string) -> error_code { - return make_error_code(errc::state_not_recoverable); - }); + BEGIN_TEST_METHOD_ATTRIBUTE(HandshakeFails) + TEST_IGNORE() + END_TEST_METHOD_ATTRIBUTE() + TEST_METHOD(HandshakeFails) { + string errorMessage; + bool connected = false; + auto ws = make_unique(Url("ws://localhost")); + ws->SetOnError([&errorMessage](Error err) { errorMessage = err.Message; }); + ws->SetOnConnect([&connected]() { connected = true; }); + ws->SetHandshakeResult([](string, string) -> error_code { + return make_error_code(errc::state_not_recoverable); + }); - ws->Connect({}, {}); - ws->Close(CloseCode::Normal, {}); + ws->Connect({}, {}); + ws->Close(CloseCode::Normal, {}); - Assert::AreNotEqual({}, errorMessage); - Assert::IsFalse(connected); -} + Assert::AreNotEqual({}, errorMessage); + Assert::IsFalse(connected); + } -BEGIN_TEST_METHOD_ATTRIBUTE(CloseSucceeds) -TEST_IGNORE() -END_TEST_METHOD_ATTRIBUTE() -TEST_METHOD(CloseSucceeds) { - string errorMessage; - promise connected; - bool closed = false; - auto ws = make_unique(Url("ws://localhost")); - ws->SetOnError([&errorMessage](Error err) { errorMessage = err.Message; }); - ws->SetOnConnect([&connected]() { connected.set_value(); }); - ws->SetOnClose( - [&closed](CloseCode code, const string &message) { closed = true; }); + BEGIN_TEST_METHOD_ATTRIBUTE(CloseSucceeds) + TEST_IGNORE() + END_TEST_METHOD_ATTRIBUTE() + TEST_METHOD(CloseSucceeds) { + string errorMessage; + promise connected; + bool closed = false; + auto ws = make_unique(Url("ws://localhost")); + ws->SetOnError([&errorMessage](Error err) { errorMessage = err.Message; }); + ws->SetOnConnect([&connected]() { connected.set_value(); }); + ws->SetOnClose( + [&closed](CloseCode code, const string &message) { closed = true; }); - ws->SetCloseResult( - []() -> error_code { return make_error_code(errc::success); }); + ws->SetCloseResult( + []() -> error_code { return make_error_code(errc::success); }); - ws->Connect({}, {}); - connected.get_future().wait(); + ws->Connect({}, {}); + connected.get_future().wait(); - ws->Close(CloseCode::Normal, "Normal"); + ws->Close(CloseCode::Normal, "Normal"); - Assert::AreNotEqual({}, errorMessage); - Assert::IsTrue(closed); -} -} -; + Assert::AreNotEqual({}, errorMessage); + Assert::IsTrue(closed); + } +}; + +// clange-format on + +} // namespace Microsoft::React::Test diff --git a/vnext/Desktop.UnitTests/BytecodeUnitTests.cpp b/vnext/Desktop.UnitTests/BytecodeUnitTests.cpp index 84b938f277..d4fb513909 100644 --- a/vnext/Desktop.UnitTests/BytecodeUnitTests.cpp +++ b/vnext/Desktop.UnitTests/BytecodeUnitTests.cpp @@ -36,6 +36,8 @@ std::vector ReadFile(const char *filename) { } // namespace +namespace Microsoft::React::Test { + TEST_CLASS(BytecodeUnitTests) { private: MinimalChakraRuntime m_chakraRuntime; @@ -369,3 +371,5 @@ TEST_CLASS(BytecodeUnitTests) { }); } }; + +} // namespace Microsoft::React::Test diff --git a/vnext/Desktop.UnitTests/LayoutAnimationTests.cpp b/vnext/Desktop.UnitTests/LayoutAnimationTests.cpp index 26f6c17d48..3a006370cc 100644 --- a/vnext/Desktop.UnitTests/LayoutAnimationTests.cpp +++ b/vnext/Desktop.UnitTests/LayoutAnimationTests.cpp @@ -6,6 +6,8 @@ using namespace facebook::react; using namespace Microsoft::VisualStudio::CppUnitTestFramework; +namespace { + constexpr auto c_typeSz = "type"; constexpr auto c_propertySz = "property"; constexpr auto c_noneSz = "none"; @@ -32,9 +34,9 @@ constexpr auto c_delaySz = "delay"; constexpr auto c_initialVelocitySz = "initialVelocity"; constexpr auto c_springDampingSz = "springDamping"; -namespace Microsoft { -namespace VisualStudio { -namespace CppUnitTestFramework { +} // namespace + +namespace Microsoft::VisualStudio::CppUnitTestFramework { template <> std::wstring ToString( @@ -75,11 +77,15 @@ ToString( return L"None"; } -} // namespace CppUnitTestFramework -} // namespace VisualStudio -} // namespace Microsoft +} // namespace Microsoft::VisualStudio::CppUnitTestFramework -TEST_CLASS(LayoutAnimationTests){ +namespace Microsoft::React::Test { + +// We turn clang format off here because it does not work with some of the +// test macros. +// clang-format off + +TEST_CLASS(LayoutAnimationTests) { /* Typical layout animation: @@ -97,159 +103,162 @@ TEST_CLASS(LayoutAnimationTests){ #pragma region LayoutAnimation Config Processing Tests - TEST_METHOD(LayoutAnimationTests_BasicLayoutAnimationPropertySetTest){ - auto duration = 500.0f; -auto delay = 0.0f; -folly::dynamic layoutAnimation = folly::dynamic::object(c_durationSz, duration)( - c_createSz, - folly::dynamic::object(c_typeSz, c_linearSz)(c_propertySz, c_scaleXYSz))( - c_updateSz, - folly::dynamic::object(c_typeSz, c_easeInSz))( - c_deleteSz, - folly::dynamic::object(c_typeSz, c_easeOutSz)(c_propertySz, c_opacitySz)); -LayoutAnimation typedLayoutAnimation(layoutAnimation); -auto typedProps = typedLayoutAnimation.Properties(); + TEST_METHOD(LayoutAnimationTests_BasicLayoutAnimationPropertySetTest){ + auto duration = 500.0f; + auto delay = 0.0f; + folly::dynamic layoutAnimation = folly::dynamic::object(c_durationSz, duration)( + c_createSz, + folly::dynamic::object(c_typeSz, c_linearSz)(c_propertySz, c_scaleXYSz))( + c_updateSz, + folly::dynamic::object(c_typeSz, c_easeInSz))( + c_deleteSz, + folly::dynamic::object(c_typeSz, c_easeOutSz)(c_propertySz, c_opacitySz)); + LayoutAnimation typedLayoutAnimation(layoutAnimation); + auto typedProps = typedLayoutAnimation.Properties(); -Assert::AreEqual(duration, typedProps.createAnimationProps.duration); -Assert::AreEqual(duration, typedProps.updateAnimationProps.duration); -Assert::AreEqual(duration, typedProps.deleteAnimationProps.duration); -Assert::AreEqual( - LayoutAnimation::AnimationType::Linear, - typedProps.createAnimationProps.animationType); -Assert::AreEqual( - LayoutAnimation::AnimationType::EaseIn, - typedProps.updateAnimationProps.animationType); -Assert::AreEqual( - LayoutAnimation::AnimationType::EaseOut, - typedProps.deleteAnimationProps.animationType); -Assert::AreEqual( - LayoutAnimation::AnimatableProperty::ScaleXY, - typedProps.createAnimationProps.animatedProp); -Assert::AreEqual( - LayoutAnimation::AnimatableProperty::None, - typedProps.updateAnimationProps.animatedProp); -Assert::AreEqual( - LayoutAnimation::AnimatableProperty::Opacity, - typedProps.deleteAnimationProps.animatedProp); -Assert::AreEqual(delay, typedProps.createAnimationProps.delay); -Assert::AreEqual(delay, typedProps.updateAnimationProps.delay); -Assert::AreEqual(delay, typedProps.deleteAnimationProps.delay); -} + Assert::AreEqual(duration, typedProps.createAnimationProps.duration); + Assert::AreEqual(duration, typedProps.updateAnimationProps.duration); + Assert::AreEqual(duration, typedProps.deleteAnimationProps.duration); + Assert::AreEqual( + LayoutAnimation::AnimationType::Linear, + typedProps.createAnimationProps.animationType); + Assert::AreEqual( + LayoutAnimation::AnimationType::EaseIn, + typedProps.updateAnimationProps.animationType); + Assert::AreEqual( + LayoutAnimation::AnimationType::EaseOut, + typedProps.deleteAnimationProps.animationType); + Assert::AreEqual( + LayoutAnimation::AnimatableProperty::ScaleXY, + typedProps.createAnimationProps.animatedProp); + Assert::AreEqual( + LayoutAnimation::AnimatableProperty::None, + typedProps.updateAnimationProps.animatedProp); + Assert::AreEqual( + LayoutAnimation::AnimatableProperty::Opacity, + typedProps.deleteAnimationProps.animatedProp); + Assert::AreEqual(delay, typedProps.createAnimationProps.delay); + Assert::AreEqual(delay, typedProps.updateAnimationProps.delay); + Assert::AreEqual(delay, typedProps.deleteAnimationProps.delay); + } -TEST_METHOD(LayoutAnimationTests_OnlyAnimateCreateTest) { - folly::dynamic layoutAnimation = folly::dynamic::object(c_durationSz, 500)( - c_createSz, - folly::dynamic::object(c_typeSz, c_linearSz)(c_propertySz, c_scaleXYSz)); - LayoutAnimation typedLayoutAnimation(layoutAnimation); - auto typedProps = typedLayoutAnimation.Properties(); + TEST_METHOD(LayoutAnimationTests_OnlyAnimateCreateTest) { + folly::dynamic layoutAnimation = folly::dynamic::object(c_durationSz, 500)( + c_createSz, + folly::dynamic::object(c_typeSz, c_linearSz)(c_propertySz, c_scaleXYSz)); + LayoutAnimation typedLayoutAnimation(layoutAnimation); + auto typedProps = typedLayoutAnimation.Properties(); - Assert::AreEqual( - LayoutAnimation::AnimationType::Linear, - typedProps.createAnimationProps.animationType); - Assert::AreEqual( - LayoutAnimation::AnimationType::None, - typedProps.updateAnimationProps.animationType); - Assert::AreEqual( - LayoutAnimation::AnimationType::None, - typedProps.deleteAnimationProps.animationType); -} + Assert::AreEqual( + LayoutAnimation::AnimationType::Linear, + typedProps.createAnimationProps.animationType); + Assert::AreEqual( + LayoutAnimation::AnimationType::None, + typedProps.updateAnimationProps.animationType); + Assert::AreEqual( + LayoutAnimation::AnimationType::None, + typedProps.deleteAnimationProps.animationType); + } -TEST_METHOD(LayoutAnimationTests_OnlyAnimateUpdateTest) { - folly::dynamic layoutAnimation = folly::dynamic::object(c_durationSz, 500)( - c_updateSz, - folly::dynamic::object(c_typeSz, c_linearSz)(c_propertySz, c_scaleXYSz)); - LayoutAnimation typedLayoutAnimation(layoutAnimation); - auto typedProps = typedLayoutAnimation.Properties(); + TEST_METHOD(LayoutAnimationTests_OnlyAnimateUpdateTest) { + folly::dynamic layoutAnimation = folly::dynamic::object(c_durationSz, 500)( + c_updateSz, + folly::dynamic::object(c_typeSz, c_linearSz)(c_propertySz, c_scaleXYSz)); + LayoutAnimation typedLayoutAnimation(layoutAnimation); + auto typedProps = typedLayoutAnimation.Properties(); - Assert::AreEqual( - LayoutAnimation::AnimationType::None, - typedProps.createAnimationProps.animationType); - Assert::AreEqual( - LayoutAnimation::AnimationType::Linear, - typedProps.updateAnimationProps.animationType); - Assert::AreEqual( - LayoutAnimation::AnimationType::None, - typedProps.deleteAnimationProps.animationType); -} + Assert::AreEqual( + LayoutAnimation::AnimationType::None, + typedProps.createAnimationProps.animationType); + Assert::AreEqual( + LayoutAnimation::AnimationType::Linear, + typedProps.updateAnimationProps.animationType); + Assert::AreEqual( + LayoutAnimation::AnimationType::None, + typedProps.deleteAnimationProps.animationType); + } -TEST_METHOD(LayoutAnimationTests_OnlyAnimateDeleteTest) { - folly::dynamic layoutAnimation = folly::dynamic::object(c_durationSz, 500)( - c_deleteSz, - folly::dynamic::object(c_typeSz, c_linearSz)(c_propertySz, c_scaleXYSz)); - LayoutAnimation typedLayoutAnimation(layoutAnimation); - auto typedProps = typedLayoutAnimation.Properties(); + TEST_METHOD(LayoutAnimationTests_OnlyAnimateDeleteTest) { + folly::dynamic layoutAnimation = folly::dynamic::object(c_durationSz, 500)( + c_deleteSz, + folly::dynamic::object(c_typeSz, c_linearSz)(c_propertySz, c_scaleXYSz)); + LayoutAnimation typedLayoutAnimation(layoutAnimation); + auto typedProps = typedLayoutAnimation.Properties(); - Assert::AreEqual( - LayoutAnimation::AnimationType::None, - typedProps.createAnimationProps.animationType); - Assert::AreEqual( - LayoutAnimation::AnimationType::None, - typedProps.updateAnimationProps.animationType); - Assert::AreEqual( - LayoutAnimation::AnimationType::Linear, - typedProps.deleteAnimationProps.animationType); -} + Assert::AreEqual( + LayoutAnimation::AnimationType::None, + typedProps.createAnimationProps.animationType); + Assert::AreEqual( + LayoutAnimation::AnimationType::None, + typedProps.updateAnimationProps.animationType); + Assert::AreEqual( + LayoutAnimation::AnimationType::Linear, + typedProps.deleteAnimationProps.animationType); + } -TEST_METHOD(LayoutAnimationTests_CustomizedDurationTest) { - auto defaultDuration = 500.0f; - auto customDuration = 50.0f; - folly::dynamic layoutAnimation = folly::dynamic::object( - c_durationSz, defaultDuration)( - c_createSz, - folly::dynamic::object(c_typeSz, c_linearSz)(c_propertySz, c_scaleXYSz))( - c_updateSz, - folly::dynamic::object(c_durationSz, customDuration)( - c_typeSz, c_easeInSz)); - LayoutAnimation typedLayoutAnimation(layoutAnimation); - auto typedProps = typedLayoutAnimation.Properties(); + TEST_METHOD(LayoutAnimationTests_CustomizedDurationTest) { + auto defaultDuration = 500.0f; + auto customDuration = 50.0f; + folly::dynamic layoutAnimation = folly::dynamic::object( + c_durationSz, defaultDuration)( + c_createSz, + folly::dynamic::object(c_typeSz, c_linearSz)(c_propertySz, c_scaleXYSz))( + c_updateSz, + folly::dynamic::object(c_durationSz, customDuration)( + c_typeSz, c_easeInSz)); + LayoutAnimation typedLayoutAnimation(layoutAnimation); + auto typedProps = typedLayoutAnimation.Properties(); - Assert::AreEqual(defaultDuration, typedProps.createAnimationProps.duration); - Assert::AreEqual(customDuration, typedProps.updateAnimationProps.duration); -} + Assert::AreEqual(defaultDuration, typedProps.createAnimationProps.duration); + Assert::AreEqual(customDuration, typedProps.updateAnimationProps.duration); + } -TEST_METHOD(LayoutAnimationTests_MultipleDelaysTest) { - auto createDelay = 50.0f; - auto updateDelay = 150.0f; - auto deleteDelay = 250.0f; - folly::dynamic layoutAnimation = folly::dynamic::object(c_durationSz, 500)( - c_createSz, - folly::dynamic::object(c_delaySz, createDelay)(c_typeSz, c_linearSz)( - c_propertySz, c_scaleXYSz))( - c_updateSz, - folly::dynamic::object(c_delaySz, updateDelay)(c_typeSz, c_easeInSz))( - c_deleteSz, - folly::dynamic::object(c_delaySz, deleteDelay)(c_typeSz, c_easeOutSz)( - c_propertySz, c_opacitySz)); - LayoutAnimation typedLayoutAnimation(layoutAnimation); - auto typedProps = typedLayoutAnimation.Properties(); + TEST_METHOD(LayoutAnimationTests_MultipleDelaysTest) { + auto createDelay = 50.0f; + auto updateDelay = 150.0f; + auto deleteDelay = 250.0f; + folly::dynamic layoutAnimation = folly::dynamic::object(c_durationSz, 500)( + c_createSz, + folly::dynamic::object(c_delaySz, createDelay)(c_typeSz, c_linearSz)( + c_propertySz, c_scaleXYSz))( + c_updateSz, + folly::dynamic::object(c_delaySz, updateDelay)(c_typeSz, c_easeInSz))( + c_deleteSz, + folly::dynamic::object(c_delaySz, deleteDelay)(c_typeSz, c_easeOutSz)( + c_propertySz, c_opacitySz)); + LayoutAnimation typedLayoutAnimation(layoutAnimation); + auto typedProps = typedLayoutAnimation.Properties(); - Assert::AreEqual(createDelay, typedProps.createAnimationProps.delay); - Assert::AreEqual(updateDelay, typedProps.updateAnimationProps.delay); - Assert::AreEqual(deleteDelay, typedProps.deleteAnimationProps.delay); -} + Assert::AreEqual(createDelay, typedProps.createAnimationProps.delay); + Assert::AreEqual(updateDelay, typedProps.updateAnimationProps.delay); + Assert::AreEqual(deleteDelay, typedProps.deleteAnimationProps.delay); + } -TEST_METHOD(LayoutAnimationTests_SpringPropertiesTest) { - auto damping = 0.7f; - auto initialVelocity = 1.0f; - folly::dynamic layoutAnimation = folly::dynamic::object(c_durationSz, 500)( - c_createSz, - folly::dynamic::object(c_typeSz, c_springSz)(c_springDampingSz, damping)( - c_initialVelocitySz, initialVelocity)(c_propertySz, c_scaleXYSz)); - LayoutAnimation typedLayoutAnimation(layoutAnimation); - auto typedProps = typedLayoutAnimation.Properties(); + TEST_METHOD(LayoutAnimationTests_SpringPropertiesTest) { + auto damping = 0.7f; + auto initialVelocity = 1.0f; + folly::dynamic layoutAnimation = folly::dynamic::object(c_durationSz, 500)( + c_createSz, + folly::dynamic::object(c_typeSz, c_springSz)(c_springDampingSz, damping)( + c_initialVelocitySz, initialVelocity)(c_propertySz, c_scaleXYSz)); + LayoutAnimation typedLayoutAnimation(layoutAnimation); + auto typedProps = typedLayoutAnimation.Properties(); - Assert::AreEqual( - LayoutAnimation::AnimationType::Spring, - typedProps.createAnimationProps.animationType); - Assert::AreEqual( - damping, - typedProps.createAnimationProps.springAnimationProperties.springDamping); - Assert::AreEqual( - initialVelocity, - typedProps.createAnimationProps.springAnimationProperties - .initialVelocity); -} + Assert::AreEqual( + LayoutAnimation::AnimationType::Spring, + typedProps.createAnimationProps.animationType); + Assert::AreEqual( + damping, + typedProps.createAnimationProps.springAnimationProperties.springDamping); + Assert::AreEqual( + initialVelocity, + typedProps.createAnimationProps.springAnimationProperties + .initialVelocity); + } #pragma endregion -} -; +}; + +// clang-format on + +} // namespace Microsoft::React::Test diff --git a/vnext/Desktop.UnitTests/MemoryMappedBufferTests.cpp b/vnext/Desktop.UnitTests/MemoryMappedBufferTests.cpp index 87f57d42b5..148e42e364 100644 --- a/vnext/Desktop.UnitTests/MemoryMappedBufferTests.cpp +++ b/vnext/Desktop.UnitTests/MemoryMappedBufferTests.cpp @@ -40,6 +40,8 @@ uint32_t GetPageSize() noexcept { } // anonymous namespace +namespace Microsoft::JSI::Test { + TEST_CLASS(MemoryMappedBufferUnitTests) { private: std::wstring m_testFileName; @@ -167,3 +169,5 @@ TEST_CLASS(MemoryMappedBufferUnitTests) { }); } }; + +} // namespace Microsoft::JSI::Test diff --git a/vnext/Desktop.UnitTests/StringConversionTest_Desktop.cpp b/vnext/Desktop.UnitTests/StringConversionTest_Desktop.cpp index 865cf7a885..3df79785de 100644 --- a/vnext/Desktop.UnitTests/StringConversionTest_Desktop.cpp +++ b/vnext/Desktop.UnitTests/StringConversionTest_Desktop.cpp @@ -11,6 +11,8 @@ using namespace facebook::react; using namespace Microsoft::VisualStudio::CppUnitTestFramework; using namespace std; +namespace Microsoft::React::Test { + TEST_CLASS(StringConversionTest_Desktop) { private: JsRuntimeHandle runtime; @@ -45,3 +47,5 @@ TEST_CLASS(StringConversionTest_Desktop) { } } }; + +} // namespace Microsoft::React::Test diff --git a/vnext/Desktop.UnitTests/UIManagerModuleTest.cpp b/vnext/Desktop.UnitTests/UIManagerModuleTest.cpp index 11eb65ba66..2b4a9b094e 100644 --- a/vnext/Desktop.UnitTests/UIManagerModuleTest.cpp +++ b/vnext/Desktop.UnitTests/UIManagerModuleTest.cpp @@ -10,6 +10,8 @@ using namespace facebook::react; using namespace Microsoft::React::Test; using namespace Microsoft::VisualStudio::CppUnitTestFramework; +namespace Microsoft::React::Test { + TEST_CLASS(UIManagerModuleTests) { protected: std::unique_ptr m_emptyUIManager; @@ -98,3 +100,5 @@ TEST_CLASS(UIManagerModuleTests) { // EXPECT_STREQ("Some Text", it->second.c_str()); } }; + +} // namespace Microsoft::React::Test diff --git a/vnext/Desktop.UnitTests/UnicodeConversionTest.cpp b/vnext/Desktop.UnitTests/UnicodeConversionTest.cpp index 3d7cf812f3..6f8e831737 100644 --- a/vnext/Desktop.UnitTests/UnicodeConversionTest.cpp +++ b/vnext/Desktop.UnitTests/UnicodeConversionTest.cpp @@ -10,6 +10,8 @@ using facebook::react::unicode::utf16ToUtf8; using facebook::react::unicode::utf8ToUtf16; using Microsoft::VisualStudio::CppUnitTestFramework::Assert; +namespace Microsoft::React::Test { + TEST_CLASS(UnicodeConversionTest) { public: TEST_METHOD(PrerequisiteTest) { @@ -117,3 +119,5 @@ TEST_CLASS(UnicodeConversionTest) { constexpr static const wchar_t *SimpleTestStringBomUtf16 = L"\xfeff\x0061\x0062\x0063"; //abc }; + +} // namespace Microsoft::React::Test diff --git a/vnext/Desktop.UnitTests/UnicodeTestStrings.cpp b/vnext/Desktop.UnitTests/UnicodeTestStrings.cpp index 219af657f5..b8c3e22581 100644 --- a/vnext/Desktop.UnitTests/UnicodeTestStrings.cpp +++ b/vnext/Desktop.UnitTests/UnicodeTestStrings.cpp @@ -3,6 +3,8 @@ #include "UnicodeTestStrings.h" +namespace Microsoft::React::Test { + std::vector g_utf8TestStrings = { // Some random ASCII characters, emojis, Chinese, Russian, Japanese, Greek, // Hebrew, Polish, Serbian, Norwegian @@ -23,3 +25,5 @@ std::vector g_utf8TestStrings = { u8",可 第七回 貢院 去 第四回 第二回 出 」. 訖乃返 後竊聽 危德至 分得意 樂而不淫. 」 出 意 ,可. 此是後話 ,愈聽愈惱 也懊悔不了 饒爾去罷」. 第三回 第五回 第二回 了」. 玉,不題 事 汗流如雨 去 冒認收了 耳 吉安而來 意 誨 出. 矣 」 出 意. 曰: 意 饒爾去罷」 事 此是後話 出 去 ,愈聽愈惱 也懊悔不了. 也懊悔不了 饒爾去罷」 ,愈聽愈惱. 耳 」 ,可 誨. 覽 耳 曰: 矣 意. 曰: 覽 出 耳 ,可. 覽 耳 曰: ,可 去 意 誨 事. 去 矣 誨 曰: 耳. 關雎 覽 」 事. 」 關雎 不稱讚 第十一回 覽 以測機 訖乃返 白圭志 分得意 ,可. 驚異 覽 耳 事 貢院 第六回 」 出 關雎 了」 第七回. 羨殺 第九回 相域 驚異 了」 德泉淹. 饒爾去罷」 關雎 此是後話 誨 也懊悔不了 ,愈聽愈惱 出 去. 覽 曰: 矣 誨 出.樂而不淫 第十一回 在一處 訖乃返 建章曰:.耳 去 事 後竊聽 」 矣 第十一回 樂而不淫.誨 關雎 去 矣.耳 誨 去 ,可 覽 曰:.出 意 誨 去 ,可 曰: 耳 事.覽 關雎 誨 事 」.建章曰: 樂而不淫 分得意.矣 ,可 饒爾去罷」 出 也懊悔不了 此是後話 ,愈聽愈惱 去.第九回 第六回 不題 招」 第七回 德泉淹.去 覽 羨殺 招」 第九回 意 第八回 」 矣 耳 曰: 第六回.事 曰: 後竊聽 」 意 白圭志 訖乃返 耳 第十一回 樂而不淫 去.耳 矣 覽 誨 事 關雎 曰: 」.,可 關雎 建章曰: 去 己轉身 覽 事 白圭志 以測機 分得意 樂而不淫 矣 耳 」.父親回衙 吉安而來 玉,不題 冒認收了 汗流如雨.耳 」 矣 事 意 出.冒認收了 玉,不題 父親回衙.吉安而來 汗流如雨 父親回衙 玉,不題 冒認收了.曰: ,可 關雎 意 」 出 覽 矣. Ярмом Венец Клоню часть славы средь.Ее скрепим спокоен Их ст Ангелов явленья То обитает на.Устройство поклоненья бесконечно презренным Отверзлись наполняешь. ..Посвятясь Род Див искренних чел потрясают Арф судилищах.Ниспошли насажден вздыхать Последуя..Звучней Господу ах Из за но Взжигай ея Ту возношу.Но ее Те То НА ту не яр.Вы ах Но во блаженстве воскрешает за Аз милосердие ею МЕЩЕРСКОГО воскресясь.Уж почитает За Ту истлеваю происшел бы.Те Но вы за Ум.Кои душ риз Шум.По Ни их ко из дальнейшие Но Ее всеконечно бледностью ты.Миг Снедает сей всю тму кротким Ходатай чуд громады.До Ах на Мы уж Он ль Со.Та ИЗ оспорить вселенну гл ты Уж погибают называем.Сие Ограждал праотцев ней тон мог Бледнеет она дал привесть тук пал благости Подвигни.Ухищреньем вознесется душ жив Злы Благословя кущ сил утесненных Муж блаженстве устремился.Как мои эхо уха.Питатель ей По Да спокойно Ты те ВВЕДЕНИЕ НА ах же.Ток гул иду рок сих.Дал ран Стрегущи Крепость сие Божеству действий Бог риз оны.Кое под Уже чьи еще.Объявил цевницы ей несется Блеснет по Да По подпора пройдет Им.Мне Обратится СЕТОВАНИЕ вой поя Взгляните ини вне.Во яд Мы же По до..Со Мы Вы То он да Но Им.Сем Кои василисков потряслась уму гор уха под тме ПРАВОСУДИЕ мою стряхнутся.Неверие Мир Сын посетит Они Меч Яры находит.Ли ад Но Ум Мы ее ст.Мой ток мое Нем поклоняюсь бег сад царствуешь сотворится Соделалось ПОБЕДИТЕЛЮ душ Яры всесильным.Чтя мир Род пал Мне кем зде.Гл Вы Кто но бы Аз мя ад.Муж ног ней гул вот.Их ни Ум мя ах.Ни до ах от Ах об се Ты.Бог над Мой тощ риз Гул вне.Же Он во та то..Увы ней чая бег цел где Кем эхо. ..Объятие имя Чья цел мирские бояться она тел.Дел мое роз вам жен дух див. .Спустились низвергнул ВЕЛИЧЕСТВО рассуждает неимоверна.кто из Но Ту ею Ея Из вы им.Сии Сын ему Лию сын увы кит.Тме сие Дух лия это Душ дна рек. ..Терновых весельем опустели за ее Небесная ей Да блистали нисходят Ту Ум.Наполняяй тех сей поя Несметных отлученье жег исчислить сокровище утешитель.Ее Ко бы Се..Покрылся восходит скорбеть трисвяту.Ни вожу яр рдел очам ни мя Ум Паче Се Даст люди.Ль он Во Аз.Жил Моя лиц лес иду жег.Вся единым рай Имя стезею дым грозно.Же ИЗ день он слов Тя не Царь дуть Кого.Муж Зри меж вод ров ков.Дав Зло мое врагу все Все даешь Древа Зорят Час.Роз оно врагам иду Объяты гореть терзав вод сделал.Тех ими быв мог.Тощ вот мир зло.Нощь Дочь бьет Свет сшел.Чая Был Тот сна выя чин..Ст та ее мы.Ρεαλισμός ως εμπειρίες συνείδηση στιγμιαία ευγένειας αρ συμβαίνει.Ταυτίζεται καθίσταται όλα παιγνιώδης λογοτεχνών δεν ενώ νέα.Ύπαρξη τις ηθικές την του ομάδες χωρική.Οι τη γενιάς ηθικής θα άλλοτε άδειου κίνησή.Πειστική πλοκάμια το καθαυτής αν αρ.Χώρα στον πι το εν πήρε μέσω ότου μέλη.Όλη σχολικά αντλούν την γέροντα κώδικες.Βλ να αδακά σο τύπου τολμά λάβει εβγάλ.Αγαπά μάγον στα για μερ θλίψη ήσυχα.Με αρ όψεις αυτών χαθεί νόημα κι επαφή.Πολιτικές να βιαστικές κι υψηλότερο μελετητές διατήρηση πω το.Ασυνήθιστη κοινωνικών υπό όλα θεωρητικοί υποθετικού παλαιότερα φιλολογική.Τράβηξε έστελνε τι ανέλιξη σο διάφορα ακροατή αλλαγές ας.Ούτε πει όλη και τσεν τις ωχρό.Κόσμου κόκκος τη οποίας τίτλος έν έπεται κι κανείς.Εάν πρώτο κλαίω πια οποίο ήξερε απ΄ απλώς τυχόν.Τότε την πήρε μερ ούτε θεός.Έργου μη κύριο κύρια ατ ήθελε ευτάς να.Πιο τόζλουτζας μια μικρόκοσμο συναντούμε διηγήματος από όλα.Δόσιμο δάκρυα πώς έκρυβε ροζ πρέπει και επί.Κινήματος το παράλληλα μαρτυρούν με περίτεχνο.Έτον έναν ου έτσι όπου αφού ως.Εξελικτική να το υπερφυσικό καταθέσουν καπετάνιου εντάσσεται υποσχέθηκε.Θα παρόμοια κόνσολον ρητορική ας καλύτερη ανάγνωση οι.Επούλ του τάξης σοφία βράδυ προ που πηγές όλα.Τα εκ σε ακούμε μορφής γενιάς.Κατά τάση πήγε εφ νέου θα μόνο νέας.Ροζ προπαντός υπό πολυφωνία παρατηρεί φίλ κατασκευή θεωρητική.Συν αντίστροφα μια λασπωμένες κατ διανοητικά μια.Μετάβαση όλο συμβολής προ απαγωγέα διήγησης ευρύτερο.Διάφορες και πρόσφατο όσο μετάβαση δυνητική ναι μητρικές.Χρειάζεσθε μου την υποτίθεται κλπ που παραμυθιού.Προκύψει εκ κι ευελιξία το σε ιστορικά ιστορικό.Διά πια πλήρει ισχυρό έζησαν σην ανάγκη καθ.Μη παράδοξη οφείλουν οι ευέλικτη ιι.Όλα προοπτική του νεότερους βασίζεται νέα παράλληλα.Ως πραγματικό παραπέμπει ας ου αναγνωστών λογοτεχνία.Στο άξιος εδώ ευρήκ δίοδο αρετή είχαν φάρσα.Γιαννίτς όσο τράνταξε υπό για δις ανάδοχου αφετέρου βιάστηκε ιστορικο.Εφτά φίλ λύπη αυτή ενώ όμως δύο δις.Ζωή γυναίκας αναδόχου μην στοιχείο.Εκφραστικό αρ ου θα ανέκφραστη πι επικρατούν στρατηγική υποβλητικό.Προκύψει να ωμότητες συνήθιζε μη εξαιτίας ανέδειξε.Εμφανής ευτελής χιούμορ αν θεωριών να ου.Διαδίκτυο παιχνίδια παραμένει αν αρ.Επιβληθούν κατασκευής προέρχεται το απ μαθητεύσει διηγημάτων ατ με.Υπ άντλησης ορίζεται κειμένου αλήθειες σο.Ροή έξω δις εξής αργά έργο του.Μικρούς αφορούν μαγικού στα κωμωδία αρχίζει πια.Εφ συνδέοντας σε αρ κατακλυσμό λογοτεχνία παραλλαγές ενδιαφέρον αισθάνεται.Ιστορικά τα δεύτερον νοημάτων πνιγμένο τι νε.Σε πολλαπλούς τι απευθύνουν μεγαλύτερο εκφραστικό.Θα εύθραυστη τα μεταβολές φουσκάλες γνωστικής.Διηνεκή μελέτης φόρεμαν πρόσωπα ας οι εξορίες πα επώνυμη.Σοφίας αντοχή μαγεία ως τριπλή οι.Προκύπτει μπαστούνι έν με φοβετζέας εν ισορροπία.Ου οράματος παράδοση καλώντας τη.Στάσης εκ μαγεία με μαρίτσ τα το μηνύει γόνατό.Κοίταζαν παιδικής ξαντίνου θα κινήσεις αν περίοδος.Ορατό ώμους χλομό πίστη εν αρχής άλλες το.Μπροστά όλα κεί βλέπετε σπιτιού.Αρ παρήγαγε το νε κάποιους διαφέρει.Εύθραυστη συναλλαγή κυριαρχία ζώγ για και συνείδηση διηγήσεων.Τα τα με σύμβαση παγίωση αν ανάμεσα.Ακούμε ταφικά τη πρέπει εφ με φεύγει μεγάλη.Άμαν του εδώ μαμά νέοι και καθ άλλο.Παραμυθιού ενοχλήσεις ταυτότητάς σε τα θα κι συγγραφική.Αναφορές πα σκοτωθεί γέροντες απαγωγής πρακτική να.Ακατόρθωτο λογοτεχνία ως οικογένειά με χολάσκεται σο να.Τον απ΄ εις μένει πει επικό ζωηρό.Ηρωίδας δεύτερη παιδικό ένα ρου.Παιγνιώδης δημιουργία επί στο παρατήρηση νέο αναφέρθηκε δεν.Ενώ πατρικές γλωσσική εκκίνηση απόλαυση άγνωστες στα ροζ.Εντάμωσεν αναδύεται πολυφωνία κι ως αποβαίνει πι απόσπασμα μπρούμυτα ατ.Νέα χλομό όλη ατο άμεσα εντός πλέον κυρία αγαπά κλπ.", // The empty string u8""}; + +} // namespace Microsoft::React::Test diff --git a/vnext/Desktop.UnitTests/UnicodeTestStrings.h b/vnext/Desktop.UnitTests/UnicodeTestStrings.h index 3b53004e25..a87659de49 100644 --- a/vnext/Desktop.UnitTests/UnicodeTestStrings.h +++ b/vnext/Desktop.UnitTests/UnicodeTestStrings.h @@ -5,4 +5,8 @@ #include #include +namespace Microsoft::React::Test { + extern std::vector g_utf8TestStrings; + +} // namespace Microsoft::React::Test diff --git a/vnext/Desktop.UnitTests/UtilsTest.cpp b/vnext/Desktop.UnitTests/UtilsTest.cpp index 8d01a5e280..8c0bb40b08 100644 --- a/vnext/Desktop.UnitTests/UtilsTest.cpp +++ b/vnext/Desktop.UnitTests/UtilsTest.cpp @@ -9,112 +9,125 @@ using namespace Microsoft::VisualStudio::CppUnitTestFramework; using std::string; -TEST_CLASS(UtilsTest){void ExpectUrl( - string urlString, - string protocol, - string host, - string port = "", - string path = "/", - string query = ""){Url url(urlString); +namespace Microsoft::React::Test { -Assert::AreEqual(protocol, url.scheme); -Assert::AreEqual(host, url.host); -Assert::AreEqual(port, url.port); -Assert::AreEqual(path, url.path); -Assert::AreEqual(query, url.queryString); -} +// We turn clang format off here because it does not work with some of the +// test macros. +// clang-format off + +TEST_CLASS(UtilsTest) { + + void ExpectUrl( + string urlString, + string protocol, + string host, + string port = "", + string path = "/", + string query = "") { + + Url url(urlString); + + Assert::AreEqual(protocol, url.scheme); + Assert::AreEqual(host, url.host); + Assert::AreEqual(port, url.port); + Assert::AreEqual(path, url.path); + Assert::AreEqual(query, url.queryString); + } #pragma region Url Tests -TEST_METHOD(UtilsTest_ValidProtocols) { - string protocols[4]{"http", "https", "ws", "wss"}; - for (auto protocol : protocols) { - ExpectUrl(string(protocol + "://internal"), protocol, "internal"); + TEST_METHOD(UtilsTest_ValidProtocols) { + string protocols[4]{"http", "https", "ws", "wss"}; + for (auto protocol : protocols) { + ExpectUrl(string(protocol + "://internal"), protocol, "internal"); + } } -} -TEST_METHOD(UtilsTest_IntraHost) { - ExpectUrl("ws://internal", "ws", "internal"); -} + TEST_METHOD(UtilsTest_IntraHost) { + ExpectUrl("ws://internal", "ws", "internal"); + } -TEST_METHOD(UtilsTest_IntraHostTrailing) { - ExpectUrl("ws://internal/", "ws", "internal"); -} + TEST_METHOD(UtilsTest_IntraHostTrailing) { + ExpectUrl("ws://internal/", "ws", "internal"); + } -TEST_METHOD(UtilsTest_IntraHostQueryLeading) { - ExpectUrl("ws://internal?", "ws", "internal"); -} + TEST_METHOD(UtilsTest_IntraHostQueryLeading) { + ExpectUrl("ws://internal?", "ws", "internal"); + } -TEST_METHOD(UtilsTest_IntraHostTrailingQueryLeading) { - ExpectUrl("ws://internal/?", "ws", "internal"); -} + TEST_METHOD(UtilsTest_IntraHostTrailingQueryLeading) { + ExpectUrl("ws://internal/?", "ws", "internal"); + } -TEST_METHOD(UtilsTest_NormalHostQueryLeading) { - ExpectUrl("ws://example.com?", "ws", "example.com"); -} + TEST_METHOD(UtilsTest_NormalHostQueryLeading) { + ExpectUrl("ws://example.com?", "ws", "example.com"); + } -TEST_METHOD(UtilsTest_IntraPort) { - ExpectUrl("ws://internal:5000", "ws", "internal", "5000"); -} + TEST_METHOD(UtilsTest_IntraPort) { + ExpectUrl("ws://internal:5000", "ws", "internal", "5000"); + } -TEST_METHOD(UtilsTest_NormalPort) { - ExpectUrl("ws://example.com:443", "ws", "example.com", "443"); -} + TEST_METHOD(UtilsTest_NormalPort) { + ExpectUrl("ws://example.com:443", "ws", "example.com", "443"); + } -TEST_METHOD(UtilsTest_PortPath) { - ExpectUrl("ws://example.com:5000/ws", "ws", "example.com", "5000", "/ws"); -} + TEST_METHOD(UtilsTest_PortPath) { + ExpectUrl("ws://example.com:5000/ws", "ws", "example.com", "5000", "/ws"); + } -TEST_METHOD(UtilsTest_Query) { - ExpectUrl( - "ws://example.com?a=1&b=2", "ws", "example.com", "", "/", "a=1&b=2"); -} + TEST_METHOD(UtilsTest_Query) { + ExpectUrl( + "ws://example.com?a=1&b=2", "ws", "example.com", "", "/", "a=1&b=2"); + } -TEST_METHOD(UtilsTest_TrailingPathQuery) { - ExpectUrl( - "ws://example.com/?a=1&b=2", "ws", "example.com", "", "/", "a=1&b=2"); -} + TEST_METHOD(UtilsTest_TrailingPathQuery) { + ExpectUrl( + "ws://example.com/?a=1&b=2", "ws", "example.com", "", "/", "a=1&b=2"); + } -TEST_METHOD(UtilsTest_HyphenHostInternal) { - ExpectUrl("wss://-my-hyphened-host--", "wss", "-my-hyphened-host--"); -} + TEST_METHOD(UtilsTest_HyphenHostInternal) { + ExpectUrl("wss://-my-hyphened-host--", "wss", "-my-hyphened-host--"); + } -TEST_METHOD(UtilsTest_NestedPathTrailingSlashLeadingQuestionMark) { - ExpectUrl( - "ws://example.com/the/nested/path/?", - "ws", - "example.com", - "", - "/the/nested/path/"); -} + TEST_METHOD(UtilsTest_NestedPathTrailingSlashLeadingQuestionMark) { + ExpectUrl( + "ws://example.com/the/nested/path/?", + "ws", + "example.com", + "", + "/the/nested/path/"); + } -TEST_METHOD(UtilsTest_NestedSubdomain) { - ExpectUrl( - "ws://nested.sub.domain.of.example.com", - "ws", - "nested.sub.domain.of.example.com"); -} + TEST_METHOD(UtilsTest_NestedSubdomain) { + ExpectUrl( + "ws://nested.sub.domain.of.example.com", + "ws", + "nested.sub.domain.of.example.com"); + } #pragma region Url Negative Tests -TEST_METHOD(UtilsTest_EmptyStringFails) { - Assert::ExpectException([]() { Url(""); }); -} + TEST_METHOD(UtilsTest_EmptyStringFails) { + Assert::ExpectException([]() { Url(""); }); + } -TEST_METHOD(UtilsTest_WrongProtocol) { - Assert::ExpectException([]() { Url("foos://internal"); }); -} + TEST_METHOD(UtilsTest_WrongProtocol) { + Assert::ExpectException([]() { Url("foos://internal"); }); + } -TEST_METHOD(UtilsTest_BadCharsInPort) { - Assert::ExpectException([]() { Url("ws://internal:50O0"); }); -} + TEST_METHOD(UtilsTest_BadCharsInPort) { + Assert::ExpectException([]() { Url("ws://internal:50O0"); }); + } -TEST_METHOD(UtilsTest_SpacesInProtocol) { - Assert::ExpectException([]() { Url(" ws://internal"); }); -} + TEST_METHOD(UtilsTest_SpacesInProtocol) { + Assert::ExpectException([]() { Url(" ws://internal"); }); + } #pragma endregion #pragma endregion -} -; +}; + +// clang-format on + +} // namespace Microsoft::React::Test diff --git a/vnext/Desktop.UnitTests/WebSocketJSExecutorTest.cpp b/vnext/Desktop.UnitTests/WebSocketJSExecutorTest.cpp index fbb8da6412..db07f7a290 100644 --- a/vnext/Desktop.UnitTests/WebSocketJSExecutorTest.cpp +++ b/vnext/Desktop.UnitTests/WebSocketJSExecutorTest.cpp @@ -7,11 +7,19 @@ using namespace Microsoft::React; using namespace Microsoft::VisualStudio::CppUnitTestFramework; -TEST_CLASS(WebSocketJSExecutorTest){ - TEST_METHOD(WebSocketJSExecutorTest_Instantiate){ - auto wsje = std::make_shared(nullptr, nullptr); +namespace Microsoft::React::Test { -Assert::IsFalse(nullptr == wsje); -} -} -; +// We turn clang format off here because it does not work with some of the +// test macros. +// clang-format off + +TEST_CLASS(WebSocketJSExecutorTest) { + TEST_METHOD(WebSocketJSExecutorTest_Instantiate){ + auto wsje = std::make_shared(nullptr, nullptr); + Assert::IsFalse(nullptr == wsje); + } +}; + +// clange-format on + +} // namespace Microsoft::React::Test diff --git a/vnext/Desktop.UnitTests/WebSocketModuleTest.cpp b/vnext/Desktop.UnitTests/WebSocketModuleTest.cpp index 77551d5689..a30f629416 100644 --- a/vnext/Desktop.UnitTests/WebSocketModuleTest.cpp +++ b/vnext/Desktop.UnitTests/WebSocketModuleTest.cpp @@ -8,6 +8,8 @@ using namespace facebook::react; using namespace facebook::xplat::module; using namespace Microsoft::VisualStudio::CppUnitTestFramework; +namespace Microsoft::React::Test { + TEST_CLASS(WebSocketModuleTest) { enum class MethodId : size_t { Connect = 0, @@ -36,3 +38,5 @@ TEST_CLASS(WebSocketModuleTest) { Assert::AreEqual(static_cast(0), module->getConstants().size()); } }; + +} // namespace Microsoft::React::Test diff --git a/vnext/Desktop.UnitTests/WebSocketTest.cpp b/vnext/Desktop.UnitTests/WebSocketTest.cpp index 0f817bd99c..1eafc5f21c 100644 --- a/vnext/Desktop.UnitTests/WebSocketTest.cpp +++ b/vnext/Desktop.UnitTests/WebSocketTest.cpp @@ -11,48 +11,57 @@ using namespace Microsoft::VisualStudio::CppUnitTestFramework; using std::string; -TEST_CLASS(WebSocketTest){TEST_METHOD(WebSocketTest_CreateAndSetHandlers){ +namespace Microsoft::React::Test { + +// We turn clang format off here because it does not work with some of the +// test macros. +// clang-format off + +TEST_CLASS(WebSocketTest) { + TEST_METHOD(WebSocketTest_CreateAndSetHandlers) { auto ws = std::make_shared(Url("ws://validurl:0/")); + Assert::IsFalse(nullptr == ws); + ws->SetOnConnect([]() {}); + ws->SetOnPing([]() {}); + ws->SetOnSend([](size_t length) {}); + ws->SetOnMessage([](std::size_t length, const string &buffer) {}); + ws->SetOnClose([](IWebSocket::CloseCode, const string &) {}); + ws->SetOnError([](const IWebSocket::Error &error) {}); + } -Assert::IsFalse(nullptr == ws); -ws->SetOnConnect([]() {}); -ws->SetOnPing([]() {}); -ws->SetOnSend([](size_t length) {}); -ws->SetOnMessage([](std::size_t length, const string &buffer) {}); -ws->SetOnClose([](IWebSocket::CloseCode, const string &) {}); -ws->SetOnError([](const IWebSocket::Error &error) {}); -} + // TODO: Implement Protocol and Socket mocks. + void ConnectAndClose() + // TEST_METHOD(WebSocketTest_ConnectAndClose) + { + auto ws = std::make_shared(Url("ws://localhost:5555/")); + bool connected = false; + ws->SetOnConnect([&connected]() { connected = true; }); -// TODO: Implement Protocol and Socket mocks. -void ConnectAndClose() -// TEST_METHOD(WebSocketTest_ConnectAndClose) -{ - auto ws = std::make_shared(Url("ws://localhost:5555/")); - bool connected = false; - ws->SetOnConnect([&connected]() { connected = true; }); + ws->Connect({}, {}); + ws->Close(IWebSocket::CloseCode::Normal, "BECAUSE!"); - ws->Connect({}, {}); - ws->Close(IWebSocket::CloseCode::Normal, "BECAUSE!"); + Assert::IsTrue(connected); + } - Assert::IsTrue(connected); -} + // TODO: Implement Protocol and Socket mocks. + void SendAndReceive() + // TEST_METHOD(WebSocketTest_SendAndReceive) + { + auto ws = std::make_shared(Url("ws://localhost:5555/")); + ws->SetOnMessage([](size_t size, const string &message) { + // EXPECT_EQ("uppercaseme_response", ss.str());//TODO: Check test server. + // Sending back "hello". + Assert::AreEqual( + string("hello"), + message); // TODO: Check test server. Sending back "hello". + }); -// TODO: Implement Protocol and Socket mocks. -void SendAndReceive() -// TEST_METHOD(WebSocketTest_SendAndReceive) -{ - auto ws = std::make_shared(Url("ws://localhost:5555/")); - ws->SetOnMessage([](size_t size, const string &message) { - // EXPECT_EQ("uppercaseme_response", ss.str());//TODO: Check test server. - // Sending back "hello". - Assert::AreEqual( - string("hello"), - message); // TODO: Check test server. Sending back "hello". - }); + ws->Connect({}, {}); + ws->Send("uppercaseme"); + ws->Close(IWebSocket::CloseCode::Normal, ""); + } +}; - ws->Connect({}, {}); - ws->Send("uppercaseme"); - ws->Close(IWebSocket::CloseCode::Normal, ""); -} -} -; +// clang-format on + +} // namespace Microsoft::React::Test