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

Side by Side Diff: components/filesystem/files_test_base.h

Issue 1176653002: mandoline filesystem: add a sqlite3 vfs to proxy filesystem usage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix win 8 Created 5 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
« no previous file with comments | « components/filesystem/file_impl_unittest.cc ('k') | components/filesystem/files_test_base.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/application/public/cpp/application_test_base.h" 10 #include "mojo/application/public/cpp/application_test_base.h"
11 11
12 namespace filesystem { 12 namespace filesystem {
13 13
14 // TODO(vtl): Stuff copied from mojo/public/cpp/bindings/lib/template_util.h.
15 template <class T, T v>
16 struct IntegralConstant {
17 static const T value = v;
18 };
19
20 template <class T, T v>
21 const T IntegralConstant<T, v>::value;
22
23 typedef IntegralConstant<bool, true> TrueType;
24 typedef IntegralConstant<bool, false> FalseType;
25
26 template <class T>
27 struct IsConst : FalseType {};
28 template <class T>
29 struct IsConst<const T> : TrueType {};
30
31 template <bool B, typename T = void>
32 struct EnableIf {};
33
34 template <typename T>
35 struct EnableIf<true, T> {
36 typedef T type;
37 };
38
39 typedef char YesType;
40
41 struct NoType {
42 YesType dummy[2];
43 };
44
45 template <typename T>
46 struct IsMoveOnlyType {
47 template <typename U>
48 static YesType Test(const typename U::MoveOnlyTypeForCPP03*);
49
50 template <typename U>
51 static NoType Test(...);
52
53 static const bool value =
54 sizeof(Test<T>(0)) == sizeof(YesType) && !IsConst<T>::value;
55 };
56
57 template <typename T>
58 typename EnableIf<!IsMoveOnlyType<T>::value, T>::type& Forward(T& t) {
59 return t;
60 }
61
62 template <typename T>
63 typename EnableIf<IsMoveOnlyType<T>::value, T>::type Forward(T& t) {
64 return t.Pass();
65 }
66 // TODO(vtl): (End of stuff copied from template_util.h.)
67
68 template <typename T1>
69 mojo::Callback<void(T1)> Capture(T1* t1) {
70 return [t1](T1 got_t1) { *t1 = Forward(got_t1); };
71 }
72
73 template <typename T1, typename T2>
74 mojo::Callback<void(T1, T2)> Capture(T1* t1, T2* t2) {
75 return [t1, t2](T1 got_t1, T2 got_t2) {
76 *t1 = Forward(got_t1);
77 *t2 = Forward(got_t2);
78 };
79 }
80
81 class FilesTestBase : public mojo::test::ApplicationTestBase { 14 class FilesTestBase : public mojo::test::ApplicationTestBase {
82 public: 15 public:
83 FilesTestBase(); 16 FilesTestBase();
84 ~FilesTestBase() override; 17 ~FilesTestBase() override;
85 18
86 void SetUp() override; 19 void SetUp() override;
87 20
88 protected: 21 protected:
89 // Note: This has an out parameter rather than returning the |DirectoryPtr|, 22 // Note: This has an out parameter rather than returning the |DirectoryPtr|,
90 // since |ASSERT_...()| doesn't work with return values. 23 // since |ASSERT_...()| doesn't work with return values.
91 void GetTemporaryRoot(DirectoryPtr* directory); 24 void GetTemporaryRoot(DirectoryPtr* directory);
92 25
93 FileSystemPtr& files() { return files_; } 26 FileSystemPtr& files() { return files_; }
94 27
95 private: 28 private:
96 FileSystemPtr files_; 29 FileSystemPtr files_;
97 30
98 DISALLOW_COPY_AND_ASSIGN(FilesTestBase); 31 DISALLOW_COPY_AND_ASSIGN(FilesTestBase);
99 }; 32 };
100 33
101 } // namespace filesystem 34 } // namespace filesystem
102 35
103 #endif // COMPONENTS_FILESYSTEM_FILES_TEST_BASE_H_ 36 #endif // COMPONENTS_FILESYSTEM_FILES_TEST_BASE_H_
OLDNEW
« no previous file with comments | « components/filesystem/file_impl_unittest.cc ('k') | components/filesystem/files_test_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698