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

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

Issue 16998003: Update CrOS to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 6 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 "chrome/browser/chromeos/drive/change_list_processor.h" 5 #include "chrome/browser/chromeos/drive/change_list_processor.h"
6 6
7 #include "base/files/scoped_temp_dir.h" 7 #include "base/files/scoped_temp_dir.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/threading/sequenced_worker_pool.h" 9 #include "base/threading/sequenced_worker_pool.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 google_apis::test_util::RunBlockingPoolTask(); 111 google_apis::test_util::RunBlockingPoolTask();
112 return processor.changed_dirs(); 112 return processor.changed_dirs();
113 } 113 }
114 114
115 // Gets the resource entry for the path from |metadata_| synchronously. 115 // Gets the resource entry for the path from |metadata_| synchronously.
116 // Returns null if the entry does not exist. 116 // Returns null if the entry does not exist.
117 scoped_ptr<ResourceEntry> GetResourceEntry(const std::string& path) { 117 scoped_ptr<ResourceEntry> GetResourceEntry(const std::string& path) {
118 FileError error = FILE_ERROR_FAILED; 118 FileError error = FILE_ERROR_FAILED;
119 scoped_ptr<ResourceEntry> entry(new ResourceEntry); 119 scoped_ptr<ResourceEntry> entry(new ResourceEntry);
120 base::PostTaskAndReplyWithResult( 120 base::PostTaskAndReplyWithResult(
121 blocking_task_runner_, 121 blocking_task_runner_.get(),
122 FROM_HERE, 122 FROM_HERE,
123 base::Bind(&internal::ResourceMetadata::GetResourceEntryByPath, 123 base::Bind(&internal::ResourceMetadata::GetResourceEntryByPath,
124 base::Unretained(metadata_.get()), 124 base::Unretained(metadata_.get()),
125 base::FilePath::FromUTF8Unsafe(path), 125 base::FilePath::FromUTF8Unsafe(path),
126 entry.get()), 126 entry.get()),
127 base::Bind(google_apis::test_util::CreateCopyResultCallback(&error))); 127 base::Bind(google_apis::test_util::CreateCopyResultCallback(&error)));
128 google_apis::test_util::RunBlockingPoolTask(); 128 google_apis::test_util::RunBlockingPoolTask();
129 if (error != FILE_ERROR_OK) 129 if (error != FILE_ERROR_OK)
130 entry.reset(); 130 entry.reset();
131 return entry.Pass(); 131 return entry.Pass();
132 } 132 }
133 133
134 // Gets the largest changestamp stored in |metadata_|. 134 // Gets the largest changestamp stored in |metadata_|.
135 int64 GetChangestamp() { 135 int64 GetChangestamp() {
136 int64 changestamp = -1; 136 int64 changestamp = -1;
137 base::PostTaskAndReplyWithResult( 137 base::PostTaskAndReplyWithResult(
138 blocking_task_runner_, 138 blocking_task_runner_.get(),
139 FROM_HERE, 139 FROM_HERE,
140 base::Bind(&internal::ResourceMetadata::GetLargestChangestamp, 140 base::Bind(&internal::ResourceMetadata::GetLargestChangestamp,
141 base::Unretained(metadata_.get())), 141 base::Unretained(metadata_.get())),
142 base::Bind(google_apis::test_util::CreateCopyResultCallback( 142 base::Bind(
143 &changestamp))); 143 google_apis::test_util::CreateCopyResultCallback(&changestamp)));
144 google_apis::test_util::RunBlockingPoolTask(); 144 google_apis::test_util::RunBlockingPoolTask();
145 return changestamp; 145 return changestamp;
146 } 146 }
147 147
148 private: 148 private:
149 base::MessageLoopForUI message_loop_; 149 base::MessageLoopForUI message_loop_;
150 content::TestBrowserThread ui_thread_; 150 content::TestBrowserThread ui_thread_;
151 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; 151 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
152 base::ScopedTempDir temp_dir_; 152 base::ScopedTempDir temp_dir_;
153 scoped_ptr<internal::ResourceMetadata, test_util::DestroyHelperForTests> 153 scoped_ptr<internal::ResourceMetadata, test_util::DestroyHelperForTests>
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 ApplyChangeList(ParseChangeList(kTestJson)); 494 ApplyChangeList(ParseChangeList(kTestJson));
495 495
496 EXPECT_EQ(16730, GetChangestamp()); // the value is written in kTestJson. 496 EXPECT_EQ(16730, GetChangestamp()); // the value is written in kTestJson.
497 EXPECT_FALSE(GetResourceEntry("drive/root/New Directory/new_pdf_file.pdf")); 497 EXPECT_FALSE(GetResourceEntry("drive/root/New Directory/new_pdf_file.pdf"));
498 498
499 EXPECT_TRUE(changed_dirs.empty()); 499 EXPECT_TRUE(changed_dirs.empty());
500 } 500 }
501 501
502 } // namespace internal 502 } // namespace internal
503 } // namespace drive 503 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698