OLD | NEW |
1 // Copyright (c) 2006-2008 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/defaults.h" | 5 #include "chrome/browser/defaults.h" |
6 #include "chrome/browser/renderer_host/test/test_render_view_host.h" | 6 #include "chrome/browser/renderer_host/test/test_render_view_host.h" |
7 #include "chrome/browser/sessions/session_types.h" | 7 #include "chrome/browser/sessions/session_types.h" |
8 #include "chrome/browser/sessions/session_service.h" | 8 #include "chrome/browser/sessions/session_service.h" |
9 #include "chrome/browser/sessions/tab_restore_service.h" | 9 #include "chrome/browser/sessions/tab_restore_service.h" |
10 #include "chrome/browser/tab_contents/navigation_entry.h" | 10 #include "chrome/browser/tab_contents/navigation_entry.h" |
11 #include "chrome/test/testing_profile.h" | 11 #include "chrome/test/testing_profile.h" |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 EXPECT_TRUE(url1_ == tab->navigations[0].url()); | 187 EXPECT_TRUE(url1_ == tab->navigations[0].url()); |
188 EXPECT_TRUE(url2_ == tab->navigations[1].url()); | 188 EXPECT_TRUE(url2_ == tab->navigations[1].url()); |
189 EXPECT_TRUE(url3_ == tab->navigations[2].url()); | 189 EXPECT_TRUE(url3_ == tab->navigations[2].url()); |
190 EXPECT_EQ(2, tab->current_navigation_index); | 190 EXPECT_EQ(2, tab->current_navigation_index); |
191 EXPECT_EQ(time_factory_->TimeNow().ToInternalValue(), | 191 EXPECT_EQ(time_factory_->TimeNow().ToInternalValue(), |
192 tab->timestamp.ToInternalValue()); | 192 tab->timestamp.ToInternalValue()); |
193 } | 193 } |
194 | 194 |
195 // Tests restoring a single pinned tab. | 195 // Tests restoring a single pinned tab. |
196 TEST_F(TabRestoreServiceTest, RestorePinnedAndApp) { | 196 TEST_F(TabRestoreServiceTest, RestorePinnedAndApp) { |
197 if (!browser_defaults::kEnablePinnedTabs) | |
198 return; | |
199 | |
200 AddThreeNavigations(); | 197 AddThreeNavigations(); |
201 | 198 |
202 // Have the service record the tab. | 199 // Have the service record the tab. |
203 service_->CreateHistoricalTab(&controller()); | 200 service_->CreateHistoricalTab(&controller()); |
204 | 201 |
205 // One entry should be created. | 202 // One entry should be created. |
206 ASSERT_EQ(1U, service_->entries().size()); | 203 ASSERT_EQ(1U, service_->entries().size()); |
207 | 204 |
208 // We have to explicitly mark the tab as pinned as there is no browser for | 205 // We have to explicitly mark the tab as pinned as there is no browser for |
209 // these tests. | 206 // these tests. |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 EXPECT_EQ(2, tab->current_navigation_index); | 363 EXPECT_EQ(2, tab->current_navigation_index); |
367 EXPECT_EQ(time_factory_->TimeNow().ToInternalValue(), | 364 EXPECT_EQ(time_factory_->TimeNow().ToInternalValue(), |
368 tab->timestamp.ToInternalValue()); | 365 tab->timestamp.ToInternalValue()); |
369 EXPECT_TRUE(url1_ == tab->navigations[0].url()); | 366 EXPECT_TRUE(url1_ == tab->navigations[0].url()); |
370 EXPECT_TRUE(url2_ == tab->navigations[1].url()); | 367 EXPECT_TRUE(url2_ == tab->navigations[1].url()); |
371 EXPECT_TRUE(url3_ == tab->navigations[2].url()); | 368 EXPECT_TRUE(url3_ == tab->navigations[2].url()); |
372 } | 369 } |
373 | 370 |
374 // Make sure pinned state is correctly loaded from session service. | 371 // Make sure pinned state is correctly loaded from session service. |
375 TEST_F(TabRestoreServiceTest, LoadPreviousSessionAndTabsPinned) { | 372 TEST_F(TabRestoreServiceTest, LoadPreviousSessionAndTabsPinned) { |
376 if (!browser_defaults::kEnablePinnedTabs) | |
377 return; | |
378 | |
379 CreateSessionServiceWithOneWindow(true); | 373 CreateSessionServiceWithOneWindow(true); |
380 | 374 |
381 profile()->GetSessionService()->MoveCurrentSessionToLastSession(); | 375 profile()->GetSessionService()->MoveCurrentSessionToLastSession(); |
382 | 376 |
383 AddThreeNavigations(); | 377 AddThreeNavigations(); |
384 | 378 |
385 service_->CreateHistoricalTab(&controller()); | 379 service_->CreateHistoricalTab(&controller()); |
386 | 380 |
387 RecreateService(); | 381 RecreateService(); |
388 | 382 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 | 469 |
476 // And verify the entry. | 470 // And verify the entry. |
477 TabRestoreService::Entry* restored_entry = service_->entries().front(); | 471 TabRestoreService::Entry* restored_entry = service_->entries().front(); |
478 ASSERT_EQ(TabRestoreService::TAB, restored_entry->type); | 472 ASSERT_EQ(TabRestoreService::TAB, restored_entry->type); |
479 TabRestoreService::Tab* restored_tab = | 473 TabRestoreService::Tab* restored_tab = |
480 static_cast<TabRestoreService::Tab*>(restored_entry); | 474 static_cast<TabRestoreService::Tab*>(restored_entry); |
481 EXPECT_EQ(tab_timestamp.ToInternalValue(), | 475 EXPECT_EQ(tab_timestamp.ToInternalValue(), |
482 restored_tab->timestamp.ToInternalValue()); | 476 restored_tab->timestamp.ToInternalValue()); |
483 } | 477 } |
484 | 478 |
OLD | NEW |