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

Side by Side Diff: chrome/browser/sync_file_system/local/syncable_file_system_unittest.cc

Issue 145693005: [FileAPI] Replace default leveldb::Env with leveldb::MemEnv in tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 10 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "base/stl_util.h" 5 #include "base/stl_util.h"
6 #include "chrome/browser/sync_file_system/local/canned_syncable_file_system.h" 6 #include "chrome/browser/sync_file_system/local/canned_syncable_file_system.h"
7 #include "chrome/browser/sync_file_system/local/local_file_change_tracker.h" 7 #include "chrome/browser/sync_file_system/local/local_file_change_tracker.h"
8 #include "chrome/browser/sync_file_system/local/local_file_sync_context.h" 8 #include "chrome/browser/sync_file_system/local/local_file_sync_context.h"
9 #include "chrome/browser/sync_file_system/local/sync_file_system_backend.h" 9 #include "chrome/browser/sync_file_system/local/sync_file_system_backend.h"
10 #include "chrome/browser/sync_file_system/syncable_file_system_util.h" 10 #include "chrome/browser/sync_file_system/syncable_file_system_util.h"
11 #include "content/public/test/sandbox_file_system_test_helper.h" 11 #include "content/public/test/sandbox_file_system_test_helper.h"
12 #include "content/public/test/test_browser_thread_bundle.h" 12 #include "content/public/test/test_browser_thread_bundle.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 #include "third_party/leveldatabase/src/helpers/memenv/memenv.h"
15 #include "third_party/leveldatabase/src/include/leveldb/env.h"
14 #include "webkit/browser/fileapi/async_file_test_helper.h" 16 #include "webkit/browser/fileapi/async_file_test_helper.h"
15 #include "webkit/browser/fileapi/file_system_context.h" 17 #include "webkit/browser/fileapi/file_system_context.h"
16 #include "webkit/browser/fileapi/file_system_operation_context.h" 18 #include "webkit/browser/fileapi/file_system_operation_context.h"
17 #include "webkit/browser/fileapi/isolated_context.h" 19 #include "webkit/browser/fileapi/isolated_context.h"
18 #include "webkit/browser/quota/quota_manager.h" 20 #include "webkit/browser/quota/quota_manager.h"
19 #include "webkit/common/fileapi/file_system_types.h" 21 #include "webkit/common/fileapi/file_system_types.h"
20 #include "webkit/common/quota/quota_types.h" 22 #include "webkit/common/quota/quota_types.h"
21 23
22 using base::PlatformFileError; 24 using base::PlatformFileError;
23 using content::SandboxFileSystemTestHelper; 25 using content::SandboxFileSystemTestHelper;
24 using fileapi::FileSystemContext; 26 using fileapi::FileSystemContext;
25 using fileapi::FileSystemOperationContext; 27 using fileapi::FileSystemOperationContext;
26 using fileapi::FileSystemURL; 28 using fileapi::FileSystemURL;
27 using fileapi::FileSystemURLSet; 29 using fileapi::FileSystemURLSet;
28 using quota::QuotaManager; 30 using quota::QuotaManager;
29 using quota::QuotaStatusCode; 31 using quota::QuotaStatusCode;
30 32
31 namespace sync_file_system { 33 namespace sync_file_system {
32 34
33 class SyncableFileSystemTest : public testing::Test { 35 class SyncableFileSystemTest : public testing::Test {
34 public: 36 public:
35 SyncableFileSystemTest() 37 SyncableFileSystemTest()
36 : file_system_(GURL("http://example.com/"), 38 : in_memory_env_(leveldb::NewMemEnv(leveldb::Env::Default())),
39 file_system_(GURL("http://example.com/"),
40 in_memory_env_.get(),
37 base::MessageLoopProxy::current().get(), 41 base::MessageLoopProxy::current().get(),
38 base::MessageLoopProxy::current().get()), 42 base::MessageLoopProxy::current().get()),
39 weak_factory_(this) {} 43 weak_factory_(this) {}
40 44
41 virtual void SetUp() { 45 virtual void SetUp() {
42 ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); 46 ASSERT_TRUE(data_dir_.CreateUniqueTempDir());
43
44 file_system_.SetUp(); 47 file_system_.SetUp();
45 48
46 sync_context_ = 49 sync_context_ =
47 new LocalFileSyncContext(data_dir_.path(), 50 new LocalFileSyncContext(data_dir_.path(),
51 in_memory_env_.get(),
48 base::MessageLoopProxy::current().get(), 52 base::MessageLoopProxy::current().get(),
49 base::MessageLoopProxy::current().get()); 53 base::MessageLoopProxy::current().get());
50 ASSERT_EQ( 54 ASSERT_EQ(
51 sync_file_system::SYNC_STATUS_OK, 55 sync_file_system::SYNC_STATUS_OK,
52 file_system_.MaybeInitializeFileSystemContext(sync_context_.get())); 56 file_system_.MaybeInitializeFileSystemContext(sync_context_.get()));
53 } 57 }
54 58
55 virtual void TearDown() { 59 virtual void TearDown() {
56 if (sync_context_.get()) 60 if (sync_context_.get())
57 sync_context_->ShutdownOnUIThread(); 61 sync_context_->ShutdownOnUIThread();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 } 95 }
92 96
93 LocalFileChangeTracker* change_tracker() { 97 LocalFileChangeTracker* change_tracker() {
94 return file_system_.backend()->change_tracker(); 98 return file_system_.backend()->change_tracker();
95 } 99 }
96 100
97 ScopedEnableSyncFSDirectoryOperation enable_directory_operation_; 101 ScopedEnableSyncFSDirectoryOperation enable_directory_operation_;
98 102
99 base::ScopedTempDir data_dir_; 103 base::ScopedTempDir data_dir_;
100 content::TestBrowserThreadBundle thread_bundle_; 104 content::TestBrowserThreadBundle thread_bundle_;
105 scoped_ptr<leveldb::Env> in_memory_env_;
101 CannedSyncableFileSystem file_system_; 106 CannedSyncableFileSystem file_system_;
102 107
103 private: 108 private:
104 scoped_refptr<LocalFileSyncContext> sync_context_; 109 scoped_refptr<LocalFileSyncContext> sync_context_;
105 110
106 base::WeakPtrFactory<SyncableFileSystemTest> weak_factory_; 111 base::WeakPtrFactory<SyncableFileSystemTest> weak_factory_;
107 112
108 DISALLOW_COPY_AND_ASSIGN(SyncableFileSystemTest); 113 DISALLOW_COPY_AND_ASSIGN(SyncableFileSystemTest);
109 }; 114 };
110 115
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 // Now try copying the directory into the syncable file system, which should 280 // Now try copying the directory into the syncable file system, which should
276 // fail if directory operation is disabled. (http://crbug.com/161442) 281 // fail if directory operation is disabled. (http://crbug.com/161442)
277 EXPECT_NE(base::File::FILE_OK, 282 EXPECT_NE(base::File::FILE_OK,
278 file_system_.Copy(kSrcDir, URL("dest"))); 283 file_system_.Copy(kSrcDir, URL("dest")));
279 284
280 other_file_system_.TearDown(); 285 other_file_system_.TearDown();
281 SetEnableSyncFSDirectoryOperation(was_enabled); 286 SetEnableSyncFSDirectoryOperation(was_enabled);
282 } 287 }
283 288
284 } // namespace sync_file_system 289 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698