Include all dupe types (event when value is zero) in scan stats.
[chromium-blink-merge.git] / components / filesystem / files_test_base.h
blob36e15d526e7cf65ff5acc7c5ae276056fa742421
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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_FILESYSTEM_FILES_TEST_BASE_H_
6 #define COMPONENTS_FILESYSTEM_FILES_TEST_BASE_H_
8 #include "base/macros.h"
9 #include "components/filesystem/public/interfaces/file_system.mojom.h"
10 #include "mojo/application/public/cpp/application_test_base.h"
12 namespace filesystem {
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;
20 template <class T, T v>
21 const T IntegralConstant<T, v>::value;
23 typedef IntegralConstant<bool, true> TrueType;
24 typedef IntegralConstant<bool, false> FalseType;
26 template <class T>
27 struct IsConst : FalseType {};
28 template <class T>
29 struct IsConst<const T> : TrueType {};
31 template <bool B, typename T = void>
32 struct EnableIf {};
34 template <typename T>
35 struct EnableIf<true, T> {
36 typedef T type;
39 typedef char YesType;
41 struct NoType {
42 YesType dummy[2];
45 template <typename T>
46 struct IsMoveOnlyType {
47 template <typename U>
48 static YesType Test(const typename U::MoveOnlyTypeForCPP03*);
50 template <typename U>
51 static NoType Test(...);
53 static const bool value =
54 sizeof(Test<T>(0)) == sizeof(YesType) && !IsConst<T>::value;
57 template <typename T>
58 typename EnableIf<!IsMoveOnlyType<T>::value, T>::type& Forward(T& t) {
59 return t;
62 template <typename T>
63 typename EnableIf<IsMoveOnlyType<T>::value, T>::type Forward(T& t) {
64 return t.Pass();
66 // TODO(vtl): (End of stuff copied from template_util.h.)
68 template <typename T1>
69 mojo::Callback<void(T1)> Capture(T1* t1) {
70 return [t1](T1 got_t1) { *t1 = Forward(got_t1); };
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);
81 class FilesTestBase : public mojo::test::ApplicationTestBase {
82 public:
83 FilesTestBase();
84 ~FilesTestBase() override;
86 void SetUp() override;
88 protected:
89 // Note: This has an out parameter rather than returning the |DirectoryPtr|,
90 // since |ASSERT_...()| doesn't work with return values.
91 void GetTemporaryRoot(DirectoryPtr* directory);
93 FileSystemPtr& files() { return files_; }
95 private:
96 FileSystemPtr files_;
98 DISALLOW_COPY_AND_ASSIGN(FilesTestBase);
101 } // namespace filesystem
103 #endif // COMPONENTS_FILESYSTEM_FILES_TEST_BASE_H_