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

Side by Side Diff: components/leveldb/leveldb_service_unittest.cc

Issue 2008383002: Remove a bunch of stuff in //mojo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 7 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/macros.h" 6 #include "base/macros.h"
7 #include "components/filesystem/public/interfaces/directory.mojom.h" 7 #include "components/filesystem/public/interfaces/directory.mojom.h"
8 #include "components/filesystem/public/interfaces/file_system.mojom.h" 8 #include "components/filesystem/public/interfaces/file_system.mojom.h"
9 #include "components/filesystem/public/interfaces/types.mojom.h" 9 #include "components/filesystem/public/interfaces/types.mojom.h"
10 #include "components/leveldb/public/interfaces/leveldb.mojom.h" 10 #include "components/leveldb/public/interfaces/leveldb.mojom.h"
11 #include "mojo/common/common_type_converters.h" 11 #include "mojo/common/common_type_converters.h"
12 #include "mojo/public/cpp/bindings/binding_set.h" 12 #include "mojo/public/cpp/bindings/binding_set.h"
13 #include "mojo/util/capture_util.h"
14 #include "services/shell/public/cpp/shell_connection.h" 13 #include "services/shell/public/cpp/shell_connection.h"
15 #include "services/shell/public/cpp/shell_test.h" 14 #include "services/shell/public/cpp/shell_test.h"
16 15
17 using filesystem::mojom::FileError; 16 using filesystem::mojom::FileError;
18 using mojo::Capture;
19 17
20 namespace leveldb { 18 namespace leveldb {
21 namespace { 19 namespace {
22 20
21 template <typename T1>
22 mojo::Callback<void(T1)> Capture(T1* t1) {
23 return [t1](T1 got_t1) { *t1 = std::move(got_t1); };
24 }
25
26 template <typename T1, typename T2>
27 mojo::Callback<void(T1, T2)> Capture(T1* t1, T2* t2) {
28 return [t1, t2](T1 got_t1, T2 got_t2) {
29 *t1 = std::move(got_t1);
30 *t2 = std::move(got_t2);
31 };
32 }
33
23 class LevelDBServiceTest : public shell::test::ShellTest { 34 class LevelDBServiceTest : public shell::test::ShellTest {
24 public: 35 public:
25 LevelDBServiceTest() : ShellTest("exe:leveldb_service_unittests") {} 36 LevelDBServiceTest() : ShellTest("exe:leveldb_service_unittests") {}
26 ~LevelDBServiceTest() override {} 37 ~LevelDBServiceTest() override {}
27 38
28 protected: 39 protected:
29 // Overridden from mojo::test::ApplicationTestBase: 40 // Overridden from mojo::test::ApplicationTestBase:
30 void SetUp() override { 41 void SetUp() override {
31 ShellTest::SetUp(); 42 ShellTest::SetUp();
32 connector()->ConnectToInterface("mojo:filesystem", &files_); 43 connector()->ConnectToInterface("mojo:filesystem", &files_);
33 connector()->ConnectToInterface("mojo:leveldb", &leveldb_); 44 connector()->ConnectToInterface("mojo:leveldb", &leveldb_);
34 } 45 }
35 46
36 void TearDown() override { 47 void TearDown() override {
37 leveldb_.reset(); 48 leveldb_.reset();
38 files_.reset(); 49 files_.reset();
39 ShellTest::TearDown(); 50 ShellTest::TearDown();
40 } 51 }
41 52
42 // Note: This has an out parameter rather than returning the |DirectoryPtr|, 53 // Note: This has an out parameter rather than returning the |DirectoryPtr|,
43 // since |ASSERT_...()| doesn't work with return values. 54 // since |ASSERT_...()| doesn't work with return values.
44 void GetTempDirectory(filesystem::mojom::DirectoryPtr* directory) { 55 void GetTempDirectory(filesystem::mojom::DirectoryPtr* directory) {
45 FileError error = FileError::FAILED; 56 FileError error = FileError::FAILED;
46 files()->OpenTempDirectory(GetProxy(directory), mojo::Capture(&error)); 57 files()->OpenTempDirectory(GetProxy(directory), Capture(&error));
47 ASSERT_TRUE(files().WaitForIncomingResponse()); 58 ASSERT_TRUE(files().WaitForIncomingResponse());
48 ASSERT_EQ(FileError::OK, error); 59 ASSERT_EQ(FileError::OK, error);
49 } 60 }
50 61
51 filesystem::mojom::FileSystemPtr& files() { return files_; } 62 filesystem::mojom::FileSystemPtr& files() { return files_; }
52 mojom::LevelDBServicePtr& leveldb() { return leveldb_; } 63 mojom::LevelDBServicePtr& leveldb() { return leveldb_; }
53 64
54 private: 65 private:
55 filesystem::mojom::FileSystemPtr files_; 66 filesystem::mojom::FileSystemPtr files_;
56 mojom::LevelDBServicePtr leveldb_; 67 mojom::LevelDBServicePtr leveldb_;
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 key_values.SetToEmpty(); 503 key_values.SetToEmpty();
493 database->GetPrefixed(mojo::Array<uint8_t>::From(prefix), 504 database->GetPrefixed(mojo::Array<uint8_t>::From(prefix),
494 Capture(&error, &key_values)); 505 Capture(&error, &key_values));
495 ASSERT_TRUE(database.WaitForIncomingResponse()); 506 ASSERT_TRUE(database.WaitForIncomingResponse());
496 EXPECT_EQ(mojom::DatabaseError::OK, error); 507 EXPECT_EQ(mojom::DatabaseError::OK, error);
497 EXPECT_TRUE(key_values.empty()); 508 EXPECT_TRUE(key_values.empty());
498 } 509 }
499 510
500 } // namespace 511 } // namespace
501 } // namespace leveldb 512 } // namespace leveldb
OLDNEW
« no previous file with comments | « components/filesystem/files_test_base.cc ('k') | components/leveldb/remote_iterator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698