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

Unified Diff: components/sessions/content/content_serialized_navigation_driver_unittest.cc

Issue 2310363002: Persist offline page info in a navigation entry if needed (Closed)
Patch Set: Add extended info support Created 4 years, 3 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
Index: components/sessions/content/content_serialized_navigation_driver_unittest.cc
diff --git a/components/sessions/content/content_serialized_navigation_driver_unittest.cc b/components/sessions/content/content_serialized_navigation_driver_unittest.cc
index 67a34512d8cd3cf2e86a7e711ae4b3d5fcfeffa2..98f1eaf559ab327f8b0d7d76137bdcdd880d7df6 100644
--- a/components/sessions/content/content_serialized_navigation_driver_unittest.cc
+++ b/components/sessions/content/content_serialized_navigation_driver_unittest.cc
@@ -13,6 +13,29 @@
namespace sessions {
+namespace {
+const char kExtendedInfoKey[] = "Key 1";
+const char kExtendedInfoValue[] = "Value 1";
+
+class TestExtendedInfoHandler :
+ public SerializedNavigationDriver::ExtendedInfoHandler {
+ public:
+ TestExtendedInfoHandler() {}
+ ~TestExtendedInfoHandler() override {}
+
+ std::string GetExtendedInfo(
+ const content::NavigationEntry& entry) const override {
+ return kExtendedInfoValue;
+ }
+
+ void RestoreExtendedInfo(
+ const std::string& info, content::NavigationEntry* entry) override {
+
+ }
+};
+
+} // namespace
+
// Tests that PageState data is properly sanitized when post data is present.
TEST(ContentSerializedNavigationDriverTest, PickleSanitizationWithPostData) {
ContentSerializedNavigationDriver* driver =
@@ -117,4 +140,14 @@ TEST(ContentSerializedNavigationDriverTest, SanitizeWithReferrerPolicyNever) {
EXPECT_EQ(page_state.ToEncodedData(), navigation.encoded_page_state());
}
+TEST(ContentSerializedNavigationDriverTest, ExtendedInfoHandler) {
+ ContentSerializedNavigationDriver* driver =
+ ContentSerializedNavigationDriver::GetInstance();
+
+ std::unique_ptr<SerializedNavigationDriver::ExtendedInfoHandler> handler(
+ new TestExtendedInfoHandler);
+ driver->RegisterExtendedInfoHandler(kExtendedInfoKey, std::move(handler));
+ EXPECT_EQ(1U, driver->GetAllExtendedInfoHandlers().size());
+}
+
} // namespace sessions

Powered by Google App Engine
This is Rietveld 408576698