From b36441ba5f6e1452b1caad747dfd5638192d8028 Mon Sep 17 00:00:00 2001 From: Matt Cooley Date: Fri, 1 Nov 2019 14:08:26 -0700 Subject: [PATCH] Remove AsyncHelper, Resource and Module.cpp from CalculatorUnitTests project. (#746) --- src/CalculatorUnitTests/AsyncHelper.cpp | 39 --------- src/CalculatorUnitTests/AsyncHelper.h | 74 ------------------ .../CalculatorUnitTests.rc | Bin 2664 -> 0 bytes .../CalculatorUnitTests.vcxproj | 10 +-- .../CalculatorUnitTests.vcxproj.filters | 7 -- src/CalculatorUnitTests/Module.cpp | 22 ------ .../StandardViewModelUnitTests.cpp | 6 +- src/CalculatorUnitTests/pch.h | 31 -------- src/CalculatorUnitTests/resource.h | 14 ---- 9 files changed, 4 insertions(+), 199 deletions(-) delete mode 100644 src/CalculatorUnitTests/AsyncHelper.cpp delete mode 100644 src/CalculatorUnitTests/AsyncHelper.h delete mode 100644 src/CalculatorUnitTests/CalculatorUnitTests.rc delete mode 100644 src/CalculatorUnitTests/Module.cpp delete mode 100644 src/CalculatorUnitTests/resource.h diff --git a/src/CalculatorUnitTests/AsyncHelper.cpp b/src/CalculatorUnitTests/AsyncHelper.cpp deleted file mode 100644 index 73937a5..0000000 --- a/src/CalculatorUnitTests/AsyncHelper.cpp +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#include "pch.h" -#include "AsyncHelper.h" -#include -#include - -using namespace std; -using namespace concurrency; -using namespace Platform; -using namespace CalculatorApp; -using namespace Windows::UI::Core; -using namespace Windows::ApplicationModel::Core; - -task AsyncHelper::RunOnUIThreadAsync(function&& action) -{ - auto callback = ref new DispatchedHandler([action]() { action(); }); - - return create_task(CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::Normal, callback)); -} - -void AsyncHelper::RunOnUIThread(function&& action, DWORD timeout) -{ - task waitTask = RunOnUIThreadAsync([action]() { action(); }); - - WaitForTask(waitTask, timeout); -} - -void AsyncHelper::Delay(DWORD milliseconds) -{ - thread timer(bind(CalculatorApp::AsyncHelper::Sleep, milliseconds)); - timer.join(); -} - -void AsyncHelper::Sleep(DWORD milliseconds) -{ - this_thread::sleep_for(chrono::milliseconds(milliseconds)); -} diff --git a/src/CalculatorUnitTests/AsyncHelper.h b/src/CalculatorUnitTests/AsyncHelper.h deleted file mode 100644 index db52809..0000000 --- a/src/CalculatorUnitTests/AsyncHelper.h +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#pragma once -#include - -namespace CalculatorApp -{ - class AsyncHelper - { - public: - static concurrency::task RunOnUIThreadAsync(std::function&& action); - static void RunOnUIThread(std::function&& action, DWORD timeout = INFINITE); - static void Delay(DWORD milliseconds); - - template - static void RunOnUIThread(std::function()>&& action, DWORD timeout = INFINITE) - { - concurrency::task t; - concurrency::task uiTask = - RunOnUIThreadAsync([&t, action]() { t = action(); }).then([&t]() { t.wait(); }, concurrency::task_continuation_context::use_arbitrary()); - - WaitForTask(uiTask, timeout); - } - - template - static bool WaitForTask(concurrency::task& t, DWORD timeout = INFINITE) - { - Microsoft::WRL::Wrappers::Event event(CreateEventEx(nullptr, nullptr, CREATE_EVENT_MANUAL_RESET, EVENT_ALL_ACCESS)); - if (!event.IsValid()) - { - throw std::bad_alloc(); - } - - Platform::Exception ^ ex; - t.then( - [&event, &ex](concurrency::task prevTask) { - try - { - prevTask.get(); - } - catch (Platform::Exception ^ e) - { - ex = e; - } - - if (event.IsValid()) - { - SetEvent(event.Get()); - } - }, - concurrency::task_continuation_context::use_arbitrary()); - - DWORD waitResult; // = STATUS_PENDING; - waitResult = WaitForSingleObjectEx(event.Get(), timeout, true); - event.Close(); - - if (ex != nullptr) - { - throw ex; - } - - if (waitResult == WAIT_FAILED) - { - throw ref new Platform::Exception(-1, L"Error in waiting for task completion: " + waitResult.ToString()); - } - - return waitResult == WAIT_OBJECT_0; - } - - private: - static void Sleep(DWORD milliseconds); - }; -} diff --git a/src/CalculatorUnitTests/CalculatorUnitTests.rc b/src/CalculatorUnitTests/CalculatorUnitTests.rc deleted file mode 100644 index 6d285329154a138f9216537b866148988d06f675..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2664 zcmdUxTTAOe5Xb+|g5M#wFN$KlJo%`t7CE&_FQQN=VvQDRJTxu7_}M+@HyamYlPF#u zBFlC*)0x?s|6G!P&o$K)=tN^(YpMsu>`*g!=kQ|9b)^YUb*-}k-RedWdkTLB9l@JI zO>fTWnsdODSsUvwGMie~61UVGt-_7?cY^fD$yPG@o4QlQNtyg zL&rMRP#qn@ZE$X@rAs(neou4&r^VUdZ$6Z7dG9<8)C8ABj6+a*&^__bK*wX?I-RZ>XYU#ks|yti8}>b(odZbbi0 z$W%-X1X?BM5l_AkyPT4)jJ1|i1#zmU#tyHQH@!8&;=Ycks-&m7^iQAes&n&@>T0pf z?h`90)a+rSLk$nnYNNmAZf(JB!|g+xu1@!~ftBqApNcbSb$*UVf6#9Hx}MJOR-ap= zwzol~Sn`0#o37tYHh5Y2^K+oBmlPO~3yZ_E?q+hqO25VR5}je2>_7V)mVz&HI09JUAu* diff --git a/src/CalculatorUnitTests/CalculatorUnitTests.vcxproj b/src/CalculatorUnitTests/CalculatorUnitTests.vcxproj index 5c313c5..e93899d 100644 --- a/src/CalculatorUnitTests/CalculatorUnitTests.vcxproj +++ b/src/CalculatorUnitTests/CalculatorUnitTests.vcxproj @@ -207,12 +207,10 @@ - - UnitTestApp.xaml @@ -238,7 +236,6 @@ - @@ -248,7 +245,6 @@ - @@ -272,7 +268,6 @@ - @@ -288,9 +283,6 @@ Designer - - - {311e866d-8b93-4609-a691-265941fee101} @@ -302,4 +294,4 @@ - + \ No newline at end of file diff --git a/src/CalculatorUnitTests/CalculatorUnitTests.vcxproj.filters b/src/CalculatorUnitTests/CalculatorUnitTests.vcxproj.filters index 63c8bc4..dfafb3c 100644 --- a/src/CalculatorUnitTests/CalculatorUnitTests.vcxproj.filters +++ b/src/CalculatorUnitTests/CalculatorUnitTests.vcxproj.filters @@ -9,7 +9,6 @@ - @@ -17,7 +16,6 @@ - @@ -33,20 +31,15 @@ - - Mocks - - - diff --git a/src/CalculatorUnitTests/Module.cpp b/src/CalculatorUnitTests/Module.cpp deleted file mode 100644 index 825b62e..0000000 --- a/src/CalculatorUnitTests/Module.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#include "pch.h" -#include - -using namespace Microsoft::VisualStudio::CppUnitTestFramework; - -namespace CalculatorUnitTests -{ - BEGIN_TEST_MODULE_ATTRIBUTE() - TEST_MODULE_ATTRIBUTE(L"APPX:CertificateFileName", L"CalculatorUnitTests.cer:TrustedPeople") - END_TEST_MODULE_ATTRIBUTE() - - TEST_MODULE_INITIALIZE(ModuleSetup) - { - } - - TEST_MODULE_CLEANUP(ModuleCleanup) - { - } -} diff --git a/src/CalculatorUnitTests/StandardViewModelUnitTests.cpp b/src/CalculatorUnitTests/StandardViewModelUnitTests.cpp index 6a82173..e882ace 100644 --- a/src/CalculatorUnitTests/StandardViewModelUnitTests.cpp +++ b/src/CalculatorUnitTests/StandardViewModelUnitTests.cpp @@ -509,7 +509,7 @@ namespace CalculatorUnitTests VERIFY_ARE_EQUAL(Utils::GetStringValue(m_viewModel->DecimalDisplayValue), StringReference(L"15")); VERIFY_ARE_EQUAL(Utils::GetStringValue(m_viewModel->OctalDisplayValue), StringReference(L"17")); VERIFY_ARE_EQUAL(Utils::GetStringValue(m_viewModel->BinaryDisplayValue), StringReference(L"1111")); - auto val = ref new PC::Vector(64, false); + auto val = ref new Platform::Collections::Vector(64, false); val->SetAt(0, true); val->SetAt(1, true); val->SetAt(2, true); @@ -562,7 +562,7 @@ namespace CalculatorUnitTests VERIFY_ARE_EQUAL(Utils::GetStringValue(m_viewModel->DecimalDisplayValue), StringReference(L"123,456,789")); VERIFY_ARE_EQUAL(Utils::GetStringValue(m_viewModel->OctalDisplayValue), StringReference(L"726 746 425")); VERIFY_ARE_EQUAL(Utils::GetStringValue(m_viewModel->BinaryDisplayValue), StringReference(L"0111 0101 1011 1100 1101 0001 0101")); - auto val = ref new PC::Vector(64, false); + auto val = ref new Platform::Collections::Vector(64, false); val->SetAt(0, true); val->SetAt(2, true); val->SetAt(4, true); @@ -599,7 +599,7 @@ namespace CalculatorUnitTests Utils::GetStringValue(m_viewModel->BinaryDisplayValue), StringReference(L"1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1110")); VERIFY_ARE_EQUAL(m_viewModel->DisplayValue, StringReference(L"-2")); - auto val = ref new PC::Vector(64, true); + auto val = ref new Platform::Collections::Vector(64, true); val->SetAt(0, false); CompareVector(m_viewModel->BinaryDigits, val); } diff --git a/src/CalculatorUnitTests/pch.h b/src/CalculatorUnitTests/pch.h index 029bb46..b4137b2 100644 --- a/src/CalculatorUnitTests/pch.h +++ b/src/CalculatorUnitTests/pch.h @@ -48,37 +48,6 @@ #include "winrt/Windows.Globalization.DateTimeFormatting.h" #include "winrt/Windows.System.UserProfile.h" -namespace CalculatorApp -{ - namespace WF = Windows::Foundation; - namespace WUC = Windows::UI::Core; - namespace WX = Windows::UI::Xaml; - namespace WXC = Windows::UI::Xaml::Controls; - namespace WXCP = Windows::UI::Xaml::Controls::Primitives; - namespace P = Platform; - namespace PC = Platform::Collections; - namespace WXI = Windows::UI::Xaml::Input; - namespace WFC = Windows::Foundation::Collections; - namespace WS = Windows::System; - namespace WAR = Windows::ApplicationModel::Resources; - namespace WXMA = Windows::UI::Xaml::Media::Animation; - namespace WXD = Windows::UI::Xaml::Data; - namespace WXInt = Windows::UI::Xaml::Interop; - namespace WXM = Windows::UI::Xaml::Markup; - namespace WXA = Windows::UI::Xaml::Automation; -} - -// The following namespaces exist as a convenience to resolve -// ambiguity for Windows types in the Windows::UI::Xaml::Automation::Peers -// namespace that only exist on RS3. -// Once the app switches to min version RS3, the namespaces can be removed. -// TODO - MSFT 12735088 -namespace StandardPeers = Windows::UI::Xaml::Automation::Peers; -namespace CalculatorApp::Common::Automation -{ -} -namespace CustomPeers = CalculatorApp::Common::Automation; - // CalcManager Headers #include "CalcManager/ExpressionCommand.h" #include "CalcManager/CalculatorResource.h" diff --git a/src/CalculatorUnitTests/resource.h b/src/CalculatorUnitTests/resource.h deleted file mode 100644 index 12d93a3..0000000 --- a/src/CalculatorUnitTests/resource.h +++ /dev/null @@ -1,14 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by CalculatorUnitTests_VS.rc - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 101 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1001 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif