3 new revisions:

Revision: 14f898a07c24
Branch:   default
Author:   Pekka Klärck
Date:     Thu Feb  6 08:03:33 2014 UTC
Log: util.js: Added spec for utils with Matcher tests as initial content
http://code.google.com/p/robotframework/source/detail?r=14f898a07c24

Revision: 39552ace3c31
Branch:   default
Author:   Pekka Klärck
Date:     Thu Feb  6 08:58:11 2014 UTC
Log:      util.js: Cleanup
http://code.google.com/p/robotframework/source/detail?r=39552ace3c31

Revision: ea80a6cfd63d
Branch:   default
Author:   Pekka Klärck
Date:     Thu Feb  6 09:29:14 2014 UTC
Log:      report.html: Generic search by URL....
http://code.google.com/p/robotframework/source/detail?r=ea80a6cfd63d

==============================================================================
Revision: 14f898a07c24
Branch:   default
Author:   Pekka Klärck
Date:     Thu Feb  6 08:03:33 2014 UTC
Log: util.js: Added spec for utils with Matcher tests as initial content
http://code.google.com/p/robotframework/source/detail?r=14f898a07c24

Added:
 /utest/webcontent/spec/UtilSpec.js
Modified:
 /utest/webcontent/SpecRunner.html

=======================================
--- /dev/null
+++ /utest/webcontent/spec/UtilSpec.js  Thu Feb  6 08:03:33 2014 UTC
@@ -0,0 +1,45 @@
+describe("Testing Matcher", function () {
+
+    it("should match equal string", function () {
+        expect(util.Matcher('xxx').matches('xxx')).toBeTruthy();
+        expect(util.Matcher('xxx').matches('yyy')).not.toBeTruthy();
+    });
+
+    it("should match case and space sensitively", function () {
+        var matches = util.Matcher('Hello World').matches;
+        expect(matches('hello WORLD')).toBeTruthy();
+        expect(matches('HELLOWORLD')).toBeTruthy();
+        expect(matches('h e l l o   w o r l d')).toBeTruthy();
+    });
+
+    it("should support * wildcard", function () {
+        var matches = util.Matcher('Hello*').matches;
+        expect(matches('Hello')).toBeTruthy();
+        expect(matches('Hello world')).toBeTruthy();
+        expect(matches('HELLOWORLD')).toBeTruthy();
+        expect(matches('Hillo')).not.toBeTruthy();
+    });
+
+    it("should support ? wildcard", function () {
+        var matches = util.Matcher('H???o').matches;
+        expect(matches('Hello')).toBeTruthy();
+        expect(matches('happo')).toBeTruthy();
+        expect(matches('Hello!')).not.toBeTruthy();
+    });
+
+    it("should escape regexp meta characters", function () {
+        var matches = util.Matcher('a+.?').matches;
+        expect(matches('a+.x')).toBeTruthy();
+        expect(matches('A+.X')).toBeTruthy();
+        expect(matches('a+.')).not.toBeTruthy();
+        expect(matches('aaa')).not.toBeTruthy();
+    });
+
+    it("should support matching any", function () {
+        var matchesAny = util.Matcher('ab?d*').matchesAny;
+        expect(matchesAny(['xxx', 'abcd'])).toBeTruthy();
+        expect(matchesAny(['xxx', 'abc'])).not.toBeTruthy();
+        expect(matchesAny([])).not.toBeTruthy();
+    });
+
+});
=======================================
--- /utest/webcontent/SpecRunner.html   Sat Oct 12 17:41:29 2013 UTC
+++ /utest/webcontent/SpecRunner.html   Thu Feb  6 08:03:33 2014 UTC
@@ -34,6 +34,7 @@
   <script type="text/javascript" src="spec/StatisticsSpec.js"></script>
   <script type="text/javascript" src="spec/ContainsTag.js"></script>
   <script type="text/javascript" src="spec/LogLevelSpec.js"></script>
+  <script type="text/javascript" src="spec/UtilSpec.js"></script>

 </head>
 <body>

==============================================================================
Revision: 39552ace3c31
Branch:   default
Author:   Pekka Klärck
Date:     Thu Feb  6 08:58:11 2014 UTC
Log:      util.js: Cleanup
http://code.google.com/p/robotframework/source/detail?r=39552ace3c31

Modified:
 /src/robot/htmldata/rebot/util.js

=======================================
--- /src/robot/htmldata/rebot/util.js   Wed Feb  5 13:03:09 2014 UTC
+++ /src/robot/htmldata/rebot/util.js   Thu Feb  6 08:58:11 2014 UTC
@@ -138,8 +138,8 @@
     function createGeneratedAgoString(generatedMillis) {
         generatedMillis = timestamp(generatedMillis);
         function timeString(time, shortUnit) {
-            var unit = {'y': 'year', 'd': 'day', 'h': 'hour',
-                        'm': 'minute', 's': 'second'}[shortUnit];
+            var unit = {y: 'year', d: 'day', h: 'hour', m: 'minute',
+                        s: 'second'}[shortUnit];
             var end = time == 1 ? ' ' : 's ';
             return time + ' ' + unit + end;
         }
@@ -150,25 +150,24 @@
         var generated = Math.round(generatedMillis / 1000);
         var current = Math.round(new Date().getTime() / 1000);
         var elapsed = current - generated;
+        var prefix = '';
         if (elapsed < 0) {
+            prefix = '- ';
             elapsed = Math.abs(elapsed);
-            prefix = '- ';
-        } else {
-            prefix = '';
         }
         var secs  = elapsed % 60;
         var mins  = Math.floor(elapsed / 60) % 60;
         var hours = Math.floor(elapsed / (60*60)) % 24;
         var days  = Math.floor(elapsed / (60*60*24)) % 365;
         var years = Math.floor(elapsed / (60*60*24*365));
-        if (years > 0) {
+        if (years) {
             days = compensateLeapYears(days, years);
             return prefix + timeString(years, 'y') + timeString(days, 'd');
-        } else if (days > 0) {
+        } else if (days) {
             return prefix + timeString(days, 'd') + timeString(hours, 'h');
-        } else if (hours > 0) {
+        } else if (hours) {
             return prefix + timeString(hours, 'h') + timeString(mins, 'm');
-        } else if (mins > 0) {
+        } else if (mins) {
             return prefix + timeString(mins, 'm') + timeString(secs, 's');
         } else {
             return prefix + timeString(secs, 's');

==============================================================================
Revision: ea80a6cfd63d
Branch:   default
Author:   Pekka Klärck
Date:     Thu Feb  6 09:29:14 2014 UTC
Log:      report.html: Generic search by URL.

Update issue 1634
Initial implementation to search by URL. Handling special chars like & and = does not work currently, but fixing that requires changes to how URLs are handled in general.
http://code.google.com/p/robotframework/source/detail?r=ea80a6cfd63d

Modified:
 /src/robot/htmldata/rebot/report.html
 /src/robot/htmldata/rebot/util.js
 /utest/webcontent/spec/UtilSpec.js

=======================================
--- /src/robot/htmldata/rebot/report.html       Wed Feb  5 13:42:51 2014 UTC
+++ /src/robot/htmldata/rebot/report.html       Thu Feb  6 09:29:14 2014 UTC
@@ -108,6 +108,8 @@
 function showDetailsByHash() {
     if (window.location.hash == window.prevLocationHash)
         return;
+    // TODO: Should not decode here yet! And should never use decodeURI
+    // but decodeURIComponen. Also, why '%' -> '%25'???
     var hash = window.location.hash.substring(1).replace('%', '%25');
     var hashParts = decodeURI(hash).split('_');
     var key = hashParts.shift();
@@ -115,7 +117,7 @@
     var action = {'totals': showTotalSelector,
                   'tags':   showTagSelector,
                   'suites': showSuiteSelector,
-                  'search': showSearchSelector,
+                  'search': urlSearch,
                   'total':  totalDetailSelected,
                   'tag':    tagDetailSelected,
                   'suite':  suiteDetailSelected}[key];
@@ -138,9 +140,9 @@
     scrollToSelector('suites');
 }

-function showSearchSelector() {
-    renderSearchSelector();
-    scrollToSelector('search');
+function urlSearch(query) {
+    var params = util.parseQueryString(query);
+ searchExecuted(params.suite, params.test, params.include, params.exclude);
 }

 function totalDetailSelected(name) {
@@ -235,16 +237,16 @@
 }

 function searchExecuted(suite, test, include, exclude) {
-    if (!(suite || test || include || exclude))
-        return;
     renderSearchSelector(suite, test, include, exclude);
-    renderSearchDetails(suite, test, include, exclude);
- scrollToSelector('search_' + suite + '::' + test + '::' + include + '::' + exclude);
+    if (suite || test || include || exclude) {
+        renderSearchDetails(suite, test, include, exclude);
+ scrollToSelector('search_suite=' + suite + '&test=' + test + '&include=' + include + '&exclude=' + exclude);
+    }
 }

 function renderSearchSelector(suite, test, include, exclude) {
     var args = {linkTarget: (suite || test || include || exclude) ?
- ('search_' + suite + '::' + test + '::' + include + '::' + exclude) : + ('search_suite=' + suite + '&test=' + test + '&include=' + include + '&exclude=' + exclude) :
                             'search',
                 searchTabStatus: 'detail-tab-selected'};
var search = {suite: suite, test: test, include: include, exclude: exclude};
=======================================
--- /src/robot/htmldata/rebot/util.js   Thu Feb  6 08:58:11 2014 UTC
+++ /src/robot/htmldata/rebot/util.js   Thu Feb  6 09:29:14 2014 UTC
@@ -173,6 +173,22 @@
             return prefix + timeString(secs, 's');
         }
     }
+
+    function parseQueryString(query) {
+        var result = {};
+        if (!query)
+            return result;
+        var params = query.split('&');
+        var parts;
+        function decode(item) {
+            return decodeURIComponent(item.replace('+', ' '));
+        }
+        for (var i = 0, len = params.length; i < len; i++) {
+            parts = params[i].split('=');
+            result[decode(parts.shift())] = decode(parts.join('='));
+        }
+        return result;
+    }

     return {
         map: map,
@@ -191,6 +207,7 @@
         dateTimeFromDate: dateTimeFromDate,
         formatElapsed: formatElapsed,
         timestamp: timestamp,
-        createGeneratedAgoString: createGeneratedAgoString
+        createGeneratedAgoString: createGeneratedAgoString,
+        parseQueryString: parseQueryString
     };
 }();
=======================================
--- /utest/webcontent/spec/UtilSpec.js  Thu Feb  6 08:03:33 2014 UTC
+++ /utest/webcontent/spec/UtilSpec.js  Thu Feb  6 09:29:14 2014 UTC
@@ -43,3 +43,38 @@
     });

 });
+
+describe("Testing parseQueryString", function () {
+    var parse = util.parseQueryString;
+
+    it("should parse empty string", function () {
+        expect(parse('')).toEqual({});
+    });
+
+    it("should parse one param", function () {
+        expect(parse('foo=bar')).toEqual({foo: 'bar'});
+    });
+
+    it("should parse multiple params", function () {
+        expect(parse('a=1&b=2&c=3')).toEqual({a: '1', b: '2', c: '3'});
+    });
+
+    it("should accept param with name alone (i.e. no =)", function () {
+        expect(parse('foo')).toEqual({foo: ''});
+        expect(parse('foo&bar')).toEqual({foo: '', bar: ''});
+        expect(parse('a&b=2&c=&d')).toEqual({a: '', b: '2', c: '', d: ''});
+    });
+
+ it("should accept = in value (although it should be encoded)", function () {
+        expect(parse('a=1=2&b==')).toEqual({a: '1=2', b: '='});
+    });
+
+    it("should convert + to space", function () {
+        expect(parse('value=hello+world')).toEqual({value: 'hello world'});
+    });
+
+    it("should decode uri", function () {
+        expect(parse('value=%26%20%3d')).toEqual({value: '& ='});
+    });
+
+});

--

--- You received this message because you are subscribed to the Google Groups "robotframework-commit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to robotframework-commit+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to