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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/sessions/session_backend.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sessions/session_backend_unittest.cc
===================================================================
--- chrome/browser/sessions/session_backend_unittest.cc (revision 11702)
+++ chrome/browser/sessions/session_backend_unittest.cc (working copy)
@@ -180,3 +180,32 @@
AssertCommandEqualsData(empty_command, commands[0]);
STLDeleteElements(&commands);
}
+
+// Writes a command, appends another command with reset to true, then reads
+// making sure we only get back the second command.
+TEST_F(SessionBackendTest, Truncate) {
+ scoped_refptr<SessionBackend> backend(
+ new SessionBackend(BaseSessionService::SESSION_RESTORE, path_));
+ struct TestData first_data = { 1, "a" };
+ std::vector<SessionCommand*> commands;
+ commands.push_back(CreateCommandFromData(first_data));
+ backend->AppendCommands(new SessionCommands(commands), false);
+ commands.clear();
+
+ // Write another command, this time resetting the file when appending.
+ struct TestData second_data = { 2, "b" };
+ commands.push_back(CreateCommandFromData(second_data));
+ backend->AppendCommands(new SessionCommands(commands), true);
+ commands.clear();
+
+ // Read it back in.
+ backend = NULL;
+ backend = new SessionBackend(BaseSessionService::SESSION_RESTORE, path_);
+ backend->ReadLastSessionCommandsImpl(&commands);
+
+ // And make sure we get back the expected data.
+ ASSERT_EQ(1, commands.size());
+ AssertCommandEqualsData(second_data, commands[0]);
+
+ STLDeleteElements(&commands);
+}
« 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