| 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 "components/sessions/core/tab_restore_service.h" | |
| 6 | |
| 7 #include "testing/gtest/include/gtest/gtest.h" | |
| 8 | |
| 9 namespace sessions { | |
| 10 | |
| 11 namespace { | |
| 12 | |
| 13 void PopulateTab(TabRestoreService::Tab* tab) { | |
| 14 tab->timestamp = base::Time::FromDoubleT(100.0); | |
| 15 tab->from_last_session = true; | |
| 16 tab->current_navigation_index = 42; | |
| 17 tab->browser_id = 1; | |
| 18 tab->tabstrip_index = 5; | |
| 19 tab->pinned = true; | |
| 20 tab->extension_app_id = "dummy"; | |
| 21 tab->user_agent_override = "override"; | |
| 22 } | |
| 23 | |
| 24 void TestEntryEquality(TabRestoreService::Entry* expected, | |
| 25 TabRestoreService::Entry* actual) { | |
| 26 EXPECT_EQ(expected->id, actual->id); | |
| 27 EXPECT_EQ(expected->type, actual->type); | |
| 28 EXPECT_EQ(expected->timestamp, actual->timestamp); | |
| 29 EXPECT_EQ(expected->from_last_session, actual->from_last_session); | |
| 30 } | |
| 31 | |
| 32 void TestTabEquality(TabRestoreService::Tab* expected, | |
| 33 TabRestoreService::Tab* actual) { | |
| 34 TestEntryEquality(expected, actual); | |
| 35 EXPECT_EQ(expected->current_navigation_index, | |
| 36 actual->current_navigation_index); | |
| 37 EXPECT_EQ(expected->browser_id, actual->browser_id); | |
| 38 EXPECT_EQ(expected->tabstrip_index, actual->tabstrip_index); | |
| 39 EXPECT_EQ(expected->pinned, actual->pinned); | |
| 40 EXPECT_EQ(expected->extension_app_id, actual->extension_app_id); | |
| 41 EXPECT_EQ(expected->user_agent_override, actual->user_agent_override); | |
| 42 } | |
| 43 | |
| 44 TEST(Tab, CopyConstructor) { | |
| 45 TabRestoreService::Tab tab_to_copy; | |
| 46 PopulateTab(&tab_to_copy); | |
| 47 | |
| 48 TabRestoreService::Tab copied_tab(tab_to_copy); | |
| 49 TestTabEquality(&tab_to_copy, &copied_tab); | |
| 50 } | |
| 51 | |
| 52 TEST(Tab, AssignmentOperator) { | |
| 53 TabRestoreService::Tab tab_to_assign; | |
| 54 PopulateTab(&tab_to_assign); | |
| 55 | |
| 56 TabRestoreService::Tab assigned_tab; | |
| 57 assigned_tab = tab_to_assign; | |
| 58 TestTabEquality(&tab_to_assign, &assigned_tab); | |
| 59 } | |
| 60 | |
| 61 } // namespace | |
| 62 | |
| 63 } // namespace sessions | |
| OLD | NEW |