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

Unified Diff: chrome/browser/sessions/session_common_utils_unittest.cc

Issue 2493573002: Make sure that the browser will always restore settings page instead of sign out page after user si… (Closed)
Patch Set: append the missing file Created 4 years, 1 month 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: chrome/browser/sessions/session_common_utils_unittest.cc
diff --git a/chrome/browser/sessions/session_common_utils_unittest.cc b/chrome/browser/sessions/session_common_utils_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b39e8dabb8900a73c011514c3dc353f6e8b12ce3
--- /dev/null
+++ b/chrome/browser/sessions/session_common_utils_unittest.cc
@@ -0,0 +1,46 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/sessions/session_common_utils.h"
+
+#include <memory>
+
+#include "components/sessions/content/content_serialized_navigation_builder.h"
+#include "components/sessions/core/serialized_navigation_entry.h"
+#include "components/sessions/core/session_types.h"
+#include "content/public/browser/navigation_entry.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace {
+
+void AppendNavigations(sessions::SessionTab& tab,
+ content::NavigationEntry* entry) {
+ tab.navigations.push_back(
+ sessions::ContentSerializedNavigationBuilder::FromNavigationEntry(
+ 0, *entry));
+}
+
+} // namespace
+class SessionCommonUtilTest : public ::testing::Test {};
+
+TEST_F(SessionCommonUtilTest, GetSelectedIndex) {
+ const GURL settings_page("chrome://settings");
+ const GURL sign_out_page("chrome://settings/signOut");
+ sessions::SessionTab tab;
+
+ std::unique_ptr<content::NavigationEntry> entry1(
+ content::NavigationEntry::Create());
+ std::unique_ptr<content::NavigationEntry> entry2(
+ content::NavigationEntry::Create());
+ entry1->SetVirtualURL(settings_page);
+ entry2->SetVirtualURL(sign_out_page);
+
+ AppendNavigations(tab, entry1.get());
+ AppendNavigations(tab, entry2.get());
+
+ tab.current_navigation_index = 0;
+ ASSERT_EQ(0, GetSelectedIndexFromTab(tab));
+ tab.current_navigation_index = 1;
+ ASSERT_EQ(0, GetSelectedIndexFromTab(tab));
+}

Powered by Google App Engine
This is Rietveld 408576698