OLD | NEW |
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/file_system/get_file_for_saving_operatio
n.h" | 5 #include "chrome/browser/chromeos/drive/file_system/get_file_for_saving_operatio
n.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 public: | 30 public: |
31 void set_quit_closure(const base::Closure& quit_closure) { | 31 void set_quit_closure(const base::Closure& quit_closure) { |
32 quit_closure_ = quit_closure; | 32 quit_closure_ = quit_closure; |
33 } | 33 } |
34 | 34 |
35 const std::string& updated_local_id() const { | 35 const std::string& updated_local_id() const { |
36 return updated_local_id_; | 36 return updated_local_id_; |
37 } | 37 } |
38 | 38 |
39 // OperationDelegate overrides. | 39 // OperationDelegate overrides. |
40 virtual void OnEntryUpdatedByOperation(const ClientContext& /* context */, | 40 void OnEntryUpdatedByOperation(const ClientContext& /* context */, |
41 const std::string& local_id) override { | 41 const std::string& local_id) override { |
42 updated_local_id_ = local_id; | 42 updated_local_id_ = local_id; |
43 if (!quit_closure_.is_null()) | 43 if (!quit_closure_.is_null()) |
44 quit_closure_.Run(); | 44 quit_closure_.Run(); |
45 } | 45 } |
46 | 46 |
47 private: | 47 private: |
48 std::string updated_local_id_; | 48 std::string updated_local_id_; |
49 base::Closure quit_closure_; | 49 base::Closure quit_closure_; |
50 }; | 50 }; |
51 | 51 |
52 } // namespace | 52 } // namespace |
53 | 53 |
54 class GetFileForSavingOperationTest : public OperationTestBase { | 54 class GetFileForSavingOperationTest : public OperationTestBase { |
55 protected: | 55 protected: |
56 // FileWriteWatcher requires TYPE_IO message loop to run. | 56 // FileWriteWatcher requires TYPE_IO message loop to run. |
57 GetFileForSavingOperationTest() | 57 GetFileForSavingOperationTest() |
58 : OperationTestBase(content::TestBrowserThreadBundle::IO_MAINLOOP) { | 58 : OperationTestBase(content::TestBrowserThreadBundle::IO_MAINLOOP) { |
59 } | 59 } |
60 | 60 |
61 virtual void SetUp() override { | 61 void SetUp() override { |
62 OperationTestBase::SetUp(); | 62 OperationTestBase::SetUp(); |
63 | 63 |
64 operation_.reset(new GetFileForSavingOperation( | 64 operation_.reset(new GetFileForSavingOperation( |
65 logger(), blocking_task_runner(), &delegate_, scheduler(), metadata(), | 65 logger(), blocking_task_runner(), &delegate_, scheduler(), metadata(), |
66 cache(), temp_dir())); | 66 cache(), temp_dir())); |
67 operation_->file_write_watcher_for_testing()->DisableDelayForTesting(); | 67 operation_->file_write_watcher_for_testing()->DisableDelayForTesting(); |
68 } | 68 } |
69 | 69 |
70 TestDelegate delegate_; | 70 TestDelegate delegate_; |
71 scoped_ptr<GetFileForSavingOperation> operation_; | 71 scoped_ptr<GetFileForSavingOperation> operation_; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 google_apis::test_util::CreateCopyResultCallback( | 144 google_apis::test_util::CreateCopyResultCallback( |
145 &error, &local_path, &entry)); | 145 &error, &local_path, &entry)); |
146 content::RunAllBlockingPoolTasksUntilIdle(); | 146 content::RunAllBlockingPoolTasksUntilIdle(); |
147 | 147 |
148 // Checks that an error is returned. | 148 // Checks that an error is returned. |
149 EXPECT_EQ(FILE_ERROR_EXISTS, error); | 149 EXPECT_EQ(FILE_ERROR_EXISTS, error); |
150 } | 150 } |
151 | 151 |
152 } // namespace file_system | 152 } // namespace file_system |
153 } // namespace drive | 153 } // namespace drive |
OLD | NEW |