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
=== modified file 'qt/tests/qmltests/api/tst_WebView_loading.qml'
--- qt/tests/qmltests/api/tst_WebView_loading.qml 2015-02-26 20:59:00 +0000
+++ qt/tests/qmltests/api/tst_WebView_loading.qml 2015-03-02 21:53:23 +0000
@@ -162,6 +162,29 @@
162 compare(spy.count, 1,162 compare(spy.count, 1,
163 "WebView.loading should have changed twice during the load");163 "WebView.loading should have changed twice during the load");
164 compare(expectedLoadEvents.length, 0, "Some load events are missing");164 compare(expectedLoadEvents.length, 0, "Some load events are missing");
165
166 // Verify that reloading a page that triggered an error
167 // generates the same sequence of load events
168 spy.clear();
169 expectedLoadEvents = [
170 { type: LoadEvent.TypeStarted, url: url, loading: true },
171 { type: LoadEvent.TypeFailed, url: url, loading: true },
172 { type: LoadEvent.TypeCommitted, url: url, error: true, loading: true }
173 ];
174 webView.reload();
175
176 verify(webView.loading,
177 "WebView.loading should be true once we start loading");
178 compare(spy.count, 1);
179
180 spy.clear();
181 spy.wait();
182
183 verify(!webView.loading,
184 "WebView.loading should be false after we finish loading");
185 compare(spy.count, 1,
186 "WebView.loading should have changed twice during the load");
187 compare(expectedLoadEvents.length, 0, "Some load events are missing");
165 }188 }
166189
167 function test_WebView_loading5_redirection() {190 function test_WebView_loading5_redirection() {
168191
=== modified file 'qt/tests/qmltests/api/tst_WebView_save_restore_state.qml'
--- qt/tests/qmltests/api/tst_WebView_save_restore_state.qml 2014-11-20 12:37:10 +0000
+++ qt/tests/qmltests/api/tst_WebView_save_restore_state.qml 2015-03-02 21:53:23 +0000
@@ -149,4 +149,44 @@
149 "document.querySelector('#textInput').value") == "Te$t"; });149 "document.querySelector('#textInput').value") == "Te$t"; });
150 restored.destroy();150 restored.destroy();
151 }151 }
152
153 function test_WebView_save_and_restore_error_page_data() {
154 return get_restore_types();
155 }
156
157 // Test that restoring the state of a navigation that had triggered an error
158 // triggers the error again (see https://launchpad.net/bugs/1423531).
159 function test_WebView_save_and_restore_error_page(data) {
160 var url = "http://invalid/";
161 webView.url = url;
162 verify(webView.waitForLoadCommitted(),
163 "Timed out waiting for error page");
164
165 var state = webView.currentState;
166 verify(state.length > 0);
167
168 var restored = webViewComponent.createObject(
169 webView, {"restoreType": data.restoreType, "restoreState": state});
170 verify(restored !== null);
171
172 var expectedLoadEvents = [
173 { type: LoadEvent.TypeStarted, isError: false },
174 { type: LoadEvent.TypeFailed, isError: false },
175 { type: LoadEvent.TypeCommitted, isError: true }
176 ];
177 function _loadEvent(event) {
178 var expected = expectedLoadEvents[0];
179 compare(event.type, expected.type);
180 compare(event.url, url);
181 compare(event.isError, expected.isError);
182 expectedLoadEvents.shift();
183 }
184 restored.loadEvent.connect(_loadEvent);
185
186 tryCompare(restored, "url", url);
187 restored.waitFor(function() {
188 return (expectedLoadEvents.length === 0);
189 });
190 restored.destroy();
191 }
152}192}

Subscribers

People subscribed via source and target branches