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

Unified Diff: chrome/browser/history/visit_log_unittest.cc

Issue 187004: Adding in memory log of history visit database. This... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 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/history/visit_log.cc ('k') | chrome/chrome.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/history/visit_log_unittest.cc
===================================================================
--- chrome/browser/history/visit_log_unittest.cc (revision 0)
+++ chrome/browser/history/visit_log_unittest.cc (revision 0)
@@ -0,0 +1,45 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/history/visit_log.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+// A simple test that makes sure events are recorded correctly in circular
+// buffer.
+TEST(VisitLog, SimpleRecording) {
+ history::VisitLog vlog;
+
+ unsigned char* vlog_buffer = vlog.events();
+ int vlog_buffer_size = vlog.events_buffer_size();
+
+ ASSERT_EQ(history::VisitLog::NO_OP, vlog_buffer[0]);
+ ASSERT_EQ(history::VisitLog::NO_OP, vlog_buffer[1]);
+ ASSERT_EQ(history::VisitLog::NO_OP, vlog_buffer[2]);
+ ASSERT_EQ(history::VisitLog::NO_OP, vlog_buffer[vlog_buffer_size-1]);
+
+ for (int i=0; i<vlog_buffer_size; i++)
+ vlog.AddEvent(history::VisitLog::ADD_VISIT);
+
+ ASSERT_EQ(history::VisitLog::ADD_VISIT, vlog_buffer[0]);
+ ASSERT_EQ(history::VisitLog::ADD_VISIT, vlog_buffer[1]);
+ ASSERT_EQ(history::VisitLog::ADD_VISIT, vlog_buffer[2]);
+ ASSERT_EQ(history::VisitLog::ADD_VISIT, vlog_buffer[vlog_buffer_size-1]);
+ ASSERT_EQ(vlog_buffer_size, vlog.num_add());
+ ASSERT_EQ(0, vlog.num_delete());
+ ASSERT_EQ(0, vlog.num_update());
+ ASSERT_EQ(0, vlog.num_select());
+
+ vlog.AddEvent(history::VisitLog::DELETE_VISIT);
+ vlog.AddEvent(history::VisitLog::UPDATE_VISIT);
+ vlog.AddEvent(history::VisitLog::SELECT_VISIT);
+
+ ASSERT_EQ(history::VisitLog::DELETE_VISIT, vlog_buffer[0]);
+ ASSERT_EQ(history::VisitLog::UPDATE_VISIT, vlog_buffer[1]);
+ ASSERT_EQ(history::VisitLog::SELECT_VISIT, vlog_buffer[2]);
+ ASSERT_EQ(history::VisitLog::ADD_VISIT, vlog_buffer[vlog_buffer_size-1]);
+ ASSERT_EQ(vlog_buffer_size, vlog.num_add());
+ ASSERT_EQ(1, vlog.num_delete());
+ ASSERT_EQ(1, vlog.num_update());
+ ASSERT_EQ(1, vlog.num_select());
+}
« no previous file with comments | « chrome/browser/history/visit_log.cc ('k') | chrome/chrome.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698