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

Side by Side Diff: sql/mojo/sql_test_base.h

Issue 1231493002: mandoline filesystem: Save cookie data to the mojo:filesystem. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge with ToT Created 5 years, 5 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
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 SQL_MOJO_SQL_TEST_BASE_H_ 5 #ifndef SQL_MOJO_SQL_TEST_BASE_H_
6 #define SQL_MOJO_SQL_TEST_BASE_H_ 6 #define SQL_MOJO_SQL_TEST_BASE_H_
7 7
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "components/filesystem/public/interfaces/file_system.mojom.h" 10 #include "components/filesystem/public/interfaces/file_system.mojom.h"
11 #include "mojo/application/public/cpp/application_test_base.h" 11 #include "mojo/application/public/cpp/application_test_base.h"
12 #include "sql/connection.h" 12 #include "sql/connection.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 namespace sql { 15 namespace sql {
16 16
17 class Connection; 17 class Connection;
18 class ScopedMojoFilesystemVFS; 18 class ScopedMojoFilesystemVFS;
19 19
20 // Base class for SQL tests. 20 // Base class for SQL tests.
21 // 21 //
22 // WARNING: We want to run the same gtest based unit test code both against 22 // WARNING: We want to run the same gtest based unit test code both against
23 // chromium (which uses this implementation here), and the mojo code (which 23 // chromium (which uses this implementation here), and the mojo code (which
24 // uses a different class named SQLTestBase). These two classes need to have 24 // uses a different class named SQLTestBase). These two classes need to have
25 // the same interface because we compile time switch them based on a 25 // the same interface because we compile time switch them based on a
26 // #define. We need to have two different implementations because the mojo 26 // #define. We need to have two different implementations because the mojo
27 // version derives from mojo::test::ApplicationTestBase instead of 27 // version derives from mojo::test::ApplicationTestBase instead of
28 // testing::Test. 28 // testing::Test.
29 class SQLTestBase : public mojo::test::ApplicationTestBase { 29 class SQLTestBase : public mojo::test::ApplicationTestBase,
30 public filesystem::FileSystemClient {
30 public: 31 public:
31 SQLTestBase(); 32 SQLTestBase();
32 ~SQLTestBase() override; 33 ~SQLTestBase() override;
33 34
34 enum WriteJunkType { 35 enum WriteJunkType {
35 TYPE_OVERWRITE_AND_TRUNCATE, 36 TYPE_OVERWRITE_AND_TRUNCATE,
36 TYPE_OVERWRITE 37 TYPE_OVERWRITE
37 }; 38 };
38 39
39 // Returns the path to the database. 40 // Returns the path to the database.
(...skipping 21 matching lines...) Expand all
61 // Writes junk to the start of the file. 62 // Writes junk to the start of the file.
62 void WriteJunkToDatabase(WriteJunkType type); 63 void WriteJunkToDatabase(WriteJunkType type);
63 64
64 // Sets the database file size to 0. 65 // Sets the database file size to 0.
65 void TruncateDatabase(); 66 void TruncateDatabase();
66 67
67 // Overridden from testing::Test: 68 // Overridden from testing::Test:
68 void SetUp() override; 69 void SetUp() override;
69 void TearDown() override; 70 void TearDown() override;
70 71
72 // Overridden from FileSystemClient:
73 void OnFileSystemShutdown() override;
74
71 protected: 75 protected:
72 filesystem::FileSystemPtr& files() { return files_; } 76 filesystem::FileSystemPtr& files() { return files_; }
73 77
74 private: 78 private:
75 filesystem::FileSystemPtr files_; 79 filesystem::FileSystemPtr files_;
76 80
77 scoped_ptr<ScopedMojoFilesystemVFS> vfs_; 81 scoped_ptr<ScopedMojoFilesystemVFS> vfs_;
82 mojo::Binding<filesystem::FileSystemClient> binding_;
78 sql::Connection db_; 83 sql::Connection db_;
79 84
80 DISALLOW_COPY_AND_ASSIGN(SQLTestBase); 85 DISALLOW_COPY_AND_ASSIGN(SQLTestBase);
81 }; 86 };
82 87
83 } // namespace sql 88 } // namespace sql
84 89
85 #endif // SQL_MOJO_SQL_TEST_BASE_H_ 90 #endif // SQL_MOJO_SQL_TEST_BASE_H_
OLDNEW
« sql/mojo/mojo_vfs.cc ('K') | « sql/mojo/mojo_vfs.cc ('k') | sql/mojo/sql_test_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698