diff --git a/test/DynamicDependency/data/WindowsAppRuntime.Test.Singleton.Msix/WindowsAppRuntime.Test.Singleton.Msix.vcxproj b/test/DynamicDependency/data/WindowsAppRuntime.Test.Singleton.Msix/WindowsAppRuntime.Test.Singleton.Msix.vcxproj index bc3464e38e..13cca41c69 100644 --- a/test/DynamicDependency/data/WindowsAppRuntime.Test.Singleton.Msix/WindowsAppRuntime.Test.Singleton.Msix.vcxproj +++ b/test/DynamicDependency/data/WindowsAppRuntime.Test.Singleton.Msix/WindowsAppRuntime.Test.Singleton.Msix.vcxproj @@ -94,10 +94,27 @@ REM TODO Clean WindowsAppRuntime.Test.Singleton.msix + PushNotificationsLongRunningTask + + $(TargetBasename).StartupTask + $(OutDir)$(StartupExe) + $(StartupExeDir)\$(StartupExe).exe + + $(TargetBasename) + $(OutDir)$(TargetExe) + $(TargetExeDir)\$(TargetExe).exe + + $(TargetBasename).ProxyStub + $(OutDir)$(TargetExeProxyStub) + $(TargetExeProxyStubDir)\$(TargetExeProxyStub).dll - + + + + + $(RepoTestCertificatePFX) @@ -107,6 +124,17 @@ + + + {bf3fced0-cadb-490a-93a7-4d90e1f45ab0} + + + {1debbff6-ee6e-4944-9de2-35b7a686af42} + + + {1307dd1b-bbe8-4cd0-b1a0-0db6d61eeaa0} + + diff --git a/test/DynamicDependency/data/WindowsAppRuntime.Test.Singleton.Msix/appxmanifest.xml b/test/DynamicDependency/data/WindowsAppRuntime.Test.Singleton.Msix/appxmanifest.xml index 48c68538f0..846fb81440 100644 --- a/test/DynamicDependency/data/WindowsAppRuntime.Test.Singleton.Msix/appxmanifest.xml +++ b/test/DynamicDependency/data/WindowsAppRuntime.Test.Singleton.Msix/appxmanifest.xml @@ -29,6 +29,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/PushNotificationTests/APITests.cpp b/test/PushNotificationTests/APITests.cpp deleted file mode 100644 index 1215b71713..0000000000 --- a/test/PushNotificationTests/APITests.cpp +++ /dev/null @@ -1,328 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See LICENSE in the project root for license information. - -#include "pch.h" -#include -#include "MockBackgroundTaskInstance.h" - -using namespace WEX::Common; -using namespace WEX::Logging; -using namespace WEX::TestExecution; - -using namespace winrt::Windows::ApplicationModel::Activation; -using namespace winrt::Windows::ApplicationModel::Background; -using namespace winrt::Windows::Foundation; -using namespace winrt::Windows::Foundation::Collections; -using namespace winrt::Windows::Management::Deployment; -using namespace winrt::Windows::Storage; -using namespace winrt::Windows::System; - -namespace Test::PushNotifications -{ - class APITests - { - private: - wil::unique_event m_failed; - wil::unique_process_handle m_processHandle; - winrt::com_ptr m_testAppLauncher; - - public: - BEGIN_TEST_CLASS(APITests) - TEST_CLASS_PROPERTY(L"Description", L"Windows App SDK Push Notifications test") - TEST_CLASS_PROPERTY(L"ThreadingModel", L"MTA") - TEST_CLASS_PROPERTY(L"RunAs:Class", L"RestrictedUser") - END_TEST_CLASS() - - static const int testWaitTime() - { - return 3000; - } - - static const int channelTestWaitTime() - { - return 303000; // Need to wait 300000ms for channel request + 3000ms for application overhead - } - - static PCWSTR GetTestPackageFile() - { - return L"PushNotificationsTestAppPackage"; - } - - static PCWSTR GetTestPackageFullName() - { - return L"PushNotificationsTestAppPackage_1.0.0.0_" WINDOWSAPPRUNTIME_TEST_PACKAGE_DDLM_ARCHITECTURE L"__8wekyb3d8bbwe"; - } - - TEST_CLASS_SETUP(ClassInit) - { - try - { - // Cleanup previous installations. Need this to remove any manual installations outside of running this tests. - TP::RemovePackage(GetTestPackageFullName()); - TP::RemovePackage_PushNotificationsLongRunningTask(); - TP::RemovePackage_DynamicDependencyLifetimeManager(); - TP::RemovePackage_DynamicDependencyDataStore(); - TP::RemovePackage_WindowsAppRuntimeFramework(); - - TP::AddPackage_WindowsAppRuntimeFramework(); // Installs WARfwk - TP::AddPackage_DynamicDependencyDataStore(); // Installs WARmain - TP::AddPackage_DynamicDependencyLifetimeManager(); // Installs WARddlm - TP::AddPackage_PushNotificationsLongRunningTask(); // Installs the PushNotifications long running task. - TP::WapProj::AddPackage(TAEF::GetDeploymentDir(), GetTestPackageFile(), L".msix"); // Installs PushNotificationsTestApp.msix - } - catch (...) - { - return false; - } - - m_testAppLauncher = winrt::create_instance(CLSID_ApplicationActivationManager, CLSCTX_ALL); - return true; - } - - TEST_CLASS_CLEANUP(ClassUninit) - { - try - { - // Remove in reverse order to avoid conflicts between inter-dependent packages. - TP::RemovePackage(GetTestPackageFullName()); - TP::RemovePackage_PushNotificationsLongRunningTask(); - TP::RemovePackage_DynamicDependencyLifetimeManager(); - TP::RemovePackage_DynamicDependencyDataStore(); - TP::RemovePackage_WindowsAppRuntimeFramework(); - } - catch (...) - { - return false; - } - return true; - } - - TEST_METHOD_SETUP(MethodInit) - { - VERIFY_IS_TRUE(TP::IsPackageRegistered_WindowsAppRuntimeFramework()); - VERIFY_IS_TRUE(TP::IsPackageRegistered_DynamicDependencyDataStore()); - VERIFY_IS_TRUE(TP::IsPackageRegistered_DynamicDependencyLifetimeManager()); - VERIFY_IS_TRUE(TP::IsPackageRegistered_PushNotificationsLongRunningTask()); - return true; - } - - TEST_METHOD_CLEANUP(MethodUninit) - { - VERIFY_IS_TRUE(TP::IsPackageRegistered_WindowsAppRuntimeFramework()); - VERIFY_IS_TRUE(TP::IsPackageRegistered_DynamicDependencyDataStore()); - VERIFY_IS_TRUE(TP::IsPackageRegistered_DynamicDependencyLifetimeManager()); - VERIFY_IS_TRUE(TP::IsPackageRegistered_PushNotificationsLongRunningTask()); - - m_processHandle.reset(); - return true; - } - - wil::unique_handle RunUnpackaged(const std::wstring& command, const std::wstring& args, const std::wstring& directory) - { - SHELLEXECUTEINFO ei{}; - ei.cbSize = sizeof(SHELLEXECUTEINFO); - ei.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_DOENVSUBST; - ei.lpFile = command.c_str(); - ei.lpParameters = args.c_str(); - ei.lpDirectory = directory.c_str(); - ei.nShow = SW_NORMAL; - - if (!ShellExecuteEx(&ei)) - { - auto lastError = GetLastError(); - VERIFY_WIN32_SUCCEEDED(lastError); - } - - wil::unique_handle process{ ei.hProcess }; - return process; - } - - void RunTest(const PCWSTR& testName, const int& waitTime) - { - DWORD processId {}; - VERIFY_SUCCEEDED(m_testAppLauncher->ActivateApplication(L"PushNotificationsTestAppPackage_8wekyb3d8bbwe!App", testName, AO_NONE, &processId)); - - m_processHandle.reset(OpenProcess(SYNCHRONIZE | PROCESS_QUERY_LIMITED_INFORMATION, FALSE, processId)); - VERIFY_IS_TRUE(m_processHandle.is_valid()); - - VERIFY_IS_TRUE(wil::handle_wait(m_processHandle.get(), waitTime)); - - DWORD exitCode {}; - VERIFY_WIN32_BOOL_SUCCEEDED(GetExitCodeProcess(m_processHandle.get(), &exitCode)); - VERIFY_ARE_EQUAL(exitCode, 0); - } - - const std::wstring GetDeploymentDir() - { - WEX::Common::String deploymentDir; - WEX::TestExecution::RuntimeParameters::TryGetValue(L"TestDeploymentDir", deploymentDir); - return reinterpret_cast(deploymentDir.GetBuffer()); - } - - void RunTestUnpackaged(const PCWSTR& testName, const int& waitTime) - { - auto processHandle = RunUnpackaged(L"PushNotificationsTestApp.exe", testName, GetDeploymentDir()); - VERIFY_IS_TRUE(processHandle.is_valid()); - - VERIFY_IS_TRUE(wil::handle_wait(processHandle.get(), channelTestWaitTime())); - - DWORD exitCode{}; - VERIFY_WIN32_BOOL_SUCCEEDED(GetExitCodeProcess(processHandle.get(), &exitCode)); - VERIFY_ARE_EQUAL(exitCode, 0); - } - - TEST_METHOD(BackgroundActivation) - { - RunTest(L"BackgroundActivationTest", testWaitTime()); // Need to launch one time to enable background activation. - - auto LocalBackgroundTask = winrt::create_instance(c_comServerId, CLSCTX_ALL); - auto mockBackgroundTaskInstance = winrt::make(); - VERIFY_NO_THROW(LocalBackgroundTask.Run(mockBackgroundTaskInstance)); - } - - TEST_METHOD(MultipleBackgroundActivation) - { - RunTest(L"BackgroundActivationTest", testWaitTime()); // Need to launch one time to enable background activation. - - auto LocalBackgroundTask1 = winrt::create_instance(c_comServerId, CLSCTX_ALL); - auto mockBackgroundTaskInstance1 = winrt::make(); - - auto LocalBackgroundTask2 = winrt::create_instance(c_comServerId, CLSCTX_ALL); - auto mockBackgroundTaskInstance2 = winrt::make(); - - VERIFY_NO_THROW(LocalBackgroundTask1.Run(mockBackgroundTaskInstance1)); - VERIFY_NO_THROW(LocalBackgroundTask2.Run(mockBackgroundTaskInstance2)); - - } - - TEST_METHOD(ChannelRequestUsingNullRemoteId) - { - RunTest(L"ChannelRequestUsingNullRemoteId", testWaitTime()); - } - - TEST_METHOD(ChannelRequestUsingNullRemoteId_Unpackaged) - { - RunTestUnpackaged(L"ChannelRequestUsingNullRemoteId", testWaitTime()); - } - - TEST_METHOD(ChannelRequestUsingRemoteId) - { - RunTest(L"ChannelRequestUsingRemoteId", channelTestWaitTime()); - } - - TEST_METHOD(ChannelRequestUsingRemoteId_Unpackaged) - { - RunTestUnpackaged(L"ChannelRequestUsingRemoteId", channelTestWaitTime()); - } - - TEST_METHOD(MultipleChannelClose_Unpackaged) - { - RunTestUnpackaged(L"MultipleChannelClose", 3000000); - } - - TEST_METHOD(VerifyRegisterandUnregister) - { - RunTest(L"VerifyRegisterandUnregister", testWaitTime()); - } - - TEST_METHOD(VerifyRegisterandUnregister_Unpackaged) - { - RunTestUnpackaged(L"VerifyRegisterandUnregister", testWaitTime()); - } - - TEST_METHOD(VerifyRegisterandUnregisterAll) - { - RunTest(L"VerifyRegisterandUnregisterAll", testWaitTime()); - } - - TEST_METHOD(VerifyRegisterandUnregisterAll_Unpackaged) - { - RunTestUnpackaged(L"VerifyRegisterandUnregisterAll", testWaitTime()); - } - - TEST_METHOD(MultipleRegister) - { - RunTest(L"MultipleRegister", testWaitTime()); - } - - TEST_METHOD(MultipleRegister_Unpackaged) - { - RunTestUnpackaged(L"MultipleRegister", testWaitTime()); - } - - TEST_METHOD(VerifyMultipleRegisterAndUnregister) - { - RunTest(L"VerifyMultipleRegisterAndUnregister", testWaitTime()); - } - - TEST_METHOD(VerifyMultipleRegisterAndUnregister_Unpackaged) - { - RunTestUnpackaged(L"VerifyMultipleRegisterAndUnregister", testWaitTime()); - } - - TEST_METHOD(VerifyMultipleRegisterAndUnregisterAll) - { - RunTest(L"VerifyMultipleRegisterAndUnregisterAll", testWaitTime()); - } - - TEST_METHOD(VerifyMultipleRegisterAndUnregisterAll_Unpackaged) - { - RunTestUnpackaged(L"VerifyMultipleRegisterAndUnregisterAll", testWaitTime()); - } - - TEST_METHOD(VerifyUnregisterTwice) - { - RunTest(L"VerifyUnregisterTwice", testWaitTime()); - } - - TEST_METHOD(VerifyUnregisterTwice_Unpackaged) - { - RunTestUnpackaged(L"VerifyUnregisterTwice", testWaitTime()); - } - - TEST_METHOD(VerifyUnregisterAll) - { - RunTest(L"VerifyUnregisterAll", testWaitTime()); - } - - TEST_METHOD(VerifyUnregisterAll_Unpackaged) - { - RunTestUnpackaged(L"VerifyUnregisterAll", testWaitTime()); - } - - TEST_METHOD(VerifyUnregisterAllTwice) - { - RunTest(L"VerifyUnregisterAllTwice", testWaitTime()); - } - - TEST_METHOD(VerifyUnregisterAllTwice_Unpackaged) - { - RunTestUnpackaged(L"VerifyUnregisterAllTwice", testWaitTime()); - } - - TEST_METHOD(VerifyUnregisterAndUnregisterAll) - { - RunTest(L"VerifyUnregisterAndUnregisterAll", testWaitTime()); - } - - TEST_METHOD(VerifyUnregisterAndUnregisterAll_Unpackaged) - { - RunTestUnpackaged(L"VerifyUnregisterAndUnregisterAll", testWaitTime()); - } - - TEST_METHOD(VerifyForegroundHandlerSucceeds) - { - RunTest(L"VerifyForegroundHandlerSucceeds", testWaitTime()); - } - - TEST_METHOD(VerifyForegroundHandlerFails) - { - RunTest(L"VerifyForegroundHandlerFails", testWaitTime()); - } - - TEST_METHOD(VerifyProtocolActivation_Unpackaged) - { - RunTestUnpackaged(L"----WindowsAppRuntimePushServer:-Payload:\"\"", testWaitTime()); - } - }; -} diff --git a/test/PushNotificationTests/BaseTestSuite.cpp b/test/PushNotificationTests/BaseTestSuite.cpp new file mode 100644 index 0000000000..e7f0203520 --- /dev/null +++ b/test/PushNotificationTests/BaseTestSuite.cpp @@ -0,0 +1,249 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#include "pch.h" + +#include "PushNotification-Test-Constants.h" +#include "BaseTestSuite.h" + +using namespace WEX::Common; +using namespace WEX::Logging; +using namespace WEX::TestExecution; + +using namespace winrt::Windows::ApplicationModel::Activation; +using namespace winrt::Windows::ApplicationModel::Background; +using namespace winrt::Windows::Foundation; +using namespace winrt::Windows::Foundation::Collections; +using namespace winrt::Windows::Management::Deployment; +using namespace winrt::Windows::Storage; +using namespace winrt::Windows::System; +using namespace winrt::Microsoft::Windows::PushNotifications; + +void BaseTestSuite::ClassSetup() +{ + ::Test::Bootstrap::Setup(); + bool isSelfContained{}; + VERIFY_SUCCEEDED(TestData::TryGetValue(L"SelfContained", isSelfContained)); + + if (!isSelfContained) + { + ::WindowsAppRuntime::SelfContained::TestInitialize(::Test::Bootstrap::TP::WindowsAppRuntimeFramework::c_PackageFamilyName); + } +} + +void BaseTestSuite::ClassCleanup() +{ + ::Test::Bootstrap::Cleanup(); +} + +void BaseTestSuite::MethodCleanup() +{ + if (!m_unregisteredFully) + { + PushNotificationManager::Default().UnregisterAll(); + m_unregisteredFully = true; + } +} + +HRESULT BaseTestSuite::ChannelRequestHelper(IAsyncOperationWithProgress const& channelOperation) +{ + if (channelOperation.wait_for(c_timeout) != winrt::Windows::Foundation::AsyncStatus::Completed) + { + channelOperation.Cancel(); + RETURN_WIN32(ERROR_TIMEOUT); // timed out or failed + } + + auto result{ channelOperation.GetResults() }; + auto status{ result.Status() }; + RETURN_HR_IF(result.ExtendedError(), status != PushNotificationChannelStatus::CompletedSuccess); + + result.Channel().Close(); + return S_OK; +} + +void BaseTestSuite::RegisterWithPushNotificationManager() +{ + PushNotificationManager::Default().Register(); + m_unregisteredFully = false; +} + +void BaseTestSuite::UnregisterAllWithPushNotificationManager() +{ + PushNotificationManager::Default().UnregisterAll(); + m_unregisteredFully = true; +} + +void BaseTestSuite::ChannelRequestUsingNullRemoteId() +{ + if (PushNotificationManager::Default().IsSupported()) + { + VERIFY_THROWS_HR(PushNotificationManager::Default().CreateChannelAsync(winrt::guid()).get(), E_INVALIDARG); + } + else + { + auto channelOperation{ PushNotificationManager::Default().CreateChannelAsync(winrt::guid()) }; + VERIFY_ARE_EQUAL(ChannelRequestHelper(channelOperation), E_FAIL); + } +} + +void BaseTestSuite::ChannelRequestUsingRemoteId() +{ + if (PushNotificationManager::Default().IsSupported()) + { + auto channelOperation{ PushNotificationManager::Default().CreateChannelAsync(c_azureRemoteId) }; + VERIFY_SUCCEEDED(ChannelRequestHelper(channelOperation)); + } + else + { + auto channelOperation{ PushNotificationManager::Default().CreateChannelAsync(c_azureRemoteId) }; + VERIFY_ARE_EQUAL(ChannelRequestHelper(channelOperation), E_FAIL); + } +} + +// Currently failing - https://github.com/microsoft/WindowsAppSDK/issues/2392 +void BaseTestSuite::MultipleChannelClose() +{ + auto channelOperation{ PushNotificationManager::Default().CreateChannelAsync(c_azureRemoteId) }; + if (channelOperation.wait_for(c_timeout) != winrt::Windows::Foundation::AsyncStatus::Completed) + { + channelOperation.Cancel(); + VERIFY_FAIL(L"Channel request hit timeout."); + } + + auto result{ channelOperation.GetResults() }; + VERIFY_ARE_EQUAL(result.Status(), PushNotificationChannelStatus::CompletedSuccess); + + result.Channel().Close(); + VERIFY_THROWS_HR(result.Channel().Close(), WPN_E_CHANNEL_CLOSED); +} + +void BaseTestSuite::VerifyRegisterAndUnregister() +{ + RegisterWithPushNotificationManager(); + + PushNotificationManager::Default().Unregister(); +} + +void BaseTestSuite::VerifyUnregisterFails() +{ + if (PushNotificationManager::Default().IsSupported()) + { + VERIFY_THROWS_HR(PushNotificationManager::Default().Unregister(), E_UNEXPECTED); + } + else + { + PushNotificationManager::Default().Unregister(); + } +} + +void BaseTestSuite::VerifyUnregisterAllFails() +{ + if (PushNotificationManager::Default().IsSupported()) + { + VERIFY_THROWS_HR(PushNotificationManager::Default().UnregisterAll(), E_UNEXPECTED); + } + else + { + PushNotificationManager::Default().UnregisterAll(); + } +} + +void BaseTestSuite::VerifyRegisterAndUnregisterAll() +{ + RegisterWithPushNotificationManager(); + UnregisterAllWithPushNotificationManager(); +} + +void BaseTestSuite::MultipleRegister() +{ + RegisterWithPushNotificationManager(); + if (PushNotificationManager::Default().IsSupported()) + { + VERIFY_THROWS_HR(PushNotificationManager::Default().Register(), HRESULT_FROM_WIN32(ERROR_ALREADY_REGISTERED)); + } + else + { + PushNotificationManager::Default().Register(); + } +} + +void BaseTestSuite::VerifyMultipleRegisterAndUnregister() +{ + RegisterWithPushNotificationManager(); + + PushNotificationManager::Default().Unregister(); + + if (PushNotificationManager::Default().IsSupported()) + { + VERIFY_THROWS_HR(PushNotificationManager::Default().Register(), HRESULT_FROM_WIN32(ERROR_ALREADY_REGISTERED)); + } + else + { + PushNotificationManager::Default().Register(); + } +} + +void BaseTestSuite::VerifyMultipleRegisterAndUnregisterAll() +{ + RegisterWithPushNotificationManager(); + UnregisterAllWithPushNotificationManager(); + + RegisterWithPushNotificationManager(); + UnregisterAllWithPushNotificationManager(); +} + +void BaseTestSuite::VerifyUnregisterTwice() +{ + RegisterWithPushNotificationManager(); + + PushNotificationManager::Default().Unregister(); + if (PushNotificationManager::Default().IsSupported()) + { + VERIFY_THROWS_HR(PushNotificationManager::Default().Unregister(), E_UNEXPECTED); + } + else + { + PushNotificationManager::Default().Unregister(); + } +} + +void BaseTestSuite::VerifyUnregisterAllTwice() +{ + RegisterWithPushNotificationManager(); + UnregisterAllWithPushNotificationManager(); + + if (PushNotificationManager::Default().IsSupported()) + { + VERIFY_THROWS_HR(PushNotificationManager::Default().UnregisterAll(), E_UNEXPECTED); + } + else + { + PushNotificationManager::Default().UnregisterAll(); + } +} + +void BaseTestSuite::VerifyUnregisterAndUnregisterAll() +{ + RegisterWithPushNotificationManager(); + PushNotificationManager::Default().Unregister(); + UnregisterAllWithPushNotificationManager(); +} + +void BaseTestSuite::VerifyForegroundHandlerSucceeds() +{ + PushNotificationManager::Default().PushReceived([](const auto&, PushNotificationReceivedEventArgs const& /* args */) {}); + RegisterWithPushNotificationManager(); +} + +void BaseTestSuite::VerifyForegroundHandlerFails() +{ + RegisterWithPushNotificationManager(); + if (PushNotificationManager::Default().IsSupported()) + { + VERIFY_THROWS_HR(PushNotificationManager::Default().PushReceived([](const auto&, PushNotificationReceivedEventArgs const& /* args */) {}), HRESULT_FROM_WIN32(ERROR_NOT_FOUND)); + } + else + { + PushNotificationManager::Default().PushReceived([](const auto&, PushNotificationReceivedEventArgs const& /* args */) {}); + } +} diff --git a/test/PushNotificationTests/BaseTestSuite.h b/test/PushNotificationTests/BaseTestSuite.h new file mode 100644 index 0000000000..3bf0a24522 --- /dev/null +++ b/test/PushNotificationTests/BaseTestSuite.h @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#include "pch.h" +#include + +using namespace WEX::Common; +using namespace WEX::Logging; +using namespace WEX::TestExecution; +using namespace winrt::Windows::Foundation; +using namespace winrt::Microsoft::Windows::PushNotifications; + +class BaseTestSuite +{ + public: + // Unit test environment functions + void ClassSetup(); + void ClassCleanup(); + void MethodCleanup(); + + // Base unit tests + void ChannelRequestUsingNullRemoteId(); + void ChannelRequestUsingRemoteId(); + void MultipleChannelClose(); // Currently failing + void VerifyRegisterAndUnregister(); + void VerifyRegisterAndUnregisterAll(); + void VerifyUnregisterFails(); + void VerifyUnregisterAllFails(); + void MultipleRegister(); + void VerifyMultipleRegisterAndUnregister(); + void VerifyMultipleRegisterAndUnregisterAll(); + void VerifyUnregisterTwice(); + void VerifyUnregisterAllTwice(); + void VerifyUnregisterAndUnregisterAll(); + void VerifyForegroundHandlerSucceeds(); + void VerifyForegroundHandlerFails(); + + private: + HRESULT ChannelRequestHelper(IAsyncOperationWithProgress const& channelOperation); + void RegisterWithPushNotificationManager(); + void UnregisterAllWithPushNotificationManager(); + + bool m_unregisteredFully{ true }; +}; diff --git a/test/PushNotificationTests/LRPTests.cpp b/test/PushNotificationTests/LRPTests.cpp index d5f294e964..0de336bc58 100644 --- a/test/PushNotificationTests/LRPTests.cpp +++ b/test/PushNotificationTests/LRPTests.cpp @@ -34,6 +34,11 @@ namespace Test::PushNotifications try { VERIFY_SUCCEEDED(::CoInitializeEx(nullptr, COINITBASE_MULTITHREADED)); + TP::RemovePackage_PushNotificationsLongRunningTask(); + TP::RemovePackage_DynamicDependencyLifetimeManager(); + TP::RemovePackage_DynamicDependencyDataStore(); + TP::RemovePackage_WindowsAppRuntimeFramework(); + TP::AddPackage_WindowsAppRuntimeFramework(); // Installs WASfwk TP::AddPackage_DynamicDependencyDataStore(); // Installs WASmain TP::AddPackage_DynamicDependencyLifetimeManager(); // Installs WASddlm diff --git a/test/PushNotificationTests/PackagedTests.cpp b/test/PushNotificationTests/PackagedTests.cpp new file mode 100644 index 0000000000..bf55dc57aa --- /dev/null +++ b/test/PushNotificationTests/PackagedTests.cpp @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. +#include "pch.h" +#include "PackagedTests.h" + +void PackagedTests::ChannelRequestUsingNullRemoteId() +{ + BaseTestSuite::ChannelRequestUsingNullRemoteId(); +} + +void PackagedTests::ChannelRequestUsingRemoteId() +{ + BaseTestSuite::ChannelRequestUsingRemoteId(); +} + +// Currently failing - https://github.com/microsoft/WindowsAppSDK/issues/2392 +void PackagedTests::MultipleChannelClose() +{ + BaseTestSuite::MultipleChannelClose(); +} + +void PackagedTests::VerifyRegisterAndUnregister() +{ + BaseTestSuite::VerifyRegisterAndUnregister(); +} + +void PackagedTests::VerifyUnregisterFails() +{ + BaseTestSuite::VerifyUnregisterFails(); +} + +void PackagedTests::VerifyUnregisterAllFails() +{ + BaseTestSuite::VerifyUnregisterAllFails(); +} + +void PackagedTests::VerifyRegisterAndUnregisterAll() +{ + BaseTestSuite::VerifyRegisterAndUnregisterAll(); +} + +void PackagedTests::MultipleRegister() +{ + BaseTestSuite::MultipleRegister(); +} + +void PackagedTests::VerifyMultipleRegisterAndUnregister() +{ + BaseTestSuite::VerifyMultipleRegisterAndUnregister(); +} + +void PackagedTests::VerifyMultipleRegisterAndUnregisterAll() +{ + BaseTestSuite::VerifyMultipleRegisterAndUnregisterAll(); +} + +void PackagedTests::VerifyUnregisterTwice() +{ + BaseTestSuite::VerifyUnregisterTwice(); +} + +void PackagedTests::VerifyUnregisterAllTwice() +{ + BaseTestSuite::VerifyUnregisterAllTwice(); +} + +void PackagedTests::VerifyUnregisterAndUnregisterAll() +{ + BaseTestSuite::VerifyUnregisterAndUnregisterAll(); +} + +void PackagedTests::VerifyForegroundHandlerSucceeds() +{ + BaseTestSuite::VerifyForegroundHandlerSucceeds(); +} + +void PackagedTests::VerifyForegroundHandlerFails() +{ + BaseTestSuite::VerifyForegroundHandlerFails(); +} diff --git a/test/PushNotificationTests/PackagedTests.h b/test/PushNotificationTests/PackagedTests.h new file mode 100644 index 0000000000..2a56324efd --- /dev/null +++ b/test/PushNotificationTests/PackagedTests.h @@ -0,0 +1,64 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#include "pch.h" +#include "BaseTestSuite.h" + +using namespace WEX::Common; +using namespace WEX::Logging; +using namespace WEX::TestExecution; + +class PackagedTests : BaseTestSuite +{ + BEGIN_TEST_CLASS(PackagedTests) + TEST_CLASS_PROPERTY(L"ThreadingModel", L"MTA") + TEST_CLASS_PROPERTY(L"RunFixtureAs:Class", L"RestrictedUser") + TEST_CLASS_PROPERTY(L"IsolationLevel", L"Class") + TEST_CLASS_PROPERTY(L"Data:SelfContained", L"{true, false}") + TEST_CLASS_PROPERTY(L"RunAs", L"UAP") + TEST_CLASS_PROPERTY(L"UAP:Host", L"PackagedCWA") + TEST_CLASS_PROPERTY(L"UAP:AppxManifest", L"PushNotifications-AppxManifest.xml") + END_TEST_CLASS() + + TEST_CLASS_SETUP(ClassInit) + { + BaseTestSuite::ClassSetup(); + return true; + } + + TEST_CLASS_CLEANUP(ClassUninit) + { + BaseTestSuite::ClassCleanup(); + return true; + } + + TEST_METHOD_SETUP(MethodInit) + { + return true; + } + + TEST_METHOD_CLEANUP(MethodUninit) + { + BaseTestSuite::MethodCleanup(); + return true; + } + + TEST_METHOD(ChannelRequestUsingNullRemoteId); + TEST_METHOD(ChannelRequestUsingRemoteId); + BEGIN_TEST_METHOD(MultipleChannelClose) // Currently failing + TEST_METHOD_PROPERTY(L"Ignore", L"true") + END_TEST_METHOD() + TEST_METHOD(VerifyRegisterAndUnregister); + TEST_METHOD(VerifyRegisterAndUnregisterAll); + TEST_METHOD(VerifyUnregisterFails); + TEST_METHOD(VerifyUnregisterAllFails); + TEST_METHOD(MultipleRegister); + TEST_METHOD(VerifyMultipleRegisterAndUnregister); + TEST_METHOD(VerifyMultipleRegisterAndUnregisterAll); + TEST_METHOD(VerifyUnregisterTwice); + TEST_METHOD(VerifyUnregisterAllTwice); + TEST_METHOD(VerifyUnregisterAndUnregisterAll); + TEST_METHOD(VerifyForegroundHandlerSucceeds); + TEST_METHOD(VerifyForegroundHandlerFails); +}; + diff --git a/test/PushNotificationTests/PushNotification-Test-Constants.h b/test/PushNotificationTests/PushNotification-Test-Constants.h new file mode 100644 index 0000000000..21ad68fcc0 --- /dev/null +++ b/test/PushNotificationTests/PushNotification-Test-Constants.h @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. +#pragma once + +inline const winrt::hstring c_rawNotificationPayload = L""; +static const std::chrono::seconds c_timeout = std::chrono::seconds(300); +inline IID c_azureRemoteId = winrt::guid(L"a2e4a323-b518-4799-9e80-0b37aeb0d225"); // Generated from ms.portal.azure.com +inline IID c_dummyRemoteId = winrt::guid(L"CA1A4AB2-AC1D-4EFC-A132-E5A191CA285A"); // Dummy guid from visual studio guid tool generator +inline IID c_remoteId = winrt::guid("A7652901-313C-4EFA-A303-95C371A00DAB"); +inline IID c_comServerId = winrt::guid("ccd2ae3f-764f-4ae3-be45-9804761b28b2"); // Value from PushNotificationsTestAppPackage ComActivator in appxmanifest. +inline IID c_fakeComServerId = winrt::guid("00000000-0000-0000-0000-000000000001"); diff --git a/test/PushNotificationTests/PushNotificationTests.vcxproj b/test/PushNotificationTests/PushNotificationTests.vcxproj index f25487a212..cbfcddc9cd 100644 --- a/test/PushNotificationTests/PushNotificationTests.vcxproj +++ b/test/PushNotificationTests/PushNotificationTests.vcxproj @@ -1,6 +1,6 @@ - + Debug @@ -61,7 +61,7 @@ true Unicode - + DynamicLibrary true v142 @@ -80,7 +80,6 @@ - @@ -116,156 +115,166 @@ true - - false - - + - Use - Level3 - true - true + Level4 true - %(AdditionalIncludeDirectories);$(OutDir)\..\WindowsAppRuntime_DLL;..\inc;$(OutDir)\..\WindowsAppRuntime_BootstrapDLL;$(OutDir)..\PushNotificationsLongRunningTask.ProxyStub - WIN32;NDEBUG;%(PreprocessorDefinitions);;INLINE_TEST_METHOD_MARKUP - true + WIN32;_DEBUG;PUSHNOTIFICATIONTESTS_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + Use pch.h + $(OutDir)..\PushNotificationsLongRunningTask.ProxyStub;$(RepoRoot)\test\inc;$(RepoRoot)\Dev\Common;$(ProjectDir)..\inc;$(ProjectDir)..\..\dev\WindowsAppRuntime_BootstrapDLL\ - Windows - true - true - $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories);$(OutDir)\..\WindowsAppRuntime_DLL onecore.lib;onecoreuap.lib;Microsoft.WindowsAppRuntime.lib;wex.common.lib;wex.logger.lib;te.common.lib;%(AdditionalDependencies) + $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories);$(OutDir)\..\WindowsAppRuntime_DLL + Microsoft.WindowsAppRuntime.Bootstrap.dll;%(DelayLoadDLLs) + Microsoft.WindowsAppRuntime.dll;%(DelayLoadDLLs) + Windows + true + false - + - Use - Level3 + Level4 + true + true true - %(AdditionalIncludeDirectories);$(OutDir)\..\WindowsAppRuntime_DLL;..\inc;$(OutDir)\..\WindowsAppRuntime_BootstrapDLL;$(OutDir)..\PushNotificationsLongRunningTask.ProxyStub - WIN32;_DEBUG;%(PreprocessorDefinitions);;INLINE_TEST_METHOD_MARKUP - true + WIN32;NDEBUG;PUSHNOTIFICATIONTESTS_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + Use pch.h + $(OutDir)..\PushNotificationsLongRunningTask.ProxyStub;$(RepoRoot)\test\inc;$(RepoRoot)\Dev\Common;$(ProjectDir)..\inc;$(ProjectDir)..\..\dev\WindowsAppRuntime_BootstrapDLL\ - Windows - $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories);$(OutDir)\..\WindowsAppRuntime_DLL onecore.lib;onecoreuap.lib;Microsoft.WindowsAppRuntime.lib;wex.common.lib;wex.logger.lib;te.common.lib;%(AdditionalDependencies) + $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories);$(OutDir)\..\WindowsAppRuntime_DLL + Microsoft.WindowsAppRuntime.Bootstrap.dll;%(DelayLoadDLLs) + Microsoft.WindowsAppRuntime.dll;%(DelayLoadDLLs) + Windows + true + true + true + false - Use - Level3 + Level4 true - %(AdditionalIncludeDirectories);$(OutDir)\..\WindowsAppRuntime_DLL;..\inc;$(OutDir)\..\WindowsAppRuntime_BootstrapDLL;$(OutDir)..\PushNotificationsLongRunningTask.ProxyStub - _DEBUG;%(PreprocessorDefinitions);;INLINE_TEST_METHOD_MARKUP - true + _DEBUG;PUSHNOTIFICATIONTESTS_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + Use pch.h + $(OutDir)..\PushNotificationsLongRunningTask.ProxyStub;$(RepoRoot)\test\inc;$(RepoRoot)\Dev\Common;$(ProjectDir)..\inc;$(ProjectDir)..\..\dev\WindowsAppRuntime_BootstrapDLL\ - Windows - $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories);$(OutDir)\..\WindowsAppRuntime_DLL onecore.lib;onecoreuap.lib;Microsoft.WindowsAppRuntime.lib;wex.common.lib;wex.logger.lib;te.common.lib;%(AdditionalDependencies) + $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories);$(OutDir)\..\WindowsAppRuntime_DLL + Microsoft.WindowsAppRuntime.Bootstrap.dll;%(DelayLoadDLLs) + Microsoft.WindowsAppRuntime.dll;%(DelayLoadDLLs) + Windows + true + false - + - Use - Level3 + Level4 + true + true true - %(AdditionalIncludeDirectories);$(OutDir)\..\WindowsAppRuntime_DLL;..\inc;$(OutDir)\..\WindowsAppRuntime_BootstrapDLL;$(OutDir)..\PushNotificationsLongRunningTask.ProxyStub - _DEBUG;%(PreprocessorDefinitions);;INLINE_TEST_METHOD_MARKUP - true + NDEBUG;PUSHNOTIFICATIONTESTS_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + Use pch.h + $(OutDir)..\PushNotificationsLongRunningTask.ProxyStub;$(RepoRoot)\test\inc;$(RepoRoot)\Dev\Common;$(ProjectDir)..\inc;$(ProjectDir)..\..\dev\WindowsAppRuntime_BootstrapDLL\ - Windows - $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories);$(OutDir)\..\WindowsAppRuntime_DLL onecore.lib;onecoreuap.lib;Microsoft.WindowsAppRuntime.lib;wex.common.lib;wex.logger.lib;te.common.lib;%(AdditionalDependencies) + $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories);$(OutDir)\..\WindowsAppRuntime_DLL + Microsoft.WindowsAppRuntime.Bootstrap.dll;%(DelayLoadDLLs) + Microsoft.WindowsAppRuntime.dll;%(DelayLoadDLLs) + Windows + true + true + true + false - + - Use - Level3 - true - true + Level4 true - %(AdditionalIncludeDirectories);$(OutDir)\..\WindowsAppRuntime_DLL;..\inc;$(OutDir)\..\WindowsAppRuntime_BootstrapDLL;$(OutDir)..\PushNotificationsLongRunningTask.ProxyStub - NDEBUG;%(PreprocessorDefinitions);;INLINE_TEST_METHOD_MARKUP - true + _DEBUG;PUSHNOTIFICATIONTESTS_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + Use pch.h + $(OutDir)..\PushNotificationsLongRunningTask.ProxyStub;$(RepoRoot)\test\inc;$(RepoRoot)\Dev\Common;$(ProjectDir)..\inc;$(ProjectDir)..\..\dev\WindowsAppRuntime_BootstrapDLL\ - Windows - true - true - $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories);$(OutDir)\..\WindowsAppRuntime_DLL onecore.lib;onecoreuap.lib;Microsoft.WindowsAppRuntime.lib;wex.common.lib;wex.logger.lib;te.common.lib;%(AdditionalDependencies) + $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories);$(OutDir)\..\WindowsAppRuntime_DLL + Microsoft.WindowsAppRuntime.Bootstrap.dll;%(DelayLoadDLLs) + Microsoft.WindowsAppRuntime.dll;%(DelayLoadDLLs) + Windows + true + false - Use - Level3 + Level4 true true true - %(AdditionalIncludeDirectories);$(OutDir)\..\WindowsAppRuntime_DLL;..\inc;$(OutDir)\..\WindowsAppRuntime_BootstrapDLL;$(OutDir)..\PushNotificationsLongRunningTask.ProxyStub - NDEBUG;%(PreprocessorDefinitions);;INLINE_TEST_METHOD_MARKUP - true + WIN32;NDEBUG;PUSHNOTIFICATIONTESTS_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + Use pch.h + $(OutDir)..\PushNotificationsLongRunningTask.ProxyStub;$(RepoRoot)\test\inc;$(RepoRoot)\Dev\Common;$(ProjectDir)..\inc;$(ProjectDir)..\..\dev\WindowsAppRuntime_BootstrapDLL\ + onecore.lib;onecoreuap.lib;Microsoft.WindowsAppRuntime.lib;wex.common.lib;wex.logger.lib;te.common.lib;%(AdditionalDependencies) + $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories);$(OutDir)\..\WindowsAppRuntime_DLL + Microsoft.WindowsAppRuntime.Bootstrap.dll;%(DelayLoadDLLs) + Microsoft.WindowsAppRuntime.dll;%(DelayLoadDLLs) Windows true true - $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories);$(OutDir)\..\WindowsAppRuntime_DLL - onecore.lib;onecoreuap.lib;Microsoft.WindowsAppRuntime.lib;wex.common.lib;wex.logger.lib;te.common.lib;%(AdditionalDependencies) + true + false - - + + + + - - - + + - Create - Create Create + Create Create + Create Create Create - Create - Create - + - - .Debug - _Debug - $(AppxPackageDir)\PushNotificationsTestAppPackage_1.0.0.0_$(PlatformTarget)$(TestPkgDebugConfigName)_Test - $(TestPkgOutputPath)\PushNotificationsTestAppPackage_1.0.0.0_$(PlatformTarget)$(TestPkgDebugConfigName).msix - - - - - - - - {bf3fced0-cadb-490a-93a7-4d90e1f45ab0} - + + $(OutDir)\..\WindowsAppRuntime_DLL\Microsoft.Windows.PushNotifications.winmd + true + @@ -273,27 +282,30 @@ - - $(OutDir)\..\WindowsAppRuntime_DLL\Microsoft.Windows.PushNotifications.winmd - true - + + true + true + true + true + - + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - + + - + \ No newline at end of file diff --git a/test/PushNotificationTests/PushNotificationTests.vcxproj.filters b/test/PushNotificationTests/PushNotificationTests.vcxproj.filters index fd40c7c2bd..8059c2a4c0 100644 --- a/test/PushNotificationTests/PushNotificationTests.vcxproj.filters +++ b/test/PushNotificationTests/PushNotificationTests.vcxproj.filters @@ -21,27 +21,30 @@ Header Files - - Source Files + + Header Files - - Source Files + + Header Files + + + Header Files + + + Header Files Source Files - + Source Files - + Source Files - - Source Files - - + Source Files @@ -50,9 +53,12 @@ - - - CopyFiles - + + + + + + Source Files + \ No newline at end of file diff --git a/test/PushNotificationTests/PushNotifications-AppxManifest.xml b/test/PushNotificationTests/PushNotifications-AppxManifest.xml new file mode 100644 index 0000000000..0560f08fb1 --- /dev/null +++ b/test/PushNotificationTests/PushNotifications-AppxManifest.xml @@ -0,0 +1,54 @@ + + + + + + + WindowsAppRuntime.Test.PushNotifications for tests + Windows APP SDK + taef.png + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/PushNotificationTests/UnpackagedTests.cpp b/test/PushNotificationTests/UnpackagedTests.cpp new file mode 100644 index 0000000000..dd8bfcbac0 --- /dev/null +++ b/test/PushNotificationTests/UnpackagedTests.cpp @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. +#include "pch.h" +#include "UnpackagedTests.h" + +void UnpackagedTests::ChannelRequestUsingNullRemoteId() +{ + BaseTestSuite::ChannelRequestUsingNullRemoteId(); +} + +void UnpackagedTests::ChannelRequestUsingRemoteId() +{ + BaseTestSuite::ChannelRequestUsingRemoteId(); +} + +// Currently failing - https://github.com/microsoft/WindowsAppSDK/issues/2392 +void UnpackagedTests::MultipleChannelClose() +{ + BaseTestSuite::MultipleChannelClose(); +} + +void UnpackagedTests::VerifyRegisterAndUnregister() +{ + BaseTestSuite::VerifyRegisterAndUnregister(); +} + +void UnpackagedTests::VerifyUnregisterFails() +{ + BaseTestSuite::VerifyUnregisterFails(); +} + +void UnpackagedTests::VerifyUnregisterAllFails() +{ + BaseTestSuite::VerifyUnregisterAllFails(); +} + +void UnpackagedTests::VerifyRegisterAndUnregisterAll() +{ + BaseTestSuite::VerifyRegisterAndUnregisterAll(); +} + +void UnpackagedTests::MultipleRegister() +{ + BaseTestSuite::MultipleRegister(); +} + +void UnpackagedTests::VerifyMultipleRegisterAndUnregister() +{ + BaseTestSuite::VerifyMultipleRegisterAndUnregister(); +} + +void UnpackagedTests::VerifyMultipleRegisterAndUnregisterAll() +{ + BaseTestSuite::VerifyMultipleRegisterAndUnregisterAll(); +} + +void UnpackagedTests::VerifyUnregisterTwice() +{ + BaseTestSuite::VerifyUnregisterTwice(); +} + +void UnpackagedTests::VerifyUnregisterAllTwice() +{ + BaseTestSuite::VerifyUnregisterAllTwice(); +} + +void UnpackagedTests::VerifyUnregisterAndUnregisterAll() +{ + BaseTestSuite::VerifyUnregisterAndUnregisterAll(); +} + +void UnpackagedTests::VerifyForegroundHandlerSucceeds() +{ + BaseTestSuite::VerifyForegroundHandlerSucceeds(); +} + +void UnpackagedTests::VerifyForegroundHandlerFails() +{ + BaseTestSuite::VerifyForegroundHandlerFails(); +} diff --git a/test/PushNotificationTests/UnpackagedTests.h b/test/PushNotificationTests/UnpackagedTests.h new file mode 100644 index 0000000000..8c2c0d92c2 --- /dev/null +++ b/test/PushNotificationTests/UnpackagedTests.h @@ -0,0 +1,62 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#include "pch.h" +#include "BaseTestSuite.h" + +using namespace WEX::Common; +using namespace WEX::Logging; +using namespace WEX::TestExecution; + +class UnpackagedTests : BaseTestSuite +{ + BEGIN_TEST_CLASS(UnpackagedTests) + TEST_CLASS_PROPERTY(L"Description", L"Windows App SDK Push Notifications test") + TEST_CLASS_PROPERTY(L"ThreadingModel", L"MTA") + TEST_CLASS_PROPERTY(L"RunAs:Class", L"RestrictedUser") + TEST_CLASS_PROPERTY(L"IsolationLevel", L"Class") + TEST_CLASS_PROPERTY(L"Data:SelfContained", L"{true, false}") + END_TEST_CLASS() + + TEST_CLASS_SETUP(ClassInit) + { + BaseTestSuite::ClassSetup(); + return true; + } + + TEST_CLASS_CLEANUP(ClassUninit) + { + BaseTestSuite::ClassCleanup(); + return true; + } + + TEST_METHOD_SETUP(MethodInit) + { + return true; + } + + TEST_METHOD_CLEANUP(MethodUninit) + { + BaseTestSuite::MethodCleanup(); + return true; + } + + TEST_METHOD(ChannelRequestUsingNullRemoteId); + TEST_METHOD(ChannelRequestUsingRemoteId); + BEGIN_TEST_METHOD(MultipleChannelClose) // Currently failing + TEST_METHOD_PROPERTY(L"Ignore", L"true") + END_TEST_METHOD() + TEST_METHOD(VerifyRegisterAndUnregister); + TEST_METHOD(VerifyRegisterAndUnregisterAll); + TEST_METHOD(VerifyUnregisterFails); + TEST_METHOD(VerifyUnregisterAllFails); + TEST_METHOD(MultipleRegister); + TEST_METHOD(VerifyMultipleRegisterAndUnregister); + TEST_METHOD(VerifyMultipleRegisterAndUnregisterAll); + TEST_METHOD(VerifyUnregisterTwice); + TEST_METHOD(VerifyUnregisterAllTwice); + TEST_METHOD(VerifyUnregisterAndUnregisterAll); + TEST_METHOD(VerifyForegroundHandlerSucceeds); + TEST_METHOD(VerifyForegroundHandlerFails); +}; + diff --git a/test/PushNotificationTests/packages.config b/test/PushNotificationTests/packages.config index 71b99361d6..6b0a29d23a 100644 --- a/test/PushNotificationTests/packages.config +++ b/test/PushNotificationTests/packages.config @@ -1,6 +1,6 @@  - + - + \ No newline at end of file diff --git a/test/PushNotificationTests/pch.h b/test/PushNotificationTests/pch.h index dea78ec628..e9dc540edd 100644 --- a/test/PushNotificationTests/pch.h +++ b/test/PushNotificationTests/pch.h @@ -6,6 +6,7 @@ #include +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers #include #include #include @@ -39,6 +40,15 @@ #include #include +#include + +#define VERIFY_THROWS_HR(expression, hr) \ + VERIFY_THROWS_SPECIFIC(expression, \ + winrt::hresult_error, \ + [&](winrt::hresult_error e) -> bool \ + { \ + return (e.code() == hr); \ + }) namespace TP = ::Test::Packages; namespace TAEF = ::Test::TAEF; diff --git a/test/TestApps/PushNotificationsTestApp/main.cpp b/test/TestApps/PushNotificationsTestApp/main.cpp index 4ef8e9b10d..4f990e5cf6 100644 --- a/test/TestApps/PushNotificationsTestApp/main.cpp +++ b/test/TestApps/PushNotificationsTestApp/main.cpp @@ -1,5 +1,4 @@ #include "pch.h" -#include #include #include #include @@ -17,8 +16,9 @@ using namespace winrt::Windows::Storage::Streams; winrt::guid remoteId1(L"a2e4a323-b518-4799-9e80-0b37aeb0d225"); // Generated from ms.portal.azure.com winrt::guid remoteId2(L"CA1A4AB2-AC1D-4EFC-A132-E5A191CA285A"); // Dummy guid from visual studio guid tool generator - constexpr auto timeout{ std::chrono::seconds(300) }; +inline const winrt::hstring c_rawNotificationPayload = L""; + bool ChannelRequestUsingNullRemoteId() { diff --git a/test/TestApps/ToastNotificationsTestApp/main.cpp b/test/TestApps/ToastNotificationsTestApp/main.cpp index 22b26e42d8..bbea87d430 100644 --- a/test/TestApps/ToastNotificationsTestApp/main.cpp +++ b/test/TestApps/ToastNotificationsTestApp/main.cpp @@ -1,5 +1,4 @@ #include "pch.h" -#include #include #include #include "WindowsAppRuntime.Test.AppModel.h" diff --git a/test/ToastNotificationTests/APITests.cpp b/test/ToastNotificationTests/APITests.cpp index fade62a6ad..ecf3e047ab 100644 --- a/test/ToastNotificationTests/APITests.cpp +++ b/test/ToastNotificationTests/APITests.cpp @@ -1,6 +1,6 @@ #include "pch.h" #include "NotificationActivationCallback.h" -#include +#include "AppNotification-Test-Constants.h" using namespace WEX::Common; using namespace WEX::Logging; diff --git a/test/ToastNotificationTests/AppNotification-Test-Constants.h b/test/ToastNotificationTests/AppNotification-Test-Constants.h new file mode 100644 index 0000000000..b657742c11 --- /dev/null +++ b/test/ToastNotificationTests/AppNotification-Test-Constants.h @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. +#pragma once + +inline const winrt::hstring c_rawNotificationPayload = L""; +inline const std::chrono::seconds c_timeout = std::chrono::seconds(300); +inline IID c_toastComServerId = winrt::guid("1940dba9-0f64-4f0d-8a4b-5d207b812e61"); // Value from ToastNotificationsTestAppPackage ComActivator in appxmanifest. diff --git a/test/ToastNotificationTests/ToastNotificationTests.vcxproj b/test/ToastNotificationTests/ToastNotificationTests.vcxproj index a425d6bd47..c32741f04f 100644 --- a/test/ToastNotificationTests/ToastNotificationTests.vcxproj +++ b/test/ToastNotificationTests/ToastNotificationTests.vcxproj @@ -235,6 +235,7 @@ + @@ -266,9 +267,9 @@ - $(OutDir)\..\WindowsAppRuntime_DLL\Microsoft.Windows.AppLifecycle.winmd - true - + $(OutDir)\..\WindowsAppRuntime_DLL\Microsoft.Windows.AppLifecycle.winmd + true + $(OutDir)\..\WindowsAppRuntime_DLL\Microsoft.Windows.AppNotifications.winmd true diff --git a/test/ToastNotificationTests/ToastNotificationTests.vcxproj.filters b/test/ToastNotificationTests/ToastNotificationTests.vcxproj.filters index f4cfc65598..ef950bacf1 100644 --- a/test/ToastNotificationTests/ToastNotificationTests.vcxproj.filters +++ b/test/ToastNotificationTests/ToastNotificationTests.vcxproj.filters @@ -18,6 +18,9 @@ Header Files + + Header Files + @@ -34,5 +37,6 @@ + \ No newline at end of file diff --git a/test/inc/TestDef.h b/test/inc/TestDef.h index 8adf3f430f..ddb4a2014e 100644 --- a/test/inc/TestDef.h +++ b/test/inc/TestDef.h @@ -22,11 +22,6 @@ static const std::wstring c_testRequestRestartNowRestartedPhaseEventName = L"Win static const std::wstring c_testRequestRestartNowRestartedPhasePackagedEventName = L"WindowsAppRuntimeTestRequestRestartNowRestartedPhasePackagedEventName"; static const std::wstring c_testPushPhaseEventName = L"WindowsAppRuntimeTestPushPhaseEventName"; -inline const winrt::hstring c_rawNotificationPayload = L""; -inline IID c_remoteId = winrt::guid("A7652901-313C-4EFA-A303-95C371A00DAB"); -inline IID c_comServerId = winrt::guid("ccd2ae3f-764f-4ae3-be45-9804761b28b2"); // Value from PushNotificationsTestAppPackage ComActivator in appxmanifest. -inline IID c_toastComServerId = winrt::guid("1940dba9-0f64-4f0d-8a4b-5d207b812e61"); // Value from ToastNotificationsTestAppPackage ComActivator in appxmanifest. -inline IID c_fakeComServerId = winrt::guid("00000000-0000-0000-0000-000000000001"); #ifndef WIDEN2 #define WIDEN2(x) L ## x diff --git a/test/inc/WindowsAppRuntime.Test.Bootstrap.h b/test/inc/WindowsAppRuntime.Test.Bootstrap.h index 35466b4988..aa4a051221 100644 --- a/test/inc/WindowsAppRuntime.Test.Bootstrap.h +++ b/test/inc/WindowsAppRuntime.Test.Bootstrap.h @@ -22,7 +22,7 @@ namespace Test::Bootstrap DDLM = 0x0004, Singleton = 0x0008, - Default = Framework | Main | DDLM, + Default = Framework | Main | DDLM | Singleton, }; } DEFINE_ENUM_FLAG_OPERATORS(Test::Bootstrap::Packages) @@ -154,8 +154,8 @@ namespace Test::Bootstrap inline void Cleanup() { - CleanupPackages(); CleanupBootstrap(); + CleanupPackages(); } }