OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef COMPONENTS_FILESYSTEM_FILES_TEST_BASE_H_ | 5 #ifndef COMPONENTS_FILESYSTEM_FILES_TEST_BASE_H_ |
6 #define COMPONENTS_FILESYSTEM_FILES_TEST_BASE_H_ | 6 #define COMPONENTS_FILESYSTEM_FILES_TEST_BASE_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "components/filesystem/public/interfaces/file_system.mojom.h" | 9 #include "components/filesystem/public/interfaces/file_system.mojom.h" |
10 #include "mojo/public/cpp/bindings/binding.h" | 10 #include "mojo/public/cpp/bindings/binding.h" |
11 #include "services/shell/public/cpp/shell_test.h" | 11 #include "services/shell/public/cpp/shell_test.h" |
12 | 12 |
13 namespace filesystem { | 13 namespace filesystem { |
14 | 14 |
| 15 template <typename T1> |
| 16 mojo::Callback<void(T1)> Capture(T1* t1) { |
| 17 return [t1](T1 got_t1) { *t1 = std::move(got_t1); }; |
| 18 } |
| 19 |
| 20 template <typename T1, typename T2> |
| 21 mojo::Callback<void(T1, T2)> Capture(T1* t1, T2* t2) { |
| 22 return [t1, t2](T1 got_t1, T2 got_t2) { |
| 23 *t1 = std::move(got_t1); |
| 24 *t2 = std::move(got_t2); |
| 25 }; |
| 26 } |
| 27 |
| 28 template <typename T1, typename T2, typename T3> |
| 29 mojo::Callback<void(T1, T2, T3)> Capture(T1* t1, T2* t2, T3* t3) { |
| 30 return [t1, t2, t3](T1 got_t1, T2 got_t2, T3 got_t3) { |
| 31 *t1 = std::move(got_t1); |
| 32 *t2 = std::move(got_t2); |
| 33 *t3 = std::move(got_t3); |
| 34 }; |
| 35 } |
| 36 |
15 class FilesTestBase : public shell::test::ShellTest { | 37 class FilesTestBase : public shell::test::ShellTest { |
16 public: | 38 public: |
17 FilesTestBase(); | 39 FilesTestBase(); |
18 ~FilesTestBase() override; | 40 ~FilesTestBase() override; |
19 | 41 |
20 // Overridden from shell::test::ShellTest: | 42 // Overridden from shell::test::ShellTest: |
21 void SetUp() override; | 43 void SetUp() override; |
22 | 44 |
23 protected: | 45 protected: |
24 // Note: This has an out parameter rather than returning the |DirectoryPtr|, | 46 // Note: This has an out parameter rather than returning the |DirectoryPtr|, |
25 // since |ASSERT_...()| doesn't work with return values. | 47 // since |ASSERT_...()| doesn't work with return values. |
26 void GetTemporaryRoot(mojom::DirectoryPtr* directory); | 48 void GetTemporaryRoot(mojom::DirectoryPtr* directory); |
27 | 49 |
28 mojom::FileSystemPtr& files() { return files_; } | 50 mojom::FileSystemPtr& files() { return files_; } |
29 | 51 |
30 private: | 52 private: |
31 mojom::FileSystemPtr files_; | 53 mojom::FileSystemPtr files_; |
32 | 54 |
33 DISALLOW_COPY_AND_ASSIGN(FilesTestBase); | 55 DISALLOW_COPY_AND_ASSIGN(FilesTestBase); |
34 }; | 56 }; |
35 | 57 |
36 } // namespace filesystem | 58 } // namespace filesystem |
37 | 59 |
38 #endif // COMPONENTS_FILESYSTEM_FILES_TEST_BASE_H_ | 60 #endif // COMPONENTS_FILESYSTEM_FILES_TEST_BASE_H_ |
OLD | NEW |