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/write_on_cache_file.h" | 5 #include "chrome/browser/chromeos/drive/write_on_cache_file.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "chrome/browser/chromeos/drive/dummy_file_system.h" | 8 #include "chrome/browser/chromeos/drive/dummy_file_system.h" |
9 #include "content/public/test/test_browser_thread_bundle.h" | 9 #include "content/public/test/test_browser_thread_bundle.h" |
10 #include "content/public/test/test_utils.h" | 10 #include "content/public/test/test_utils.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 FILE_PATH_LITERAL("/tmp/local.txt"); | 23 FILE_PATH_LITERAL("/tmp/local.txt"); |
24 | 24 |
25 class TestFileSystem : public DummyFileSystem { | 25 class TestFileSystem : public DummyFileSystem { |
26 public: | 26 public: |
27 TestFileSystem() : num_closed_(0) { | 27 TestFileSystem() : num_closed_(0) { |
28 } | 28 } |
29 | 29 |
30 int num_closed() const { return num_closed_; } | 30 int num_closed() const { return num_closed_; } |
31 | 31 |
32 // Mimics OpenFile. It fails if the |file_path| points to a hosted document. | 32 // Mimics OpenFile. It fails if the |file_path| points to a hosted document. |
33 virtual void OpenFile(const base::FilePath& file_path, | 33 void OpenFile(const base::FilePath& file_path, |
34 OpenMode open_mode, | 34 OpenMode open_mode, |
35 const std::string& mime_type, | 35 const std::string& mime_type, |
36 const OpenFileCallback& callback) override { | 36 const OpenFileCallback& callback) override { |
37 EXPECT_EQ(OPEN_OR_CREATE_FILE, open_mode); | 37 EXPECT_EQ(OPEN_OR_CREATE_FILE, open_mode); |
38 | 38 |
39 // Emulate a case of opening a hosted document. | 39 // Emulate a case of opening a hosted document. |
40 if (file_path == base::FilePath(kInvalidPath)) { | 40 if (file_path == base::FilePath(kInvalidPath)) { |
41 callback.Run(FILE_ERROR_INVALID_OPERATION, base::FilePath(), | 41 callback.Run(FILE_ERROR_INVALID_OPERATION, base::FilePath(), |
42 base::Closure()); | 42 base::Closure()); |
43 return; | 43 return; |
44 } | 44 } |
45 | 45 |
46 callback.Run(FILE_ERROR_OK, base::FilePath(kLocalPath), | 46 callback.Run(FILE_ERROR_OK, base::FilePath(kLocalPath), |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 base::FilePath(kInvalidPath), | 93 base::FilePath(kInvalidPath), |
94 std::string(), // mime_type | 94 std::string(), // mime_type |
95 google_apis::test_util::CreateCopyResultCallback(&error, &path)); | 95 google_apis::test_util::CreateCopyResultCallback(&error, &path)); |
96 content::RunAllBlockingPoolTasksUntilIdle(); | 96 content::RunAllBlockingPoolTasksUntilIdle(); |
97 | 97 |
98 EXPECT_EQ(FILE_ERROR_INVALID_OPERATION, error); | 98 EXPECT_EQ(FILE_ERROR_INVALID_OPERATION, error); |
99 EXPECT_TRUE(path.empty()); | 99 EXPECT_TRUE(path.empty()); |
100 } | 100 } |
101 | 101 |
102 } // namespace drive | 102 } // namespace drive |
OLD | NEW |