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

Unified Diff: components/leveldb/leveldb_service_unittest.cc

Issue 1935863002: mojo: Fix leveldb unittests by making fs::Directories cloneable. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Gyp continues to exist. Created 4 years, 8 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 | « components/filesystem/shared_temp_dir.cc ('k') | services/user/user_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/leveldb/leveldb_service_unittest.cc
diff --git a/components/leveldb/leveldb_service_unittest.cc b/components/leveldb/leveldb_service_unittest.cc
index 1f9b7029e5dc3f1e5d05ace153aba68b2fc18a36..000727c0bf55194c57fadc8ed354b70475a5a90a 100644
--- a/components/leveldb/leveldb_service_unittest.cc
+++ b/components/leveldb/leveldb_service_unittest.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/bind.h"
#include "base/macros.h"
#include "components/filesystem/public/interfaces/directory.mojom.h"
#include "components/filesystem/public/interfaces/file_system.mojom.h"
@@ -40,10 +41,9 @@ class LevelDBServiceTest : public shell::test::ShellTest {
// Note: This has an out parameter rather than returning the |DirectoryPtr|,
// since |ASSERT_...()| doesn't work with return values.
- void GetUserDataDir(filesystem::DirectoryPtr* directory) {
+ void GetTempDirectory(filesystem::DirectoryPtr* directory) {
FileError error = FileError::FAILED;
- files()->OpenPersistentFileSystem(GetProxy(directory),
- mojo::Capture(&error));
+ files()->OpenTempDirectory(GetProxy(directory), mojo::Capture(&error));
ASSERT_TRUE(files().WaitForIncomingResponse());
ASSERT_EQ(FileError::OK, error);
}
@@ -187,22 +187,24 @@ TEST_F(LevelDBServiceTest, WriteBatch) {
EXPECT_EQ("", value.To<std::string>());
}
-// TODO(crbug.com/602820) Test is flaky.
-#if defined(OS_LINUX) || defined(OS_WIN)
-#define MAYBE_Reconnect DISABLED_Reconnect
-#else
-#define MAYBE_Reconnect Reconnect
-#endif
-TEST_F(LevelDBServiceTest, MAYBE_Reconnect) {
+TEST_F(LevelDBServiceTest, Reconnect) {
DatabaseError error;
+ filesystem::DirectoryPtr temp_directory;
+ GetTempDirectory(&temp_directory);
+
{
filesystem::DirectoryPtr directory;
- GetUserDataDir(&directory);
+ temp_directory->Clone(GetProxy(&directory));
LevelDBDatabasePtr database;
- leveldb()->Open(std::move(directory), "test", GetProxy(&database),
- Capture(&error));
+ leveldb::OpenOptionsPtr options = leveldb::OpenOptions::New();
+ options->error_if_exists = true;
+ options->create_if_missing = true;
+ leveldb()->OpenWithOptions(std::move(options),
+ std::move(directory), "test",
+ GetProxy(&database),
+ Capture(&error));
ASSERT_TRUE(leveldb().WaitForIncomingResponse());
EXPECT_EQ(DatabaseError::OK, error);
@@ -219,7 +221,7 @@ TEST_F(LevelDBServiceTest, MAYBE_Reconnect) {
{
filesystem::DirectoryPtr directory;
- GetUserDataDir(&directory);
+ temp_directory->Clone(GetProxy(&directory));
// Reconnect to the database.
LevelDBDatabasePtr database;
« no previous file with comments | « components/filesystem/shared_temp_dir.cc ('k') | services/user/user_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698