Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@
<summary>Gets or sets optional string to be displayed instead of the default percentage string.</summary>
<returns>The optional value string override.</returns>
</member>
<member name="P:Microsoft.Windows.AppNotifications.AppNotificationProgressData.IsIndeterminate">
<summary>Gets or sets a value indicating whether the progress bar should show an indeterminate loading animation. If true, the Value property is ignored.</summary>
<returns>True if the progress bar is indeterminate; otherwise, false.</returns>
</member>
<member name="T:Microsoft.Windows.AppNotifications.AppNotificationProgressResult">
<summary>Specifies the result of an app notification progress update operation invoked with a call to UpdateAsync.</summary>
</member>
Expand Down
14 changes: 14 additions & 0 deletions dev/AppNotifications/AppNotificationProgressData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ namespace winrt::Microsoft::Windows::AppNotifications::implementation
}
void AppNotificationProgressData::Value(double progressValue)
{
THROW_HR_IF(E_INVALIDARG, progressValue < 0.0 || progressValue > 1.0);
Comment thread
guimafelipe marked this conversation as resolved.

auto lock{ m_lock.lock_exclusive() };

m_progressValue = progressValue;
Expand Down Expand Up @@ -74,4 +76,16 @@ namespace winrt::Microsoft::Windows::AppNotifications::implementation

m_progressStatus = progressStatus;
}
bool AppNotificationProgressData::IsIndeterminate()
{
auto lock{ m_lock.lock_shared() };

return m_isIndeterminate;
}
void AppNotificationProgressData::IsIndeterminate(bool isIndeterminate)
{
auto lock{ m_lock.lock_exclusive() };

m_isIndeterminate = isIndeterminate;
}
}
3 changes: 3 additions & 0 deletions dev/AppNotifications/AppNotificationProgressData.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ namespace winrt::Microsoft::Windows::AppNotifications::implementation
void ValueStringOverride(hstring const& progressValueString);
hstring Status();
void Status(hstring const& progressStatus);
bool IsIndeterminate();
void IsIndeterminate(bool isIndeterminate);

private:
uint32_t m_sequenceNumber = 1;
hstring m_title;
double m_progressValue{};
hstring m_progressValueString;
hstring m_progressStatus;
bool m_isIndeterminate{ false };
wil::srwlock m_lock;
};
}
Expand Down
9 changes: 8 additions & 1 deletion dev/AppNotifications/AppNotificationUtility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,14 @@ winrt::Microsoft::Windows::AppNotifications::AppNotification Microsoft::Windows:

double progressValue{};
THROW_IF_FAILED(toastProgressData->get_Value(&progressValue));
progressData.Value(progressValue);
if (progressValue < 0.0)
{
progressData.IsIndeterminate(true);
}
else
{
progressData.Value(progressValue);
}

wil::unique_hstring progressValueString{};
THROW_IF_FAILED(toastProgressData->get_ValueStringOverride(&progressValueString));
Expand Down
5 changes: 5 additions & 0 deletions dev/AppNotifications/AppNotifications.idl
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ namespace Microsoft.Windows.AppNotifications

// Gets/Sets the Value for the Status. Binds to {progressStatus} in progress xml tag
String Status;

// Gets/Sets whether the progress bar should show an indeterminate loading animation.
// If true, Value is ignored and the progress bar displays an indeterminate state.
Comment thread
guimafelipe marked this conversation as resolved.
[contract(AppNotificationsContract, 4)]
Boolean IsIndeterminate;
}

// The Notification User Setting or Notification Group Policy Setting
Expand Down
11 changes: 10 additions & 1 deletion dev/AppNotifications/NotificationProgressData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ NotificationProgressData::NotificationProgressData(winrt::AppNotificationProgres
m_progressData.Title(progressData.Title());
m_progressData.Value(progressData.Value());
m_progressData.ValueStringOverride(progressData.ValueStringOverride());
m_progressData.IsIndeterminate(progressData.IsIndeterminate());
}

STDMETHODIMP NotificationProgressData::get_SequenceNumber(_Out_ unsigned int* value) noexcept
Expand All @@ -41,7 +42,15 @@ CATCH_RETURN()

STDMETHODIMP NotificationProgressData::get_Value(_Out_ double* value) noexcept
{
*value = m_progressData.Value();
if (m_progressData.IsIndeterminate())
{
Comment thread
guimafelipe marked this conversation as resolved.
// Return -1.0 as a sentinel value to indicate indeterminate state to the ToastABI layer.
*value = -1.0;
}
else
{
*value = m_progressData.Value();
}
Comment thread
guimafelipe marked this conversation as resolved.
return S_OK;
}

Expand Down
1 change: 1 addition & 0 deletions test/AppNotificationTests/AppNotifications.Test.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ namespace AppNotifications::Test
VERIFY_ARE_EQUAL(expected.Value(), actual.Value());
VERIFY_ARE_EQUAL(expected.ValueStringOverride(), actual.ValueStringOverride());
VERIFY_ARE_EQUAL(expected.Status(), actual.Status());
VERIFY_ARE_EQUAL(expected.IsIndeterminate(), actual.IsIndeterminate());
}

enum class ExpectedTransientProperties {
Expand Down
65 changes: 65 additions & 0 deletions test/AppNotificationTests/BaseTestSuite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,71 @@ void BaseTestSuite::VerifyToastProgressDataSequence0Fail()
VERIFY_THROWS_HR(GetToastProgressData(L"PStatus", L"PTitle", 0.10, L"10%", 0), E_INVALIDARG);
}

void BaseTestSuite::VerifyProgressDataIsIndeterminateDefault()
{
AppNotificationProgressData progressData{ 1 };
VERIFY_IS_FALSE(progressData.IsIndeterminate());
}

void BaseTestSuite::VerifyProgressDataIsIndeterminateSetTrue()
{
AppNotificationProgressData progressData{ 1 };
VERIFY_IS_FALSE(progressData.IsIndeterminate());

progressData.IsIndeterminate(true);
VERIFY_IS_TRUE(progressData.IsIndeterminate());
}

void BaseTestSuite::VerifyProgressDataIsIndeterminateFromToast()
{
AppNotification toast{ CreateToastNotification() };

AppNotificationProgressData progressData{ 1 };
progressData.Status(L"Status");
progressData.Title(L"Title");
progressData.Value(0.14);
progressData.ValueStringOverride(L"14%");
progressData.IsIndeterminate(true);
toast.Progress(progressData);

auto progressDataFromToast{ toast.Progress() };
VERIFY_ARE_EQUAL(progressDataFromToast.Status(), L"Status");
VERIFY_ARE_EQUAL(progressDataFromToast.Title(), L"Title");
VERIFY_ARE_EQUAL(progressDataFromToast.ValueStringOverride(), L"14%");
VERIFY_ARE_EQUAL(progressDataFromToast.SequenceNumber(), 1u);
VERIFY_IS_TRUE(progressDataFromToast.IsIndeterminate());
}
Comment thread
guimafelipe marked this conversation as resolved.

Comment thread
guimafelipe marked this conversation as resolved.
void BaseTestSuite::VerifyProgressDataValueValidation()
{
AppNotificationProgressData progressData{ 1 };

// Valid edge cases: 0.0 and 1.0 should succeed
progressData.Value(0.0);
VERIFY_ARE_EQUAL(progressData.Value(), 0.0);

progressData.Value(1.0);
VERIFY_ARE_EQUAL(progressData.Value(), 1.0);

// Invalid values: out of [0.0, 1.0] range should throw E_INVALIDARG
VERIFY_THROWS_HR(progressData.Value(-0.1), E_INVALIDARG);
VERIFY_THROWS_HR(progressData.Value(1.1), E_INVALIDARG);
}

void BaseTestSuite::VerifyUpdateToastProgressDataWithIndeterminate()
{
RegisterWithAppNotificationManager();
PostToastHelper(L"IndeterminateTag", L"IndeterminateGroup");

AppNotificationProgressData progressData{ 1 };
progressData.Status(L"Loading");
progressData.Title(L"Title");
progressData.IsIndeterminate(true);

auto progressResultOperation{ AppNotificationManager::Default().UpdateAsync(progressData, L"IndeterminateTag", L"IndeterminateGroup") };
ProgressResultOperationHelper(progressResultOperation, winrt::AppNotificationProgressResult::Succeeded);
}

void BaseTestSuite::VerifyShowToast()
{
RegisterWithAppNotificationManager();
Expand Down
5 changes: 5 additions & 0 deletions test/AppNotificationTests/BaseTestSuite.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ class BaseTestSuite
void VerifyRemoveAllAsyncWithNoActiveToastDoesNotThrow();
void VerifyRemoveAllAsync();
void VerifyToastProgressDataSequence0Fail();
void VerifyProgressDataIsIndeterminateDefault();
void VerifyProgressDataIsIndeterminateSetTrue();
void VerifyProgressDataIsIndeterminateFromToast();
void VerifyProgressDataValueValidation();
void VerifyUpdateToastProgressDataWithIndeterminate();
void VerifyIconPathExists();
void VerifyExplicitAppId();
void VerifyToastConferencingConfigAllDevicesSet();
Expand Down
25 changes: 25 additions & 0 deletions test/AppNotificationTests/PackagedTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,31 @@ void PackagedTests::VerifyToastProgressDataSequence0Fail()
BaseTestSuite::VerifyToastProgressDataSequence0Fail();
}

void PackagedTests::VerifyProgressDataIsIndeterminateDefault()
{
BaseTestSuite::VerifyProgressDataIsIndeterminateDefault();
}

void PackagedTests::VerifyProgressDataIsIndeterminateSetTrue()
{
BaseTestSuite::VerifyProgressDataIsIndeterminateSetTrue();
}

void PackagedTests::VerifyProgressDataIsIndeterminateFromToast()
{
BaseTestSuite::VerifyProgressDataIsIndeterminateFromToast();
}

void PackagedTests::VerifyProgressDataValueValidation()
{
BaseTestSuite::VerifyProgressDataValueValidation();
}

void PackagedTests::VerifyUpdateToastProgressDataWithIndeterminate()
{
BaseTestSuite::VerifyUpdateToastProgressDataWithIndeterminate();
}

void PackagedTests::VerifyShowToast()
{
BaseTestSuite::VerifyShowToast();
Expand Down
5 changes: 5 additions & 0 deletions test/AppNotificationTests/PackagedTests.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ class PackagedTests : BaseTestSuite
TEST_METHOD(VerifyToastSuppressDisplay);
TEST_METHOD(VerifyToastExpiresOnReboot);
TEST_METHOD(VerifyToastProgressDataSequence0Fail);
TEST_METHOD(VerifyProgressDataIsIndeterminateDefault);
TEST_METHOD(VerifyProgressDataIsIndeterminateSetTrue);
TEST_METHOD(VerifyProgressDataIsIndeterminateFromToast);
TEST_METHOD(VerifyProgressDataValueValidation);
TEST_METHOD(VerifyUpdateToastProgressDataWithIndeterminate);
TEST_METHOD(VerifyShowToast);
TEST_METHOD(VerifyUpdateToastProgressDataUsingValidTagAndValidGroup);
TEST_METHOD(VerifyUpdateToastProgressDataUsingValidTagAndEmptyGroup);
Expand Down
25 changes: 25 additions & 0 deletions test/AppNotificationTests/UnpackagedTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,31 @@ void UnpackagedTests::VerifyToastProgressDataSequence0Fail()
BaseTestSuite::VerifyToastProgressDataSequence0Fail();
}

void UnpackagedTests::VerifyProgressDataIsIndeterminateDefault()
{
BaseTestSuite::VerifyProgressDataIsIndeterminateDefault();
}

void UnpackagedTests::VerifyProgressDataIsIndeterminateSetTrue()
{
BaseTestSuite::VerifyProgressDataIsIndeterminateSetTrue();
}

void UnpackagedTests::VerifyProgressDataIsIndeterminateFromToast()
{
BaseTestSuite::VerifyProgressDataIsIndeterminateFromToast();
}

void UnpackagedTests::VerifyProgressDataValueValidation()
{
BaseTestSuite::VerifyProgressDataValueValidation();
}

void UnpackagedTests::VerifyUpdateToastProgressDataWithIndeterminate()
{
BaseTestSuite::VerifyUpdateToastProgressDataWithIndeterminate();
}

void UnpackagedTests::VerifyShowToast()
{
BaseTestSuite::VerifyShowToast();
Expand Down
5 changes: 5 additions & 0 deletions test/AppNotificationTests/UnpackagedTests.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ class UnpackagedTests : BaseTestSuite
TEST_METHOD(VerifyToastSuppressDisplay);
TEST_METHOD(VerifyToastExpiresOnReboot);
TEST_METHOD(VerifyToastProgressDataSequence0Fail);
TEST_METHOD(VerifyProgressDataIsIndeterminateDefault);
TEST_METHOD(VerifyProgressDataIsIndeterminateSetTrue);
TEST_METHOD(VerifyProgressDataIsIndeterminateFromToast);
Comment thread
guimafelipe marked this conversation as resolved.
TEST_METHOD(VerifyProgressDataValueValidation);
TEST_METHOD(VerifyUpdateToastProgressDataWithIndeterminate);
TEST_METHOD(VerifyShowToast);
TEST_METHOD(VerifyUpdateToastProgressDataUsingValidTagAndValidGroup);
TEST_METHOD(VerifyUpdateToastProgressDataUsingValidTagAndEmptyGroup);
Expand Down