Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 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
12 changes: 12 additions & 0 deletions dev/AppNotifications/AppNotificationProgressData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,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
4 changes: 4 additions & 0 deletions dev/AppNotifications/AppNotifications.idl
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ 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.
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
35 changes: 35 additions & 0 deletions test/AppNotificationTests/BaseTestSuite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,41 @@ 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::VerifyShowToast()
{
RegisterWithAppNotificationManager();
Expand Down
3 changes: 3 additions & 0 deletions test/AppNotificationTests/BaseTestSuite.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ class BaseTestSuite
void VerifyRemoveAllAsyncWithNoActiveToastDoesNotThrow();
void VerifyRemoveAllAsync();
void VerifyToastProgressDataSequence0Fail();
void VerifyProgressDataIsIndeterminateDefault();
void VerifyProgressDataIsIndeterminateSetTrue();
void VerifyProgressDataIsIndeterminateFromToast();
void VerifyIconPathExists();
void VerifyExplicitAppId();
void VerifyToastConferencingConfigAllDevicesSet();
Expand Down
15 changes: 15 additions & 0 deletions test/AppNotificationTests/UnpackagedTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,21 @@ void UnpackagedTests::VerifyToastProgressDataSequence0Fail()
BaseTestSuite::VerifyToastProgressDataSequence0Fail();
}

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

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

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

void UnpackagedTests::VerifyShowToast()
{
BaseTestSuite::VerifyShowToast();
Expand Down
3 changes: 3 additions & 0 deletions test/AppNotificationTests/UnpackagedTests.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ 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(VerifyShowToast);
TEST_METHOD(VerifyUpdateToastProgressDataUsingValidTagAndValidGroup);
TEST_METHOD(VerifyUpdateToastProgressDataUsingValidTagAndEmptyGroup);
Expand Down