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

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

Issue 53007: Porting of unit tests in chrome/ (Closed)
Patch Set: Created 11 years, 9 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
OLDNEW
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/sessions/session_types.h" 5 #include "chrome/browser/sessions/session_types.h"
6 #include "chrome/browser/sessions/tab_restore_service.h" 6 #include "chrome/browser/sessions/tab_restore_service.h"
7 #include "chrome/browser/tab_contents/navigation_entry.h" 7 #include "chrome/browser/tab_contents/navigation_entry.h"
8 #include "chrome/test/test_tab_contents.h" 8 #include "chrome/test/test_tab_contents.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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 TestTabContents* test_contents_; 91 TestTabContents* test_contents_;
92 }; 92 };
93 93
94 TEST_F(TabRestoreServiceTest, Basic) { 94 TEST_F(TabRestoreServiceTest, Basic) {
95 AddThreeNavigations(); 95 AddThreeNavigations();
96 96
97 // Have the service record the tab. 97 // Have the service record the tab.
98 service_->CreateHistoricalTab(controller_); 98 service_->CreateHistoricalTab(controller_);
99 99
100 // Make sure an entry was created. 100 // Make sure an entry was created.
101 ASSERT_EQ(1, service_->entries().size()); 101 ASSERT_EQ(1U, service_->entries().size());
102 102
103 // Make sure the entry matches. 103 // Make sure the entry matches.
104 TabRestoreService::Entry* entry = service_->entries().front(); 104 TabRestoreService::Entry* entry = service_->entries().front();
105 ASSERT_EQ(TabRestoreService::TAB, entry->type); 105 ASSERT_EQ(TabRestoreService::TAB, entry->type);
106 TabRestoreService::Tab* tab = static_cast<TabRestoreService::Tab*>(entry); 106 TabRestoreService::Tab* tab = static_cast<TabRestoreService::Tab*>(entry);
107 ASSERT_EQ(3, tab->navigations.size()); 107 ASSERT_EQ(3U, tab->navigations.size());
108 EXPECT_TRUE(url1_ == tab->navigations[0].url()); 108 EXPECT_TRUE(url1_ == tab->navigations[0].url());
109 EXPECT_TRUE(url2_ == tab->navigations[1].url()); 109 EXPECT_TRUE(url2_ == tab->navigations[1].url());
110 EXPECT_TRUE(url3_ == tab->navigations[2].url()); 110 EXPECT_TRUE(url3_ == tab->navigations[2].url());
111 EXPECT_EQ(2, tab->current_navigation_index); 111 EXPECT_EQ(2, tab->current_navigation_index);
112 112
113 NavigateToIndex(1); 113 NavigateToIndex(1);
114 114
115 // And check again. 115 // And check again.
116 service_->CreateHistoricalTab(controller_); 116 service_->CreateHistoricalTab(controller_);
117 117
118 // There should be two entries now. 118 // There should be two entries now.
119 ASSERT_EQ(2, service_->entries().size()); 119 ASSERT_EQ(2U, service_->entries().size());
120 120
121 // Make sure the entry matches 121 // Make sure the entry matches
122 entry = service_->entries().front(); 122 entry = service_->entries().front();
123 ASSERT_EQ(TabRestoreService::TAB, entry->type); 123 ASSERT_EQ(TabRestoreService::TAB, entry->type);
124 tab = static_cast<TabRestoreService::Tab*>(entry); 124 tab = static_cast<TabRestoreService::Tab*>(entry);
125 ASSERT_EQ(3, tab->navigations.size()); 125 ASSERT_EQ(3U, tab->navigations.size());
126 EXPECT_TRUE(url1_ == tab->navigations[0].url()); 126 EXPECT_TRUE(url1_ == tab->navigations[0].url());
127 EXPECT_TRUE(url2_ == tab->navigations[1].url()); 127 EXPECT_TRUE(url2_ == tab->navigations[1].url());
128 EXPECT_TRUE(url3_ == tab->navigations[2].url()); 128 EXPECT_TRUE(url3_ == tab->navigations[2].url());
129 EXPECT_EQ(1, tab->current_navigation_index); 129 EXPECT_EQ(1, tab->current_navigation_index);
130 } 130 }
131 131
132 // Make sure TabRestoreService doesn't create an entry for a tab with no 132 // Make sure TabRestoreService doesn't create an entry for a tab with no
133 // navigations. 133 // navigations.
134 TEST_F(TabRestoreServiceTest, DontCreateEmptyTab) { 134 TEST_F(TabRestoreServiceTest, DontCreateEmptyTab) {
135 service_->CreateHistoricalTab(controller_); 135 service_->CreateHistoricalTab(controller_);
136 EXPECT_TRUE(service_->entries().empty()); 136 EXPECT_TRUE(service_->entries().empty());
137 } 137 }
138 138
139 // Tests restoring a single tab. 139 // Tests restoring a single tab.
140 TEST_F(TabRestoreServiceTest, Restore) { 140 TEST_F(TabRestoreServiceTest, Restore) {
141 AddThreeNavigations(); 141 AddThreeNavigations();
142 142
143 // Have the service record the tab. 143 // Have the service record the tab.
144 service_->CreateHistoricalTab(controller_); 144 service_->CreateHistoricalTab(controller_);
145 145
146 // Recreate the service and have it load the tabs. 146 // Recreate the service and have it load the tabs.
147 RecreateService(); 147 RecreateService();
148 148
149 // One entry should be created. 149 // One entry should be created.
150 ASSERT_EQ(1, service_->entries().size()); 150 ASSERT_EQ(1U, service_->entries().size());
151 151
152 // And verify the entry. 152 // And verify the entry.
153 TabRestoreService::Entry* entry = service_->entries().front(); 153 TabRestoreService::Entry* entry = service_->entries().front();
154 ASSERT_EQ(TabRestoreService::TAB, entry->type); 154 ASSERT_EQ(TabRestoreService::TAB, entry->type);
155 TabRestoreService::Tab* tab = static_cast<TabRestoreService::Tab*>(entry); 155 TabRestoreService::Tab* tab = static_cast<TabRestoreService::Tab*>(entry);
156 ASSERT_EQ(3, tab->navigations.size()); 156 ASSERT_EQ(3U, tab->navigations.size());
157 EXPECT_TRUE(url1_ == tab->navigations[0].url()); 157 EXPECT_TRUE(url1_ == tab->navigations[0].url());
158 EXPECT_TRUE(url2_ == tab->navigations[1].url()); 158 EXPECT_TRUE(url2_ == tab->navigations[1].url());
159 EXPECT_TRUE(url3_ == tab->navigations[2].url()); 159 EXPECT_TRUE(url3_ == tab->navigations[2].url());
160 EXPECT_EQ(2, tab->current_navigation_index); 160 EXPECT_EQ(2, tab->current_navigation_index);
161 } 161 }
162 162
163 // Make sure a tab that is restored doesn't come back. 163 // Make sure a tab that is restored doesn't come back.
164 TEST_F(TabRestoreServiceTest, DontLoadRestoredTab) { 164 TEST_F(TabRestoreServiceTest, DontLoadRestoredTab) {
165 AddThreeNavigations(); 165 AddThreeNavigations();
166 166
167 // Have the service record the tab. 167 // Have the service record the tab.
168 service_->CreateHistoricalTab(controller_); 168 service_->CreateHistoricalTab(controller_);
169 ASSERT_EQ(1, service_->entries().size()); 169 ASSERT_EQ(1U, service_->entries().size());
170 170
171 // Restore the tab. 171 // Restore the tab.
172 service_->RestoreEntryById(NULL, service_->entries().front()->id, true); 172 service_->RestoreEntryById(NULL, service_->entries().front()->id, true);
173 ASSERT_TRUE(service_->entries().empty()); 173 ASSERT_TRUE(service_->entries().empty());
174 174
175 // Recreate the service and have it load the tabs. 175 // Recreate the service and have it load the tabs.
176 RecreateService(); 176 RecreateService();
177 177
178 // There should be no entries. 178 // There should be no entries.
179 ASSERT_EQ(0, service_->entries().size()); 179 ASSERT_EQ(0U, service_->entries().size());
180 } 180 }
181 181
182 // Make sure we don't persist entries to disk that have post data. 182 // Make sure we don't persist entries to disk that have post data.
183 TEST_F(TabRestoreServiceTest, DontPersistPostData1) { 183 TEST_F(TabRestoreServiceTest, DontPersistPostData1) {
184 AddThreeNavigations(); 184 AddThreeNavigations();
185 controller_->GetEntryAtIndex(2)->set_has_post_data(true); 185 controller_->GetEntryAtIndex(2)->set_has_post_data(true);
186 186
187 // Have the service record the tab. 187 // Have the service record the tab.
188 service_->CreateHistoricalTab(controller_); 188 service_->CreateHistoricalTab(controller_);
189 ASSERT_EQ(1, service_->entries().size()); 189 ASSERT_EQ(1U, service_->entries().size());
190 190
191 // Recreate the service and have it load the tabs. 191 // Recreate the service and have it load the tabs.
192 RecreateService(); 192 RecreateService();
193 193
194 // One entry should be created. 194 // One entry should be created.
195 ASSERT_EQ(1, service_->entries().size()); 195 ASSERT_EQ(1U, service_->entries().size());
196 196
197 // And verify the entry, the last navigation (url3_) should not have 197 // And verify the entry, the last navigation (url3_) should not have
198 // been written to disk as it contained post data. 198 // been written to disk as it contained post data.
199 TabRestoreService::Entry* entry = service_->entries().front(); 199 TabRestoreService::Entry* entry = service_->entries().front();
200 ASSERT_EQ(TabRestoreService::TAB, entry->type); 200 ASSERT_EQ(TabRestoreService::TAB, entry->type);
201 TabRestoreService::Tab* tab = static_cast<TabRestoreService::Tab*>(entry); 201 TabRestoreService::Tab* tab = static_cast<TabRestoreService::Tab*>(entry);
202 ASSERT_EQ(2, tab->navigations.size()); 202 ASSERT_EQ(2U, tab->navigations.size());
203 EXPECT_TRUE(url1_ == tab->navigations[0].url()); 203 EXPECT_TRUE(url1_ == tab->navigations[0].url());
204 EXPECT_TRUE(url2_ == tab->navigations[1].url()); 204 EXPECT_TRUE(url2_ == tab->navigations[1].url());
205 EXPECT_EQ(1, tab->current_navigation_index); 205 EXPECT_EQ(1, tab->current_navigation_index);
206 } 206 }
207 207
208 // Make sure we don't persist entries to disk that have post data. This 208 // Make sure we don't persist entries to disk that have post data. This
209 // differs from DontPersistPostData1 in that all navigations before the 209 // differs from DontPersistPostData1 in that all navigations before the
210 // current index have post data. 210 // current index have post data.
211 TEST_F(TabRestoreServiceTest, DontPersistPostData2) { 211 TEST_F(TabRestoreServiceTest, DontPersistPostData2) {
212 AddThreeNavigations(); 212 AddThreeNavigations();
213 NavigateToIndex(1); 213 NavigateToIndex(1);
214 controller_->GetEntryAtIndex(0)->set_has_post_data(true); 214 controller_->GetEntryAtIndex(0)->set_has_post_data(true);
215 controller_->GetEntryAtIndex(1)->set_has_post_data(true); 215 controller_->GetEntryAtIndex(1)->set_has_post_data(true);
216 216
217 // Have the service record the tab. 217 // Have the service record the tab.
218 service_->CreateHistoricalTab(controller_); 218 service_->CreateHistoricalTab(controller_);
219 ASSERT_EQ(1, service_->entries().size()); 219 ASSERT_EQ(1U, service_->entries().size());
220 220
221 // Recreate the service and have it load the tabs. 221 // Recreate the service and have it load the tabs.
222 RecreateService(); 222 RecreateService();
223 223
224 // One entry should be created. 224 // One entry should be created.
225 ASSERT_EQ(1, service_->entries().size()); 225 ASSERT_EQ(1U, service_->entries().size());
226 226
227 // And verify the entry, the last navigation (url3_) should not have 227 // And verify the entry, the last navigation (url3_) should not have
228 // been written to disk as it contained post data. 228 // been written to disk as it contained post data.
229 TabRestoreService::Entry* entry = service_->entries().front(); 229 TabRestoreService::Entry* entry = service_->entries().front();
230 ASSERT_EQ(TabRestoreService::TAB, entry->type); 230 ASSERT_EQ(TabRestoreService::TAB, entry->type);
231 TabRestoreService::Tab* tab = static_cast<TabRestoreService::Tab*>(entry); 231 TabRestoreService::Tab* tab = static_cast<TabRestoreService::Tab*>(entry);
232 ASSERT_EQ(1, tab->navigations.size()); 232 ASSERT_EQ(1U, tab->navigations.size());
233 EXPECT_TRUE(url3_ == tab->navigations[0].url()); 233 EXPECT_TRUE(url3_ == tab->navigations[0].url());
234 EXPECT_EQ(0, tab->current_navigation_index); 234 EXPECT_EQ(0, tab->current_navigation_index);
235 } 235 }
236 236
237 // Make sure we don't persist entries to disk that have post data. This 237 // Make sure we don't persist entries to disk that have post data. This
238 // differs from DontPersistPostData1 in that all the navigations have post 238 // differs from DontPersistPostData1 in that all the navigations have post
239 // data, so that nothing should be persisted. 239 // data, so that nothing should be persisted.
240 TEST_F(TabRestoreServiceTest, DontPersistPostData3) { 240 TEST_F(TabRestoreServiceTest, DontPersistPostData3) {
241 AddThreeNavigations(); 241 AddThreeNavigations();
242 controller_->GetEntryAtIndex(0)->set_has_post_data(true); 242 controller_->GetEntryAtIndex(0)->set_has_post_data(true);
243 controller_->GetEntryAtIndex(1)->set_has_post_data(true); 243 controller_->GetEntryAtIndex(1)->set_has_post_data(true);
244 controller_->GetEntryAtIndex(2)->set_has_post_data(true); 244 controller_->GetEntryAtIndex(2)->set_has_post_data(true);
245 245
246 // Have the service record the tab. 246 // Have the service record the tab.
247 service_->CreateHistoricalTab(controller_); 247 service_->CreateHistoricalTab(controller_);
248 ASSERT_EQ(1, service_->entries().size()); 248 ASSERT_EQ(1U, service_->entries().size());
249 249
250 // Recreate the service and have it load the tabs. 250 // Recreate the service and have it load the tabs.
251 RecreateService(); 251 RecreateService();
252 252
253 // One entry should be created. 253 // One entry should be created.
254 ASSERT_TRUE(service_->entries().empty()); 254 ASSERT_TRUE(service_->entries().empty());
255 } 255 }
256 256
257 // Make sure we don't persist entries to disk that have post data. This 257 // Make sure we don't persist entries to disk that have post data. This
258 // differs from DontPersistPostData1 in that all the navigations have post 258 // differs from DontPersistPostData1 in that all the navigations have post
259 // data, so that nothing should be persisted. 259 // data, so that nothing should be persisted.
260 TEST_F(TabRestoreServiceTest, DontLoadTwice) { 260 TEST_F(TabRestoreServiceTest, DontLoadTwice) {
261 AddThreeNavigations(); 261 AddThreeNavigations();
262 262
263 // Have the service record the tab. 263 // Have the service record the tab.
264 service_->CreateHistoricalTab(controller_); 264 service_->CreateHistoricalTab(controller_);
265 ASSERT_EQ(1, service_->entries().size()); 265 ASSERT_EQ(1U, service_->entries().size());
266 266
267 // Recreate the service and have it load the tabs. 267 // Recreate the service and have it load the tabs.
268 RecreateService(); 268 RecreateService();
269 269
270 service_->LoadTabsFromLastSession(); 270 service_->LoadTabsFromLastSession();
271 271
272 // There should only be one entry. 272 // There should only be one entry.
273 ASSERT_EQ(1, service_->entries().size()); 273 ASSERT_EQ(1U, service_->entries().size());
274 } 274 }
275 275
276 // Makes sure we load the previous session as necessary. 276 // Makes sure we load the previous session as necessary.
277 TEST_F(TabRestoreServiceTest, LoadPreviousSession) { 277 TEST_F(TabRestoreServiceTest, LoadPreviousSession) {
278 CreateSessionServiceWithOneWindow(); 278 CreateSessionServiceWithOneWindow();
279 279
280 profile_->GetSessionService()->MoveCurrentSessionToLastSession(); 280 profile_->GetSessionService()->MoveCurrentSessionToLastSession();
281 281
282 service_->LoadTabsFromLastSession(); 282 service_->LoadTabsFromLastSession();
283 283
284 // Make sure we get back one entry with one tab whose url is url1. 284 // Make sure we get back one entry with one tab whose url is url1.
285 ASSERT_EQ(1, service_->entries().size()); 285 ASSERT_EQ(1U, service_->entries().size());
286 TabRestoreService::Entry* entry2 = service_->entries().front(); 286 TabRestoreService::Entry* entry2 = service_->entries().front();
287 ASSERT_EQ(TabRestoreService::WINDOW, entry2->type); 287 ASSERT_EQ(TabRestoreService::WINDOW, entry2->type);
288 TabRestoreService::Window* window = 288 TabRestoreService::Window* window =
289 static_cast<TabRestoreService::Window*>(entry2); 289 static_cast<TabRestoreService::Window*>(entry2);
290 ASSERT_EQ(1, window->tabs.size()); 290 ASSERT_EQ(1U, window->tabs.size());
291 EXPECT_EQ(0, window->selected_tab_index); 291 EXPECT_EQ(0, window->selected_tab_index);
292 ASSERT_EQ(1, window->tabs[0].navigations.size()); 292 ASSERT_EQ(1U, window->tabs[0].navigations.size());
293 EXPECT_EQ(0, window->tabs[0].current_navigation_index); 293 EXPECT_EQ(0, window->tabs[0].current_navigation_index);
294 EXPECT_TRUE(url1_ == window->tabs[0].navigations[0].url()); 294 EXPECT_TRUE(url1_ == window->tabs[0].navigations[0].url());
295 } 295 }
296 296
297 // Makes sure we don't attempt to load previous sessions after a restore. 297 // Makes sure we don't attempt to load previous sessions after a restore.
298 TEST_F(TabRestoreServiceTest, DontLoadAfterRestore) { 298 TEST_F(TabRestoreServiceTest, DontLoadAfterRestore) {
299 CreateSessionServiceWithOneWindow(); 299 CreateSessionServiceWithOneWindow();
300 300
301 profile_->GetSessionService()->MoveCurrentSessionToLastSession(); 301 profile_->GetSessionService()->MoveCurrentSessionToLastSession();
302 302
303 profile_->set_restored_last_session(true); 303 profile_->set_restored_last_session(true);
304 304
305 service_->LoadTabsFromLastSession(); 305 service_->LoadTabsFromLastSession();
306 306
307 // Because we restored a session TabRestoreService shouldn't load the tabs. 307 // Because we restored a session TabRestoreService shouldn't load the tabs.
308 ASSERT_EQ(0, service_->entries().size()); 308 ASSERT_EQ(0U, service_->entries().size());
309 } 309 }
310 310
311 // Makes sure we don't attempt to load previous sessions after a clean exit. 311 // Makes sure we don't attempt to load previous sessions after a clean exit.
312 TEST_F(TabRestoreServiceTest, DontLoadAfterCleanExit) { 312 TEST_F(TabRestoreServiceTest, DontLoadAfterCleanExit) {
313 CreateSessionServiceWithOneWindow(); 313 CreateSessionServiceWithOneWindow();
314 314
315 profile_->GetSessionService()->MoveCurrentSessionToLastSession(); 315 profile_->GetSessionService()->MoveCurrentSessionToLastSession();
316 316
317 profile_->set_last_session_exited_cleanly(true); 317 profile_->set_last_session_exited_cleanly(true);
318 318
319 service_->LoadTabsFromLastSession(); 319 service_->LoadTabsFromLastSession();
320 320
321 ASSERT_EQ(0, service_->entries().size()); 321 ASSERT_EQ(0U, service_->entries().size());
322 } 322 }
323 323
324 TEST_F(TabRestoreServiceTest, LoadPreviousSessionAndTabs) { 324 TEST_F(TabRestoreServiceTest, LoadPreviousSessionAndTabs) {
325 CreateSessionServiceWithOneWindow(); 325 CreateSessionServiceWithOneWindow();
326 326
327 profile_->GetSessionService()->MoveCurrentSessionToLastSession(); 327 profile_->GetSessionService()->MoveCurrentSessionToLastSession();
328 328
329 AddThreeNavigations(); 329 AddThreeNavigations();
330 330
331 service_->CreateHistoricalTab(controller_); 331 service_->CreateHistoricalTab(controller_);
332 332
333 RecreateService(); 333 RecreateService();
334 334
335 // We should get back two entries, one from the previous session and one from 335 // We should get back two entries, one from the previous session and one from
336 // the tab restore service. The previous session entry should be first. 336 // the tab restore service. The previous session entry should be first.
337 ASSERT_EQ(2, service_->entries().size()); 337 ASSERT_EQ(2U, service_->entries().size());
338 // The first entry should come from the session service. 338 // The first entry should come from the session service.
339 TabRestoreService::Entry* entry = service_->entries().front(); 339 TabRestoreService::Entry* entry = service_->entries().front();
340 ASSERT_EQ(TabRestoreService::WINDOW, entry->type); 340 ASSERT_EQ(TabRestoreService::WINDOW, entry->type);
341 TabRestoreService::Window* window = 341 TabRestoreService::Window* window =
342 static_cast<TabRestoreService::Window*>(entry); 342 static_cast<TabRestoreService::Window*>(entry);
343 ASSERT_EQ(1, window->tabs.size()); 343 ASSERT_EQ(1U, window->tabs.size());
344 EXPECT_EQ(0, window->selected_tab_index); 344 EXPECT_EQ(0, window->selected_tab_index);
345 ASSERT_EQ(1, window->tabs[0].navigations.size()); 345 ASSERT_EQ(1U, window->tabs[0].navigations.size());
346 EXPECT_EQ(0, window->tabs[0].current_navigation_index); 346 EXPECT_EQ(0, window->tabs[0].current_navigation_index);
347 EXPECT_TRUE(url1_ == window->tabs[0].navigations[0].url()); 347 EXPECT_TRUE(url1_ == window->tabs[0].navigations[0].url());
348 348
349 // Then the closed tab. 349 // Then the closed tab.
350 entry = *(++service_->entries().begin()); 350 entry = *(++service_->entries().begin());
351 ASSERT_EQ(TabRestoreService::TAB, entry->type); 351 ASSERT_EQ(TabRestoreService::TAB, entry->type);
352 TabRestoreService::Tab* tab = static_cast<TabRestoreService::Tab*>(entry); 352 TabRestoreService::Tab* tab = static_cast<TabRestoreService::Tab*>(entry);
353 ASSERT_EQ(3, tab->navigations.size()); 353 ASSERT_EQ(3U, tab->navigations.size());
354 EXPECT_EQ(2, tab->current_navigation_index); 354 EXPECT_EQ(2, tab->current_navigation_index);
355 EXPECT_TRUE(url1_ == tab->navigations[0].url()); 355 EXPECT_TRUE(url1_ == tab->navigations[0].url());
356 EXPECT_TRUE(url2_ == tab->navigations[1].url()); 356 EXPECT_TRUE(url2_ == tab->navigations[1].url());
357 EXPECT_TRUE(url3_ == tab->navigations[2].url()); 357 EXPECT_TRUE(url3_ == tab->navigations[2].url());
358 } 358 }
359 359
360 // Creates TabRestoreService::kMaxEntries + 1 windows in the session service 360 // Creates TabRestoreService::kMaxEntries + 1 windows in the session service
361 // and makes sure we only get back TabRestoreService::kMaxEntries on restore. 361 // and makes sure we only get back TabRestoreService::kMaxEntries on restore.
362 TEST_F(TabRestoreServiceTest, ManyWindowsInSessionService) { 362 TEST_F(TabRestoreServiceTest, ManyWindowsInSessionService) {
363 CreateSessionServiceWithOneWindow(); 363 CreateSessionServiceWithOneWindow();
(...skipping 11 matching lines...) Expand all
375 375
376 // We should get back kMaxEntries entries. We added more, but 376 // We should get back kMaxEntries entries. We added more, but
377 // TabRestoreService only allows up to kMaxEntries. 377 // TabRestoreService only allows up to kMaxEntries.
378 ASSERT_EQ(TabRestoreService::kMaxEntries, service_->entries().size()); 378 ASSERT_EQ(TabRestoreService::kMaxEntries, service_->entries().size());
379 379
380 // The first entry should come from the session service. 380 // The first entry should come from the session service.
381 TabRestoreService::Entry* entry = service_->entries().front(); 381 TabRestoreService::Entry* entry = service_->entries().front();
382 ASSERT_EQ(TabRestoreService::WINDOW, entry->type); 382 ASSERT_EQ(TabRestoreService::WINDOW, entry->type);
383 TabRestoreService::Window* window = 383 TabRestoreService::Window* window =
384 static_cast<TabRestoreService::Window*>(entry); 384 static_cast<TabRestoreService::Window*>(entry);
385 ASSERT_EQ(1, window->tabs.size()); 385 ASSERT_EQ(1U, window->tabs.size());
386 EXPECT_EQ(0, window->selected_tab_index); 386 EXPECT_EQ(0, window->selected_tab_index);
387 ASSERT_EQ(1, window->tabs[0].navigations.size()); 387 ASSERT_EQ(1U, window->tabs[0].navigations.size());
388 EXPECT_EQ(0, window->tabs[0].current_navigation_index); 388 EXPECT_EQ(0, window->tabs[0].current_navigation_index);
389 EXPECT_TRUE(url1_ == window->tabs[0].navigations[0].url()); 389 EXPECT_TRUE(url1_ == window->tabs[0].navigations[0].url());
390 } 390 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698