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 <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 : public BrowserWithTestWindowTest { | 121 : public BrowserWithTestWindowTest { |
122 public: | 122 public: |
123 RecentTabsSubMenuModelTest() | 123 RecentTabsSubMenuModelTest() |
124 : sync_service_(CreateProfileSyncServiceParamsForTest(&testing_profile_)), | 124 : sync_service_(CreateProfileSyncServiceParamsForTest(&testing_profile_)), |
125 local_device_(new syncer::LocalDeviceInfoProviderMock( | 125 local_device_(new syncer::LocalDeviceInfoProviderMock( |
126 "RecentTabsSubMenuModelTest", | 126 "RecentTabsSubMenuModelTest", |
127 "Test Machine", | 127 "Test Machine", |
128 "Chromium 10k", | 128 "Chromium 10k", |
129 "Chrome 10k", | 129 "Chrome 10k", |
130 sync_pb::SyncEnums_DeviceType_TYPE_LINUX, | 130 sync_pb::SyncEnums_DeviceType_TYPE_LINUX, |
131 "device_id")) { | 131 "device_id")), |
132 sync_prefs_.reset(new syncer::SyncPrefs(testing_profile_.GetPrefs())); | 132 dummy_router_(base::MakeUnique<DummyRouter>()), |
133 manager_.reset(new sync_sessions::SessionsSyncManager( | 133 sync_prefs_( |
134 sync_service_.GetSyncClient()->GetSyncSessionsClient(), | 134 base::MakeUnique<syncer::SyncPrefs>(testing_profile_.GetPrefs())), |
135 sync_prefs_.get(), local_device_.get(), | 135 manager_(base::MakeUnique<sync_sessions::SessionsSyncManager>( |
136 std::unique_ptr<sync_sessions::LocalSessionEventRouter>( | 136 sync_service_.GetSyncClient()->GetSyncSessionsClient(), |
137 new DummyRouter()), | 137 sync_prefs_.get(), |
138 base::Closure(), base::Closure())); | 138 local_device_.get(), |
| 139 dummy_router_.get(), |
| 140 base::Closure(), |
| 141 base::Closure())) { |
139 manager_->MergeDataAndStartSyncing( | 142 manager_->MergeDataAndStartSyncing( |
140 syncer::SESSIONS, syncer::SyncDataList(), | 143 syncer::SESSIONS, syncer::SyncDataList(), |
141 std::unique_ptr<syncer::SyncChangeProcessor>( | 144 std::unique_ptr<syncer::SyncChangeProcessor>( |
142 new syncer::FakeSyncChangeProcessor), | 145 new syncer::FakeSyncChangeProcessor), |
143 std::unique_ptr<syncer::SyncErrorFactory>( | 146 std::unique_ptr<syncer::SyncErrorFactory>( |
144 new syncer::SyncErrorFactoryMock)); | 147 new syncer::SyncErrorFactoryMock)); |
145 } | 148 } |
146 | 149 |
147 void WaitForLoadFromLastSession() { | 150 void WaitForLoadFromLastSession() { |
148 content::RunAllBlockingPoolTasksUntilIdle(); | 151 content::RunAllBlockingPoolTasksUntilIdle(); |
(...skipping 11 matching lines...) Expand all Loading... |
160 return manager_.get(); | 163 return manager_.get(); |
161 } | 164 } |
162 | 165 |
163 void RegisterRecentTabs(RecentTabsBuilderTestHelper* helper) { | 166 void RegisterRecentTabs(RecentTabsBuilderTestHelper* helper) { |
164 helper->ExportToSessionsSyncManager(manager_.get()); | 167 helper->ExportToSessionsSyncManager(manager_.get()); |
165 } | 168 } |
166 | 169 |
167 private: | 170 private: |
168 TestingProfile testing_profile_; | 171 TestingProfile testing_profile_; |
169 browser_sync::ProfileSyncServiceMock sync_service_; | 172 browser_sync::ProfileSyncServiceMock sync_service_; |
| 173 std::unique_ptr<syncer::LocalDeviceInfoProviderMock> local_device_; |
| 174 std::unique_ptr<DummyRouter> dummy_router_; |
170 std::unique_ptr<syncer::SyncPrefs> sync_prefs_; | 175 std::unique_ptr<syncer::SyncPrefs> sync_prefs_; |
171 std::unique_ptr<sync_sessions::SessionsSyncManager> manager_; | 176 std::unique_ptr<sync_sessions::SessionsSyncManager> manager_; |
172 std::unique_ptr<syncer::LocalDeviceInfoProviderMock> local_device_; | |
173 }; | 177 }; |
174 | 178 |
175 // Test disabled "Recently closed" header with no foreign tabs. | 179 // Test disabled "Recently closed" header with no foreign tabs. |
176 TEST_F(RecentTabsSubMenuModelTest, NoTabs) { | 180 TEST_F(RecentTabsSubMenuModelTest, NoTabs) { |
177 TestRecentTabsSubMenuModel model(NULL, browser(), NULL); | 181 TestRecentTabsSubMenuModel model(NULL, browser(), NULL); |
178 | 182 |
179 // Expected menu: | 183 // Expected menu: |
180 // Menu index Menu items | 184 // Menu index Menu items |
181 // --------------------------------------------- | 185 // --------------------------------------------- |
182 // 0 History | 186 // 0 History |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
607 // 2 Recently closed heaer (disabled) | 611 // 2 Recently closed heaer (disabled) |
608 // 3 <separator> | 612 // 3 <separator> |
609 // 4 No tabs from other Devices | 613 // 4 No tabs from other Devices |
610 | 614 |
611 TestRecentTabsSubMenuModel model(NULL, browser(), NULL); | 615 TestRecentTabsSubMenuModel model(NULL, browser(), NULL); |
612 EXPECT_EQ(5, model.GetItemCount()); | 616 EXPECT_EQ(5, model.GetItemCount()); |
613 EXPECT_EQ(-1, model.GetMaxWidthForItemAtIndex(2)); | 617 EXPECT_EQ(-1, model.GetMaxWidthForItemAtIndex(2)); |
614 EXPECT_NE(-1, model.GetMaxWidthForItemAtIndex(3)); | 618 EXPECT_NE(-1, model.GetMaxWidthForItemAtIndex(3)); |
615 EXPECT_EQ(-1, model.GetMaxWidthForItemAtIndex(4)); | 619 EXPECT_EQ(-1, model.GetMaxWidthForItemAtIndex(4)); |
616 } | 620 } |
OLD | NEW |