Merge lp:~osomon/webbrowser-app/historyUpdateOnLoadCommitted into lp:webbrowser-app
- historyUpdateOnLoadCommitted
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Olivier Tilloy |
Approved revision: | 1029 |
Merged at revision: | 1372 |
Proposed branch: | lp:~osomon/webbrowser-app/historyUpdateOnLoadCommitted |
Merge into: | lp:webbrowser-app |
Diff against target: |
391 lines (+229/-40) 6 files modified
src/app/webbrowser/Browser.qml (+29/-2) src/app/webbrowser/history-model.cpp (+37/-1) src/app/webbrowser/history-model.h (+2/-1) tests/autopilot/webbrowser_app/tests/http_server.py (+32/-1) tests/autopilot/webbrowser_app/tests/test_history.py (+80/-34) tests/unittests/history-model/tst_HistoryModelTests.cpp (+49/-1) |
To merge this branch: | bzr merge lp:~osomon/webbrowser-app/historyUpdateOnLoadCommitted |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Riccardo Padovani (community) | Approve | ||
PS Jenkins bot | continuous-integration | Needs Fixing | |
Ubuntu Phablet Team | Pending | ||
Review via email: mp+259361@code.launchpad.net |
Commit message
Store entries in the history database on load committed, not load succeeded.
This ensures that content-initiated navigations are also stored.
Description of the change
PS Jenkins bot (ps-jenkins) wrote : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1018
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Riccardo Padovani (rpadovani) wrote : | # |
+ browser.
Why this and not
browser.
?
I mean, we're updating the database, it's better to do it with last data we have, isn't it?
Olivier Tilloy (osomon) wrote : | # |
> + browser.
> webviewInternal
>
> Why this and not
>
> browser.
>
> ?
>
> I mean, we're updating the database, it's better to do it with last data we
> have, isn't it?
Some pages dynamically update the title to convey live information (like the ugly "scrolling title" effect, see e.g. http://
This is consistent with how chromium on desktop behaves.
Riccardo Padovani (rpadovani) wrote : | # |
Looks good to me now :-)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1019
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1020
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1020
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1020
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
FAILURE: http://
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1020
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 1021. By Olivier Tilloy
-
Merge the latest changes from trunk and resolve conflicts.
- 1022. By Olivier Tilloy
-
Add an update(…) method to HistoryModel, to allow updating the title and icon of an entry without incrementing the corresponding number of visits.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1022
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 1023. By Olivier Tilloy
-
Simplify code a bit.
Do not prevent dynamic favicon updates from updating the history database, to be consistent with what chromium does.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1023
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 1024. By Olivier Tilloy
-
Add some autopilot tests to verify that favicons are stored and updated in the history database.
- 1025. By Olivier Tilloy
-
Factor out common code.
- 1026. By Olivier Tilloy
-
Add autopilot tests to verify that a page’s title is stored in history, but not dynamically updated.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1025
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 1027. By Olivier Tilloy
-
Add an autopilot test to verify that history.pushState() inserts a new entry in the history database.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1026
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1027
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Riccardo Padovani (rpadovani) wrote : | # |
I only read the code and seems good to me, just a couple of very little improvements inline.
I'll test asap.
- 1028. By Olivier Tilloy
-
Swap the order in which conditions are evaluated, from cheapest to most expensive.
- 1029. By Olivier Tilloy
-
Move code out of else block to avoid compiler warning (control reaches end of non-void function [-Wreturn-type]).
Olivier Tilloy (osomon) wrote : | # |
Thanks, those were very good points, I addressed them.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1029
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Riccardo Padovani (rpadovani) wrote : | # |
Thanks! Tested a bit and seems to work like a charm.
Preview Diff
1 | === modified file 'src/app/webbrowser/Browser.qml' | |||
2 | --- src/app/webbrowser/Browser.qml 2016-02-23 11:24:33 +0000 | |||
3 | +++ src/app/webbrowser/Browser.qml 2016-03-01 09:31:14 +0000 | |||
4 | @@ -1263,20 +1263,47 @@ | |||
5 | 1263 | } | 1263 | } |
6 | 1264 | } | 1264 | } |
7 | 1265 | 1265 | ||
8 | 1266 | QtObject { | ||
9 | 1267 | id: webviewInternal | ||
10 | 1268 | property url storedUrl: "" | ||
11 | 1269 | property bool titleSet: false | ||
12 | 1270 | property string title: "" | ||
13 | 1271 | } | ||
14 | 1266 | onLoadEvent: { | 1272 | onLoadEvent: { |
15 | 1267 | if (event.type == Oxide.LoadEvent.TypeCommitted) { | 1273 | if (event.type == Oxide.LoadEvent.TypeCommitted) { |
16 | 1268 | chrome.findInPageMode = false | 1274 | chrome.findInPageMode = false |
17 | 1275 | webviewInternal.titleSet = false | ||
18 | 1276 | webviewInternal.title = title | ||
19 | 1269 | } | 1277 | } |
20 | 1270 | 1278 | ||
21 | 1271 | if (webviewimpl.incognito) { | 1279 | if (webviewimpl.incognito) { |
22 | 1272 | return | 1280 | return |
23 | 1273 | } | 1281 | } |
24 | 1274 | 1282 | ||
27 | 1275 | if (event.type == Oxide.LoadEvent.TypeSucceeded && | 1283 | if ((event.type == Oxide.LoadEvent.TypeCommitted) && |
28 | 1276 | 300 > event.httpStatusCode && event.httpStatusCode >= 200) { | 1284 | !event.isError && |
29 | 1285 | (300 > event.httpStatusCode) && (event.httpStatusCode >= 200)) { | ||
30 | 1286 | webviewInternal.storedUrl = event.url | ||
31 | 1277 | HistoryModel.add(event.url, title, icon) | 1287 | HistoryModel.add(event.url, title, icon) |
32 | 1278 | } | 1288 | } |
33 | 1279 | } | 1289 | } |
34 | 1290 | onTitleChanged: { | ||
35 | 1291 | if (!webviewInternal.titleSet && webviewInternal.storedUrl.toString()) { | ||
36 | 1292 | // Record the title to avoid updating the history database | ||
37 | 1293 | // every time the page dynamically updates its title. | ||
38 | 1294 | // We don’t want pages that update their title every second | ||
39 | 1295 | // to achieve an ugly "scrolling title" effect to flood the | ||
40 | 1296 | // history database with updates. | ||
41 | 1297 | webviewInternal.titleSet = true | ||
42 | 1298 | webviewInternal.title = title | ||
43 | 1299 | HistoryModel.update(webviewInternal.storedUrl, title, icon) | ||
44 | 1300 | } | ||
45 | 1301 | } | ||
46 | 1302 | onIconChanged: { | ||
47 | 1303 | if (webviewInternal.storedUrl.toString()) { | ||
48 | 1304 | HistoryModel.update(webviewInternal.storedUrl, webviewInternal.title, icon) | ||
49 | 1305 | } | ||
50 | 1306 | } | ||
51 | 1280 | 1307 | ||
52 | 1281 | onGeolocationPermissionRequested: requestGeolocationPermission(request) | 1308 | onGeolocationPermissionRequested: requestGeolocationPermission(request) |
53 | 1282 | 1309 | ||
54 | 1283 | 1310 | ||
55 | === modified file 'src/app/webbrowser/history-model.cpp' | |||
56 | --- src/app/webbrowser/history-model.cpp 2015-10-07 11:10:14 +0000 | |||
57 | +++ src/app/webbrowser/history-model.cpp 2016-03-01 09:31:14 +0000 | |||
58 | @@ -1,5 +1,5 @@ | |||
59 | 1 | /* | 1 | /* |
61 | 2 | * Copyright 2013-2015 Canonical Ltd. | 2 | * Copyright 2013-2016 Canonical Ltd. |
62 | 3 | * | 3 | * |
63 | 4 | * This file is part of webbrowser-app. | 4 | * This file is part of webbrowser-app. |
64 | 5 | * | 5 | * |
65 | @@ -301,6 +301,42 @@ | |||
66 | 301 | } | 301 | } |
67 | 302 | 302 | ||
68 | 303 | /*! | 303 | /*! |
69 | 304 | Update an existing entry in the model. | ||
70 | 305 | |||
71 | 306 | If no entry with the same URL exists yet, do nothing (and return false). | ||
72 | 307 | Otherwise the title and icon of the existing entry are updated (the number | ||
73 | 308 | of visits remains unchanged). | ||
74 | 309 | |||
75 | 310 | Return true if an update actually happened, false otherwise. | ||
76 | 311 | */ | ||
77 | 312 | bool HistoryModel::update(const QUrl& url, const QString& title, const QUrl& icon) | ||
78 | 313 | { | ||
79 | 314 | if (url.isEmpty()) { | ||
80 | 315 | return false; | ||
81 | 316 | } | ||
82 | 317 | int index = getEntryIndex(url); | ||
83 | 318 | if (index == -1) { | ||
84 | 319 | return false; | ||
85 | 320 | } | ||
86 | 321 | QVector<int> roles; | ||
87 | 322 | const HistoryEntry& entry = m_entries.at(index); | ||
88 | 323 | if (title != entry.title) { | ||
89 | 324 | m_entries[index].title = title; | ||
90 | 325 | roles << Title; | ||
91 | 326 | } | ||
92 | 327 | if (icon != entry.icon) { | ||
93 | 328 | m_entries[index].icon = icon; | ||
94 | 329 | roles << Icon; | ||
95 | 330 | } | ||
96 | 331 | if (roles.isEmpty()) { | ||
97 | 332 | return false; | ||
98 | 333 | } | ||
99 | 334 | Q_EMIT dataChanged(this->index(index, 0), this->index(index, 0), roles); | ||
100 | 335 | updateExistingEntryInDatabase(entry); | ||
101 | 336 | return true; | ||
102 | 337 | } | ||
103 | 338 | |||
104 | 339 | /*! | ||
105 | 304 | Remove a given URL from the history model. | 340 | Remove a given URL from the history model. |
106 | 305 | 341 | ||
107 | 306 | If the URL was not previously visited, do nothing. | 342 | If the URL was not previously visited, do nothing. |
108 | 307 | 343 | ||
109 | === modified file 'src/app/webbrowser/history-model.h' | |||
110 | --- src/app/webbrowser/history-model.h 2015-10-07 11:10:14 +0000 | |||
111 | +++ src/app/webbrowser/history-model.h 2016-03-01 09:31:14 +0000 | |||
112 | @@ -1,5 +1,5 @@ | |||
113 | 1 | /* | 1 | /* |
115 | 2 | * Copyright 2013-2015 Canonical Ltd. | 2 | * Copyright 2013-2016 Canonical Ltd. |
116 | 3 | * | 3 | * |
117 | 4 | * This file is part of webbrowser-app. | 4 | * This file is part of webbrowser-app. |
118 | 5 | * | 5 | * |
119 | @@ -62,6 +62,7 @@ | |||
120 | 62 | void setDatabasePath(const QString& path); | 62 | void setDatabasePath(const QString& path); |
121 | 63 | 63 | ||
122 | 64 | Q_INVOKABLE int add(const QUrl& url, const QString& title, const QUrl& icon); | 64 | Q_INVOKABLE int add(const QUrl& url, const QString& title, const QUrl& icon); |
123 | 65 | Q_INVOKABLE bool update(const QUrl& url, const QString& title, const QUrl& icon); | ||
124 | 65 | Q_INVOKABLE void removeEntryByUrl(const QUrl& url); | 66 | Q_INVOKABLE void removeEntryByUrl(const QUrl& url); |
125 | 66 | Q_INVOKABLE void removeEntriesByDate(const QDate& date); | 67 | Q_INVOKABLE void removeEntriesByDate(const QDate& date); |
126 | 67 | Q_INVOKABLE void removeEntriesByDomain(const QString& domain); | 68 | Q_INVOKABLE void removeEntriesByDomain(const QString& domain); |
127 | 68 | 69 | ||
128 | === modified file 'tests/autopilot/webbrowser_app/tests/http_server.py' | |||
129 | --- tests/autopilot/webbrowser_app/tests/http_server.py 2015-10-26 11:09:25 +0000 | |||
130 | +++ tests/autopilot/webbrowser_app/tests/http_server.py 2016-03-01 09:31:14 +0000 | |||
131 | @@ -1,6 +1,6 @@ | |||
132 | 1 | # -*- coding: utf-8 -*- | 1 | # -*- coding: utf-8 -*- |
133 | 2 | # | 2 | # |
135 | 3 | # Copyright 2013-2015 Canonical | 3 | # Copyright 2013-2016 Canonical |
136 | 4 | # | 4 | # |
137 | 5 | # This program is free software: you can redistribute it and/or modify it | 5 | # This program is free software: you can redistribute it and/or modify it |
138 | 6 | # under the terms of the GNU General Public License version 3, as published | 6 | # under the terms of the GNU General Public License version 3, as published |
139 | @@ -215,6 +215,37 @@ | |||
140 | 215 | "}, function() { location.href = '/test1' } " + | 215 | "}, function() { location.href = '/test1' } " + |
141 | 216 | ", function() { location.href = '/test2' })</script>" | 216 | ", function() { location.href = '/test2' })</script>" |
142 | 217 | ) | 217 | ) |
143 | 218 | elif self.path == "/favicon": | ||
144 | 219 | self.send_response(200) | ||
145 | 220 | html = '<html><head><link rel="icon" type="image/png" ' | ||
146 | 221 | html += 'href="/assets/icon1.png"></head>' | ||
147 | 222 | html += '<body>favicon</body></html>' | ||
148 | 223 | self.send_html(html) | ||
149 | 224 | elif self.path == "/changingfavicon": | ||
150 | 225 | self.send_response(200) | ||
151 | 226 | html = '<html><head><link id="favicon" rel="shortcut icon" ' | ||
152 | 227 | html += 'type="image/png" href="icon0.png"></head><body><script>' | ||
153 | 228 | html += 'var i = 0; window.setInterval(function() {' | ||
154 | 229 | html += 'document.getElementById("favicon").href = ++i + ' | ||
155 | 230 | html += '".png"; }, 1000);</script></body></html>' | ||
156 | 231 | self.send_html(html) | ||
157 | 232 | elif self.path == "/changingtitle": | ||
158 | 233 | self.send_response(200) | ||
159 | 234 | html = '<html><head><title>title0</title></head><body><script>' | ||
160 | 235 | html += 'var i = 0; window.setInterval(function() { ' | ||
161 | 236 | html += 'document.title = "title" + ++i; }, 500);</script></body>' | ||
162 | 237 | html += '</html>' | ||
163 | 238 | self.send_html(html) | ||
164 | 239 | elif self.path == "/pushstate": | ||
165 | 240 | self.send_response(200) | ||
166 | 241 | html = '<html><head><title>push state</title></head>' | ||
167 | 242 | html += '<body style="margin: 0"><a id="link">' | ||
168 | 243 | html += '<div style="height: 100%"></div></a><script>' | ||
169 | 244 | html += 'document.getElementById("link").addEventListener("click",' | ||
170 | 245 | html += ' function(e) { document.title = "state pushed"; ' | ||
171 | 246 | html += 'history.pushState(null, null, "/statepushed"); });' | ||
172 | 247 | html += '</script></body></html>' | ||
173 | 248 | self.send_html(html) | ||
174 | 218 | else: | 249 | else: |
175 | 219 | self.send_error(404) | 250 | self.send_error(404) |
176 | 220 | 251 | ||
177 | 221 | 252 | ||
178 | === modified file 'tests/autopilot/webbrowser_app/tests/test_history.py' | |||
179 | --- tests/autopilot/webbrowser_app/tests/test_history.py 2015-11-23 10:25:26 +0000 | |||
180 | +++ tests/autopilot/webbrowser_app/tests/test_history.py 2016-03-01 09:31:14 +0000 | |||
181 | @@ -1,6 +1,6 @@ | |||
182 | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
183 | 2 | # | 2 | # |
185 | 3 | # Copyright 2015 Canonical | 3 | # Copyright 2015-2016 Canonical |
186 | 4 | # | 4 | # |
187 | 5 | # This program is free software: you can redistribute it and/or modify it | 5 | # This program is free software: you can redistribute it and/or modify it |
188 | 6 | # under the terms of the GNU General Public License version 3, as published | 6 | # under the terms of the GNU General Public License version 3, as published |
189 | @@ -16,7 +16,7 @@ | |||
190 | 16 | 16 | ||
191 | 17 | import time | 17 | import time |
192 | 18 | 18 | ||
194 | 19 | from testtools.matchers import Equals | 19 | from testtools.matchers import EndsWith, Equals, StartsWith |
195 | 20 | from autopilot.matchers import Eventually | 20 | from autopilot.matchers import Eventually |
196 | 21 | 21 | ||
197 | 22 | from webbrowser_app.tests import StartOpenRemotePageTestCaseBase | 22 | from webbrowser_app.tests import StartOpenRemotePageTestCaseBase |
198 | @@ -24,45 +24,36 @@ | |||
199 | 24 | 24 | ||
200 | 25 | class TestHistory(StartOpenRemotePageTestCaseBase): | 25 | class TestHistory(StartOpenRemotePageTestCaseBase): |
201 | 26 | 26 | ||
217 | 27 | def test_history_not_save_404(self): | 27 | def expect_history_entries(self, ordered_urls): |
218 | 28 | url = self.base_url + "/404page" | 28 | history = self.main_window.get_history_view() |
204 | 29 | self.main_window.go_to_url(url) | ||
205 | 30 | self.main_window.wait_until_page_loaded(url) | ||
206 | 31 | |||
207 | 32 | # A valid url to be sure the fact the 404 page isn't present in the | ||
208 | 33 | # history view isn't a timing issue. | ||
209 | 34 | url = self.base_url + "/test2" | ||
210 | 35 | self.main_window.go_to_url(url) | ||
211 | 36 | self.main_window.wait_until_page_loaded(url) | ||
212 | 37 | |||
213 | 38 | history = self.open_history() | ||
214 | 39 | |||
215 | 40 | # We have domains with subsections only on mobiles. | ||
216 | 41 | # On wide we take all the entries directly | ||
219 | 42 | if self.main_window.wide: | 29 | if self.main_window.wide: |
220 | 43 | delegates = history.get_entries() | ||
221 | 44 | |||
222 | 45 | # 2 addresses: /test1 and /test2 | ||
223 | 46 | self.assertThat(lambda: len(history.get_entries()), | 30 | self.assertThat(lambda: len(history.get_entries()), |
227 | 47 | Eventually(Equals(2))) | 31 | Eventually(Equals(len(ordered_urls)))) |
228 | 48 | self.assertThat(sorted([delegate.url for delegate in delegates]), | 32 | entries = history.get_entries() |
226 | 49 | Equals(sorted([self.url, url]))) | ||
229 | 50 | else: | 33 | else: |
230 | 51 | # 1 domain: the local one | ||
231 | 52 | domain_entries = history.get_domain_entries() | ||
232 | 53 | self.assertThat(lambda: len(history.get_domain_entries()), | 34 | self.assertThat(lambda: len(history.get_domain_entries()), |
233 | 54 | Eventually(Equals(1))) | 35 | Eventually(Equals(1))) |
236 | 55 | 36 | self.pointing_device.click_object(history.get_domain_entries()[0]) | |
235 | 56 | self.pointing_device.click_object(domain_entries[0]) | ||
237 | 57 | expanded_history = self.main_window.get_expanded_history_view() | 37 | expanded_history = self.main_window.get_expanded_history_view() |
238 | 58 | |||
239 | 59 | # 2 addresses: /test1 and /test2 | ||
240 | 60 | self.assertThat(lambda: len(expanded_history.get_entries()), | 38 | self.assertThat(lambda: len(expanded_history.get_entries()), |
246 | 61 | Eventually(Equals(2))) | 39 | Eventually(Equals(len(ordered_urls)))) |
247 | 62 | 40 | entries = expanded_history.get_entries() | |
248 | 63 | delegates = expanded_history.get_entries() | 41 | self.assertThat([entry.url for entry in entries], Equals(ordered_urls)) |
249 | 64 | self.assertThat(sorted([delegate.url for delegate in delegates]), | 42 | return entries |
250 | 65 | Equals(sorted([self.url, url]))) | 43 | |
251 | 44 | def test_404_not_saved(self): | ||
252 | 45 | url = self.base_url + "/notfound" | ||
253 | 46 | self.main_window.go_to_url(url) | ||
254 | 47 | self.main_window.wait_until_page_loaded(url) | ||
255 | 48 | |||
256 | 49 | # A valid url to be sure the fact the 404 page isn't present in the | ||
257 | 50 | # history view isn't a timing issue. | ||
258 | 51 | url = self.base_url + "/test2" | ||
259 | 52 | self.main_window.go_to_url(url) | ||
260 | 53 | self.main_window.wait_until_page_loaded(url) | ||
261 | 54 | |||
262 | 55 | self.open_history() | ||
263 | 56 | self.expect_history_entries([url, self.url]) | ||
264 | 66 | 57 | ||
265 | 67 | def test_expanded_history_view_header_swallows_clicks(self): | 58 | def test_expanded_history_view_header_swallows_clicks(self): |
266 | 68 | # Regression test for https://launchpad.net/bugs/1518904 | 59 | # Regression test for https://launchpad.net/bugs/1518904 |
267 | @@ -78,3 +69,58 @@ | |||
268 | 78 | # There should be only one instance on the expanded history view. | 69 | # There should be only one instance on the expanded history view. |
269 | 79 | # If there’s more, the following call will raise an exception. | 70 | # If there’s more, the following call will raise an exception. |
270 | 80 | self.main_window.get_expanded_history_view() | 71 | self.main_window.get_expanded_history_view() |
271 | 72 | |||
272 | 73 | def test_favicon_saved(self): | ||
273 | 74 | # Regression test for https://launchpad.net/bugs/1549780 | ||
274 | 75 | url = self.base_url + "/favicon" | ||
275 | 76 | self.main_window.go_to_url(url) | ||
276 | 77 | self.main_window.wait_until_page_loaded(url) | ||
277 | 78 | self.open_history() | ||
278 | 79 | first = self.expect_history_entries([url, self.url])[0] | ||
279 | 80 | self.assertThat(first.url, Equals(url)) | ||
280 | 81 | favicon = self.base_url + "/assets/icon1.png" | ||
281 | 82 | self.assertThat(first.icon, Equals(favicon)) | ||
282 | 83 | |||
283 | 84 | def test_favicon_updated(self): | ||
284 | 85 | # Verify that a page dynamically updating its favicon | ||
285 | 86 | # triggers an update in the history database. | ||
286 | 87 | url = self.base_url + "/changingfavicon" | ||
287 | 88 | self.main_window.go_to_url(url) | ||
288 | 89 | self.main_window.wait_until_page_loaded(url) | ||
289 | 90 | self.open_history() | ||
290 | 91 | first = self.expect_history_entries([url, self.url])[0] | ||
291 | 92 | indexes = set() | ||
292 | 93 | while len(indexes) < 3: | ||
293 | 94 | self.assertThat(first.url, Equals(url)) | ||
294 | 95 | icon = first.icon | ||
295 | 96 | self.assertThat(icon, StartsWith(self.base_url)) | ||
296 | 97 | self.assertThat(icon, EndsWith(".png")) | ||
297 | 98 | indexes.add(int(first.icon[(len(self.base_url)+1):-4])) | ||
298 | 99 | |||
299 | 100 | def test_title_saved(self): | ||
300 | 101 | self.open_history() | ||
301 | 102 | entry = self.expect_history_entries([self.url])[0] | ||
302 | 103 | self.assertThat(entry.title, Equals("test page 1")) | ||
303 | 104 | |||
304 | 105 | def test_title_not_updated(self): | ||
305 | 106 | # Verify that a page dynamically updating its title | ||
306 | 107 | # does NOT trigger an update in the history database. | ||
307 | 108 | url = self.base_url + "/changingtitle" | ||
308 | 109 | self.main_window.go_to_url(url) | ||
309 | 110 | self.main_window.wait_until_page_loaded(url) | ||
310 | 111 | self.open_history() | ||
311 | 112 | first = self.expect_history_entries([url, self.url])[0] | ||
312 | 113 | for i in range(10): | ||
313 | 114 | self.assertThat(first.title, Equals("title0")) | ||
314 | 115 | time.sleep(0.5) | ||
315 | 116 | |||
316 | 117 | def test_pushstate_updates_history(self): | ||
317 | 118 | url = self.base_url + "/pushstate" | ||
318 | 119 | self.main_window.go_to_url(url) | ||
319 | 120 | self.main_window.wait_until_page_loaded(url) | ||
320 | 121 | webview = self.main_window.get_current_webview() | ||
321 | 122 | self.pointing_device.click_object(webview) | ||
322 | 123 | pushed = self.base_url + "/statepushed" | ||
323 | 124 | self.main_window.wait_until_page_loaded(pushed) | ||
324 | 125 | self.open_history() | ||
325 | 126 | self.expect_history_entries([pushed, url, self.url]) | ||
326 | 81 | 127 | ||
327 | === modified file 'tests/unittests/history-model/tst_HistoryModelTests.cpp' | |||
328 | --- tests/unittests/history-model/tst_HistoryModelTests.cpp 2015-10-07 11:10:14 +0000 | |||
329 | +++ tests/unittests/history-model/tst_HistoryModelTests.cpp 2016-03-01 09:31:14 +0000 | |||
330 | @@ -1,5 +1,5 @@ | |||
331 | 1 | /* | 1 | /* |
333 | 2 | * Copyright 2013 Canonical Ltd. | 2 | * Copyright 2013-2016 Canonical Ltd. |
334 | 3 | * | 3 | * |
335 | 4 | * This file is part of webbrowser-app. | 4 | * This file is part of webbrowser-app. |
336 | 5 | * | 5 | * |
337 | @@ -136,6 +136,54 @@ | |||
338 | 136 | QVERIFY(roles.contains(HistoryModel::Visits)); | 136 | QVERIFY(roles.contains(HistoryModel::Visits)); |
339 | 137 | } | 137 | } |
340 | 138 | 138 | ||
341 | 139 | void shouldUpdateAttributes() | ||
342 | 140 | { | ||
343 | 141 | qRegisterMetaType<QVector<int> >(); | ||
344 | 142 | QSignalSpy spyChanged(model, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&, const QVector<int>&))); | ||
345 | 143 | QUrl url(QStringLiteral("http://example.org/")); | ||
346 | 144 | QCOMPARE(model->add(url, QStringLiteral(""), QUrl()), 1); | ||
347 | 145 | |||
348 | 146 | QVERIFY(!model->update(QUrl(), QStringLiteral(""), QUrl())); | ||
349 | 147 | QVERIFY(spyChanged.isEmpty()); | ||
350 | 148 | |||
351 | 149 | QVERIFY(!model->update(QUrl(QStringLiteral("http://example.com/")), QStringLiteral(""), QUrl())); | ||
352 | 150 | QVERIFY(spyChanged.isEmpty()); | ||
353 | 151 | |||
354 | 152 | QVERIFY(!model->update(url, QStringLiteral(""), QUrl())); | ||
355 | 153 | QVERIFY(spyChanged.isEmpty()); | ||
356 | 154 | |||
357 | 155 | QVERIFY(model->update(url, QStringLiteral("title update"), QUrl())); | ||
358 | 156 | QCOMPARE(spyChanged.count(), 1); | ||
359 | 157 | QList<QVariant> args = spyChanged.takeFirst(); | ||
360 | 158 | QCOMPARE(args.at(0).toModelIndex().row(), 0); | ||
361 | 159 | QCOMPARE(args.at(1).toModelIndex().row(), 0); | ||
362 | 160 | QVector<int> roles = args.at(2).value<QVector<int> >(); | ||
363 | 161 | QCOMPARE(roles.size(), 1); | ||
364 | 162 | QVERIFY(roles.contains(HistoryModel::Title)); | ||
365 | 163 | QCOMPARE(model->get(0)[QStringLiteral("visits")].toInt(), 1); | ||
366 | 164 | |||
367 | 165 | QVERIFY(model->update(url, QStringLiteral("title update"), QUrl(QStringLiteral("image://webicon/123")))); | ||
368 | 166 | QCOMPARE(spyChanged.count(), 1); | ||
369 | 167 | args = spyChanged.takeFirst(); | ||
370 | 168 | QCOMPARE(args.at(0).toModelIndex().row(), 0); | ||
371 | 169 | QCOMPARE(args.at(1).toModelIndex().row(), 0); | ||
372 | 170 | roles = args.at(2).value<QVector<int> >(); | ||
373 | 171 | QCOMPARE(roles.size(), 1); | ||
374 | 172 | QVERIFY(roles.contains(HistoryModel::Icon)); | ||
375 | 173 | QCOMPARE(model->get(0)[QStringLiteral("visits")].toInt(), 1); | ||
376 | 174 | |||
377 | 175 | QVERIFY(model->update(url, QStringLiteral("title update 2"), QUrl(QStringLiteral("image://webicon/1234")))); | ||
378 | 176 | QCOMPARE(spyChanged.count(), 1); | ||
379 | 177 | args = spyChanged.takeFirst(); | ||
380 | 178 | QCOMPARE(args.at(0).toModelIndex().row(), 0); | ||
381 | 179 | QCOMPARE(args.at(1).toModelIndex().row(), 0); | ||
382 | 180 | roles = args.at(2).value<QVector<int> >(); | ||
383 | 181 | QCOMPARE(roles.size(), 2); | ||
384 | 182 | QVERIFY(roles.contains(HistoryModel::Title)); | ||
385 | 183 | QVERIFY(roles.contains(HistoryModel::Icon)); | ||
386 | 184 | QCOMPARE(model->get(0)[QStringLiteral("visits")].toInt(), 1); | ||
387 | 185 | } | ||
388 | 186 | |||
389 | 139 | void shouldNotifyWhenHidingOrUnHidingExistingEntry() | 187 | void shouldNotifyWhenHidingOrUnHidingExistingEntry() |
390 | 140 | { | 188 | { |
391 | 141 | qRegisterMetaType<QVector<int> >(); | 189 | qRegisterMetaType<QVector<int> >(); |
FAILED: Continuous integration, rev:1017 jenkins. qa.ubuntu. com/job/ webbrowser- app-ci/ 1778/ jenkins. qa.ubuntu. com/job/ generic- deb-autopilot- vivid-touch/ 2861/console jenkins. qa.ubuntu. com/job/ webbrowser- app-vivid- amd64-ci/ 535 jenkins. qa.ubuntu. com/job/ webbrowser- app-vivid- armhf-ci/ 535 jenkins. qa.ubuntu. com/job/ webbrowser- app-vivid- armhf-ci/ 535/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ webbrowser- app-vivid- i386-ci/ 535 jenkins. qa.ubuntu. com/job/ generic- deb-autopilot- runner- vivid-mako/ 2451/console jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- vivid-armhf/ 2859 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- vivid-armhf/ 2859/artifact/ work/output/ *zip*/output. zip s-jenkins. ubuntu- ci:8080/ job/touch- flash-device/ 20559
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/webbrowser- app-ci/ 1778/rebuild
http://