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 669548 - tests: add ephy-web-view test
tests: add ephy-web-view test
Status: RESOLVED FIXED
Product: epiphany
Classification: Core
Component: General
unspecified
Other All
: Normal normal
: ---
Assigned To: Epiphany Maintainers
Epiphany Maintainers
Depends on:
Blocks: 669461
 
 
Reported: 2012-02-07 10:17 UTC by Diego Escalante Urrelo (not reading bugmail)
Modified: 2012-03-10 19:17 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
tests: add ephy-web-view test (5.71 KB, patch)
2012-02-07 10:17 UTC, Diego Escalante Urrelo (not reading bugmail)
reviewed Details | Review
tests: add ephy-web-view test (3.67 KB, patch)
2012-02-07 20:20 UTC, Diego Escalante Urrelo (not reading bugmail)
needs-work Details | Review
ephy-web-view: share non-search-regex for testing (2.68 KB, patch)
2012-02-10 00:48 UTC, Diego Escalante Urrelo (not reading bugmail)
needs-work Details | Review
tests: add ephy-web-view test (9.19 KB, patch)
2012-02-10 00:51 UTC, Diego Escalante Urrelo (not reading bugmail)
reviewed Details | Review
tests: add ephy-web-view test (9.25 KB, patch)
2012-02-25 21:06 UTC, Diego Escalante Urrelo (not reading bugmail)
reviewed Details | Review
ephy-web-view: share non-search-regex for testing (4.26 KB, patch)
2012-03-01 20:58 UTC, Diego Escalante Urrelo (not reading bugmail)
committed Details | Review
tests: add ephy-web-view test (8.52 KB, patch)
2012-03-02 20:32 UTC, Diego Escalante Urrelo (not reading bugmail)
committed Details | Review

Description Diego Escalante Urrelo (not reading bugmail) 2012-02-07 10:17:13 UTC
To test our faulty url loading, which will be a bug itself.

"Depends" on bug #613756 (Makefile.am)
Comment 1 Diego Escalante Urrelo (not reading bugmail) 2012-02-07 10:17:15 UTC
Created attachment 206961 [details] [review]
tests: add ephy-web-view test

Currently only testing ephy_web_view_load_url
Comment 2 Diego Escalante Urrelo (not reading bugmail) 2012-02-07 10:20:06 UTC
Review of attachment 206961 [details] [review]:

::: tests/ephy-web-view.c
@@ +73,3 @@
+  GMainLoop *loop;
+  EphyWebView *view;
+} Fixture;

Don't really need the loop now, perhaps will later. Should I take it out?

@@ +92,3 @@
+{
+  g_assert (EPHY_IS_WEB_VIEW (fixture->view));
+}

I wonder if tests should include this kind of cases. Isn't it too superfluous?
Comment 3 Xan Lopez 2012-02-07 13:50:35 UTC
Review of attachment 206961 [details] [review]:

::: tests/ephy-web-view.c
@@ +33,3 @@
+#include <glib/gstdio.h>
+#include <gtk/gtk.h>
+#include <string.h>

Used?

@@ +92,3 @@
+{
+  g_assert (EPHY_IS_WEB_VIEW (fixture->view));
+}

It's implictly tested by the others, so I guess it's a bit silly yes.

@@ +96,3 @@
+typedef struct {
+  const char *url;
+  const char *loaded_url;

I insist about this thing freaking me out!

@@ +106,3 @@
+  { "gnome.org:80", "http://gnome.org:80/" },
+  { "gnome", "http://gnome" },
+#endif

Just kill this for now.

@@ +123,3 @@
+    test = tests_load_url[i];
+
+    url = get_uri_for_path ("/");

Where is this used?

@@ +126,3 @@
+
+    ephy_web_view_load_url (fixture->view, test.url);
+    view_url = ephy_web_view_get_address (fixture->view);

This is actually fascinating. You don't need to run the mainloop at all for that to work? :S

@@ +150,3 @@
+  }
+
+  server = soup_server_new (SOUP_SERVER_PORT, 0, NULL);

You probably want to unref the serve rat the end and stuff.

@@ +153,3 @@
+  soup_server_run_async (server);
+
+  base_uri = soup_uri_new ("http://127.0.0.1/");

and this...?
Comment 4 Diego Escalante Urrelo (not reading bugmail) 2012-02-07 20:20:52 UTC
Created attachment 207021 [details] [review]
tests: add ephy-web-view test

Currently only testing ephy_web_view_load_url

=

Comments applied. Removed Fixture and SoupServer since they are unused.
Comment 5 Xan Lopez 2012-02-08 11:24:20 UTC
I honestly doubt this is testing anything at all. It probably just temporarily sets the URL in the view in preparation for loading the page, and unless you run the mainloop and have a web server replying you are not doing anything else. So this does not seem very useful as a test. Am I wrong?
Comment 6 Xan Lopez 2012-02-08 11:33:36 UTC
Review of attachment 207021 [details] [review]:

Let's do a full page load test.
Comment 7 Diego Escalante Urrelo (not reading bugmail) 2012-02-10 00:48:45 UTC
Created attachment 207222 [details] [review]
ephy-web-view: share non-search-regex for testing

=

Needed for more extensive testing.
Comment 8 Diego Escalante Urrelo (not reading bugmail) 2012-02-10 00:51:18 UTC
Created attachment 207223 [details] [review]
tests: add ephy-web-view test

=

Ok here is an improved version of this test.
It now covers:

- ephy_web_view_load_url with a GMainLoop to check the actual results.

- the GRegex to determine if a string is non-searchable


The GRegex is an important part of the puzzle to have proper loading.
There are a few test cases that don't pass with the current GRegex.

Will remove TEST_EPHY_WEB_VIEW_NON_SEARCH_REGEX for commit.
Comment 9 Xan Lopez 2012-02-22 10:48:53 UTC
Review of attachment 207222 [details] [review]:

This should go in ephy-private.h
Comment 10 Xan Lopez 2012-02-22 11:49:44 UTC
Review of attachment 207223 [details] [review]:

Looks good, a few nitpicks.

::: tests/ephy-web-view-test.c
@@ +79,3 @@
+  g_assert_cmpstr (loaded_url, ==, expected_url);
+
+  g_signal_handlers_disconnect_by_func (view, notify_load_status_cb, loop);

Perhaps it's better to just use the same view always, set up in the setup_fixture stuff for tests, to avoid having to do this all the time.

@@ +144,3 @@
+    EphyWebView *view;
+
+    view = EPHY_WEB_VIEW (ephy_web_view_new ());

This is kinda leaked, right?

@@ +146,3 @@
+    view = EPHY_WEB_VIEW (ephy_web_view_new ());
+    test = test_load_url[i];
+    loop = g_main_loop_new (NULL, TRUE);

Not really important, but you want FALSE there, not TRUE.

@@ +223,3 @@
+
+  regex = g_regex_new (EPHY_WEB_VIEW_NON_SEARCH_REGEX,
+                       G_REGEX_OPTIMIZE, G_REGEX_MATCH_NOTEMPTY, &error);

Nitpick, but optimizing the regex for a test probably does not make a lot of sense.

@@ +259,3 @@
+  _ephy_shell_create_instance (FALSE);
+
+  if (!ephy_file_helpers_init (NULL, TRUE, FALSE, NULL)) {

This should really go before you create the shell instance... if it does not make any difference then it's probably useless for testing purposes.

Idea: make a private ephy_test_init that does everything needed, and use it.
Comment 11 Diego Escalante Urrelo (not reading bugmail) 2012-02-25 21:06:30 UTC
Created attachment 208420 [details] [review]
tests: add ephy-web-view test

Updated with your comments.

Re: reusing the web-view is not a big gain IMO. Plus it might give bogus
results if URL loading gets somewhat queued. Consider that I am not
precisely based on evidence for this affirmation.

I guess the ref_sink+unref combo is fine, right?
Comment 12 Diego Escalante Urrelo (not reading bugmail) 2012-02-25 21:08:33 UTC
(In reply to comment #9)
> Review of attachment 207222 [details] [review]:
> 
> This should go in ephy-private.h

ephy-private.h is in src/, AFAIR we avoid depending on stuff from src/

Should I create a embed/ephy-embed-private.h to be included by src/ephy-private.h?
Comment 13 Xan Lopez 2012-02-26 08:28:17 UTC
(In reply to comment #12)
> ephy-private.h is in src/, AFAIR we avoid depending on stuff from src/
> 
> Should I create a embed/ephy-embed-private.h to be included by
> src/ephy-private.h?

Yep, exactly that.
Comment 14 Diego Escalante Urrelo (not reading bugmail) 2012-03-01 20:58:59 UTC
Created attachment 208817 [details] [review]
ephy-web-view: share non-search-regex for testing

Add ephy-embed-private.h
=

Should be good now.
Comment 15 Xan Lopez 2012-03-02 19:02:21 UTC
Review of attachment 208817 [details] [review]:

Looks good.
Comment 16 Xan Lopez 2012-03-02 19:04:35 UTC
Review of attachment 208817 [details] [review]:

Maybe ephy-private.h should include ephy-embed-private.h too, for completeness.
Comment 17 Xan Lopez 2012-03-02 19:04:55 UTC
Review of attachment 208420 [details] [review]:

::: tests/ephy-web-view-test.c
@@ +203,3 @@
+                                        "^localhost(\\.[^[:space:]]+)?(:\\d+)?(/.*)?$|" \
+
+#endif

What?

@@ +215,3 @@
+                                        "^file:.*$" \
+                                        ")"
+

I thought the point was to include this from the private header?
Comment 18 Diego Escalante Urrelo (not reading bugmail) 2012-03-02 19:25:11 UTC
(In reply to comment #17)
> Review of attachment 208420 [details] [review]:
> 
> ::: tests/ephy-web-view-test.c
> @@ +203,3 @@
> +                                       
> "^localhost(\\.[^[:space:]]+)?(:\\d+)?(/.*)?$|" \
> +
> +#endif
> 
> What?
> 
> @@ +215,3 @@
> +                                        "^file:.*$" \
> +                                        ")"
> +
> 
> I thought the point was to include this from the private header?

Oops. Forgot to remove that. Those lines are just to be removed, they are not used currently.
I was using that define just to test some tweaks to the regexp.
Comment 19 Diego Escalante Urrelo (not reading bugmail) 2012-03-02 20:32:42 UTC
Created attachment 208873 [details] [review]
tests: add ephy-web-view test

Testing ephy_web_view_load_url and the internal GRegex of EphyWebView.
Comment 20 Xan Lopez 2012-03-09 14:34:16 UTC
Review of attachment 208873 [details] [review]:

Go.
Comment 21 Diego Escalante Urrelo (not reading bugmail) 2012-03-10 19:17:03 UTC
Done!

Attachment 208817 [details] pushed as 643d1fd - ephy-web-view: share non-search-regex for testing
Attachment 208873 [details] pushed as b56ec17 - tests: add ephy-web-view test