Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(565)

Side by Side Diff: ios/web/navigation/history_state_operations_inttest.mm

Issue 2604103002: Created test for restoring state object after back/forward navigation. (Closed)
Patch Set: rebase + eugene's comments Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/memory/ptr_util.h" 5 #include "base/memory/ptr_util.h"
6 #include "base/strings/string_number_conversions.h" 6 #include "base/strings/string_number_conversions.h"
7 #include "base/strings/sys_string_conversions.h" 7 #include "base/strings/sys_string_conversions.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "base/test/ios/wait_util.h" 9 #include "base/test/ios/wait_util.h"
10 #import "ios/web/navigation/navigation_item_impl.h" 10 #import "ios/web/navigation/navigation_item_impl.h"
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 GURL empty_url; 301 GURL empty_url;
302 SetStateParams(new_state, empty_title, empty_url); 302 SetStateParams(new_state, empty_title, empty_url);
303 ASSERT_TRUE(web::test::TapWebViewElementWithId(web_state(), kReplaceStateId)); 303 ASSERT_TRUE(web::test::TapWebViewElementWithId(web_state(), kReplaceStateId));
304 // Reload the page and check that the state object is present. 304 // Reload the page and check that the state object is present.
305 Reload(); 305 Reload();
306 ASSERT_TRUE(IsOnLoadTextVisible()); 306 ASSERT_TRUE(IsOnLoadTextVisible());
307 base::test::ios::WaitUntilCondition(^bool { 307 base::test::ios::WaitUntilCondition(^bool {
308 return GetJavaScriptState() == new_state; 308 return GetJavaScriptState() == new_state;
309 }); 309 });
310 } 310 }
311
312 // Tests that the state object is correctly set for a page after a back/forward
313 // navigation.
314 TEST_F(HistoryStateOperationsTest, StateReplacementBackForward) {
315 // Navigate to about:blank then navigate back to the test page. The created
316 // NavigationItem can be used later to verify that the state is replaced
317 // rather than pushed.
318 GURL about_blank("about:blank");
319 LoadUrl(about_blank);
320 ExecuteBlockAndWaitForLoad(state_operations_url(), ^{
321 navigation_manager()->GoBack();
322 });
323 ASSERT_EQ(state_operations_url(), GetLastCommittedItem()->GetURL());
324 // Set up the state parameters and tap the replace state button.
325 std::string new_state("STATE OBJECT");
326 std::string empty_title("");
327 GURL empty_url("");
328 SetStateParams(new_state, empty_title, empty_url);
329 ASSERT_TRUE(web::test::TapWebViewElementWithId(web_state(), kReplaceStateId));
330 // Go forward and back, then check that the state object is present.
331 ExecuteBlockAndWaitForLoad(about_blank, ^{
332 navigation_manager()->GoForward();
333 });
334 ExecuteBlockAndWaitForLoad(state_operations_url(), ^{
335 navigation_manager()->GoBack();
336 });
337 ASSERT_TRUE(IsOnLoadTextVisible());
338 base::test::ios::WaitUntilCondition(^bool {
339 return GetJavaScriptState() == new_state;
340 });
341 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698