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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/web/navigation/navigation_manager_impl.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web/web_state/web_state_unittest.mm
diff --git a/ios/web/web_state/web_state_unittest.mm b/ios/web/web_state/web_state_unittest.mm
index 92d8e359ffa6fbed0b8ec9c2840065cdd3c8641a..9f13e6a0868370694ce1032e0b49479083510e08 100644
--- a/ios/web/web_state/web_state_unittest.mm
+++ b/ios/web/web_state/web_state_unittest.mm
@@ -7,6 +7,7 @@
#include "base/mac/bind_objc_block.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
+#import "ios/web/public/navigation_manager.h"
#import "ios/web/public/test/web_test_with_web_state.h"
namespace web {
@@ -74,4 +75,30 @@
web_state()->RemoveScriptCommandCallback("test");
}
+// 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.
+// manager is empty.
+TEST_F(WebStateTest, ReloadWithNormalTypeWithEmptyNavigationManager) {
+ NavigationManager* navigation_manager = web_state()->GetNavigationManager();
+ 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.
+ ASSERT_FALSE(navigation_manager->GetTransientItem());
+ ASSERT_FALSE(navigation_manager->GetPendingItem());
+ ASSERT_FALSE(navigation_manager->GetLastCommittedItem());
+
+ navigation_manager->Reload(web::ReloadType::NORMAL,
+ 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.
+}
+
+// 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.
+// when navigation manager is empty.
+TEST_F(WebStateTest, ReloadWithOriginalTypeWithEmptyNavigationManager) {
+ NavigationManager* navigation_manager = web_state()->GetNavigationManager();
+ ASSERT_TRUE(navigation_manager);
+ ASSERT_FALSE(navigation_manager->GetTransientItem());
+ ASSERT_FALSE(navigation_manager->GetPendingItem());
+ ASSERT_FALSE(navigation_manager->GetLastCommittedItem());
+
+ navigation_manager->Reload(web::ReloadType::ORIGINAL_REQUEST_URL,
+ false /* check_for_repost */);
+}
+
} // namespace web
« 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