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

Side by Side 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, 3 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/history/visit_log.cc ('k') | chrome/chrome.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/history/visit_log.h"
6 #include "testing/gtest/include/gtest/gtest.h"
7
8 // A simple test that makes sure events are recorded correctly in circular
9 // buffer.
10 TEST(VisitLog, SimpleRecording) {
11 history::VisitLog vlog;
12
13 unsigned char* vlog_buffer = vlog.events();
14 int vlog_buffer_size = vlog.events_buffer_size();
15
16 ASSERT_EQ(history::VisitLog::NO_OP, vlog_buffer[0]);
17 ASSERT_EQ(history::VisitLog::NO_OP, vlog_buffer[1]);
18 ASSERT_EQ(history::VisitLog::NO_OP, vlog_buffer[2]);
19 ASSERT_EQ(history::VisitLog::NO_OP, vlog_buffer[vlog_buffer_size-1]);
20
21 for (int i=0; i<vlog_buffer_size; i++)
22 vlog.AddEvent(history::VisitLog::ADD_VISIT);
23
24 ASSERT_EQ(history::VisitLog::ADD_VISIT, vlog_buffer[0]);
25 ASSERT_EQ(history::VisitLog::ADD_VISIT, vlog_buffer[1]);
26 ASSERT_EQ(history::VisitLog::ADD_VISIT, vlog_buffer[2]);
27 ASSERT_EQ(history::VisitLog::ADD_VISIT, vlog_buffer[vlog_buffer_size-1]);
28 ASSERT_EQ(vlog_buffer_size, vlog.num_add());
29 ASSERT_EQ(0, vlog.num_delete());
30 ASSERT_EQ(0, vlog.num_update());
31 ASSERT_EQ(0, vlog.num_select());
32
33 vlog.AddEvent(history::VisitLog::DELETE_VISIT);
34 vlog.AddEvent(history::VisitLog::UPDATE_VISIT);
35 vlog.AddEvent(history::VisitLog::SELECT_VISIT);
36
37 ASSERT_EQ(history::VisitLog::DELETE_VISIT, vlog_buffer[0]);
38 ASSERT_EQ(history::VisitLog::UPDATE_VISIT, vlog_buffer[1]);
39 ASSERT_EQ(history::VisitLog::SELECT_VISIT, vlog_buffer[2]);
40 ASSERT_EQ(history::VisitLog::ADD_VISIT, vlog_buffer[vlog_buffer_size-1]);
41 ASSERT_EQ(vlog_buffer_size, vlog.num_add());
42 ASSERT_EQ(1, vlog.num_delete());
43 ASSERT_EQ(1, vlog.num_update());
44 ASSERT_EQ(1, vlog.num_select());
45 }
OLDNEW
« 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