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

Side by Side Diff: ios/web/web_state/web_state_unittest.mm

Issue 2780703002: Reload with empty navigation manager should not crash (Closed)
Patch Set: Rebase Created 3 years, 8 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 #import "ios/web/public/web_state/web_state.h" 5 #import "ios/web/public/web_state/web_state.h"
6 6
7 #include "base/mac/bind_objc_block.h" 7 #include "base/mac/bind_objc_block.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #import "ios/web/public/navigation_manager.h"
10 #import "ios/web/public/test/web_test_with_web_state.h" 11 #import "ios/web/public/test/web_test_with_web_state.h"
11 12
12 namespace web { 13 namespace web {
13 14
14 // Test fixture for web::WebTest class. 15 // Test fixture for web::WebTest class.
15 typedef web::WebTestWithWebState WebStateTest; 16 typedef web::WebTestWithWebState WebStateTest;
16 17
17 // Tests script execution with and without callback. 18 // Tests script execution with and without callback.
18 TEST_F(WebStateTest, ScriptExecution) { 19 TEST_F(WebStateTest, ScriptExecution) {
19 LoadHtml("<html></html>"); 20 LoadHtml("<html></html>");
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 " webkit = undefined;" 68 " webkit = undefined;"
68 " __gCrWeb.message.invokeOnHost({'command': 'test.webkit-overriding'});" 69 " __gCrWeb.message.invokeOnHost({'command': 'test.webkit-overriding'});"
69 "</script>"); 70 "</script>");
70 71
71 WaitForCondition(^{ 72 WaitForCondition(^{
72 return message_received; 73 return message_received;
73 }); 74 });
74 web_state()->RemoveScriptCommandCallback("test"); 75 web_state()->RemoveScriptCommandCallback("test");
75 } 76 }
76 77
78 // Tests that reload with web::ReloadType::NORMAL is no-op when navigation
79 // manager is empty.
80 TEST_F(WebStateTest, ReloadWithNormalTypeWithEmptyNavigationManager) {
81 NavigationManager* navigation_manager = web_state()->GetNavigationManager();
82 ASSERT_FALSE(navigation_manager->GetTransientItem());
83 ASSERT_FALSE(navigation_manager->GetPendingItem());
84 ASSERT_FALSE(navigation_manager->GetLastCommittedItem());
85
86 navigation_manager->Reload(web::ReloadType::NORMAL,
87 false /* check_for_repost */);
88
89 ASSERT_FALSE(navigation_manager->GetTransientItem());
90 ASSERT_FALSE(navigation_manager->GetPendingItem());
91 ASSERT_FALSE(navigation_manager->GetLastCommittedItem());
92 }
93
94 // Tests that reload with web::ReloadType::ORIGINAL_REQUEST_URL is no-op when
95 // navigation manager is empty.
96 TEST_F(WebStateTest, ReloadWithOriginalTypeWithEmptyNavigationManager) {
97 NavigationManager* navigation_manager = web_state()->GetNavigationManager();
98 ASSERT_FALSE(navigation_manager->GetTransientItem());
99 ASSERT_FALSE(navigation_manager->GetPendingItem());
100 ASSERT_FALSE(navigation_manager->GetLastCommittedItem());
101
102 navigation_manager->Reload(web::ReloadType::ORIGINAL_REQUEST_URL,
103 false /* check_for_repost */);
104
105 ASSERT_FALSE(navigation_manager->GetTransientItem());
106 ASSERT_FALSE(navigation_manager->GetPendingItem());
107 ASSERT_FALSE(navigation_manager->GetLastCommittedItem());
108 }
109
77 } // namespace web 110 } // namespace web
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