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

Side by Side Diff: chrome/browser/sync_file_system/drive_backend/leveldb_wrapper_unittest.cc

Issue 426063008: [SyncFS] Fix a bug in LevelDBWrapper::Iterator::Next (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/sync_file_system/drive_backend/leveldb_wrapper.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/sync_file_system/drive_backend/leveldb_wrapper.h" 5 #include "chrome/browser/sync_file_system/drive_backend/leveldb_wrapper.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 108
109 itr->Next(); 109 itr->Next();
110 EXPECT_TRUE(itr->Valid()); 110 EXPECT_TRUE(itr->Valid());
111 EXPECT_EQ("d", itr->key().ToString()); 111 EXPECT_EQ("d", itr->key().ToString());
112 EXPECT_EQ("4", itr->value().ToString()); 112 EXPECT_EQ("4", itr->value().ToString());
113 113
114 itr->Next(); 114 itr->Next();
115 EXPECT_FALSE(itr->Valid()); 115 EXPECT_FALSE(itr->Valid());
116 } 116 }
117 117
118 TEST_F(LevelDBWrapperTest, Iterator2Test) {
119 GetDB()->Put("a", "1");
120 GetDB()->Put("b", "2");
121 GetDB()->Put("c", "3");
122 // Keep pending transanctions on memory.
123
124 scoped_ptr<LevelDBWrapper::Iterator> itr = GetDB()->NewIterator();
125
126 std::string prev_key;
127 std::string prev_value;
128 int loop_counter = 0;
129 for (itr->SeekToFirst(); itr->Valid(); itr->Next()) {
130 ASSERT_NE(prev_key, itr->key().ToString());
131 ASSERT_NE(prev_value, itr->value().ToString());
132 prev_key = itr->key().ToString();
133 prev_value = itr->value().ToString();
134 ++loop_counter;
135 }
136 EXPECT_EQ(3, loop_counter);
137 EXPECT_EQ("c", prev_key);
138 EXPECT_EQ("3", prev_value);
139 }
140
118 TEST_F(LevelDBWrapperTest, PutTest) { 141 TEST_F(LevelDBWrapperTest, PutTest) {
119 TestData merged_data[] = {{"a", "1"}, {"aa", "new0"}, {"ab", "0"}, 142 TestData merged_data[] = {{"a", "1"}, {"aa", "new0"}, {"ab", "0"},
120 {"bb", "new2"}, {"c", "new1"}, {"d", "4"}}; 143 {"bb", "new2"}, {"c", "new1"}, {"d", "4"}};
121 TestData orig_data[] = {{"a", "1"}, {"ab", "0"}, {"bb", "3"}, {"d", "4"}}; 144 TestData orig_data[] = {{"a", "1"}, {"ab", "0"}, {"bb", "3"}, {"d", "4"}};
122 145
123 CreateDefaultDatabase(); 146 CreateDefaultDatabase();
124 147
125 // Add pending transactions. 148 // Add pending transactions.
126 GetDB()->Put("aa", "new0"); 149 GetDB()->Put("aa", "new0");
127 GetDB()->Put("c", "new1"); 150 GetDB()->Put("c", "new1");
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 GetDB()->Delete("ab"); 201 GetDB()->Delete("ab");
179 GetDB()->Commit(); 202 GetDB()->Commit();
180 GetDB()->Clear(); 203 GetDB()->Clear();
181 204
182 SCOPED_TRACE("DeleteTest_Commit"); 205 SCOPED_TRACE("DeleteTest_Commit");
183 CheckDBContents(merged_data, arraysize(merged_data)); 206 CheckDBContents(merged_data, arraysize(merged_data));
184 } 207 }
185 208
186 } // namespace drive_backend 209 } // namespace drive_backend
187 } // namespace sync_file_system 210 } // namespace sync_file_system
OLDNEW
« no previous file with comments | « chrome/browser/sync_file_system/drive_backend/leveldb_wrapper.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698