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

Unified 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, 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 | « no previous file | 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..a68359f69ef60e28ad9551d9d85cc799aeb62be0 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,36 @@
web_state()->RemoveScriptCommandCallback("test");
}
+// Tests that reload with web::ReloadType::NORMAL is no-op when navigation
+// manager is empty.
+TEST_F(WebStateTest, ReloadWithNormalTypeWithEmptyNavigationManager) {
+ NavigationManager* navigation_manager = web_state()->GetNavigationManager();
+ 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 */);
+
+ ASSERT_FALSE(navigation_manager->GetTransientItem());
+ ASSERT_FALSE(navigation_manager->GetPendingItem());
+ ASSERT_FALSE(navigation_manager->GetLastCommittedItem());
+}
+
+// Tests that reload with web::ReloadType::ORIGINAL_REQUEST_URL is no-op when
+// navigation manager is empty.
+TEST_F(WebStateTest, ReloadWithOriginalTypeWithEmptyNavigationManager) {
+ NavigationManager* navigation_manager = web_state()->GetNavigationManager();
+ 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 */);
+
+ ASSERT_FALSE(navigation_manager->GetTransientItem());
+ ASSERT_FALSE(navigation_manager->GetPendingItem());
+ ASSERT_FALSE(navigation_manager->GetLastCommittedItem());
+}
+
} // namespace web
« 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