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

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: Change include navigation_manager.h to import Created 3 years, 9 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 | « ios/web/navigation/navigation_manager_impl.mm ('k') | 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 will not crash when navigation
Eugene But (OOO till 7-30) 2017/03/28 01:46:38 s/will not crash/is no-op
liaoyuke 2017/03/28 16:06:31 Done.
79 // manager is empty.
80 TEST_F(WebStateTest, ReloadWithNormalTypeWithEmptyNavigationManager) {
81 NavigationManager* navigation_manager = web_state()->GetNavigationManager();
82 ASSERT_TRUE(navigation_manager);
Eugene But (OOO till 7-30) 2017/03/28 01:46:38 WebState can not return null NM
liaoyuke 2017/03/28 16:06:31 Done.
83 ASSERT_FALSE(navigation_manager->GetTransientItem());
84 ASSERT_FALSE(navigation_manager->GetPendingItem());
85 ASSERT_FALSE(navigation_manager->GetLastCommittedItem());
86
87 navigation_manager->Reload(web::ReloadType::NORMAL,
88 false /* check_for_repost */);
Eugene But (OOO till 7-30) 2017/03/28 01:46:38 Could you please check that NM is still empty.
liaoyuke 2017/03/28 16:06:31 Done.
89 }
90
91 // Tests that reload with web::ReloadType::ORIGINAL_REQUEST_URL will not crash
Eugene But (OOO till 7-30) 2017/03/28 01:46:38 Same comments as from the previous method
liaoyuke 2017/03/28 16:06:32 Done.
92 // when navigation manager is empty.
93 TEST_F(WebStateTest, ReloadWithOriginalTypeWithEmptyNavigationManager) {
94 NavigationManager* navigation_manager = web_state()->GetNavigationManager();
95 ASSERT_TRUE(navigation_manager);
96 ASSERT_FALSE(navigation_manager->GetTransientItem());
97 ASSERT_FALSE(navigation_manager->GetPendingItem());
98 ASSERT_FALSE(navigation_manager->GetLastCommittedItem());
99
100 navigation_manager->Reload(web::ReloadType::ORIGINAL_REQUEST_URL,
101 false /* check_for_repost */);
102 }
103
77 } // namespace web 104 } // namespace web
OLDNEW
« no previous file with comments | « ios/web/navigation/navigation_manager_impl.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698