OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/sessions/session_common_utils.h" |
| 6 |
| 7 #include <memory> |
| 8 |
| 9 #include "components/sessions/content/content_serialized_navigation_builder.h" |
| 10 #include "components/sessions/core/serialized_navigation_entry.h" |
| 11 #include "components/sessions/core/session_types.h" |
| 12 #include "content/public/browser/navigation_entry.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 |
| 15 namespace { |
| 16 |
| 17 void AppendNavigations(sessions::SessionTab* tab, |
| 18 content::NavigationEntry* entry) { |
| 19 tab->navigations.push_back( |
| 20 sessions::ContentSerializedNavigationBuilder::FromNavigationEntry( |
| 21 0, *entry)); |
| 22 } |
| 23 |
| 24 } // namespace |
| 25 class SessionCommonUtilTest : public ::testing::Test {}; |
| 26 |
| 27 TEST_F(SessionCommonUtilTest, GetSelectedIndex) { |
| 28 const GURL settings_page("chrome://settings"); |
| 29 const GURL sign_out_page("chrome://settings/signOut"); |
| 30 sessions::SessionTab tab; |
| 31 |
| 32 std::unique_ptr<content::NavigationEntry> entry1( |
| 33 content::NavigationEntry::Create()); |
| 34 std::unique_ptr<content::NavigationEntry> entry2( |
| 35 content::NavigationEntry::Create()); |
| 36 entry1->SetVirtualURL(settings_page); |
| 37 entry2->SetVirtualURL(sign_out_page); |
| 38 |
| 39 AppendNavigations(&tab, entry1.get()); |
| 40 AppendNavigations(&tab, entry2.get()); |
| 41 |
| 42 tab.current_navigation_index = 0; |
| 43 ASSERT_EQ(0, GetNavigationIndexToSelect(tab)); |
| 44 tab.current_navigation_index = 1; |
| 45 ASSERT_EQ(0, GetNavigationIndexToSelect(tab)); |
| 46 } |
OLD | NEW |