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

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

Issue 42209: Merge 11262 - Fixes possible crash in SessionBackend. I believe what's happen... (Closed) Base URL: svn://chrome-svn.corp.google.com/chrome/branches/169/src/
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
« no previous file with comments | « chrome/browser/sessions/session_backend.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/file_path.h" 5 #include "base/file_path.h"
6 #include "base/file_util.h" 6 #include "base/file_util.h"
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/time.h" 9 #include "base/time.h"
10 #include "chrome/browser/sessions/session_backend.h" 10 #include "chrome/browser/sessions/session_backend.h"
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 empty_commands->push_back(CreateCommandFromData(empty_command)); 173 empty_commands->push_back(CreateCommandFromData(empty_command));
174 backend->AppendCommands(empty_commands, true); 174 backend->AppendCommands(empty_commands, true);
175 backend->MoveCurrentSessionToLastSession(); 175 backend->MoveCurrentSessionToLastSession();
176 176
177 std::vector<SessionCommand*> commands; 177 std::vector<SessionCommand*> commands;
178 backend->ReadLastSessionCommandsImpl(&commands); 178 backend->ReadLastSessionCommandsImpl(&commands);
179 ASSERT_EQ(1, commands.size()); 179 ASSERT_EQ(1, commands.size());
180 AssertCommandEqualsData(empty_command, commands[0]); 180 AssertCommandEqualsData(empty_command, commands[0]);
181 STLDeleteElements(&commands); 181 STLDeleteElements(&commands);
182 } 182 }
183
184 // Writes a command, appends another command with reset to true, then reads
185 // making sure we only get back the second command.
186 TEST_F(SessionBackendTest, Truncate) {
187 scoped_refptr<SessionBackend> backend(
188 new SessionBackend(BaseSessionService::SESSION_RESTORE, path_));
189 struct TestData first_data = { 1, "a" };
190 std::vector<SessionCommand*> commands;
191 commands.push_back(CreateCommandFromData(first_data));
192 backend->AppendCommands(new SessionCommands(commands), false);
193 commands.clear();
194
195 // Write another command, this time resetting the file when appending.
196 struct TestData second_data = { 2, "b" };
197 commands.push_back(CreateCommandFromData(second_data));
198 backend->AppendCommands(new SessionCommands(commands), true);
199 commands.clear();
200
201 // Read it back in.
202 backend = NULL;
203 backend = new SessionBackend(BaseSessionService::SESSION_RESTORE, path_);
204 backend->ReadLastSessionCommandsImpl(&commands);
205
206 // And make sure we get back the expected data.
207 ASSERT_EQ(1, commands.size());
208 AssertCommandEqualsData(second_data, commands[0]);
209
210 STLDeleteElements(&commands);
211 }
OLDNEW
« no previous file with comments | « chrome/browser/sessions/session_backend.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698