[gnome-software/wip/improve-tests: 475/475] Reset the progress to 0 when setting a non-action state
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/improve-tests: 475/475] Reset the progress to 0 when setting a non-action state
- Date: Fri, 25 Jan 2019 16:27:57 +0000 (UTC)
commit 883c3c1e11cd90703c3ab1c92fd1a1c02509c8e2
Author: Joaquim Rocha <jrocha endlessm com>
Date: Mon May 14 17:02:44 2018 +0200
Reset the progress to 0 when setting a non-action state
Per hughsie, when setting a non-action state, the apps' progress should
be reset to 0.
This patch adds that and also its coverage in the dummy plugin's tests.
lib/gs-app.c | 10 ++++++++++
plugins/dummy/gs-self-test.c | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 45 insertions(+)
---
diff --git a/lib/gs-app.c b/lib/gs-app.c
index e9d5c063..45492afa 100644
--- a/lib/gs-app.c
+++ b/lib/gs-app.c
@@ -1021,6 +1021,16 @@ gs_app_set_state_internal (GsApp *app, AsAppState state)
state == AS_APP_STATE_AVAILABLE)
priv->install_date = 0;
+ /* reset the progress on non-action states */
+ if (priv->progress != 0 &&
+ (state == AS_APP_STATE_INSTALLED ||
+ state == AS_APP_STATE_AVAILABLE_LOCAL ||
+ state == AS_APP_STATE_AVAILABLE ||
+ state == AS_APP_STATE_PURCHASABLE)) {
+ priv->progress = 0;
+ gs_app_queue_notify (app, "progress");
+ }
+
/* save this to simplify error handling in the plugins */
switch (state) {
case AS_APP_STATE_INSTALLING:
diff --git a/plugins/dummy/gs-self-test.c b/plugins/dummy/gs-self-test.c
index 1c7cc694..89c290df 100644
--- a/plugins/dummy/gs-self-test.c
+++ b/plugins/dummy/gs-self-test.c
@@ -749,6 +749,38 @@ gs_plugins_dummy_limit_parallel_ops_func (GsPluginLoader *plugin_loader)
gs_plugin_loader_set_max_parallel_ops (plugin_loader, 0);
}
+static void
+gs_plugin_dummy_progress_func (GsPluginLoader *plugin_loader)
+{
+ g_autoptr(GsApp) app = gs_app_new ("chiron-paid.desktop");
+ gs_app_set_management_plugin (app, "dummy");
+
+ /* check available state */
+ gs_app_set_state (app, AS_APP_STATE_UNKNOWN);
+ gs_app_set_state (app, AS_APP_STATE_AVAILABLE);
+ gs_app_set_state (app, AS_APP_STATE_INSTALLING);
+ gs_app_set_progress (app, 50);
+ g_assert_cmpuint (gs_app_get_progress (app), ==, 50);
+ gs_app_set_state (app, AS_APP_STATE_AVAILABLE);
+ g_assert_cmpuint (gs_app_get_progress (app), ==, 0);
+
+ /* check installed state */
+ gs_app_set_state (app, AS_APP_STATE_INSTALLING);
+ gs_app_set_progress (app, 50);
+ g_assert_cmpuint (gs_app_get_progress (app), ==, 50);
+ gs_app_set_state (app, AS_APP_STATE_INSTALLED);
+ g_assert_cmpuint (gs_app_get_progress (app), ==, 0);
+
+ /* check purchasable state */
+ gs_app_set_state (app, AS_APP_STATE_UNKNOWN);
+ gs_app_set_state (app, AS_APP_STATE_PURCHASABLE);
+ gs_app_set_state (app, AS_APP_STATE_PURCHASING);
+ gs_app_set_progress (app, 50);
+ g_assert_cmpuint (gs_app_get_progress (app), ==, 50);
+ gs_app_set_state (app, AS_APP_STATE_PURCHASABLE);
+ g_assert_cmpuint (gs_app_get_progress (app), ==, 0);
+}
+
int
main (int argc, char **argv)
{
@@ -905,6 +937,9 @@ main (int argc, char **argv)
g_test_add_data_func ("/gnome-software/plugins/dummy/limit-parallel-ops",
plugin_loader,
(GTestDataFunc) gs_plugins_dummy_limit_parallel_ops_func);
+ g_test_add_data_func ("/gnome-software/plugins/dummy/progress",
+ plugin_loader,
+ (GTestDataFunc) gs_plugin_dummy_progress_func);
return g_test_run ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]