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

Side by Side Diff: services/shell/public/cpp/shell_test.h

Issue 1882423004: Move shell service to toplevel shell namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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 #ifndef SERVICES_SHELL_PUBLIC_CPP_SHELL_TEST_H_ 5 #ifndef SERVICES_SHELL_PUBLIC_CPP_SHELL_TEST_H_
6 #define SERVICES_SHELL_PUBLIC_CPP_SHELL_TEST_H_ 6 #define SERVICES_SHELL_PUBLIC_CPP_SHELL_TEST_H_
7 7
8 #include <memory>
9
8 #include "base/macros.h" 10 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "services/shell/public/cpp/connector.h" 11 #include "services/shell/public/cpp/connector.h"
11 #include "services/shell/public/cpp/shell_client.h" 12 #include "services/shell/public/cpp/shell_client.h"
12 #include "services/shell/public/cpp/shell_connection.h" 13 #include "services/shell/public/cpp/shell_connection.h"
13 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
14 15
15 namespace base { 16 namespace base {
16 class MessageLoop; 17 class MessageLoop;
17 } 18 }
18 19
19 namespace mojo {
20 namespace shell { 20 namespace shell {
21
21 class BackgroundShell; 22 class BackgroundShell;
22 } 23
23 namespace test { 24 namespace test {
24 25
25 class ShellTest; 26 class ShellTest;
26 27
27 // A default implementation of ShellClient for use in ShellTests. Tests wishing 28 // A default implementation of ShellClient for use in ShellTests. Tests wishing
28 // to customize this should subclass this class instead of ShellClient, 29 // to customize this should subclass this class instead of ShellClient,
29 // otherwise they will have to call ShellTest::InitializeCalled() to forward 30 // otherwise they will have to call ShellTest::InitializeCalled() to forward
30 // metadata from Initialize() to the test. 31 // metadata from Initialize() to the test.
31 class ShellTestClient : public mojo::ShellClient { 32 class ShellTestClient : public ShellClient {
32 public: 33 public:
33 explicit ShellTestClient(ShellTest* test); 34 explicit ShellTestClient(ShellTest* test);
34 ~ShellTestClient() override; 35 ~ShellTestClient() override;
35 36
36 protected: 37 protected:
37 void Initialize(Connector* connector, 38 void Initialize(Connector* connector,
38 const Identity& identity, 39 const Identity& identity,
39 uint32_t id) override; 40 uint32_t id) override;
40 41
41 private: 42 private:
(...skipping 20 matching lines...) Expand all
62 63
63 // Instance information received from the Shell during Initialize(). 64 // Instance information received from the Shell during Initialize().
64 const std::string& test_name() const { return initialize_name_; } 65 const std::string& test_name() const { return initialize_name_; }
65 const std::string& test_userid() const { return initialize_userid_; } 66 const std::string& test_userid() const { return initialize_userid_; }
66 uint32_t test_instance_id() const { return initialize_instance_id_; } 67 uint32_t test_instance_id() const { return initialize_instance_id_; }
67 68
68 // By default, creates a simple ShellClient that captures the metadata sent 69 // By default, creates a simple ShellClient that captures the metadata sent
69 // via Initialize(). Override to customize, but custom implementations must 70 // via Initialize(). Override to customize, but custom implementations must
70 // call InitializeCalled() to forward the metadata so test_name() etc all 71 // call InitializeCalled() to forward the metadata so test_name() etc all
71 // work. 72 // work.
72 virtual scoped_ptr<ShellClient> CreateShellClient(); 73 virtual std::unique_ptr<ShellClient> CreateShellClient();
73 74
74 virtual scoped_ptr<base::MessageLoop> CreateMessageLoop(); 75 virtual std::unique_ptr<base::MessageLoop> CreateMessageLoop();
75 76
76 // Call to set Initialize() metadata when GetShellClient() is overridden. 77 // Call to set Initialize() metadata when GetShellClient() is overridden.
77 void InitializeCalled(Connector* connector, 78 void InitializeCalled(Connector* connector,
78 const std::string& name, 79 const std::string& name,
79 const std::string& userid, 80 const std::string& userid,
80 uint32_t id); 81 uint32_t id);
81 82
82 // testing::Test: 83 // testing::Test:
83 void SetUp() override; 84 void SetUp() override;
84 void TearDown() override; 85 void TearDown() override;
85 86
86 private: 87 private:
87 friend ShellTestClient; 88 friend ShellTestClient;
88 89
89 scoped_ptr<ShellClient> shell_client_; 90 std::unique_ptr<ShellClient> shell_client_;
90 91
91 scoped_ptr<base::MessageLoop> message_loop_; 92 std::unique_ptr<base::MessageLoop> message_loop_;
92 scoped_ptr<shell::BackgroundShell> background_shell_; 93 std::unique_ptr<BackgroundShell> background_shell_;
93 scoped_ptr<ShellConnection> shell_connection_; 94 std::unique_ptr<ShellConnection> shell_connection_;
94 95
95 // See constructor. 96 // See constructor.
96 std::string test_name_; 97 std::string test_name_;
97 98
98 Connector* connector_ = nullptr; 99 Connector* connector_ = nullptr;
99 std::string initialize_name_; 100 std::string initialize_name_;
100 std::string initialize_userid_ = shell::mojom::kInheritUserID; 101 std::string initialize_userid_ = shell::mojom::kInheritUserID;
101 uint32_t initialize_instance_id_ = shell::mojom::kInvalidInstanceID; 102 uint32_t initialize_instance_id_ = shell::mojom::kInvalidInstanceID;
102 103
103 base::Closure initialize_called_; 104 base::Closure initialize_called_;
104 105
105 DISALLOW_COPY_AND_ASSIGN(ShellTest); 106 DISALLOW_COPY_AND_ASSIGN(ShellTest);
106 }; 107 };
107 108
108 } // namespace test 109 } // namespace test
109 } // namespace mojo 110 } // namespace shell
110 111
111 #endif // SERVICES_SHELL_PUBLIC_CPP_SHELL_TEST_H_ 112 #endif // SERVICES_SHELL_PUBLIC_CPP_SHELL_TEST_H_
OLDNEW
« no previous file with comments | « services/shell/public/cpp/shell_connection.h ('k') | services/shell/public/cpp/tests/interface_registry_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698