After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 668758 - ephy-download: update and fix tests for make check
ephy-download: update and fix tests for make check
Status: RESOLVED FIXED
Product: epiphany
Classification: Core
Component: Downloads
unspecified
Other All
: Normal normal
: ---
Assigned To: Epiphany Maintainers
Epiphany Maintainers
Depends on:
Blocks:
 
 
Reported: 2012-01-26 16:58 UTC by Diego Escalante Urrelo (not reading bugmail)
Modified: 2012-01-30 19:39 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
ephy-download: emit completed after processing download (1.39 KB, patch)
2012-01-26 16:58 UTC, Diego Escalante Urrelo (not reading bugmail)
none Details | Review
tests: ephy-download: missing ephy_download_start (2.12 KB, patch)
2012-01-26 16:58 UTC, Diego Escalante Urrelo (not reading bugmail)
accepted-commit_now Details | Review
ephy-download: emit completed after processing download (2.17 KB, patch)
2012-01-26 17:20 UTC, Diego Escalante Urrelo (not reading bugmail)
reviewed Details | Review
tests: ephy-download: missing ephy_download_start (1.96 KB, patch)
2012-01-30 19:14 UTC, Diego Escalante Urrelo (not reading bugmail)
committed Details | Review

Description Diego Escalante Urrelo (not reading bugmail) 2012-01-26 16:58:24 UTC
Found a bug while doing it. Attaching patches.
Comment 1 Diego Escalante Urrelo (not reading bugmail) 2012-01-26 16:58:26 UTC
Created attachment 206201 [details] [review]
ephy-download: emit completed after processing download

Allowing the user to act freely on the EphyDownload object when
the completed signal is called, i.e: unrefing the object.
Comment 2 Diego Escalante Urrelo (not reading bugmail) 2012-01-26 16:58:28 UTC
Created attachment 206202 [details] [review]
tests: ephy-download: missing ephy_download_start
Comment 3 Diego Escalante Urrelo (not reading bugmail) 2012-01-26 17:20:19 UTC
Created attachment 206207 [details] [review]
ephy-download: emit completed after processing download

Allowing the user to act freely on the EphyDownload object when
the completed signal is called, i.e: unrefing the object.

Also use a switch instead of lots of ifs.

==

This is an alternative to the previos patch, plaes correctly suggested to use a switch instead of an if for this.
Comment 4 Xan Lopez 2012-01-26 22:29:51 UTC
Review of attachment 206207 [details] [review]:

Does this fix anything? FWIW, if you perform all the actions before "completed" is emitted it's not very clear what can you do in the callback.

::: embed/ephy-download.c
@@ +902,3 @@
+      } else {
+        ephy_download_do_download_action (download, EPHY_DOWNLOAD_ACTION_NONE);
+      }

While you are at it, no braces in single line clauses.
Comment 5 Xan Lopez 2012-01-26 22:30:46 UTC
Review of attachment 206202 [details] [review]:

OK, minus the HTML_STRING thing.

::: tests/ephy-download.c
@@ +35,3 @@
 #include <string.h>
 
+#define HTML_STRING "testing-ephy-download"

Unrelated? Make this another commit (and just go ahead and commit it).
Comment 6 Diego Escalante Urrelo (not reading bugmail) 2012-01-27 02:40:55 UTC
(In reply to comment #4)
> Review of attachment 206207 [details] [review]:
> 
> Does this fix anything? FWIW, if you perform all the actions before "completed"
> is emitted it's not very clear what can you do in the callback.
> 

I discovered that in the test I couldn't unref the EphyDownload object in the completed callback. ephy_download_do_download_action received a NULL @download when I did that.

I considered that the callback should allow you to kill the @download object.
Another option is to hold a ref and free it on ephy_download_do_download_action?

Consider that the signal is not meant to allow you to stop the default handler like other API. We could change it to do so however, and returning TRUE would mean to not call ephy_download_do_download_action.
Comment 7 Xan Lopez 2012-01-30 11:03:39 UTC
(In reply to comment #6)
> I considered that the callback should allow you to kill the @download object.
> Another option is to hold a ref and free it on
> ephy_download_do_download_action?

Hrm. I'd say ephy itself should get rid of the object if it can? For instance, connecting to "completed" just to unref the object seems pretty pointless.

> 
> Consider that the signal is not meant to allow you to stop the default handler
> like other API. We could change it to do so however, and returning TRUE would
> mean to not call ephy_download_do_download_action.

I guess we should not do that until we actually need it for some reason.
Comment 8 Diego Escalante Urrelo (not reading bugmail) 2012-01-30 19:14:03 UTC
Created attachment 206468 [details] [review]
tests: ephy-download: missing ephy_download_start

This version doesn't require the API adjust.
Comment 9 Xan Lopez 2012-01-30 19:24:45 UTC
Review of attachment 206468 [details] [review]:

OK.
Comment 10 Diego Escalante Urrelo (not reading bugmail) 2012-01-30 19:39:39 UTC
Attachment 206468 [details] pushed as 87b9227 - tests: ephy-download: missing ephy_download_start

Done.