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 613756 - add test for ephy-embed-utils has-web-scheme
add test for ephy-embed-utils has-web-scheme
Status: RESOLVED FIXED
Product: epiphany
Classification: Core
Component: General
git master
Other Linux
: Normal normal
: ---
Assigned To: Epiphany Maintainers
Epiphany Maintainers
Depends on:
Blocks: 669461
 
 
Reported: 2010-03-23 23:34 UTC by Diego Escalante Urrelo (not reading bugmail)
Modified: 2012-02-08 05:28 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Tests for ephy-embed-utils (2.91 KB, patch)
2010-04-13 03:28 UTC, Alexandre Martani
none Details | Review
Bugfix for ephy-embed-utils/has_web_scheme (508 bytes, patch)
2010-04-13 03:31 UTC, Alexandre Martani
none Details | Review
Tests for ephy-embed-utils (2.91 KB, patch)
2010-04-13 04:40 UTC, Alexandre Martani
none Details | Review
Tests for ephy-embed-utils (3.35 KB, patch)
2010-04-28 01:42 UTC, Alexandre Martani
none Details | Review
Bugfix for ephy-embed-utils/has_web_scheme (910 bytes, patch)
2010-04-28 01:43 UTC, Alexandre Martani
none Details | Review
Another test for ephy-embed-utils (818 bytes, patch)
2010-04-28 02:43 UTC, Alexandre Martani
none Details | Review
Fix for ephy-embed-utils/has_web_scheme (1.98 KB, patch)
2010-04-28 03:36 UTC, Alexandre Martani
needs-work Details | Review
Remove unused variable (649 bytes, patch)
2010-05-11 22:43 UTC, Alexandre Martani
rejected Details | Review
Add tests to incomplete schemes (1001 bytes, patch)
2010-05-11 22:44 UTC, Alexandre Martani
none Details | Review
tests: add test for ephy-embed-utils (3.48 KB, patch)
2010-11-07 00:20 UTC, Diego Escalante Urrelo (not reading bugmail)
reviewed Details | Review
ephy-embed-utils: prevent false positives in has_web_scheme (1.83 KB, patch)
2010-11-07 00:21 UTC, Diego Escalante Urrelo (not reading bugmail)
reviewed Details | Review
tests: add test for ephy-embed-utils (3.56 KB, patch)
2010-11-23 22:28 UTC, Diego Escalante Urrelo (not reading bugmail)
none Details | Review
ephy-embed-utils: improve has_web_scheme (2.33 KB, patch)
2010-11-23 22:28 UTC, Diego Escalante Urrelo (not reading bugmail)
none Details | Review
tests: add test for ephy-embed-utils (4.57 KB, patch)
2012-01-24 19:59 UTC, Diego Escalante Urrelo (not reading bugmail)
reviewed Details | Review
tests: add test for ephy-embed-utils (5.84 KB, patch)
2012-01-26 16:09 UTC, Diego Escalante Urrelo (not reading bugmail)
reviewed Details | Review
ephy-embed-utils: improve has_web_scheme (2.37 KB, patch)
2012-01-26 16:09 UTC, Diego Escalante Urrelo (not reading bugmail)
rejected Details | Review
ephy-embed-utils: cleanup normalize_address (1.95 KB, patch)
2012-01-26 16:09 UTC, Diego Escalante Urrelo (not reading bugmail)
rejected Details | Review
tests: add test for ephy-embed-utils (5.86 KB, patch)
2012-02-07 10:15 UTC, Diego Escalante Urrelo (not reading bugmail)
committed Details | Review

Description Diego Escalante Urrelo (not reading bugmail) 2010-03-23 23:34:16 UTC
We need more tests!
Comment 1 Alexandre Martani 2010-04-13 03:28:39 UTC
Created attachment 158568 [details] [review]
Tests for ephy-embed-utils

Test for ephy-embed-utils/address_has_web_scheme.

Note that the test currently fail, as address_has_web_scheme returns TRUE for strings starting on ":".

I don't know how to test link_message_parse, as it uses i18n functions, so it will return different values depending on locale.

Tests for normalize_web_address are on bug #612078.
Comment 2 Alexandre Martani 2010-04-13 03:31:54 UTC
Created attachment 158569 [details] [review]
Bugfix for ephy-embed-utils/has_web_scheme

Simple correction for has_web_scheme, that returns true for strings starting on ':'.
Comment 3 Alexandre Martani 2010-04-13 04:40:56 UTC
Created attachment 158572 [details] [review]
Tests for ephy-embed-utils

Declare strings as const.
Comment 4 Alexandre Martani 2010-04-28 01:42:49 UTC
Created attachment 159741 [details] [review]
Tests for ephy-embed-utils

Patch using git format-patch
Comment 5 Alexandre Martani 2010-04-28 01:43:47 UTC
Created attachment 159742 [details] [review]
Bugfix for ephy-embed-utils/has_web_scheme

Patch using git format-patch
Comment 6 Diego Escalante Urrelo (not reading bugmail) 2010-04-28 02:07:09 UTC
Review of attachment 159742 [details] [review]:

Looks good to me. Specially with the test to validate your change :).

Xan?
Comment 7 Diego Escalante Urrelo (not reading bugmail) 2010-04-28 02:09:28 UTC
Review of attachment 159741 [details] [review]:

Cool. Seems simple enough. I think it's oktc, but first let's agree on the one liner, which I also think looks safe.
Comment 8 Alexandre Martani 2010-04-28 02:43:48 UTC
Created attachment 159744 [details] [review]
Another test for ephy-embed-utils

Found another failing test for has_web_scheme, so my previous fix is wrong.
Comment 9 Alexandre Martani 2010-04-28 03:36:41 UTC
Created attachment 159746 [details] [review]
Fix for ephy-embed-utils/has_web_scheme

Not so simple as the previous one, but passes the tests.
Comment 10 Alexandre Martani 2010-05-11 22:43:00 UTC
Created attachment 160871 [details] [review]
Remove unused variable
Comment 11 Alexandre Martani 2010-05-11 22:44:18 UTC
Created attachment 160872 [details] [review]
Add tests to incomplete schemes

Test to make sure all lengths are correct.
Comment 12 Diego Escalante Urrelo (not reading bugmail) 2010-05-29 02:29:03 UTC
Comment on attachment 160871 [details] [review]
Remove unused variable

You should have removed colonpos and never add colon. See your previous patch.
Comment 13 Diego Escalante Urrelo (not reading bugmail) 2010-05-29 02:29:53 UTC
Comment on attachment 159746 [details] [review]
Fix for ephy-embed-utils/has_web_scheme

You forgot to remove colonpos and added colon.
Comment 14 Diego Escalante Urrelo (not reading bugmail) 2010-05-29 02:33:48 UTC
Patches LGTM, I'd commit them with a few nitpicks in the commit messages for tests/: add the "tests:" prefix for your two patches touching testephyembedutils.c, just like the ephy-embed-utils: prefix.
Comment 15 Diego Escalante Urrelo (not reading bugmail) 2010-11-07 00:20:57 UTC
Created attachment 173974 [details] [review]
tests: add test for ephy-embed-utils

Specifically ephy_embed_utils_address_has_web_scheme.

Bug #613756
Comment 16 Diego Escalante Urrelo (not reading bugmail) 2010-11-07 00:21:11 UTC
Created attachment 173975 [details] [review]
ephy-embed-utils: prevent false positives in has_web_scheme

Bug #613756
Comment 17 Xan Lopez 2010-11-09 04:12:36 UTC
Review of attachment 173974 [details] [review]:

::: tests/testephyembedutils.c
@@ +1,1 @@
+/* vim: set sw=2 ts=2 sts=2 et: */

only the vim ones? uh.

@@ +4,3 @@
+ * This file is part of Epiphany
+ *
+ * Copyright © 2010 - Alexandre Martani

What?

@@ +71,3 @@
+    g_assert (!ephy_embed_utils_address_has_web_scheme (without_web_scheme[i]));
+  }
+}

No braces for one line control clauses, says HACKING.
Comment 18 Xan Lopez 2010-11-09 04:14:15 UTC
Review of attachment 173975 [details] [review]:

It's not immediately obvious to me here what false positive you are fixing. Care to elaborate and put it in the commit message?
Comment 19 Diego Escalante Urrelo (not reading bugmail) 2010-11-23 22:28:46 UTC
Created attachment 175138 [details] [review]
tests: add test for ephy-embed-utils

Specifically ephy_embed_utils_address_has_web_scheme.

Bug #613756
Comment 20 Diego Escalante Urrelo (not reading bugmail) 2010-11-23 22:28:51 UTC
Created attachment 175139 [details] [review]
ephy-embed-utils: improve has_web_scheme

Fix some false positives and improve ephy_embed_utils_address_has_web_scheme():
  - returns FALSE if there's no colon before the 11th character
  - correctly handle g_ascii_strncasecmp() return value with == 0
  - hardcode colon position for each scheme
  - avoid duplicated lines with an array of schemes

Based on a patch by Alexandre Martani.

Bug #613756
Comment 21 Diego Escalante Urrelo (not reading bugmail) 2010-11-23 22:32:20 UTC
Re: your comments:

- the test is © Alexandre because he wrote it
- style fixed in test
- I rewrote the embed-utils patch almost from scratch, commit msg has a list of what's fixed, do you like the struct or is it too much?
Comment 22 Diego Escalante Urrelo (not reading bugmail) 2012-01-24 19:59:58 UTC
Created attachment 206012 [details] [review]
tests: add test for ephy-embed-utils

Specifically ephy_embed_utils_address_has_web_scheme.
Based on a patch by Alexandre Martani.
Comment 23 Xan Lopez 2012-01-26 11:23:40 UTC
Review of attachment 206012 [details] [review]:

This is OK, but what we need to test is that loading the URIs in an EphyWebView actually starts a load. That's what usually breaks, not this util method.

::: tests/ephy-embed-utils.c
@@ +5,3 @@
+ * This file is part of Epiphany
+ *
+ * Copyright © 2011 Igalia S.L.

2012

@@ +24,3 @@
+
+#include "config.h"
+#include "ephy-embed-utils.h"

An empty line here.

@@ +43,3 @@
+  { "data", "data:\%20\%40" },
+  { "about", "about:epiphany" },
+  { "epiphany-about", "epiphany-about:memory" },

It's ephy-about, not epiphany-about. Otherwise it will fail.
Comment 24 Diego Escalante Urrelo (not reading bugmail) 2012-01-26 16:09:32 UTC
Created attachment 206197 [details] [review]
tests: add test for ephy-embed-utils

Specifically ephy_embed_utils_address_has_web_scheme.
Based on a patch by Alexandre Martani.
Comment 25 Diego Escalante Urrelo (not reading bugmail) 2012-01-26 16:09:35 UTC
Created attachment 206198 [details] [review]
ephy-embed-utils: improve has_web_scheme

Fix some false positives and improve ephy_embed_utils_address_has_web_scheme():
  - returns FALSE if there's no colon before the 11th character
  - correctly handle g_ascii_strncasecmp() return value with == 0
  - hardcode colon position for each scheme
  - avoid duplicated lines with an array of schemes

Based on a patch by Alexandre Martani.
Comment 26 Diego Escalante Urrelo (not reading bugmail) 2012-01-26 16:09:38 UTC
Created attachment 206199 [details] [review]
ephy-embed-utils: cleanup normalize_address

Correctly handle g_strcmp0 return value, simplify the conditionals.
Comment 27 Xan Lopez 2012-01-30 19:57:23 UTC
Review of attachment 206198 [details] [review]:

::: embed/ephy-embed-utils.c
@@ +112,3 @@
+						       schemes[i].prefix,
+						       schemes[i].colpos) == 0);
+	}

Hum, just break early if you find it?

You are also kinda losing the small optimization of returning FALSE if there's no colon before the 11th character.
Comment 28 Xan Lopez 2012-01-30 19:58:48 UTC
Review of attachment 206197 [details] [review]:

::: tests/Makefile.am
@@ +112,3 @@
 
+test_ephy_embed_utils_SOURCES = \
+	ephy-embed-utils.c

I prefer test-ephy-embed-utils.c, otherwise there's duplicated source file names in the tree.

::: tests/ephy-embed-utils.c
@@ +5,3 @@
+ * This file is part of Epiphany
+ *
+ * Copyright © 2011 Igalia S.L.

2012.

@@ +31,3 @@
+  const char *name;
+  const char *test;
+} SchemeTest;

I honestly have no idea of what 'const char*' means in a struct.
Comment 29 Xan Lopez 2012-01-30 20:06:06 UTC
Review of attachment 206199 [details] [review]:

- I don't see how g_strcmp0 was broken before (?)
- Not immediately obvious how you are simplifying things, since you are adding much more stuff to the method, needs more explanation.
- There are still no unit tests that check that loading pages in a webview actually works, so I wouldn't keep touching this code after our last experience here.
Comment 30 Diego Escalante Urrelo (not reading bugmail) 2012-01-30 22:24:06 UTC
(In reply to comment #28)
> Review of attachment 206197 [details] [review]:
> 
> ::: tests/Makefile.am
> @@ +112,3 @@
> 
> +test_ephy_embed_utils_SOURCES = \
> +    ephy-embed-utils.c
> 
> I prefer test-ephy-embed-utils.c, otherwise there's duplicated source file
> names in the tree.

That means renaming the other tests too. My original reason for this name scheme was that tab completion on tests/ was a pest, both binaries and files were offered.

> ::: tests/ephy-embed-utils.c
> @@ +5,3 @@
> + * This file is part of Epiphany
> + *
> + * Copyright © 2011 Igalia S.L.
> 
> 2012.

:P

> @@ +31,3 @@
> +  const char *name;
> +  const char *test;
> +} SchemeTest;
> 
> I honestly have no idea of what 'const char*' means in a struct.

This is me, not knowing much C. Educate me.
Comment 31 Diego Escalante Urrelo (not reading bugmail) 2012-01-30 22:25:26 UTC
(In reply to comment #29)
> Review of attachment 206199 [details] [review]:
> 
> - I don't see how g_strcmp0 was broken before (?)
> - Not immediately obvious how you are simplifying things, since you are adding
> much more stuff to the method, needs more explanation.
> - There are still no unit tests that check that loading pages in a webview
> actually works, so I wouldn't keep touching this code after our last experience
> here.

Agree. I'll work on an additional test for EphyWebView so we can test this at both levels. From that I'll see if the changes still make sense.
Comment 32 Xan Lopez 2012-01-31 11:46:08 UTC
(In reply to comment #30)
> > I prefer test-ephy-embed-utils.c, otherwise there's duplicated source file
> > names in the tree.
> 
> That means renaming the other tests too. My original reason for this name
> scheme was that tab completion on tests/ was a pest, both binaries and files
> were offered.

I see, but I think having duplicated filenames is really bad (sucks while you are worknig on the test, and if we ever move to non-recursive Makefiles it will bite us in the ass I think). ephy-embed-utils-test.c ?

> > @@ +31,3 @@
> > +  const char *name;
> > +  const char *test;
> > +} SchemeTest;
> > 
> > I honestly have no idea of what 'const char*' means in a struct.
> 
> This is me, not knowing much C. Educate me.

What I meant is, "why are you doing that?". I'm not sure it has any useful effect in this context :)
Comment 33 Diego Escalante Urrelo (not reading bugmail) 2012-02-03 07:54:06 UTC
(In reply to comment #32)
> (In reply to comment #30)
> > > I prefer test-ephy-embed-utils.c, otherwise there's duplicated source file
> > > names in the tree.
> > 
> > That means renaming the other tests too. My original reason for this name
> > scheme was that tab completion on tests/ was a pest, both binaries and files
> > were offered.
> 
> I see, but I think having duplicated filenames is really bad (sucks while you
> are worknig on the test, and if we ever move to non-recursive Makefiles it will
> bite us in the ass I think). ephy-embed-utils-test.c ?
> 

Ok, that sounds nicer than tab frustration :-P. I will write a simple patch for that.

Btw, I already have a simple ephy-web-view test. I will include it in the next batch of patches.

> > > @@ +31,3 @@
> > > +  const char *name;
> > > +  const char *test;
> > > +} SchemeTest;
> > > 
> > > I honestly have no idea of what 'const char*' means in a struct.
> > 
> > This is me, not knowing much C. Educate me.
> 
> What I meant is, "why are you doing that?". I'm not sure it has any useful
> effect in this context :)

AFAIK because those are strings I'm not going to change, free, modify or whatever. So I guess it's just a micro micro micro optimization?
Comment 34 Diego Escalante Urrelo (not reading bugmail) 2012-02-07 10:15:16 UTC
Created attachment 206959 [details] [review]
tests: add test for ephy-embed-utils

Specifically ephy_embed_utils_address_has_web_scheme.
Based on a patch by Alexandre Martani.
Comment 35 Xan Lopez 2012-02-07 10:17:44 UTC
Review of attachment 206959 [details] [review]:

OK.
Comment 36 Diego Escalante Urrelo (not reading bugmail) 2012-02-08 05:27:50 UTC
Done! Hopefully we will fix this soon.


Attachment 206959 [details] pushed as a65a772 - tests: add test for ephy-embed-utils