| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.h" | 5 #include "chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
| 12 #include "chrome/app/chrome_command_ids.h" | 13 #include "chrome/app/chrome_command_ids.h" |
| 13 #include "chrome/browser/sessions/persistent_tab_restore_service.h" | 14 #include "chrome/browser/sessions/persistent_tab_restore_service.h" |
| 14 #include "chrome/browser/sessions/session_service.h" | 15 #include "chrome/browser/sessions/session_service.h" |
| 15 #include "chrome/browser/sessions/session_service_factory.h" | 16 #include "chrome/browser/sessions/session_service_factory.h" |
| 16 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 17 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
| 17 #include "chrome/browser/sync/glue/synced_session.h" | 18 #include "chrome/browser/sync/glue/synced_session.h" |
| 18 #include "chrome/browser/sync/profile_sync_service_mock.h" | 19 #include "chrome/browser/sync/profile_sync_service_mock.h" |
| 19 #include "chrome/browser/sync/sessions/sessions_sync_manager.h" | 20 #include "chrome/browser/sync/sessions/sessions_sync_manager.h" |
| 20 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 scoped_ptr<syncer::SyncChangeProcessor>( | 134 scoped_ptr<syncer::SyncChangeProcessor>( |
| 134 new syncer::FakeSyncChangeProcessor), | 135 new syncer::FakeSyncChangeProcessor), |
| 135 scoped_ptr<syncer::SyncErrorFactory>( | 136 scoped_ptr<syncer::SyncErrorFactory>( |
| 136 new syncer::SyncErrorFactoryMock)); | 137 new syncer::SyncErrorFactoryMock)); |
| 137 } | 138 } |
| 138 | 139 |
| 139 void WaitForLoadFromLastSession() { | 140 void WaitForLoadFromLastSession() { |
| 140 content::RunAllBlockingPoolTasksUntilIdle(); | 141 content::RunAllBlockingPoolTasksUntilIdle(); |
| 141 } | 142 } |
| 142 | 143 |
| 143 static KeyedService* GetTabRestoreService( | 144 static scoped_ptr<KeyedService> GetTabRestoreService( |
| 144 content::BrowserContext* browser_context) { | 145 content::BrowserContext* browser_context) { |
| 145 // Ownership is tranfered to the profile. | 146 return make_scoped_ptr(new PersistentTabRestoreService( |
| 146 return new PersistentTabRestoreService( | 147 Profile::FromBrowserContext(browser_context), NULL)); |
| 147 Profile::FromBrowserContext(browser_context), NULL); | |
| 148 } | 148 } |
| 149 | 149 |
| 150 browser_sync::OpenTabsUIDelegate* GetOpenTabsDelegate() { | 150 browser_sync::OpenTabsUIDelegate* GetOpenTabsDelegate() { |
| 151 return manager_.get(); | 151 return manager_.get(); |
| 152 } | 152 } |
| 153 | 153 |
| 154 void RegisterRecentTabs(RecentTabsBuilderTestHelper* helper) { | 154 void RegisterRecentTabs(RecentTabsBuilderTestHelper* helper) { |
| 155 helper->ExportToSessionsSyncManager(manager_.get()); | 155 helper->ExportToSessionsSyncManager(manager_.get()); |
| 156 } | 156 } |
| 157 | 157 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 profile(), RecentTabsSubMenuModelTest::GetTabRestoreService); | 251 profile(), RecentTabsSubMenuModelTest::GetTabRestoreService); |
| 252 | 252 |
| 253 // Add 2 tabs and close them. | 253 // Add 2 tabs and close them. |
| 254 AddTab(browser(), GURL("http://wnd/tab0")); | 254 AddTab(browser(), GURL("http://wnd/tab0")); |
| 255 AddTab(browser(), GURL("http://wnd/tab1")); | 255 AddTab(browser(), GURL("http://wnd/tab1")); |
| 256 browser()->tab_strip_model()->CloseAllTabs(); | 256 browser()->tab_strip_model()->CloseAllTabs(); |
| 257 | 257 |
| 258 // Create a SessionService for the profile (profile owns the service) and add | 258 // Create a SessionService for the profile (profile owns the service) and add |
| 259 // a window with a tab to this session. | 259 // a window with a tab to this session. |
| 260 SessionService* session_service = new SessionService(profile()); | 260 SessionService* session_service = new SessionService(profile()); |
| 261 SessionServiceFactory::SetForTestProfile(profile(), session_service); | 261 SessionServiceFactory::SetForTestProfile(profile(), |
| 262 make_scoped_ptr(session_service)); |
| 262 SessionID tab_id; | 263 SessionID tab_id; |
| 263 SessionID window_id; | 264 SessionID window_id; |
| 264 session_service->SetWindowType(window_id, | 265 session_service->SetWindowType(window_id, |
| 265 Browser::TYPE_TABBED, | 266 Browser::TYPE_TABBED, |
| 266 SessionService::TYPE_NORMAL); | 267 SessionService::TYPE_NORMAL); |
| 267 session_service->SetTabWindow(window_id, tab_id); | 268 session_service->SetTabWindow(window_id, tab_id); |
| 268 session_service->SetTabIndexInWindow(window_id, tab_id, 0); | 269 session_service->SetTabIndexInWindow(window_id, tab_id, 0); |
| 269 session_service->SetSelectedTabInWindow(window_id, 0); | 270 session_service->SetSelectedTabInWindow(window_id, 0); |
| 270 session_service->UpdateTabNavigation( | 271 session_service->UpdateTabNavigation( |
| 271 window_id, tab_id, | 272 window_id, tab_id, |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 // 0 Recently closed heaer (disabled) | 553 // 0 Recently closed heaer (disabled) |
| 553 // 1 <separator> | 554 // 1 <separator> |
| 554 // 2 No tabs from other Devices | 555 // 2 No tabs from other Devices |
| 555 | 556 |
| 556 TestRecentTabsSubMenuModel model(NULL, browser(), NULL); | 557 TestRecentTabsSubMenuModel model(NULL, browser(), NULL); |
| 557 EXPECT_EQ(3, model.GetItemCount()); | 558 EXPECT_EQ(3, model.GetItemCount()); |
| 558 EXPECT_EQ(-1, model.GetMaxWidthForItemAtIndex(0)); | 559 EXPECT_EQ(-1, model.GetMaxWidthForItemAtIndex(0)); |
| 559 EXPECT_NE(-1, model.GetMaxWidthForItemAtIndex(1)); | 560 EXPECT_NE(-1, model.GetMaxWidthForItemAtIndex(1)); |
| 560 EXPECT_EQ(-1, model.GetMaxWidthForItemAtIndex(2)); | 561 EXPECT_EQ(-1, model.GetMaxWidthForItemAtIndex(2)); |
| 561 } | 562 } |
| OLD | NEW |