OLD | NEW |
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 "chrome/browser/chromeos/drive/resource_metadata.h" | 5 #include "chrome/browser/chromeos/drive/resource_metadata.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 virtual void SetUp() OVERRIDE { | 118 virtual void SetUp() OVERRIDE { |
119 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 119 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
120 | 120 |
121 base::ThreadRestrictions::SetIOAllowed(false); // For strict thread check. | 121 base::ThreadRestrictions::SetIOAllowed(false); // For strict thread check. |
122 scoped_refptr<base::SequencedWorkerPool> pool = | 122 scoped_refptr<base::SequencedWorkerPool> pool = |
123 content::BrowserThread::GetBlockingPool(); | 123 content::BrowserThread::GetBlockingPool(); |
124 blocking_task_runner_ = | 124 blocking_task_runner_ = |
125 pool->GetSequencedTaskRunner(pool->GetSequenceToken()); | 125 pool->GetSequencedTaskRunner(pool->GetSequenceToken()); |
126 | 126 |
127 metadata_storage_.reset(new ResourceMetadataStorage( | 127 metadata_storage_.reset(new ResourceMetadataStorage( |
128 temp_dir_.path(), blocking_task_runner_)); | 128 temp_dir_.path(), blocking_task_runner_.get())); |
129 bool success = false; | 129 bool success = false; |
130 base::PostTaskAndReplyWithResult( | 130 base::PostTaskAndReplyWithResult( |
131 blocking_task_runner_, | 131 blocking_task_runner_.get(), |
132 FROM_HERE, | 132 FROM_HERE, |
133 base::Bind(&ResourceMetadataStorage::Initialize, | 133 base::Bind(&ResourceMetadataStorage::Initialize, |
134 base::Unretained(metadata_storage_.get())), | 134 base::Unretained(metadata_storage_.get())), |
135 google_apis::test_util::CreateCopyResultCallback(&success)); | 135 google_apis::test_util::CreateCopyResultCallback(&success)); |
136 google_apis::test_util::RunBlockingPoolTask(); | 136 google_apis::test_util::RunBlockingPoolTask(); |
137 ASSERT_TRUE(success); | 137 ASSERT_TRUE(success); |
138 | 138 |
139 resource_metadata_.reset(new ResourceMetadata(metadata_storage_.get(), | 139 resource_metadata_.reset(new ResourceMetadata(metadata_storage_.get(), |
140 blocking_task_runner_)); | 140 blocking_task_runner_)); |
141 | 141 |
142 FileError error = FILE_ERROR_FAILED; | 142 FileError error = FILE_ERROR_FAILED; |
143 base::PostTaskAndReplyWithResult( | 143 base::PostTaskAndReplyWithResult( |
144 blocking_task_runner_, | 144 blocking_task_runner_.get(), |
145 FROM_HERE, | 145 FROM_HERE, |
146 base::Bind(&ResourceMetadata::Initialize, | 146 base::Bind(&ResourceMetadata::Initialize, |
147 base::Unretained(resource_metadata_.get())), | 147 base::Unretained(resource_metadata_.get())), |
148 google_apis::test_util::CreateCopyResultCallback(&error)); | 148 google_apis::test_util::CreateCopyResultCallback(&error)); |
149 google_apis::test_util::RunBlockingPoolTask(); | 149 google_apis::test_util::RunBlockingPoolTask(); |
150 ASSERT_EQ(FILE_ERROR_OK, error); | 150 ASSERT_EQ(FILE_ERROR_OK, error); |
151 | 151 |
152 blocking_task_runner_->PostTask( | 152 blocking_task_runner_->PostTask( |
153 FROM_HERE, | 153 FROM_HERE, |
154 base::Bind(&SetUpEntries, | 154 base::Bind(&SetUpEntries, |
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
852 EXPECT_TRUE(entries_in_other->empty()); | 852 EXPECT_TRUE(entries_in_other->empty()); |
853 } | 853 } |
854 | 854 |
855 // Tests for methods running on the blocking task runner. | 855 // Tests for methods running on the blocking task runner. |
856 class ResourceMetadataTest : public testing::Test { | 856 class ResourceMetadataTest : public testing::Test { |
857 protected: | 857 protected: |
858 virtual void SetUp() OVERRIDE { | 858 virtual void SetUp() OVERRIDE { |
859 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 859 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
860 | 860 |
861 metadata_storage_.reset(new ResourceMetadataStorage( | 861 metadata_storage_.reset(new ResourceMetadataStorage( |
862 temp_dir_.path(), base::MessageLoopProxy::current())); | 862 temp_dir_.path(), base::MessageLoopProxy::current().get())); |
863 ASSERT_TRUE(metadata_storage_->Initialize()); | 863 ASSERT_TRUE(metadata_storage_->Initialize()); |
864 | 864 |
865 resource_metadata_.reset(new ResourceMetadata( | 865 resource_metadata_.reset(new ResourceMetadata( |
866 metadata_storage_.get(), base::MessageLoopProxy::current())); | 866 metadata_storage_.get(), base::MessageLoopProxy::current())); |
867 | 867 |
868 ASSERT_EQ(FILE_ERROR_OK, resource_metadata_->Initialize()); | 868 ASSERT_EQ(FILE_ERROR_OK, resource_metadata_->Initialize()); |
869 | 869 |
870 SetUpEntries(resource_metadata_.get()); | 870 SetUpEntries(resource_metadata_.get()); |
871 } | 871 } |
872 | 872 |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1076 else | 1076 else |
1077 ++directory_count; | 1077 ++directory_count; |
1078 } | 1078 } |
1079 | 1079 |
1080 EXPECT_EQ(7, file_count); | 1080 EXPECT_EQ(7, file_count); |
1081 EXPECT_EQ(6, directory_count); | 1081 EXPECT_EQ(6, directory_count); |
1082 } | 1082 } |
1083 | 1083 |
1084 } // namespace internal | 1084 } // namespace internal |
1085 } // namespace drive | 1085 } // namespace drive |
OLD | NEW |