Merge lp:~osomon/oxide/restore-error-page-unit-test into lp:~oxide-developers/oxide/oxide.trunk

Proposed by Olivier Tilloy
Status: Merged
Merged at revision: 1000
Proposed branch: lp:~osomon/oxide/restore-error-page-unit-test
Merge into: lp:~oxide-developers/oxide/oxide.trunk
Diff against target: 82 lines (+63/-0)
2 files modified
qt/tests/qmltests/api/tst_WebView_loading.qml (+23/-0)
qt/tests/qmltests/api/tst_WebView_save_restore_state.qml (+40/-0)
To merge this branch: bzr merge lp:~osomon/oxide/restore-error-page-unit-test
Reviewer Review Type Date Requested Status
Chris Coulson Approve
Review via email: mp+251528@code.launchpad.net

Commit message

Add a unit test to verify that restoring the state of a navigation that had triggered an error triggers the error again.
Also update an existing test to verify that reloading a page that had triggered an error generates the same sequence of load events.

To post a comment you must log in.
Revision history for this message
Chris Coulson (chrisccoulson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'qt/tests/qmltests/api/tst_WebView_loading.qml'
2--- qt/tests/qmltests/api/tst_WebView_loading.qml 2015-02-26 20:59:00 +0000
3+++ qt/tests/qmltests/api/tst_WebView_loading.qml 2015-03-02 21:53:23 +0000
4@@ -162,6 +162,29 @@
5 compare(spy.count, 1,
6 "WebView.loading should have changed twice during the load");
7 compare(expectedLoadEvents.length, 0, "Some load events are missing");
8+
9+ // Verify that reloading a page that triggered an error
10+ // generates the same sequence of load events
11+ spy.clear();
12+ expectedLoadEvents = [
13+ { type: LoadEvent.TypeStarted, url: url, loading: true },
14+ { type: LoadEvent.TypeFailed, url: url, loading: true },
15+ { type: LoadEvent.TypeCommitted, url: url, error: true, loading: true }
16+ ];
17+ webView.reload();
18+
19+ verify(webView.loading,
20+ "WebView.loading should be true once we start loading");
21+ compare(spy.count, 1);
22+
23+ spy.clear();
24+ spy.wait();
25+
26+ verify(!webView.loading,
27+ "WebView.loading should be false after we finish loading");
28+ compare(spy.count, 1,
29+ "WebView.loading should have changed twice during the load");
30+ compare(expectedLoadEvents.length, 0, "Some load events are missing");
31 }
32
33 function test_WebView_loading5_redirection() {
34
35=== modified file 'qt/tests/qmltests/api/tst_WebView_save_restore_state.qml'
36--- qt/tests/qmltests/api/tst_WebView_save_restore_state.qml 2014-11-20 12:37:10 +0000
37+++ qt/tests/qmltests/api/tst_WebView_save_restore_state.qml 2015-03-02 21:53:23 +0000
38@@ -149,4 +149,44 @@
39 "document.querySelector('#textInput').value") == "Te$t"; });
40 restored.destroy();
41 }
42+
43+ function test_WebView_save_and_restore_error_page_data() {
44+ return get_restore_types();
45+ }
46+
47+ // Test that restoring the state of a navigation that had triggered an error
48+ // triggers the error again (see https://launchpad.net/bugs/1423531).
49+ function test_WebView_save_and_restore_error_page(data) {
50+ var url = "http://invalid/";
51+ webView.url = url;
52+ verify(webView.waitForLoadCommitted(),
53+ "Timed out waiting for error page");
54+
55+ var state = webView.currentState;
56+ verify(state.length > 0);
57+
58+ var restored = webViewComponent.createObject(
59+ webView, {"restoreType": data.restoreType, "restoreState": state});
60+ verify(restored !== null);
61+
62+ var expectedLoadEvents = [
63+ { type: LoadEvent.TypeStarted, isError: false },
64+ { type: LoadEvent.TypeFailed, isError: false },
65+ { type: LoadEvent.TypeCommitted, isError: true }
66+ ];
67+ function _loadEvent(event) {
68+ var expected = expectedLoadEvents[0];
69+ compare(event.type, expected.type);
70+ compare(event.url, url);
71+ compare(event.isError, expected.isError);
72+ expectedLoadEvents.shift();
73+ }
74+ restored.loadEvent.connect(_loadEvent);
75+
76+ tryCompare(restored, "url", url);
77+ restored.waitFor(function() {
78+ return (expectedLoadEvents.length === 0);
79+ });
80+ restored.destroy();
81+ }
82 }

Subscribers

People subscribed via source and target branches