Merge lp:~abreu-alexandre/ubuntu-html5-theme/fix-autopilot-with-rss-sample-app into lp:~ubuntu-html5-theme-devs/ubuntu-html5-theme/ambiance

Proposed by Alexandre Abreu
Status: Merged
Approved by: Alexandre Abreu
Approved revision: 64
Merged at revision: 64
Proposed branch: lp:~abreu-alexandre/ubuntu-html5-theme/fix-autopilot-with-rss-sample-app
Merge into: lp:~ubuntu-html5-theme-devs/ubuntu-html5-theme/ambiance
Diff against target: 465 lines (+306/-115)
6 files modified
0.1/examples/apps/rss-reader/autopilot.html (+0/-107)
tests/autopilot/ubuntu_html5_theme/tests/__init__.py (+2/-1)
tests/autopilot/ubuntu_html5_theme/tests/test_rss_reader.py (+5/-7)
tests/data/html/apps/rss-reader/app.js (+152/-0)
tests/data/html/apps/rss-reader/index.html (+107/-0)
tests/data/html/apps/rss-reader/styles.css (+40/-0)
To merge this branch: bzr merge lp:~abreu-alexandre/ubuntu-html5-theme/fix-autopilot-with-rss-sample-app
Reviewer Review Type Date Requested Status
Adnane Belmadiaf Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+173564@code.launchpad.net

Description of the change

fix autopilot test of sample app, remove network dependancy & mocked data

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Adnane Belmadiaf (daker) wrote :

looks good to me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== removed file '0.1/examples/apps/rss-reader/autopilot.html'
2--- 0.1/examples/apps/rss-reader/autopilot.html 2013-07-08 07:53:01 +0000
3+++ 0.1/examples/apps/rss-reader/autopilot.html 1970-01-01 00:00:00 +0000
4@@ -1,107 +0,0 @@
5-<!--
6- Copyright (C) 2013 Adnane Belmadiaf <daker@ubuntu.com>
7-
8- This file is part of ubuntu-html5-theme.
9-
10- This package is free software; you can redistribute it and/or modify
11- it under the terms of the Lesser GNU General Public License as
12- published by the Free Software Foundation; either version 3 of the
13- License, or
14- (at your option) any later version.
15-
16- This package is distributed in the hope that it will be useful,
17- but WITHOUT ANY WARRANTY; without even the implied warranty of
18- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19- GNU General Public License for more details.
20-
21- You should have received a copy of the GNU Lesser General Public
22- License along with this program. If not, see
23- <http://www.gnu.org/licenses/>.
24--->
25-
26-<!DOCTYPE html>
27-<html>
28-<head>
29- <meta charset="utf-8" />
30- <meta name="copyright" content="Adnane Belmadiaf <daker@ubuntu.com>">
31- <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
32-
33- <title>RSS Mobile Reader - Ubuntu UI Example</title>
34-
35- <!-- Ubuntu UI Style imports - Ambiance theme -->
36- <link href="../../../ambiance/css/appTemplate.css" rel="stylesheet" type="text/css" />
37-
38- <link href="styles.css" rel="stylesheet" type="text/css" />
39-
40- <!-- External javascript imports -->
41- <script src="file:///usr/share/javascript/jquery/jquery.min.js"></script>
42-
43- <!-- Ubuntu UI javascript imports - Ambiance theme -->
44- <script src="../../../ambiance/js/fast-buttons.js"></script>
45- <script src="../../../ambiance/js/core.js"></script>
46- <script src="../../../ambiance/js/buttons.js"></script>
47- <script src="../../../ambiance/js/dialogs.js"></script>
48- <script src="../../../ambiance/js/pagestacks.js"></script>
49- <script src="../../../ambiance/js/popovers.js"></script>
50-
51- <script src="app.js"></script>
52-</head>
53-
54-<body>
55- <div data-role="page">
56-
57- <header data-role="header">
58- <nav data-role="navbar" class="tabs" >
59- <div class="tabs-inner">
60- <ul>
61- <li class="active" role="tab">
62- <a href="#item1" class="tab-item">RSS Mobile Reader</a>
63- </li>
64- </ul>
65- </div>
66- </nav>
67- </header>
68-
69- <div data-role="content">
70- <div data-role="pagestack">
71- <div data-role="page" id="main">
72- <section data-role="list" id="yourfeeds"></section>
73- <footer data-role="footer" class="revealed">
74- <nav>
75- <ul>
76- <li>
77- <a href="#" id="addfeed">
78- <img src="../../../ambiance/img/back@18.png" alt="Tap me!" />
79- <span>Add feed</span>
80- </a>
81- </li>
82- </ul>
83- </nav>
84- </footer>
85- </div>
86-
87- <div data-role="page" id="results">
88- <section data-role="list" id="resultscontent"></section>
89- </div>
90-
91- <div data-role="page" id="article">
92- <section id="articleinfo"></section>
93- </div>
94- </div>
95- <div data-role="dialog" id="addfeeddialog">
96- <section>
97- <h1>Add a new feed</h1>
98- <p>Type the url feed you want to add</p>
99- <input type="url" id="rssFeed" placeholder="http://">
100- <menu>
101- <button data-role="button" id="no">Cancel</button>
102- <button data-role="button" class="success" id="yes">Add</button>
103- </menu>
104- </section>
105- </div>
106- <div data-role="dialog" id="loading"><section><progress></progress></section></div>
107- </div>
108-
109- </div>
110-</body>
111-</html>
112
113=== modified file 'tests/autopilot/ubuntu_html5_theme/tests/__init__.py'
114--- tests/autopilot/ubuntu_html5_theme/tests/__init__.py 2013-07-08 07:53:01 +0000
115+++ tests/autopilot/ubuntu_html5_theme/tests/__init__.py 2013-07-08 18:31:32 +0000
116@@ -179,7 +179,8 @@
117 self.assert_url_eventually_loaded(url);
118
119 def browse_to_app(self, appname):
120- self.browse_to_url(self.create_file_url_from(self.BASE_PATH + '/' + self.APPS_SUBFOLDER_NAME + '/' + appname + '/autopilot.html'))
121+ APP_HTML_PATH = self.create_file_url_from(os.path.abspath(self.BASE_PATH + '/../../tests/data/html/' + self.APPS_SUBFOLDER_NAME + '/' + appname + '/index.html'))
122+ self.browse_to_url(APP_HTML_PATH)
123
124 def browse_to_test_html(self, html_filename):
125 self.browse_to_url(self.create_file_url_from(os.path.abspath(self.BASE_PATH + '/../../tests/data/html/' + html_filename)))
126
127=== modified file 'tests/autopilot/ubuntu_html5_theme/tests/test_rss_reader.py'
128--- tests/autopilot/ubuntu_html5_theme/tests/test_rss_reader.py 2013-07-08 07:53:01 +0000
129+++ tests/autopilot/ubuntu_html5_theme/tests/test_rss_reader.py 2013-07-08 18:31:32 +0000
130@@ -27,13 +27,11 @@
131 self.assertThat(self.is_dom_node_visible('article'), Equals(False))
132 self.assertThat(self.is_dom_node_visible('results'), Equals(False))
133
134-# Needs further mockup for autopilot.html to work offline
135-# LP: https://bugs.launchpad.net/ubuntu-html5-theme/+bug/1198820
136-# def test_switchToFeedView(self):
137-# self.click_any_dom_node_by_selector('#yourfeeds li a')
138-# self.assertThat(lambda: self.is_dom_node_visible('main'), Eventually(Equals(False)))
139-# self.assertThat(self.is_dom_node_visible('article'), Equals(False))
140-# self.assertThat(self.is_dom_node_visible('results'), Equals(True))
141+ def test_switchToFeedView(self):
142+ self.click_any_dom_node_by_selector('#yourfeeds li a')
143+ self.assertThat(lambda: self.is_dom_node_visible('main'), Eventually(Equals(False)))
144+ self.assertThat(self.is_dom_node_visible('article'), Equals(False))
145+ self.assertThat(self.is_dom_node_visible('results'), Equals(True))
146
147
148
149
150=== added directory 'tests/data/html/apps'
151=== added directory 'tests/data/html/apps/rss-reader'
152=== added file 'tests/data/html/apps/rss-reader/app.js'
153--- tests/data/html/apps/rss-reader/app.js 1970-01-01 00:00:00 +0000
154+++ tests/data/html/apps/rss-reader/app.js 2013-07-08 18:31:32 +0000
155@@ -0,0 +1,152 @@
156+/*
157+ * Copyright (C) 2013 Adnane Belmadiaf <daker@ubuntu.com>
158+ *
159+ * This file is part of ubuntu-html5-theme.
160+ *
161+ * This package is free software; you can redistribute it and/or modify
162+ * it under the terms of the Lesser GNU General Public License as
163+ * published by the Free Software Foundation; either version 3 of the
164+ * License, or
165+ * (at your option) any later version.
166+
167+ * This package is distributed in the hope that it will be useful,
168+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
169+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
170+ * GNU General Public License for more details.
171+
172+ * You should have received a copy of the GNU Lesser General Public
173+ * License along with this program. If not, see
174+ * <http://www.gnu.org/licenses/>.
175+ */
176+
177+var FEED_LOCAL_STORAGE_KEY = "my-data-feeds";
178+
179+var UI = new UbuntuUI();
180+
181+var data_feeds = {
182+ 'this.is.a.feed': {entries: [
183+ {title: 'My feed content', link: 'http://www.ubuntu.com', content: 'This is my feed'},
184+ {title: 'My feed content2', link: 'http://www.ubuntu.com', content: 'This is my feed2'},
185+ {title: 'My feed content3', link: 'http://www.ubuntu.com', content: 'This is my feed3'}
186+ ]},
187+ 'this.is.another.feed': {entries: [
188+ {title: 'My other feed content', link: 'http://www.ubuntu.com', content: 'This is my other feed'},
189+ {title: 'My other feed content2', link: 'http://www.ubuntu.com', content: 'This is my other feed2'},
190+ {title: 'My other feed content3', link: 'http://www.ubuntu.com', content: 'This is my other feed3'}
191+ ]}
192+};
193+
194+function Feed(url) {
195+ this.url = url;
196+}
197+Feed.prototype = {
198+ setNumEntries: function (count) {},
199+ load: function(callback) {
200+ callback({feed: data_feeds[this.url]});
201+ }
202+}
203+
204+
205+$(document).ready(function () {
206+
207+ UI.init();
208+ UI.pagestack.push("main");
209+
210+ if (typeof localStorage[FEED_LOCAL_STORAGE_KEY] == "undefined") {
211+ restoreDefault();
212+ }
213+ //load local storage feeds
214+ var feeds = eval(localStorage[FEED_LOCAL_STORAGE_KEY]);
215+ var myfeeds = null;
216+ if (feeds !== null) {
217+ myfeeds = "<header>My feeds</header><ul>";
218+ for (var i = 0; i < feeds.length; i++) {
219+ myfeeds += '<li><a href="#" onclick="loadFeed(\'' + feeds[i] + '\');">' + feeds[i] + '</a></li>';
220+ }
221+ myfeeds += "</ul>";
222+ $("#yourfeeds").html(myfeeds);
223+ }
224+
225+ UI.button('yes').click(function (e) {
226+ var url = $("#rssFeed").val();
227+ if (url === "") {
228+ if (!$("#addfeeddialog section").hasClass("shake")) {
229+ $("#addfeeddialog section").addClass("shake");
230+ } else {
231+ $('#addfeeddialog section').css('animation-name', 'none');
232+ $('#addfeeddialog section').css('-moz-animation-name', 'none');
233+ $('#addfeeddialog section').css('-webkit-animation-name', 'none');
234+
235+ setTimeout(function () {
236+ $('#addfeeddialog section').css('-webkit-animation-name', 'shake');
237+ }, 0);
238+ }
239+ } else {
240+ var feeds = eval(localStorage[FEED_LOCAL_STORAGE_KEY]);
241+ feeds.push(url);
242+ localStorage.setItem(FEED_LOCAL_STORAGE_KEY, JSON.stringify(feeds));
243+ window.location.reload();
244+ }
245+ });
246+
247+ UI.button('addfeed').click(function () {
248+ $('#addfeeddialog').show();
249+ });
250+
251+ UI.button('no').click(function () {
252+ $('#addfeeddialog').hide();
253+ });
254+});
255+
256+//FUNCS
257+
258+function restoreDefault() {
259+ localStorage.clear();
260+ var feeds = [];
261+ for (var feed in data_feeds) {
262+ if (data_feeds.hasOwnProperty(feed)) {
263+ feeds.push(feed);
264+ }
265+ }
266+ try {
267+ localStorage.setItem(FEED_LOCAL_STORAGE_KEY, JSON.stringify(feeds));
268+ window.location.reload();
269+ } catch (e) {
270+ if (e == QUOTA_EXCEEDED_ERR) {
271+ console.log("Error: Local Storage limit exceeds.");
272+ } else {
273+ console.log("Error: Saving to local storage.");
274+ }
275+ }
276+}
277+
278+function loadFeed(url) {
279+ UI.pagestack.push("results");
280+
281+ UI.dialog("loading").show();
282+
283+ var feed = new Feed(url);
284+ feed.setNumEntries(30);
285+ feed.load(function (result) {
286+ if (!result.error) {
287+ myfeeds_items = "<header>" + result.feed.title + "</header><ul>";
288+ for (var i = 0; i < result.feed.entries.length; i++) {
289+ myfeeds_items += '<li><a href="#" onclick=\'showArticle("' + escape(result.feed.entries[i].title) + '","' + escape(result.feed.entries[i].link) + '","' + escape(result.feed.entries[i].content) + '")\'>' + result.feed.entries[i].title.replace(/"/g, "'") + '</a></li>';
290+ }
291+ myfeeds_items += "</ul>";
292+ UI.dialog("loading").hide();
293+ $("#resultscontent").html(myfeeds_items);
294+ } else
295+ alert('feed error');
296+ });
297+}
298+
299+function showArticle(title, url, desc) {
300+ UI.pagestack.push("article");
301+
302+ if (typeof desc == "undefined")
303+ desc = "(No description provided)";
304+ $("#articleinfo").html("<p>" + unescape(title) + "</p><p>" + unescape(desc) + "</p><p><a target=\"_blank\" href=\"" + unescape(url) + "\">" + unescape(url) + "</a></p>");
305+
306+}
307+
308
309=== added file 'tests/data/html/apps/rss-reader/index.html'
310--- tests/data/html/apps/rss-reader/index.html 1970-01-01 00:00:00 +0000
311+++ tests/data/html/apps/rss-reader/index.html 2013-07-08 18:31:32 +0000
312@@ -0,0 +1,107 @@
313+<!--
314+ Copyright (C) 2013 Adnane Belmadiaf <daker@ubuntu.com>
315+
316+ This file is part of ubuntu-html5-theme.
317+
318+ This package is free software; you can redistribute it and/or modify
319+ it under the terms of the Lesser GNU General Public License as
320+ published by the Free Software Foundation; either version 3 of the
321+ License, or
322+ (at your option) any later version.
323+
324+ This package is distributed in the hope that it will be useful,
325+ but WITHOUT ANY WARRANTY; without even the implied warranty of
326+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
327+ GNU General Public License for more details.
328+
329+ You should have received a copy of the GNU Lesser General Public
330+ License along with this program. If not, see
331+ <http://www.gnu.org/licenses/>.
332+-->
333+
334+<!DOCTYPE html>
335+<html>
336+<head>
337+ <meta charset="utf-8" />
338+ <meta name="copyright" content="Adnane Belmadiaf <daker@ubuntu.com>">
339+ <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
340+
341+ <title>RSS Mobile Reader - Ubuntu UI Example</title>
342+
343+ <!-- Ubuntu UI Style imports - Ambiance theme -->
344+ <link href="../../../../../0.1/ambiance/css/appTemplate.css" rel="stylesheet" type="text/css" />
345+
346+ <link href="styles.css" rel="stylesheet" type="text/css" />
347+
348+ <!-- External javascript imports -->
349+ <script src="file:///usr/share/javascript/jquery/jquery.min.js"></script>
350+
351+ <!-- Ubuntu UI javascript imports - Ambiance theme -->
352+ <script src="../../../../../0.1/ambiance/js/fast-buttons.js"></script>
353+ <script src="../../../../../0.1/ambiance/js/core.js"></script>
354+ <script src="../../../../../0.1/ambiance/js/buttons.js"></script>
355+ <script src="../../../../../0.1/ambiance/js/dialogs.js"></script>
356+ <script src="../../../../../0.1/ambiance/js/pagestacks.js"></script>
357+ <script src="../../../../../0.1/ambiance/js/popovers.js"></script>
358+
359+ <script src="app.js"></script>
360+</head>
361+
362+<body>
363+ <div data-role="page">
364+
365+ <header data-role="header">
366+ <nav data-role="navbar" class="tabs" >
367+ <div class="tabs-inner">
368+ <ul>
369+ <li class="active" role="tab">
370+ <a href="#item1" class="tab-item">RSS Mobile Reader</a>
371+ </li>
372+ </ul>
373+ </div>
374+ </nav>
375+ </header>
376+
377+ <div data-role="content">
378+ <div data-role="pagestack">
379+ <div data-role="page" id="main">
380+ <section data-role="list" id="yourfeeds"></section>
381+ <footer data-role="footer" class="revealed">
382+ <nav>
383+ <ul>
384+ <li>
385+ <a href="#" id="addfeed">
386+ <img src="../../../../../0.1/ambiance/img/back@18.png" alt="Tap me!" />
387+ <span>Add feed</span>
388+ </a>
389+ </li>
390+ </ul>
391+ </nav>
392+ </footer>
393+ </div>
394+
395+ <div data-role="page" id="results">
396+ <section data-role="list" id="resultscontent"></section>
397+ </div>
398+
399+ <div data-role="page" id="article">
400+ <section id="articleinfo"></section>
401+ </div>
402+ </div>
403+ <div data-role="dialog" id="addfeeddialog">
404+ <section>
405+ <h1>Add a new feed</h1>
406+ <p>Type the url feed you want to add</p>
407+ <input type="url" id="rssFeed" placeholder="http://">
408+ <menu>
409+ <button data-role="button" id="no">Cancel</button>
410+ <button data-role="button" class="success" id="yes">Add</button>
411+ </menu>
412+ </section>
413+ </div>
414+ <div data-role="dialog" id="loading"><section><progress></progress></section></div>
415+ </div>
416+
417+ </div>
418+</body>
419+</html>
420
421=== added file 'tests/data/html/apps/rss-reader/styles.css'
422--- tests/data/html/apps/rss-reader/styles.css 1970-01-01 00:00:00 +0000
423+++ tests/data/html/apps/rss-reader/styles.css 2013-07-08 18:31:32 +0000
424@@ -0,0 +1,40 @@
425+/*
426+ * Copyright (C) 2013 Adnane Belmadiaf <daker@ubuntu.com>
427+ *
428+ * This file is part of ubuntu-html5-theme.
429+ *
430+ * This package is free software; you can redistribute it and/or modify
431+ * it under the terms of the Lesser GNU General Public License as
432+ * published by the Free Software Foundation; either version 3 of the
433+ * License, or
434+ * (at your option) any later version.
435+
436+ * This package is distributed in the hope that it will be useful,
437+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
438+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
439+ * GNU General Public License for more details.
440+
441+ * You should have received a copy of the GNU Lesser General Public
442+ * License along with this program. If not, see
443+ * <http://www.gnu.org/licenses/>.
444+ */
445+
446+#articleinfo {
447+ padding: 10px;
448+ -webkit-box-sizing: border-box;
449+ box-sizing: border-box;
450+}
451+
452+#articleinfo iframe {
453+ max-width: 100%;
454+}
455+
456+#articleinfo p {
457+ margin: 7px 0;
458+}
459+
460+#articleinfo a{
461+ text-decoration: none;
462+ color: #787878;
463+ font-weight: bold;
464+}
465\ No newline at end of file

Subscribers

People subscribed via source and target branches