Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Side by Side Diff: chrome/browser/sessions/tab_restore_service_browsertest.cc

Issue 10831308: Revert 151036 - Speculative revert to see if this change introduced a performance regression on Mac… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/stringprintf.h" 5 #include "base/stringprintf.h"
6 #include "base/utf_string_conversions.h" 6 #include "base/utf_string_conversions.h"
7 #include "chrome/browser/sessions/session_service_factory.h" 7 #include "chrome/browser/sessions/session_service_factory.h"
8 #include "chrome/browser/sessions/session_service.h" 8 #include "chrome/browser/sessions/session_service.h"
9 #include "chrome/browser/sessions/session_types.h" 9 #include "chrome/browser/sessions/session_types.h"
10 #include "chrome/browser/sessions/tab_restore_service.h" 10 #include "chrome/browser/sessions/tab_restore_service.h"
11 #include "chrome/browser/sessions/tab_restore_service_factory.h" 11 #include "chrome/browser/sessions/tab_restore_service_factory.h"
12 #include "chrome/browser/ui/browser_window.h" 12 #include "chrome/browser/ui/browser_window.h"
13 #include "chrome/common/chrome_notification_types.h" 13 #include "chrome/common/chrome_notification_types.h"
14 #include "chrome/common/url_constants.h" 14 #include "chrome/common/url_constants.h"
15 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 15 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
16 #include "chrome/test/base/chrome_render_view_test.h" 16 #include "chrome/test/base/chrome_render_view_test.h"
17 #include "chrome/test/base/in_process_browser_test.h" 17 #include "chrome/test/base/in_process_browser_test.h"
18 #include "chrome/test/base/testing_profile.h" 18 #include "chrome/test/base/testing_profile.h"
19 #include "content/public/browser/browser_thread.h"
19 #include "content/public/browser/navigation_controller.h" 20 #include "content/public/browser/navigation_controller.h"
20 #include "content/public/browser/navigation_entry.h" 21 #include "content/public/browser/navigation_entry.h"
21 #include "content/public/browser/notification_service.h" 22 #include "content/public/browser/notification_service.h"
22 #include "content/public/browser/notification_types.h" 23 #include "content/public/browser/notification_types.h"
23 #include "content/public/test/render_view_test.h" 24 #include "content/public/test/render_view_test.h"
25 #include "content/public/test/test_browser_thread.h"
24 #include "content/public/test/test_utils.h" 26 #include "content/public/test/test_utils.h"
25 #include "content/public/test/web_contents_tester.h" 27 #include "content/public/test/web_contents_tester.h"
26 #include "testing/gtest/include/gtest/gtest.h" 28 #include "testing/gtest/include/gtest/gtest.h"
27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" 29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h"
28 30
29 typedef TabRestoreService::Tab Tab; 31 typedef TabRestoreService::Tab Tab;
30 typedef TabRestoreService::Window Window; 32 typedef TabRestoreService::Window Window;
31 using content::WebContentsTester; 33 using content::WebContentsTester;
32 34
33 using content::NavigationEntry; 35 using content::NavigationEntry;
34 36
35 // Create subclass that overrides TimeNow so that we can control the time used 37 // Create subclass that overrides TimeNow so that we can control the time used
36 // for closed tabs and windows. 38 // for closed tabs and windows.
37 class TabRestoreTimeFactory : public TabRestoreService::TimeFactory { 39 class TabRestoreTimeFactory : public TabRestoreService::TimeFactory {
38 public: 40 public:
39 TabRestoreTimeFactory() : time_(base::Time::Now()) {} 41 TabRestoreTimeFactory() : time_(base::Time::Now()) {}
40 42
41 virtual ~TabRestoreTimeFactory() {} 43 virtual ~TabRestoreTimeFactory() {}
42 44
43 virtual base::Time TimeNow() { 45 virtual base::Time TimeNow() {
44 return time_; 46 return time_;
45 } 47 }
46 48
47 private: 49 private:
48 base::Time time_; 50 base::Time time_;
49 }; 51 };
50 52
51 class TabRestoreServiceTest : public ChromeRenderViewHostTestHarness { 53 class TabRestoreServiceTest : public ChromeRenderViewHostTestHarness {
52 public: 54 public:
53 TabRestoreServiceTest() { 55 TabRestoreServiceTest()
56 : ui_thread_(content::BrowserThread::UI, &message_loop_) {
54 url1_ = GURL("http://1"); 57 url1_ = GURL("http://1");
55 url2_ = GURL("http://2"); 58 url2_ = GURL("http://2");
56 url3_ = GURL("http://3"); 59 url3_ = GURL("http://3");
57 } 60 }
58 61
59 ~TabRestoreServiceTest() { 62 ~TabRestoreServiceTest() {
60 } 63 }
61 64
62 protected: 65 protected:
63 // testing::Test overrides 66 // testing::Test overrides
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 profile()->set_last_session_exited_cleanly(false); 136 profile()->set_last_session_exited_cleanly(false);
134 } 137 }
135 138
136 GURL url1_; 139 GURL url1_;
137 GURL url2_; 140 GURL url2_;
138 GURL url3_; 141 GURL url3_;
139 scoped_ptr<TabRestoreService> service_; 142 scoped_ptr<TabRestoreService> service_;
140 TabRestoreTimeFactory* time_factory_; 143 TabRestoreTimeFactory* time_factory_;
141 content::RenderViewTest::RendererWebKitPlatformSupportImplNoSandbox 144 content::RenderViewTest::RendererWebKitPlatformSupportImplNoSandbox
142 webkit_platform_support_; 145 webkit_platform_support_;
146 content::TestBrowserThread ui_thread_;
143 }; 147 };
144 148
145 TEST_F(TabRestoreServiceTest, Basic) { 149 TEST_F(TabRestoreServiceTest, Basic) {
146 AddThreeNavigations(); 150 AddThreeNavigations();
147 151
148 // Have the service record the tab. 152 // Have the service record the tab.
149 service_->CreateHistoricalTab(&controller(), -1); 153 service_->CreateHistoricalTab(contents(), -1);
150 154
151 // Make sure an entry was created. 155 // Make sure an entry was created.
152 ASSERT_EQ(1U, service_->entries().size()); 156 ASSERT_EQ(1U, service_->entries().size());
153 157
154 // Make sure the entry matches. 158 // Make sure the entry matches.
155 TabRestoreService::Entry* entry = service_->entries().front(); 159 TabRestoreService::Entry* entry = service_->entries().front();
156 ASSERT_EQ(TabRestoreService::TAB, entry->type); 160 ASSERT_EQ(TabRestoreService::TAB, entry->type);
157 Tab* tab = static_cast<Tab*>(entry); 161 Tab* tab = static_cast<Tab*>(entry);
158 EXPECT_FALSE(tab->pinned); 162 EXPECT_FALSE(tab->pinned);
159 EXPECT_TRUE(tab->extension_app_id.empty()); 163 EXPECT_TRUE(tab->extension_app_id.empty());
160 ASSERT_EQ(3U, tab->navigations.size()); 164 ASSERT_EQ(3U, tab->navigations.size());
161 EXPECT_TRUE(url1_ == tab->navigations[0].virtual_url()); 165 EXPECT_TRUE(url1_ == tab->navigations[0].virtual_url());
162 EXPECT_TRUE(url2_ == tab->navigations[1].virtual_url()); 166 EXPECT_TRUE(url2_ == tab->navigations[1].virtual_url());
163 EXPECT_TRUE(url3_ == tab->navigations[2].virtual_url()); 167 EXPECT_TRUE(url3_ == tab->navigations[2].virtual_url());
164 EXPECT_EQ(2, tab->current_navigation_index); 168 EXPECT_EQ(2, tab->current_navigation_index);
165 EXPECT_EQ(time_factory_->TimeNow().ToInternalValue(), 169 EXPECT_EQ(time_factory_->TimeNow().ToInternalValue(),
166 tab->timestamp.ToInternalValue()); 170 tab->timestamp.ToInternalValue());
167 171
168 NavigateToIndex(1); 172 NavigateToIndex(1);
169 173
170 // And check again. 174 // And check again.
171 service_->CreateHistoricalTab(&controller(), -1); 175 service_->CreateHistoricalTab(contents(), -1);
172 176
173 // There should be two entries now. 177 // There should be two entries now.
174 ASSERT_EQ(2U, service_->entries().size()); 178 ASSERT_EQ(2U, service_->entries().size());
175 179
176 // Make sure the entry matches 180 // Make sure the entry matches
177 entry = service_->entries().front(); 181 entry = service_->entries().front();
178 ASSERT_EQ(TabRestoreService::TAB, entry->type); 182 ASSERT_EQ(TabRestoreService::TAB, entry->type);
179 tab = static_cast<Tab*>(entry); 183 tab = static_cast<Tab*>(entry);
180 EXPECT_FALSE(tab->pinned); 184 EXPECT_FALSE(tab->pinned);
181 ASSERT_EQ(3U, tab->navigations.size()); 185 ASSERT_EQ(3U, tab->navigations.size());
182 EXPECT_EQ(url1_, tab->navigations[0].virtual_url()); 186 EXPECT_EQ(url1_, tab->navigations[0].virtual_url());
183 EXPECT_EQ(url2_, tab->navigations[1].virtual_url()); 187 EXPECT_EQ(url2_, tab->navigations[1].virtual_url());
184 EXPECT_EQ(url3_, tab->navigations[2].virtual_url()); 188 EXPECT_EQ(url3_, tab->navigations[2].virtual_url());
185 EXPECT_EQ(1, tab->current_navigation_index); 189 EXPECT_EQ(1, tab->current_navigation_index);
186 EXPECT_EQ(time_factory_->TimeNow().ToInternalValue(), 190 EXPECT_EQ(time_factory_->TimeNow().ToInternalValue(),
187 tab->timestamp.ToInternalValue()); 191 tab->timestamp.ToInternalValue());
188 } 192 }
189 193
190 // Make sure TabRestoreService doesn't create an entry for a tab with no 194 // Make sure TabRestoreService doesn't create an entry for a tab with no
191 // navigations. 195 // navigations.
192 TEST_F(TabRestoreServiceTest, DontCreateEmptyTab) { 196 TEST_F(TabRestoreServiceTest, DontCreateEmptyTab) {
193 service_->CreateHistoricalTab(&controller(), -1); 197 service_->CreateHistoricalTab(contents(), -1);
194 EXPECT_TRUE(service_->entries().empty()); 198 EXPECT_TRUE(service_->entries().empty());
195 } 199 }
196 200
197 // Tests restoring a single tab. 201 // Tests restoring a single tab.
198 TEST_F(TabRestoreServiceTest, Restore) { 202 TEST_F(TabRestoreServiceTest, Restore) {
199 AddThreeNavigations(); 203 AddThreeNavigations();
200 204
201 // Have the service record the tab. 205 // Have the service record the tab.
202 service_->CreateHistoricalTab(&controller(), -1); 206 service_->CreateHistoricalTab(contents(), -1);
203 207
204 // Recreate the service and have it load the tabs. 208 // Recreate the service and have it load the tabs.
205 RecreateService(); 209 RecreateService();
206 210
207 // One entry should be created. 211 // One entry should be created.
208 ASSERT_EQ(1U, service_->entries().size()); 212 ASSERT_EQ(1U, service_->entries().size());
209 213
210 // And verify the entry. 214 // And verify the entry.
211 TabRestoreService::Entry* entry = service_->entries().front(); 215 TabRestoreService::Entry* entry = service_->entries().front();
212 ASSERT_EQ(TabRestoreService::TAB, entry->type); 216 ASSERT_EQ(TabRestoreService::TAB, entry->type);
213 Tab* tab = static_cast<Tab*>(entry); 217 Tab* tab = static_cast<Tab*>(entry);
214 EXPECT_FALSE(tab->pinned); 218 EXPECT_FALSE(tab->pinned);
215 ASSERT_EQ(3U, tab->navigations.size()); 219 ASSERT_EQ(3U, tab->navigations.size());
216 EXPECT_TRUE(url1_ == tab->navigations[0].virtual_url()); 220 EXPECT_TRUE(url1_ == tab->navigations[0].virtual_url());
217 EXPECT_TRUE(url2_ == tab->navigations[1].virtual_url()); 221 EXPECT_TRUE(url2_ == tab->navigations[1].virtual_url());
218 EXPECT_TRUE(url3_ == tab->navigations[2].virtual_url()); 222 EXPECT_TRUE(url3_ == tab->navigations[2].virtual_url());
219 EXPECT_EQ(2, tab->current_navigation_index); 223 EXPECT_EQ(2, tab->current_navigation_index);
220 EXPECT_EQ(time_factory_->TimeNow().ToInternalValue(), 224 EXPECT_EQ(time_factory_->TimeNow().ToInternalValue(),
221 tab->timestamp.ToInternalValue()); 225 tab->timestamp.ToInternalValue());
222 } 226 }
223 227
224 // Tests restoring a single pinned tab. 228 // Tests restoring a single pinned tab.
225 TEST_F(TabRestoreServiceTest, RestorePinnedAndApp) { 229 TEST_F(TabRestoreServiceTest, RestorePinnedAndApp) {
226 AddThreeNavigations(); 230 AddThreeNavigations();
227 231
228 // Have the service record the tab. 232 // Have the service record the tab.
229 service_->CreateHistoricalTab(&controller(), -1); 233 service_->CreateHistoricalTab(contents(), -1);
230 234
231 // One entry should be created. 235 // One entry should be created.
232 ASSERT_EQ(1U, service_->entries().size()); 236 ASSERT_EQ(1U, service_->entries().size());
233 237
234 // We have to explicitly mark the tab as pinned as there is no browser for 238 // We have to explicitly mark the tab as pinned as there is no browser for
235 // these tests. 239 // these tests.
236 TabRestoreService::Entry* entry = service_->entries().front(); 240 TabRestoreService::Entry* entry = service_->entries().front();
237 ASSERT_EQ(TabRestoreService::TAB, entry->type); 241 ASSERT_EQ(TabRestoreService::TAB, entry->type);
238 Tab* tab = static_cast<Tab*>(entry); 242 Tab* tab = static_cast<Tab*>(entry);
239 tab->pinned = true; 243 tab->pinned = true;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 #endif // defined(USE_AURA) 293 #endif // defined(USE_AURA)
290 294
291 // Make sure we persist entries to disk that have post data. 295 // Make sure we persist entries to disk that have post data.
292 TEST_F(TabRestoreServiceTest, DontPersistPostData) { 296 TEST_F(TabRestoreServiceTest, DontPersistPostData) {
293 AddThreeNavigations(); 297 AddThreeNavigations();
294 controller().GetEntryAtIndex(0)->SetHasPostData(true); 298 controller().GetEntryAtIndex(0)->SetHasPostData(true);
295 controller().GetEntryAtIndex(1)->SetHasPostData(true); 299 controller().GetEntryAtIndex(1)->SetHasPostData(true);
296 controller().GetEntryAtIndex(2)->SetHasPostData(true); 300 controller().GetEntryAtIndex(2)->SetHasPostData(true);
297 301
298 // Have the service record the tab. 302 // Have the service record the tab.
299 service_->CreateHistoricalTab(&controller(), -1); 303 service_->CreateHistoricalTab(contents(), -1);
300 ASSERT_EQ(1U, service_->entries().size()); 304 ASSERT_EQ(1U, service_->entries().size());
301 305
302 // Recreate the service and have it load the tabs. 306 // Recreate the service and have it load the tabs.
303 RecreateService(); 307 RecreateService();
304 308
305 // One entry should be created. 309 // One entry should be created.
306 ASSERT_EQ(1U, service_->entries().size()); 310 ASSERT_EQ(1U, service_->entries().size());
307 311
308 const TabRestoreService::Entry* restored_entry = service_->entries().front(); 312 const TabRestoreService::Entry* restored_entry = service_->entries().front();
309 ASSERT_EQ(TabRestoreService::TAB, restored_entry->type); 313 ASSERT_EQ(TabRestoreService::TAB, restored_entry->type);
310 314
311 const Tab* restored_tab = 315 const Tab* restored_tab =
312 static_cast<const Tab*>(restored_entry); 316 static_cast<const Tab*>(restored_entry);
313 // There should be 3 navs. 317 // There should be 3 navs.
314 ASSERT_EQ(3U, restored_tab->navigations.size()); 318 ASSERT_EQ(3U, restored_tab->navigations.size());
315 EXPECT_EQ(time_factory_->TimeNow().ToInternalValue(), 319 EXPECT_EQ(time_factory_->TimeNow().ToInternalValue(),
316 restored_tab->timestamp.ToInternalValue()); 320 restored_tab->timestamp.ToInternalValue());
317 } 321 }
318 322
319 // Make sure we don't persist entries to disk that have post data. This 323 // Make sure we don't persist entries to disk that have post data. This
320 // differs from DontPersistPostData1 in that all the navigations have post 324 // differs from DontPersistPostData1 in that all the navigations have post
321 // data, so that nothing should be persisted. 325 // data, so that nothing should be persisted.
322 TEST_F(TabRestoreServiceTest, DontLoadTwice) { 326 TEST_F(TabRestoreServiceTest, DontLoadTwice) {
323 AddThreeNavigations(); 327 AddThreeNavigations();
324 328
325 // Have the service record the tab. 329 // Have the service record the tab.
326 service_->CreateHistoricalTab(&controller(), -1); 330 service_->CreateHistoricalTab(contents(), -1);
327 ASSERT_EQ(1U, service_->entries().size()); 331 ASSERT_EQ(1U, service_->entries().size());
328 332
329 // Recreate the service and have it load the tabs. 333 // Recreate the service and have it load the tabs.
330 RecreateService(); 334 RecreateService();
331 335
332 service_->LoadTabsFromLastSession(); 336 service_->LoadTabsFromLastSession();
333 337
334 // There should only be one entry. 338 // There should only be one entry.
335 ASSERT_EQ(1U, service_->entries().size()); 339 ASSERT_EQ(1U, service_->entries().size());
336 } 340 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 } 393 }
390 394
391 TEST_F(TabRestoreServiceTest, LoadPreviousSessionAndTabs) { 395 TEST_F(TabRestoreServiceTest, LoadPreviousSessionAndTabs) {
392 CreateSessionServiceWithOneWindow(false); 396 CreateSessionServiceWithOneWindow(false);
393 397
394 SessionServiceFactory::GetForProfile(profile())-> 398 SessionServiceFactory::GetForProfile(profile())->
395 MoveCurrentSessionToLastSession(); 399 MoveCurrentSessionToLastSession();
396 400
397 AddThreeNavigations(); 401 AddThreeNavigations();
398 402
399 service_->CreateHistoricalTab(&controller(), -1); 403 service_->CreateHistoricalTab(contents(), -1);
400 404
401 RecreateService(); 405 RecreateService();
402 406
403 // We should get back two entries, one from the previous session and one from 407 // We should get back two entries, one from the previous session and one from
404 // the tab restore service. The previous session entry should be first. 408 // the tab restore service. The previous session entry should be first.
405 ASSERT_EQ(2U, service_->entries().size()); 409 ASSERT_EQ(2U, service_->entries().size());
406 // The first entry should come from the session service. 410 // The first entry should come from the session service.
407 TabRestoreService::Entry* entry = service_->entries().front(); 411 TabRestoreService::Entry* entry = service_->entries().front();
408 ASSERT_EQ(TabRestoreService::WINDOW, entry->type); 412 ASSERT_EQ(TabRestoreService::WINDOW, entry->type);
409 TabRestoreService::Window* window = 413 TabRestoreService::Window* window =
(...skipping 22 matching lines...) Expand all
432 436
433 // Make sure pinned state is correctly loaded from session service. 437 // Make sure pinned state is correctly loaded from session service.
434 TEST_F(TabRestoreServiceTest, LoadPreviousSessionAndTabsPinned) { 438 TEST_F(TabRestoreServiceTest, LoadPreviousSessionAndTabsPinned) {
435 CreateSessionServiceWithOneWindow(true); 439 CreateSessionServiceWithOneWindow(true);
436 440
437 SessionServiceFactory::GetForProfile(profile())-> 441 SessionServiceFactory::GetForProfile(profile())->
438 MoveCurrentSessionToLastSession(); 442 MoveCurrentSessionToLastSession();
439 443
440 AddThreeNavigations(); 444 AddThreeNavigations();
441 445
442 service_->CreateHistoricalTab(&controller(), -1); 446 service_->CreateHistoricalTab(contents(), -1);
443 447
444 RecreateService(); 448 RecreateService();
445 449
446 // We should get back two entries, one from the previous session and one from 450 // We should get back two entries, one from the previous session and one from
447 // the tab restore service. The previous session entry should be first. 451 // the tab restore service. The previous session entry should be first.
448 ASSERT_EQ(2U, service_->entries().size()); 452 ASSERT_EQ(2U, service_->entries().size());
449 // The first entry should come from the session service. 453 // The first entry should come from the session service.
450 TabRestoreService::Entry* entry = service_->entries().front(); 454 TabRestoreService::Entry* entry = service_->entries().front();
451 ASSERT_EQ(TabRestoreService::WINDOW, entry->type); 455 ASSERT_EQ(TabRestoreService::WINDOW, entry->type);
452 TabRestoreService::Window* window = 456 TabRestoreService::Window* window =
(...skipping 23 matching lines...) Expand all
476 CreateSessionServiceWithOneWindow(false); 480 CreateSessionServiceWithOneWindow(false);
477 481
478 for (size_t i = 0; i < TabRestoreService::kMaxEntries; ++i) 482 for (size_t i = 0; i < TabRestoreService::kMaxEntries; ++i)
479 AddWindowWithOneTabToSessionService(false); 483 AddWindowWithOneTabToSessionService(false);
480 484
481 SessionServiceFactory::GetForProfile(profile())-> 485 SessionServiceFactory::GetForProfile(profile())->
482 MoveCurrentSessionToLastSession(); 486 MoveCurrentSessionToLastSession();
483 487
484 AddThreeNavigations(); 488 AddThreeNavigations();
485 489
486 service_->CreateHistoricalTab(&controller(), -1); 490 service_->CreateHistoricalTab(contents(), -1);
487 491
488 RecreateService(); 492 RecreateService();
489 493
490 // We should get back kMaxEntries entries. We added more, but 494 // We should get back kMaxEntries entries. We added more, but
491 // TabRestoreService only allows up to kMaxEntries. 495 // TabRestoreService only allows up to kMaxEntries.
492 ASSERT_EQ(TabRestoreService::kMaxEntries, service_->entries().size()); 496 ASSERT_EQ(TabRestoreService::kMaxEntries, service_->entries().size());
493 497
494 // The first entry should come from the session service. 498 // The first entry should come from the session service.
495 TabRestoreService::Entry* entry = service_->entries().front(); 499 TabRestoreService::Entry* entry = service_->entries().front();
496 ASSERT_EQ(TabRestoreService::WINDOW, entry->type); 500 ASSERT_EQ(TabRestoreService::WINDOW, entry->type);
497 TabRestoreService::Window* window = 501 TabRestoreService::Window* window =
498 static_cast<TabRestoreService::Window*>(entry); 502 static_cast<TabRestoreService::Window*>(entry);
499 ASSERT_EQ(1U, window->tabs.size()); 503 ASSERT_EQ(1U, window->tabs.size());
500 EXPECT_EQ(0, window->selected_tab_index); 504 EXPECT_EQ(0, window->selected_tab_index);
501 EXPECT_EQ(0, window->timestamp.ToInternalValue()); 505 EXPECT_EQ(0, window->timestamp.ToInternalValue());
502 ASSERT_EQ(1U, window->tabs[0].navigations.size()); 506 ASSERT_EQ(1U, window->tabs[0].navigations.size());
503 EXPECT_EQ(0, window->tabs[0].current_navigation_index); 507 EXPECT_EQ(0, window->tabs[0].current_navigation_index);
504 EXPECT_EQ(0, window->tabs[0].timestamp.ToInternalValue()); 508 EXPECT_EQ(0, window->tabs[0].timestamp.ToInternalValue());
505 EXPECT_TRUE(url1_ == window->tabs[0].navigations[0].virtual_url()); 509 EXPECT_TRUE(url1_ == window->tabs[0].navigations[0].virtual_url());
506 } 510 }
507 511
508 // Makes sure we restore the time stamp correctly. 512 // Makes sure we restore the time stamp correctly.
509 TEST_F(TabRestoreServiceTest, TimestampSurvivesRestore) { 513 TEST_F(TabRestoreServiceTest, TimestampSurvivesRestore) {
510 base::Time tab_timestamp(base::Time::FromInternalValue(123456789)); 514 base::Time tab_timestamp(base::Time::FromInternalValue(123456789));
511 515
512 AddThreeNavigations(); 516 AddThreeNavigations();
513 517
514 // Have the service record the tab. 518 // Have the service record the tab.
515 service_->CreateHistoricalTab(&controller(), -1); 519 service_->CreateHistoricalTab(contents(), -1);
516 520
517 // Make sure an entry was created. 521 // Make sure an entry was created.
518 ASSERT_EQ(1U, service_->entries().size()); 522 ASSERT_EQ(1U, service_->entries().size());
519 523
520 // Make sure the entry matches. 524 // Make sure the entry matches.
521 TabRestoreService::Entry* entry = service_->entries().front(); 525 TabRestoreService::Entry* entry = service_->entries().front();
522 ASSERT_EQ(TabRestoreService::TAB, entry->type); 526 ASSERT_EQ(TabRestoreService::TAB, entry->type);
523 Tab* tab = static_cast<Tab*>(entry); 527 Tab* tab = static_cast<Tab*>(entry);
524 tab->timestamp = tab_timestamp; 528 tab->timestamp = tab_timestamp;
525 529
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 CreateSessionServiceWithOneWindow(false); 637 CreateSessionServiceWithOneWindow(false);
634 638
635 SessionServiceFactory::GetForProfile(profile())-> 639 SessionServiceFactory::GetForProfile(profile())->
636 MoveCurrentSessionToLastSession(); 640 MoveCurrentSessionToLastSession();
637 641
638 profile()->set_restored_last_session(true); 642 profile()->set_restored_last_session(true);
639 643
640 const size_t max_entries = TabRestoreService::kMaxEntries; 644 const size_t max_entries = TabRestoreService::kMaxEntries;
641 for (size_t i = 0; i < max_entries + 5; i++) { 645 for (size_t i = 0; i < max_entries + 5; i++) {
642 NavigateAndCommit(GURL(StringPrintf("http://%d", static_cast<int>(i)))); 646 NavigateAndCommit(GURL(StringPrintf("http://%d", static_cast<int>(i))));
643 service_->CreateHistoricalTab(&controller(), -1); 647 service_->CreateHistoricalTab(contents(), -1);
644 } 648 }
645 649
646 EXPECT_EQ(max_entries, service_->entries_.size()); 650 EXPECT_EQ(max_entries, service_->entries_.size());
647 // This should not crash. 651 // This should not crash.
648 service_->LoadTabsFromLastSession(); 652 service_->LoadTabsFromLastSession();
649 EXPECT_EQ(max_entries, service_->entries_.size()); 653 EXPECT_EQ(max_entries, service_->entries_.size());
650 } 654 }
OLDNEW
« no previous file with comments | « chrome/browser/sessions/tab_restore_service.cc ('k') | chrome/browser/sessions/tab_restore_service_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698