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

Side by Side Diff: chrome/browser/chromeos/drive/remove_stale_cache_files_unittest.cc

Issue 1124813003: [chrome/browser/chromeos/drive] Avoid use of MessageLoopProxy by use of TTRH (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <string> 5 #include <string>
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/single_thread_task_runner.h"
12 #include "base/thread_task_runner_handle.h"
11 #include "chrome/browser/chromeos/drive/drive.pb.h" 13 #include "chrome/browser/chromeos/drive/drive.pb.h"
12 #include "chrome/browser/chromeos/drive/fake_free_disk_space_getter.h" 14 #include "chrome/browser/chromeos/drive/fake_free_disk_space_getter.h"
13 #include "chrome/browser/chromeos/drive/file_system_util.h" 15 #include "chrome/browser/chromeos/drive/file_system_util.h"
14 #include "chrome/browser/chromeos/drive/remove_stale_cache_files.h" 16 #include "chrome/browser/chromeos/drive/remove_stale_cache_files.h"
15 #include "chrome/browser/chromeos/drive/resource_metadata.h" 17 #include "chrome/browser/chromeos/drive/resource_metadata.h"
16 #include "chrome/browser/chromeos/drive/test_util.h" 18 #include "chrome/browser/chromeos/drive/test_util.h"
17 #include "content/public/test/test_browser_thread_bundle.h" 19 #include "content/public/test/test_browser_thread_bundle.h"
18 #include "google_apis/drive/test_util.h" 20 #include "google_apis/drive/test_util.h"
19 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
20 22
21 namespace drive { 23 namespace drive {
22 namespace internal { 24 namespace internal {
23 25
24 class RemoveStaleCacheFilesTest : public testing::Test { 26 class RemoveStaleCacheFilesTest : public testing::Test {
25 protected: 27 protected:
26 void SetUp() override { 28 void SetUp() override {
27 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 29 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
28 30
29 fake_free_disk_space_getter_.reset(new FakeFreeDiskSpaceGetter); 31 fake_free_disk_space_getter_.reset(new FakeFreeDiskSpaceGetter);
30 32
31 metadata_storage_.reset(new ResourceMetadataStorage( 33 metadata_storage_.reset(new ResourceMetadataStorage(
32 temp_dir_.path(), base::MessageLoopProxy::current().get())); 34 temp_dir_.path(), base::ThreadTaskRunnerHandle::Get()));
33 35
34 cache_.reset(new FileCache(metadata_storage_.get(), 36 cache_.reset(new FileCache(metadata_storage_.get(), temp_dir_.path(),
35 temp_dir_.path(), 37 base::ThreadTaskRunnerHandle::Get(),
36 base::MessageLoopProxy::current().get(),
37 fake_free_disk_space_getter_.get())); 38 fake_free_disk_space_getter_.get()));
38 39
39 resource_metadata_.reset(new ResourceMetadata( 40 resource_metadata_.reset(
40 metadata_storage_.get(), cache_.get(), 41 new ResourceMetadata(metadata_storage_.get(), cache_.get(),
41 base::MessageLoopProxy::current())); 42 base::ThreadTaskRunnerHandle::Get()));
42 43
43 ASSERT_TRUE(metadata_storage_->Initialize()); 44 ASSERT_TRUE(metadata_storage_->Initialize());
44 ASSERT_TRUE(cache_->Initialize()); 45 ASSERT_TRUE(cache_->Initialize());
45 ASSERT_EQ(FILE_ERROR_OK, resource_metadata_->Initialize()); 46 ASSERT_EQ(FILE_ERROR_OK, resource_metadata_->Initialize());
46 } 47 }
47 48
48 content::TestBrowserThreadBundle thread_bundle_; 49 content::TestBrowserThreadBundle thread_bundle_;
49 base::ScopedTempDir temp_dir_; 50 base::ScopedTempDir temp_dir_;
50 51
51 scoped_ptr<ResourceMetadataStorage, 52 scoped_ptr<ResourceMetadataStorage,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 RemoveStaleCacheFiles(cache_.get(), resource_metadata_.get()); 105 RemoveStaleCacheFiles(cache_.get(), resource_metadata_.get());
105 106
106 // Dirty cache should not be removed even though its MD5 doesn't match. 107 // Dirty cache should not be removed even though its MD5 doesn't match.
107 EXPECT_EQ(FILE_ERROR_OK, 108 EXPECT_EQ(FILE_ERROR_OK,
108 resource_metadata_->GetResourceEntryById(local_id, &entry)); 109 resource_metadata_->GetResourceEntryById(local_id, &entry));
109 EXPECT_TRUE(entry.file_specific_info().cache_state().is_present()); 110 EXPECT_TRUE(entry.file_specific_info().cache_state().is_present());
110 } 111 }
111 112
112 } // namespace internal 113 } // namespace internal
113 } // namespace drive 114 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698