OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/renderer_host/test/test_render_view_host.h" | 5 #include "chrome/browser/renderer_host/test/test_render_view_host.h" |
6 #include "chrome/browser/sessions/session_types.h" | 6 #include "chrome/browser/sessions/session_types.h" |
7 #include "chrome/browser/sessions/tab_restore_service.h" | 7 #include "chrome/browser/sessions/tab_restore_service.h" |
8 #include "chrome/browser/tab_contents/navigation_entry.h" | 8 #include "chrome/browser/tab_contents/navigation_entry.h" |
9 #include "chrome/test/testing_profile.h" | 9 #include "chrome/test/testing_profile.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 ASSERT_FALSE(tab->pinned); | 357 ASSERT_FALSE(tab->pinned); |
358 ASSERT_EQ(3U, tab->navigations.size()); | 358 ASSERT_EQ(3U, tab->navigations.size()); |
359 EXPECT_EQ(2, tab->current_navigation_index); | 359 EXPECT_EQ(2, tab->current_navigation_index); |
360 EXPECT_EQ(time_factory_->TimeNow().ToInternalValue(), | 360 EXPECT_EQ(time_factory_->TimeNow().ToInternalValue(), |
361 tab->timestamp.ToInternalValue()); | 361 tab->timestamp.ToInternalValue()); |
362 EXPECT_TRUE(url1_ == tab->navigations[0].url()); | 362 EXPECT_TRUE(url1_ == tab->navigations[0].url()); |
363 EXPECT_TRUE(url2_ == tab->navigations[1].url()); | 363 EXPECT_TRUE(url2_ == tab->navigations[1].url()); |
364 EXPECT_TRUE(url3_ == tab->navigations[2].url()); | 364 EXPECT_TRUE(url3_ == tab->navigations[2].url()); |
365 } | 365 } |
366 | 366 |
| 367 #if defined(ENABLE_PINNED_TABS) |
367 // Make sure pinned state is correctly loaded from session service. | 368 // Make sure pinned state is correctly loaded from session service. |
368 TEST_F(TabRestoreServiceTest, LoadPreviousSessionAndTabsPinned) { | 369 TEST_F(TabRestoreServiceTest, LoadPreviousSessionAndTabsPinned) { |
369 CreateSessionServiceWithOneWindow(true); | 370 CreateSessionServiceWithOneWindow(true); |
370 | 371 |
371 profile()->GetSessionService()->MoveCurrentSessionToLastSession(); | 372 profile()->GetSessionService()->MoveCurrentSessionToLastSession(); |
372 | 373 |
373 AddThreeNavigations(); | 374 AddThreeNavigations(); |
374 | 375 |
375 service_->CreateHistoricalTab(&controller()); | 376 service_->CreateHistoricalTab(&controller()); |
376 | 377 |
(...skipping 18 matching lines...) Expand all Loading... |
395 entry = *(++service_->entries().begin()); | 396 entry = *(++service_->entries().begin()); |
396 ASSERT_EQ(TabRestoreService::TAB, entry->type); | 397 ASSERT_EQ(TabRestoreService::TAB, entry->type); |
397 TabRestoreService::Tab* tab = static_cast<TabRestoreService::Tab*>(entry); | 398 TabRestoreService::Tab* tab = static_cast<TabRestoreService::Tab*>(entry); |
398 ASSERT_FALSE(tab->pinned); | 399 ASSERT_FALSE(tab->pinned); |
399 ASSERT_EQ(3U, tab->navigations.size()); | 400 ASSERT_EQ(3U, tab->navigations.size()); |
400 EXPECT_EQ(2, tab->current_navigation_index); | 401 EXPECT_EQ(2, tab->current_navigation_index); |
401 EXPECT_TRUE(url1_ == tab->navigations[0].url()); | 402 EXPECT_TRUE(url1_ == tab->navigations[0].url()); |
402 EXPECT_TRUE(url2_ == tab->navigations[1].url()); | 403 EXPECT_TRUE(url2_ == tab->navigations[1].url()); |
403 EXPECT_TRUE(url3_ == tab->navigations[2].url()); | 404 EXPECT_TRUE(url3_ == tab->navigations[2].url()); |
404 } | 405 } |
| 406 #endif |
405 | 407 |
406 // Creates TabRestoreService::kMaxEntries + 1 windows in the session service | 408 // Creates TabRestoreService::kMaxEntries + 1 windows in the session service |
407 // and makes sure we only get back TabRestoreService::kMaxEntries on restore. | 409 // and makes sure we only get back TabRestoreService::kMaxEntries on restore. |
408 TEST_F(TabRestoreServiceTest, ManyWindowsInSessionService) { | 410 TEST_F(TabRestoreServiceTest, ManyWindowsInSessionService) { |
409 CreateSessionServiceWithOneWindow(false); | 411 CreateSessionServiceWithOneWindow(false); |
410 | 412 |
411 for (size_t i = 0; i < TabRestoreService::kMaxEntries; ++i) | 413 for (size_t i = 0; i < TabRestoreService::kMaxEntries; ++i) |
412 AddWindowWithOneTabToSessionService(false); | 414 AddWindowWithOneTabToSessionService(false); |
413 | 415 |
414 profile()->GetSessionService()->MoveCurrentSessionToLastSession(); | 416 profile()->GetSessionService()->MoveCurrentSessionToLastSession(); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 | 467 |
466 // And verify the entry. | 468 // And verify the entry. |
467 TabRestoreService::Entry* restored_entry = service_->entries().front(); | 469 TabRestoreService::Entry* restored_entry = service_->entries().front(); |
468 ASSERT_EQ(TabRestoreService::TAB, restored_entry->type); | 470 ASSERT_EQ(TabRestoreService::TAB, restored_entry->type); |
469 TabRestoreService::Tab* restored_tab = | 471 TabRestoreService::Tab* restored_tab = |
470 static_cast<TabRestoreService::Tab*>(restored_entry); | 472 static_cast<TabRestoreService::Tab*>(restored_entry); |
471 EXPECT_EQ(tab_timestamp.ToInternalValue(), | 473 EXPECT_EQ(tab_timestamp.ToInternalValue(), |
472 restored_tab->timestamp.ToInternalValue()); | 474 restored_tab->timestamp.ToInternalValue()); |
473 } | 475 } |
474 | 476 |
OLD | NEW |