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
=== removed file '0.1/examples/apps/rss-reader/autopilot.html'
--- 0.1/examples/apps/rss-reader/autopilot.html 2013-07-08 07:53:01 +0000
+++ 0.1/examples/apps/rss-reader/autopilot.html 1970-01-01 00:00:00 +0000
@@ -1,107 +0,0 @@
1<!--
2 Copyright (C) 2013 Adnane Belmadiaf <daker@ubuntu.com>
3
4 This file is part of ubuntu-html5-theme.
5
6 This package is free software; you can redistribute it and/or modify
7 it under the terms of the Lesser GNU General Public License as
8 published by the Free Software Foundation; either version 3 of the
9 License, or
10 (at your option) any later version.
11
12 This package is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this program. If not, see
19 <http://www.gnu.org/licenses/>.
20-->
21
22<!DOCTYPE html>
23<html>
24<head>
25 <meta charset="utf-8" />
26 <meta name="copyright" content="Adnane Belmadiaf <daker@ubuntu.com>">
27 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
28
29 <title>RSS Mobile Reader - Ubuntu UI Example</title>
30
31 <!-- Ubuntu UI Style imports - Ambiance theme -->
32 <link href="../../../ambiance/css/appTemplate.css" rel="stylesheet" type="text/css" />
33
34 <link href="styles.css" rel="stylesheet" type="text/css" />
35
36 <!-- External javascript imports -->
37 <script src="file:///usr/share/javascript/jquery/jquery.min.js"></script>
38
39 <!-- Ubuntu UI javascript imports - Ambiance theme -->
40 <script src="../../../ambiance/js/fast-buttons.js"></script>
41 <script src="../../../ambiance/js/core.js"></script>
42 <script src="../../../ambiance/js/buttons.js"></script>
43 <script src="../../../ambiance/js/dialogs.js"></script>
44 <script src="../../../ambiance/js/pagestacks.js"></script>
45 <script src="../../../ambiance/js/popovers.js"></script>
46
47 <script src="app.js"></script>
48</head>
49
50<body>
51 <div data-role="page">
52
53 <header data-role="header">
54 <nav data-role="navbar" class="tabs" >
55 <div class="tabs-inner">
56 <ul>
57 <li class="active" role="tab">
58 <a href="#item1" class="tab-item">RSS Mobile Reader</a>
59 </li>
60 </ul>
61 </div>
62 </nav>
63 </header>
64
65 <div data-role="content">
66 <div data-role="pagestack">
67 <div data-role="page" id="main">
68 <section data-role="list" id="yourfeeds"></section>
69 <footer data-role="footer" class="revealed">
70 <nav>
71 <ul>
72 <li>
73 <a href="#" id="addfeed">
74 <img src="../../../ambiance/img/back@18.png" alt="Tap me!" />
75 <span>Add feed</span>
76 </a>
77 </li>
78 </ul>
79 </nav>
80 </footer>
81 </div>
82
83 <div data-role="page" id="results">
84 <section data-role="list" id="resultscontent"></section>
85 </div>
86
87 <div data-role="page" id="article">
88 <section id="articleinfo"></section>
89 </div>
90 </div>
91 <div data-role="dialog" id="addfeeddialog">
92 <section>
93 <h1>Add a new feed</h1>
94 <p>Type the url feed you want to add</p>
95 <input type="url" id="rssFeed" placeholder="http://">
96 <menu>
97 <button data-role="button" id="no">Cancel</button>
98 <button data-role="button" class="success" id="yes">Add</button>
99 </menu>
100 </section>
101 </div>
102 <div data-role="dialog" id="loading"><section><progress></progress></section></div>
103 </div>
104
105 </div>
106</body>
107</html>
1080
=== modified file 'tests/autopilot/ubuntu_html5_theme/tests/__init__.py'
--- tests/autopilot/ubuntu_html5_theme/tests/__init__.py 2013-07-08 07:53:01 +0000
+++ tests/autopilot/ubuntu_html5_theme/tests/__init__.py 2013-07-08 18:31:32 +0000
@@ -179,7 +179,8 @@
179 self.assert_url_eventually_loaded(url);179 self.assert_url_eventually_loaded(url);
180180
181 def browse_to_app(self, appname):181 def browse_to_app(self, appname):
182 self.browse_to_url(self.create_file_url_from(self.BASE_PATH + '/' + self.APPS_SUBFOLDER_NAME + '/' + appname + '/autopilot.html'))182 APP_HTML_PATH = self.create_file_url_from(os.path.abspath(self.BASE_PATH + '/../../tests/data/html/' + self.APPS_SUBFOLDER_NAME + '/' + appname + '/index.html'))
183 self.browse_to_url(APP_HTML_PATH)
183184
184 def browse_to_test_html(self, html_filename):185 def browse_to_test_html(self, html_filename):
185 self.browse_to_url(self.create_file_url_from(os.path.abspath(self.BASE_PATH + '/../../tests/data/html/' + html_filename)))186 self.browse_to_url(self.create_file_url_from(os.path.abspath(self.BASE_PATH + '/../../tests/data/html/' + html_filename)))
186187
=== modified file 'tests/autopilot/ubuntu_html5_theme/tests/test_rss_reader.py'
--- tests/autopilot/ubuntu_html5_theme/tests/test_rss_reader.py 2013-07-08 07:53:01 +0000
+++ tests/autopilot/ubuntu_html5_theme/tests/test_rss_reader.py 2013-07-08 18:31:32 +0000
@@ -27,13 +27,11 @@
27 self.assertThat(self.is_dom_node_visible('article'), Equals(False))27 self.assertThat(self.is_dom_node_visible('article'), Equals(False))
28 self.assertThat(self.is_dom_node_visible('results'), Equals(False))28 self.assertThat(self.is_dom_node_visible('results'), Equals(False))
2929
30# Needs further mockup for autopilot.html to work offline30 def test_switchToFeedView(self):
31# LP: https://bugs.launchpad.net/ubuntu-html5-theme/+bug/119882031 self.click_any_dom_node_by_selector('#yourfeeds li a')
32# def test_switchToFeedView(self):32 self.assertThat(lambda: self.is_dom_node_visible('main'), Eventually(Equals(False)))
33# self.click_any_dom_node_by_selector('#yourfeeds li a')33 self.assertThat(self.is_dom_node_visible('article'), Equals(False))
34# self.assertThat(lambda: self.is_dom_node_visible('main'), Eventually(Equals(False)))34 self.assertThat(self.is_dom_node_visible('results'), Equals(True))
35# self.assertThat(self.is_dom_node_visible('article'), Equals(False))
36# self.assertThat(self.is_dom_node_visible('results'), Equals(True))
3735
3836
3937
4038
=== added directory 'tests/data/html/apps'
=== added directory 'tests/data/html/apps/rss-reader'
=== added file 'tests/data/html/apps/rss-reader/app.js'
--- tests/data/html/apps/rss-reader/app.js 1970-01-01 00:00:00 +0000
+++ tests/data/html/apps/rss-reader/app.js 2013-07-08 18:31:32 +0000
@@ -0,0 +1,152 @@
1/*
2 * Copyright (C) 2013 Adnane Belmadiaf <daker@ubuntu.com>
3 *
4 * This file is part of ubuntu-html5-theme.
5 *
6 * This package is free software; you can redistribute it and/or modify
7 * it under the terms of the Lesser GNU General Public License as
8 * published by the Free Software Foundation; either version 3 of the
9 * License, or
10 * (at your option) any later version.
11
12 * This package is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this program. If not, see
19 * <http://www.gnu.org/licenses/>.
20 */
21
22var FEED_LOCAL_STORAGE_KEY = "my-data-feeds";
23
24var UI = new UbuntuUI();
25
26var data_feeds = {
27 'this.is.a.feed': {entries: [
28 {title: 'My feed content', link: 'http://www.ubuntu.com', content: 'This is my feed'},
29 {title: 'My feed content2', link: 'http://www.ubuntu.com', content: 'This is my feed2'},
30 {title: 'My feed content3', link: 'http://www.ubuntu.com', content: 'This is my feed3'}
31 ]},
32 'this.is.another.feed': {entries: [
33 {title: 'My other feed content', link: 'http://www.ubuntu.com', content: 'This is my other feed'},
34 {title: 'My other feed content2', link: 'http://www.ubuntu.com', content: 'This is my other feed2'},
35 {title: 'My other feed content3', link: 'http://www.ubuntu.com', content: 'This is my other feed3'}
36 ]}
37};
38
39function Feed(url) {
40 this.url = url;
41}
42Feed.prototype = {
43 setNumEntries: function (count) {},
44 load: function(callback) {
45 callback({feed: data_feeds[this.url]});
46 }
47}
48
49
50$(document).ready(function () {
51
52 UI.init();
53 UI.pagestack.push("main");
54
55 if (typeof localStorage[FEED_LOCAL_STORAGE_KEY] == "undefined") {
56 restoreDefault();
57 }
58 //load local storage feeds
59 var feeds = eval(localStorage[FEED_LOCAL_STORAGE_KEY]);
60 var myfeeds = null;
61 if (feeds !== null) {
62 myfeeds = "<header>My feeds</header><ul>";
63 for (var i = 0; i < feeds.length; i++) {
64 myfeeds += '<li><a href="#" onclick="loadFeed(\'' + feeds[i] + '\');">' + feeds[i] + '</a></li>';
65 }
66 myfeeds += "</ul>";
67 $("#yourfeeds").html(myfeeds);
68 }
69
70 UI.button('yes').click(function (e) {
71 var url = $("#rssFeed").val();
72 if (url === "") {
73 if (!$("#addfeeddialog section").hasClass("shake")) {
74 $("#addfeeddialog section").addClass("shake");
75 } else {
76 $('#addfeeddialog section').css('animation-name', 'none');
77 $('#addfeeddialog section').css('-moz-animation-name', 'none');
78 $('#addfeeddialog section').css('-webkit-animation-name', 'none');
79
80 setTimeout(function () {
81 $('#addfeeddialog section').css('-webkit-animation-name', 'shake');
82 }, 0);
83 }
84 } else {
85 var feeds = eval(localStorage[FEED_LOCAL_STORAGE_KEY]);
86 feeds.push(url);
87 localStorage.setItem(FEED_LOCAL_STORAGE_KEY, JSON.stringify(feeds));
88 window.location.reload();
89 }
90 });
91
92 UI.button('addfeed').click(function () {
93 $('#addfeeddialog').show();
94 });
95
96 UI.button('no').click(function () {
97 $('#addfeeddialog').hide();
98 });
99});
100
101//FUNCS
102
103function restoreDefault() {
104 localStorage.clear();
105 var feeds = [];
106 for (var feed in data_feeds) {
107 if (data_feeds.hasOwnProperty(feed)) {
108 feeds.push(feed);
109 }
110 }
111 try {
112 localStorage.setItem(FEED_LOCAL_STORAGE_KEY, JSON.stringify(feeds));
113 window.location.reload();
114 } catch (e) {
115 if (e == QUOTA_EXCEEDED_ERR) {
116 console.log("Error: Local Storage limit exceeds.");
117 } else {
118 console.log("Error: Saving to local storage.");
119 }
120 }
121}
122
123function loadFeed(url) {
124 UI.pagestack.push("results");
125
126 UI.dialog("loading").show();
127
128 var feed = new Feed(url);
129 feed.setNumEntries(30);
130 feed.load(function (result) {
131 if (!result.error) {
132 myfeeds_items = "<header>" + result.feed.title + "</header><ul>";
133 for (var i = 0; i < result.feed.entries.length; i++) {
134 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>';
135 }
136 myfeeds_items += "</ul>";
137 UI.dialog("loading").hide();
138 $("#resultscontent").html(myfeeds_items);
139 } else
140 alert('feed error');
141 });
142}
143
144function showArticle(title, url, desc) {
145 UI.pagestack.push("article");
146
147 if (typeof desc == "undefined")
148 desc = "(No description provided)";
149 $("#articleinfo").html("<p>" + unescape(title) + "</p><p>" + unescape(desc) + "</p><p><a target=\"_blank\" href=\"" + unescape(url) + "\">" + unescape(url) + "</a></p>");
150
151}
152
0153
=== added file 'tests/data/html/apps/rss-reader/index.html'
--- tests/data/html/apps/rss-reader/index.html 1970-01-01 00:00:00 +0000
+++ tests/data/html/apps/rss-reader/index.html 2013-07-08 18:31:32 +0000
@@ -0,0 +1,107 @@
1<!--
2 Copyright (C) 2013 Adnane Belmadiaf <daker@ubuntu.com>
3
4 This file is part of ubuntu-html5-theme.
5
6 This package is free software; you can redistribute it and/or modify
7 it under the terms of the Lesser GNU General Public License as
8 published by the Free Software Foundation; either version 3 of the
9 License, or
10 (at your option) any later version.
11
12 This package is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this program. If not, see
19 <http://www.gnu.org/licenses/>.
20-->
21
22<!DOCTYPE html>
23<html>
24<head>
25 <meta charset="utf-8" />
26 <meta name="copyright" content="Adnane Belmadiaf <daker@ubuntu.com>">
27 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
28
29 <title>RSS Mobile Reader - Ubuntu UI Example</title>
30
31 <!-- Ubuntu UI Style imports - Ambiance theme -->
32 <link href="../../../../../0.1/ambiance/css/appTemplate.css" rel="stylesheet" type="text/css" />
33
34 <link href="styles.css" rel="stylesheet" type="text/css" />
35
36 <!-- External javascript imports -->
37 <script src="file:///usr/share/javascript/jquery/jquery.min.js"></script>
38
39 <!-- Ubuntu UI javascript imports - Ambiance theme -->
40 <script src="../../../../../0.1/ambiance/js/fast-buttons.js"></script>
41 <script src="../../../../../0.1/ambiance/js/core.js"></script>
42 <script src="../../../../../0.1/ambiance/js/buttons.js"></script>
43 <script src="../../../../../0.1/ambiance/js/dialogs.js"></script>
44 <script src="../../../../../0.1/ambiance/js/pagestacks.js"></script>
45 <script src="../../../../../0.1/ambiance/js/popovers.js"></script>
46
47 <script src="app.js"></script>
48</head>
49
50<body>
51 <div data-role="page">
52
53 <header data-role="header">
54 <nav data-role="navbar" class="tabs" >
55 <div class="tabs-inner">
56 <ul>
57 <li class="active" role="tab">
58 <a href="#item1" class="tab-item">RSS Mobile Reader</a>
59 </li>
60 </ul>
61 </div>
62 </nav>
63 </header>
64
65 <div data-role="content">
66 <div data-role="pagestack">
67 <div data-role="page" id="main">
68 <section data-role="list" id="yourfeeds"></section>
69 <footer data-role="footer" class="revealed">
70 <nav>
71 <ul>
72 <li>
73 <a href="#" id="addfeed">
74 <img src="../../../../../0.1/ambiance/img/back@18.png" alt="Tap me!" />
75 <span>Add feed</span>
76 </a>
77 </li>
78 </ul>
79 </nav>
80 </footer>
81 </div>
82
83 <div data-role="page" id="results">
84 <section data-role="list" id="resultscontent"></section>
85 </div>
86
87 <div data-role="page" id="article">
88 <section id="articleinfo"></section>
89 </div>
90 </div>
91 <div data-role="dialog" id="addfeeddialog">
92 <section>
93 <h1>Add a new feed</h1>
94 <p>Type the url feed you want to add</p>
95 <input type="url" id="rssFeed" placeholder="http://">
96 <menu>
97 <button data-role="button" id="no">Cancel</button>
98 <button data-role="button" class="success" id="yes">Add</button>
99 </menu>
100 </section>
101 </div>
102 <div data-role="dialog" id="loading"><section><progress></progress></section></div>
103 </div>
104
105 </div>
106</body>
107</html>
0108
=== added file 'tests/data/html/apps/rss-reader/styles.css'
--- tests/data/html/apps/rss-reader/styles.css 1970-01-01 00:00:00 +0000
+++ tests/data/html/apps/rss-reader/styles.css 2013-07-08 18:31:32 +0000
@@ -0,0 +1,40 @@
1/*
2 * Copyright (C) 2013 Adnane Belmadiaf <daker@ubuntu.com>
3 *
4 * This file is part of ubuntu-html5-theme.
5 *
6 * This package is free software; you can redistribute it and/or modify
7 * it under the terms of the Lesser GNU General Public License as
8 * published by the Free Software Foundation; either version 3 of the
9 * License, or
10 * (at your option) any later version.
11
12 * This package is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this program. If not, see
19 * <http://www.gnu.org/licenses/>.
20 */
21
22#articleinfo {
23 padding: 10px;
24 -webkit-box-sizing: border-box;
25 box-sizing: border-box;
26}
27
28#articleinfo iframe {
29 max-width: 100%;
30}
31
32#articleinfo p {
33 margin: 7px 0;
34}
35
36#articleinfo a{
37 text-decoration: none;
38 color: #787878;
39 font-weight: bold;
40}
0\ No newline at end of file41\ No newline at end of file

Subscribers

People subscribed via source and target branches