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

Side by Side Diff: webkit/fileapi/file_system_origin_database_unittest.cc

Issue 9663021: Add database recovery for FileSystemOriginDatabase (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: bool -> enum Created 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "testing/gtest/include/gtest/gtest.h" 5 #include "testing/gtest/include/gtest/gtest.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/scoped_temp_dir.h" 10 #include "base/scoped_temp_dir.h"
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 EXPECT_EQ(origins[1].origin, origin1); 156 EXPECT_EQ(origins[1].origin, origin1);
157 EXPECT_EQ(origins[1].path, path1); 157 EXPECT_EQ(origins[1].path, path1);
158 } else { 158 } else {
159 EXPECT_EQ(origins[0].origin, origin1); 159 EXPECT_EQ(origins[0].origin, origin1);
160 EXPECT_EQ(origins[0].path, path1); 160 EXPECT_EQ(origins[0].path, path1);
161 EXPECT_EQ(origins[1].origin, origin0); 161 EXPECT_EQ(origins[1].origin, origin0);
162 EXPECT_EQ(origins[1].path, path0); 162 EXPECT_EQ(origins[1].path, path0);
163 } 163 }
164 } 164 }
165 165
166 TEST(FileSystemOriginDatabaseTest, DatabaseRecoveryTest) {
167 ScopedTempDir dir;
168 ASSERT_TRUE(dir.CreateUniqueTempDir());
169 const FilePath kDBFile = dir.path().AppendASCII("fsod.db");
170 EXPECT_FALSE(file_util::PathExists(kDBFile));
171
172 const std::string origin("example.com");
173 {
174 FilePath path;
175 FileSystemOriginDatabase database(kDBFile);
176 EXPECT_FALSE(database.HasOriginPath(origin));
177 EXPECT_TRUE(database.GetPathForOrigin(origin, &path));
178 EXPECT_FALSE(path.empty());
179 EXPECT_TRUE(database.HasOriginPath(origin));
180 }
181
182 bool created = false;
183 base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED;
184 base::PlatformFile file = base::CreatePlatformFile(
185 kDBFile.AppendASCII("CURRENT"),
186 base::PLATFORM_FILE_CREATE_ALWAYS | base::PLATFORM_FILE_WRITE,
187 &created, &error);
188 EXPECT_EQ(base::PLATFORM_FILE_OK, error);
189 EXPECT_TRUE(created);
190 EXPECT_TRUE(base::ClosePlatformFile(file));
191
192 FilePath path;
193 FileSystemOriginDatabase database(kDBFile);
194 EXPECT_FALSE(database.HasOriginPath(origin));
195 EXPECT_TRUE(database.GetPathForOrigin(origin, &path));
196 EXPECT_FALSE(path.empty());
197 EXPECT_TRUE(database.HasOriginPath(origin));
198 }
199
166 } // namespace fileapi 200 } // namespace fileapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698