| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/sessions/session_types.h" | 5 #include "chrome/browser/sessions/session_types.h" |
| 6 #include "chrome/browser/sessions/session_service.h" | 6 #include "chrome/browser/sessions/session_service.h" |
| 7 #include "chrome/browser/sessions/tab_restore_service.h" | 7 #include "chrome/browser/sessions/tab_restore_service.h" |
| 8 #include "chrome/test/render_view_test.h" | 8 #include "chrome/test/render_view_test.h" |
| 9 #include "chrome/test/testing_profile.h" | 9 #include "chrome/test/testing_profile.h" |
| 10 #include "content/browser/renderer_host/test_render_view_host.h" | 10 #include "content/browser/renderer_host/test_render_view_host.h" |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 GURL url3_; | 116 GURL url3_; |
| 117 scoped_refptr<TabRestoreService> service_; | 117 scoped_refptr<TabRestoreService> service_; |
| 118 TabRestoreTimeFactory* time_factory_; | 118 TabRestoreTimeFactory* time_factory_; |
| 119 RenderViewTest::RendererWebKitClientImplNoSandbox webkitclient_; | 119 RenderViewTest::RendererWebKitClientImplNoSandbox webkitclient_; |
| 120 }; | 120 }; |
| 121 | 121 |
| 122 TEST_F(TabRestoreServiceTest, Basic) { | 122 TEST_F(TabRestoreServiceTest, Basic) { |
| 123 AddThreeNavigations(); | 123 AddThreeNavigations(); |
| 124 | 124 |
| 125 // Have the service record the tab. | 125 // Have the service record the tab. |
| 126 service_->CreateHistoricalTab(&controller()); | 126 service_->CreateHistoricalTab(&controller(), -1); |
| 127 | 127 |
| 128 // Make sure an entry was created. | 128 // Make sure an entry was created. |
| 129 ASSERT_EQ(1U, service_->entries().size()); | 129 ASSERT_EQ(1U, service_->entries().size()); |
| 130 | 130 |
| 131 // Make sure the entry matches. | 131 // Make sure the entry matches. |
| 132 TabRestoreService::Entry* entry = service_->entries().front(); | 132 TabRestoreService::Entry* entry = service_->entries().front(); |
| 133 ASSERT_EQ(TabRestoreService::TAB, entry->type); | 133 ASSERT_EQ(TabRestoreService::TAB, entry->type); |
| 134 TabRestoreService::Tab* tab = static_cast<TabRestoreService::Tab*>(entry); | 134 TabRestoreService::Tab* tab = static_cast<TabRestoreService::Tab*>(entry); |
| 135 EXPECT_FALSE(tab->pinned); | 135 EXPECT_FALSE(tab->pinned); |
| 136 EXPECT_TRUE(tab->extension_app_id.empty()); | 136 EXPECT_TRUE(tab->extension_app_id.empty()); |
| 137 ASSERT_EQ(3U, tab->navigations.size()); | 137 ASSERT_EQ(3U, tab->navigations.size()); |
| 138 EXPECT_TRUE(url1_ == tab->navigations[0].virtual_url()); | 138 EXPECT_TRUE(url1_ == tab->navigations[0].virtual_url()); |
| 139 EXPECT_TRUE(url2_ == tab->navigations[1].virtual_url()); | 139 EXPECT_TRUE(url2_ == tab->navigations[1].virtual_url()); |
| 140 EXPECT_TRUE(url3_ == tab->navigations[2].virtual_url()); | 140 EXPECT_TRUE(url3_ == tab->navigations[2].virtual_url()); |
| 141 EXPECT_EQ(2, tab->current_navigation_index); | 141 EXPECT_EQ(2, tab->current_navigation_index); |
| 142 EXPECT_EQ(time_factory_->TimeNow().ToInternalValue(), | 142 EXPECT_EQ(time_factory_->TimeNow().ToInternalValue(), |
| 143 tab->timestamp.ToInternalValue()); | 143 tab->timestamp.ToInternalValue()); |
| 144 | 144 |
| 145 NavigateToIndex(1); | 145 NavigateToIndex(1); |
| 146 | 146 |
| 147 // And check again. | 147 // And check again. |
| 148 service_->CreateHistoricalTab(&controller()); | 148 service_->CreateHistoricalTab(&controller(), -1); |
| 149 | 149 |
| 150 // There should be two entries now. | 150 // There should be two entries now. |
| 151 ASSERT_EQ(2U, service_->entries().size()); | 151 ASSERT_EQ(2U, service_->entries().size()); |
| 152 | 152 |
| 153 // Make sure the entry matches | 153 // Make sure the entry matches |
| 154 entry = service_->entries().front(); | 154 entry = service_->entries().front(); |
| 155 ASSERT_EQ(TabRestoreService::TAB, entry->type); | 155 ASSERT_EQ(TabRestoreService::TAB, entry->type); |
| 156 tab = static_cast<TabRestoreService::Tab*>(entry); | 156 tab = static_cast<TabRestoreService::Tab*>(entry); |
| 157 EXPECT_FALSE(tab->pinned); | 157 EXPECT_FALSE(tab->pinned); |
| 158 ASSERT_EQ(3U, tab->navigations.size()); | 158 ASSERT_EQ(3U, tab->navigations.size()); |
| 159 EXPECT_EQ(url1_, tab->navigations[0].virtual_url()); | 159 EXPECT_EQ(url1_, tab->navigations[0].virtual_url()); |
| 160 EXPECT_EQ(url2_, tab->navigations[1].virtual_url()); | 160 EXPECT_EQ(url2_, tab->navigations[1].virtual_url()); |
| 161 EXPECT_EQ(url3_, tab->navigations[2].virtual_url()); | 161 EXPECT_EQ(url3_, tab->navigations[2].virtual_url()); |
| 162 EXPECT_EQ(1, tab->current_navigation_index); | 162 EXPECT_EQ(1, tab->current_navigation_index); |
| 163 EXPECT_EQ(time_factory_->TimeNow().ToInternalValue(), | 163 EXPECT_EQ(time_factory_->TimeNow().ToInternalValue(), |
| 164 tab->timestamp.ToInternalValue()); | 164 tab->timestamp.ToInternalValue()); |
| 165 } | 165 } |
| 166 | 166 |
| 167 // Make sure TabRestoreService doesn't create an entry for a tab with no | 167 // Make sure TabRestoreService doesn't create an entry for a tab with no |
| 168 // navigations. | 168 // navigations. |
| 169 TEST_F(TabRestoreServiceTest, DontCreateEmptyTab) { | 169 TEST_F(TabRestoreServiceTest, DontCreateEmptyTab) { |
| 170 service_->CreateHistoricalTab(&controller()); | 170 service_->CreateHistoricalTab(&controller(), -1); |
| 171 EXPECT_TRUE(service_->entries().empty()); | 171 EXPECT_TRUE(service_->entries().empty()); |
| 172 } | 172 } |
| 173 | 173 |
| 174 // Tests restoring a single tab. | 174 // Tests restoring a single tab. |
| 175 TEST_F(TabRestoreServiceTest, Restore) { | 175 TEST_F(TabRestoreServiceTest, Restore) { |
| 176 AddThreeNavigations(); | 176 AddThreeNavigations(); |
| 177 | 177 |
| 178 // Have the service record the tab. | 178 // Have the service record the tab. |
| 179 service_->CreateHistoricalTab(&controller()); | 179 service_->CreateHistoricalTab(&controller(), -1); |
| 180 | 180 |
| 181 // Recreate the service and have it load the tabs. | 181 // Recreate the service and have it load the tabs. |
| 182 RecreateService(); | 182 RecreateService(); |
| 183 | 183 |
| 184 // One entry should be created. | 184 // One entry should be created. |
| 185 ASSERT_EQ(1U, service_->entries().size()); | 185 ASSERT_EQ(1U, service_->entries().size()); |
| 186 | 186 |
| 187 // And verify the entry. | 187 // And verify the entry. |
| 188 TabRestoreService::Entry* entry = service_->entries().front(); | 188 TabRestoreService::Entry* entry = service_->entries().front(); |
| 189 ASSERT_EQ(TabRestoreService::TAB, entry->type); | 189 ASSERT_EQ(TabRestoreService::TAB, entry->type); |
| 190 TabRestoreService::Tab* tab = static_cast<TabRestoreService::Tab*>(entry); | 190 TabRestoreService::Tab* tab = static_cast<TabRestoreService::Tab*>(entry); |
| 191 EXPECT_FALSE(tab->pinned); | 191 EXPECT_FALSE(tab->pinned); |
| 192 ASSERT_EQ(3U, tab->navigations.size()); | 192 ASSERT_EQ(3U, tab->navigations.size()); |
| 193 EXPECT_TRUE(url1_ == tab->navigations[0].virtual_url()); | 193 EXPECT_TRUE(url1_ == tab->navigations[0].virtual_url()); |
| 194 EXPECT_TRUE(url2_ == tab->navigations[1].virtual_url()); | 194 EXPECT_TRUE(url2_ == tab->navigations[1].virtual_url()); |
| 195 EXPECT_TRUE(url3_ == tab->navigations[2].virtual_url()); | 195 EXPECT_TRUE(url3_ == tab->navigations[2].virtual_url()); |
| 196 EXPECT_EQ(2, tab->current_navigation_index); | 196 EXPECT_EQ(2, tab->current_navigation_index); |
| 197 EXPECT_EQ(time_factory_->TimeNow().ToInternalValue(), | 197 EXPECT_EQ(time_factory_->TimeNow().ToInternalValue(), |
| 198 tab->timestamp.ToInternalValue()); | 198 tab->timestamp.ToInternalValue()); |
| 199 } | 199 } |
| 200 | 200 |
| 201 // Tests restoring a single pinned tab. | 201 // Tests restoring a single pinned tab. |
| 202 TEST_F(TabRestoreServiceTest, RestorePinnedAndApp) { | 202 TEST_F(TabRestoreServiceTest, RestorePinnedAndApp) { |
| 203 AddThreeNavigations(); | 203 AddThreeNavigations(); |
| 204 | 204 |
| 205 // Have the service record the tab. | 205 // Have the service record the tab. |
| 206 service_->CreateHistoricalTab(&controller()); | 206 service_->CreateHistoricalTab(&controller(), -1); |
| 207 | 207 |
| 208 // One entry should be created. | 208 // One entry should be created. |
| 209 ASSERT_EQ(1U, service_->entries().size()); | 209 ASSERT_EQ(1U, service_->entries().size()); |
| 210 | 210 |
| 211 // We have to explicitly mark the tab as pinned as there is no browser for | 211 // We have to explicitly mark the tab as pinned as there is no browser for |
| 212 // these tests. | 212 // these tests. |
| 213 TabRestoreService::Entry* entry = service_->entries().front(); | 213 TabRestoreService::Entry* entry = service_->entries().front(); |
| 214 ASSERT_EQ(TabRestoreService::TAB, entry->type); | 214 ASSERT_EQ(TabRestoreService::TAB, entry->type); |
| 215 TabRestoreService::Tab* tab = static_cast<TabRestoreService::Tab*>(entry); | 215 TabRestoreService::Tab* tab = static_cast<TabRestoreService::Tab*>(entry); |
| 216 tab->pinned = true; | 216 tab->pinned = true; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 237 } | 237 } |
| 238 | 238 |
| 239 // Make sure we persist entries to disk that have post data. | 239 // Make sure we persist entries to disk that have post data. |
| 240 TEST_F(TabRestoreServiceTest, DontPersistPostData) { | 240 TEST_F(TabRestoreServiceTest, DontPersistPostData) { |
| 241 AddThreeNavigations(); | 241 AddThreeNavigations(); |
| 242 controller().GetEntryAtIndex(0)->set_has_post_data(true); | 242 controller().GetEntryAtIndex(0)->set_has_post_data(true); |
| 243 controller().GetEntryAtIndex(1)->set_has_post_data(true); | 243 controller().GetEntryAtIndex(1)->set_has_post_data(true); |
| 244 controller().GetEntryAtIndex(2)->set_has_post_data(true); | 244 controller().GetEntryAtIndex(2)->set_has_post_data(true); |
| 245 | 245 |
| 246 // Have the service record the tab. | 246 // Have the service record the tab. |
| 247 service_->CreateHistoricalTab(&controller()); | 247 service_->CreateHistoricalTab(&controller(), -1); |
| 248 ASSERT_EQ(1U, service_->entries().size()); | 248 ASSERT_EQ(1U, service_->entries().size()); |
| 249 | 249 |
| 250 // Recreate the service and have it load the tabs. | 250 // Recreate the service and have it load the tabs. |
| 251 RecreateService(); | 251 RecreateService(); |
| 252 | 252 |
| 253 // One entry should be created. | 253 // One entry should be created. |
| 254 ASSERT_EQ(1U, service_->entries().size()); | 254 ASSERT_EQ(1U, service_->entries().size()); |
| 255 | 255 |
| 256 const TabRestoreService::Entry* restored_entry = service_->entries().front(); | 256 const TabRestoreService::Entry* restored_entry = service_->entries().front(); |
| 257 ASSERT_EQ(TabRestoreService::TAB, restored_entry->type); | 257 ASSERT_EQ(TabRestoreService::TAB, restored_entry->type); |
| 258 | 258 |
| 259 const TabRestoreService::Tab* restored_tab = | 259 const TabRestoreService::Tab* restored_tab = |
| 260 static_cast<const TabRestoreService::Tab*>(restored_entry); | 260 static_cast<const TabRestoreService::Tab*>(restored_entry); |
| 261 // There should be 3 navs. | 261 // There should be 3 navs. |
| 262 ASSERT_EQ(3U, restored_tab->navigations.size()); | 262 ASSERT_EQ(3U, restored_tab->navigations.size()); |
| 263 EXPECT_EQ(time_factory_->TimeNow().ToInternalValue(), | 263 EXPECT_EQ(time_factory_->TimeNow().ToInternalValue(), |
| 264 restored_tab->timestamp.ToInternalValue()); | 264 restored_tab->timestamp.ToInternalValue()); |
| 265 } | 265 } |
| 266 | 266 |
| 267 // Make sure we don't persist entries to disk that have post data. This | 267 // Make sure we don't persist entries to disk that have post data. This |
| 268 // differs from DontPersistPostData1 in that all the navigations have post | 268 // differs from DontPersistPostData1 in that all the navigations have post |
| 269 // data, so that nothing should be persisted. | 269 // data, so that nothing should be persisted. |
| 270 TEST_F(TabRestoreServiceTest, DontLoadTwice) { | 270 TEST_F(TabRestoreServiceTest, DontLoadTwice) { |
| 271 AddThreeNavigations(); | 271 AddThreeNavigations(); |
| 272 | 272 |
| 273 // Have the service record the tab. | 273 // Have the service record the tab. |
| 274 service_->CreateHistoricalTab(&controller()); | 274 service_->CreateHistoricalTab(&controller(), -1); |
| 275 ASSERT_EQ(1U, service_->entries().size()); | 275 ASSERT_EQ(1U, service_->entries().size()); |
| 276 | 276 |
| 277 // Recreate the service and have it load the tabs. | 277 // Recreate the service and have it load the tabs. |
| 278 RecreateService(); | 278 RecreateService(); |
| 279 | 279 |
| 280 service_->LoadTabsFromLastSession(); | 280 service_->LoadTabsFromLastSession(); |
| 281 | 281 |
| 282 // There should only be one entry. | 282 // There should only be one entry. |
| 283 ASSERT_EQ(1U, service_->entries().size()); | 283 ASSERT_EQ(1U, service_->entries().size()); |
| 284 } | 284 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 ASSERT_EQ(0U, service_->entries().size()); | 333 ASSERT_EQ(0U, service_->entries().size()); |
| 334 } | 334 } |
| 335 | 335 |
| 336 TEST_F(TabRestoreServiceTest, LoadPreviousSessionAndTabs) { | 336 TEST_F(TabRestoreServiceTest, LoadPreviousSessionAndTabs) { |
| 337 CreateSessionServiceWithOneWindow(false); | 337 CreateSessionServiceWithOneWindow(false); |
| 338 | 338 |
| 339 profile()->GetSessionService()->MoveCurrentSessionToLastSession(); | 339 profile()->GetSessionService()->MoveCurrentSessionToLastSession(); |
| 340 | 340 |
| 341 AddThreeNavigations(); | 341 AddThreeNavigations(); |
| 342 | 342 |
| 343 service_->CreateHistoricalTab(&controller()); | 343 service_->CreateHistoricalTab(&controller(), -1); |
| 344 | 344 |
| 345 RecreateService(); | 345 RecreateService(); |
| 346 | 346 |
| 347 // We should get back two entries, one from the previous session and one from | 347 // We should get back two entries, one from the previous session and one from |
| 348 // the tab restore service. The previous session entry should be first. | 348 // the tab restore service. The previous session entry should be first. |
| 349 ASSERT_EQ(2U, service_->entries().size()); | 349 ASSERT_EQ(2U, service_->entries().size()); |
| 350 // The first entry should come from the session service. | 350 // The first entry should come from the session service. |
| 351 TabRestoreService::Entry* entry = service_->entries().front(); | 351 TabRestoreService::Entry* entry = service_->entries().front(); |
| 352 ASSERT_EQ(TabRestoreService::WINDOW, entry->type); | 352 ASSERT_EQ(TabRestoreService::WINDOW, entry->type); |
| 353 TabRestoreService::Window* window = | 353 TabRestoreService::Window* window = |
| (...skipping 21 matching lines...) Expand all Loading... |
| 375 } | 375 } |
| 376 | 376 |
| 377 // Make sure pinned state is correctly loaded from session service. | 377 // Make sure pinned state is correctly loaded from session service. |
| 378 TEST_F(TabRestoreServiceTest, LoadPreviousSessionAndTabsPinned) { | 378 TEST_F(TabRestoreServiceTest, LoadPreviousSessionAndTabsPinned) { |
| 379 CreateSessionServiceWithOneWindow(true); | 379 CreateSessionServiceWithOneWindow(true); |
| 380 | 380 |
| 381 profile()->GetSessionService()->MoveCurrentSessionToLastSession(); | 381 profile()->GetSessionService()->MoveCurrentSessionToLastSession(); |
| 382 | 382 |
| 383 AddThreeNavigations(); | 383 AddThreeNavigations(); |
| 384 | 384 |
| 385 service_->CreateHistoricalTab(&controller()); | 385 service_->CreateHistoricalTab(&controller(), -1); |
| 386 | 386 |
| 387 RecreateService(); | 387 RecreateService(); |
| 388 | 388 |
| 389 // We should get back two entries, one from the previous session and one from | 389 // We should get back two entries, one from the previous session and one from |
| 390 // the tab restore service. The previous session entry should be first. | 390 // the tab restore service. The previous session entry should be first. |
| 391 ASSERT_EQ(2U, service_->entries().size()); | 391 ASSERT_EQ(2U, service_->entries().size()); |
| 392 // The first entry should come from the session service. | 392 // The first entry should come from the session service. |
| 393 TabRestoreService::Entry* entry = service_->entries().front(); | 393 TabRestoreService::Entry* entry = service_->entries().front(); |
| 394 ASSERT_EQ(TabRestoreService::WINDOW, entry->type); | 394 ASSERT_EQ(TabRestoreService::WINDOW, entry->type); |
| 395 TabRestoreService::Window* window = | 395 TabRestoreService::Window* window = |
| (...skipping 22 matching lines...) Expand all Loading... |
| 418 TEST_F(TabRestoreServiceTest, ManyWindowsInSessionService) { | 418 TEST_F(TabRestoreServiceTest, ManyWindowsInSessionService) { |
| 419 CreateSessionServiceWithOneWindow(false); | 419 CreateSessionServiceWithOneWindow(false); |
| 420 | 420 |
| 421 for (size_t i = 0; i < TabRestoreService::kMaxEntries; ++i) | 421 for (size_t i = 0; i < TabRestoreService::kMaxEntries; ++i) |
| 422 AddWindowWithOneTabToSessionService(false); | 422 AddWindowWithOneTabToSessionService(false); |
| 423 | 423 |
| 424 profile()->GetSessionService()->MoveCurrentSessionToLastSession(); | 424 profile()->GetSessionService()->MoveCurrentSessionToLastSession(); |
| 425 | 425 |
| 426 AddThreeNavigations(); | 426 AddThreeNavigations(); |
| 427 | 427 |
| 428 service_->CreateHistoricalTab(&controller()); | 428 service_->CreateHistoricalTab(&controller(), -1); |
| 429 | 429 |
| 430 RecreateService(); | 430 RecreateService(); |
| 431 | 431 |
| 432 // We should get back kMaxEntries entries. We added more, but | 432 // We should get back kMaxEntries entries. We added more, but |
| 433 // TabRestoreService only allows up to kMaxEntries. | 433 // TabRestoreService only allows up to kMaxEntries. |
| 434 ASSERT_EQ(TabRestoreService::kMaxEntries, service_->entries().size()); | 434 ASSERT_EQ(TabRestoreService::kMaxEntries, service_->entries().size()); |
| 435 | 435 |
| 436 // The first entry should come from the session service. | 436 // The first entry should come from the session service. |
| 437 TabRestoreService::Entry* entry = service_->entries().front(); | 437 TabRestoreService::Entry* entry = service_->entries().front(); |
| 438 ASSERT_EQ(TabRestoreService::WINDOW, entry->type); | 438 ASSERT_EQ(TabRestoreService::WINDOW, entry->type); |
| 439 TabRestoreService::Window* window = | 439 TabRestoreService::Window* window = |
| 440 static_cast<TabRestoreService::Window*>(entry); | 440 static_cast<TabRestoreService::Window*>(entry); |
| 441 ASSERT_EQ(1U, window->tabs.size()); | 441 ASSERT_EQ(1U, window->tabs.size()); |
| 442 EXPECT_EQ(0, window->selected_tab_index); | 442 EXPECT_EQ(0, window->selected_tab_index); |
| 443 EXPECT_EQ(0, window->timestamp.ToInternalValue()); | 443 EXPECT_EQ(0, window->timestamp.ToInternalValue()); |
| 444 ASSERT_EQ(1U, window->tabs[0].navigations.size()); | 444 ASSERT_EQ(1U, window->tabs[0].navigations.size()); |
| 445 EXPECT_EQ(0, window->tabs[0].current_navigation_index); | 445 EXPECT_EQ(0, window->tabs[0].current_navigation_index); |
| 446 EXPECT_EQ(0, window->tabs[0].timestamp.ToInternalValue()); | 446 EXPECT_EQ(0, window->tabs[0].timestamp.ToInternalValue()); |
| 447 EXPECT_TRUE(url1_ == window->tabs[0].navigations[0].virtual_url()); | 447 EXPECT_TRUE(url1_ == window->tabs[0].navigations[0].virtual_url()); |
| 448 } | 448 } |
| 449 | 449 |
| 450 // Makes sure we restore the time stamp correctly. | 450 // Makes sure we restore the time stamp correctly. |
| 451 TEST_F(TabRestoreServiceTest, TimestampSurvivesRestore) { | 451 TEST_F(TabRestoreServiceTest, TimestampSurvivesRestore) { |
| 452 base::Time tab_timestamp(base::Time::FromInternalValue(123456789)); | 452 base::Time tab_timestamp(base::Time::FromInternalValue(123456789)); |
| 453 | 453 |
| 454 AddThreeNavigations(); | 454 AddThreeNavigations(); |
| 455 | 455 |
| 456 // Have the service record the tab. | 456 // Have the service record the tab. |
| 457 service_->CreateHistoricalTab(&controller()); | 457 service_->CreateHistoricalTab(&controller(), -1); |
| 458 | 458 |
| 459 // Make sure an entry was created. | 459 // Make sure an entry was created. |
| 460 ASSERT_EQ(1U, service_->entries().size()); | 460 ASSERT_EQ(1U, service_->entries().size()); |
| 461 | 461 |
| 462 // Make sure the entry matches. | 462 // Make sure the entry matches. |
| 463 TabRestoreService::Entry* entry = service_->entries().front(); | 463 TabRestoreService::Entry* entry = service_->entries().front(); |
| 464 ASSERT_EQ(TabRestoreService::TAB, entry->type); | 464 ASSERT_EQ(TabRestoreService::TAB, entry->type); |
| 465 TabRestoreService::Tab* tab = static_cast<TabRestoreService::Tab*>(entry); | 465 TabRestoreService::Tab* tab = static_cast<TabRestoreService::Tab*>(entry); |
| 466 tab->timestamp = tab_timestamp; | 466 tab->timestamp = tab_timestamp; |
| 467 | 467 |
| 468 // Set this, otherwise previous session won't be loaded. | 468 // Set this, otherwise previous session won't be loaded. |
| 469 profile()->set_last_session_exited_cleanly(false); | 469 profile()->set_last_session_exited_cleanly(false); |
| 470 | 470 |
| 471 RecreateService(); | 471 RecreateService(); |
| 472 | 472 |
| 473 // One entry should be created. | 473 // One entry should be created. |
| 474 ASSERT_EQ(1U, service_->entries().size()); | 474 ASSERT_EQ(1U, service_->entries().size()); |
| 475 | 475 |
| 476 // And verify the entry. | 476 // And verify the entry. |
| 477 TabRestoreService::Entry* restored_entry = service_->entries().front(); | 477 TabRestoreService::Entry* restored_entry = service_->entries().front(); |
| 478 ASSERT_EQ(TabRestoreService::TAB, restored_entry->type); | 478 ASSERT_EQ(TabRestoreService::TAB, restored_entry->type); |
| 479 TabRestoreService::Tab* restored_tab = | 479 TabRestoreService::Tab* restored_tab = |
| 480 static_cast<TabRestoreService::Tab*>(restored_entry); | 480 static_cast<TabRestoreService::Tab*>(restored_entry); |
| 481 EXPECT_EQ(tab_timestamp.ToInternalValue(), | 481 EXPECT_EQ(tab_timestamp.ToInternalValue(), |
| 482 restored_tab->timestamp.ToInternalValue()); | 482 restored_tab->timestamp.ToInternalValue()); |
| 483 } | 483 } |
| OLD | NEW |