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

Side by Side Diff: mojo/shell/public/cpp/application_test_base.h

Issue 1675083002: Rename ApplicationDelegate to ShellClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@delegate
Patch Set: . Created 4 years, 10 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 | « mojo/shell/public/cpp/application_runner.h ('k') | mojo/shell/public/cpp/connection.h » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 MOJO_SHELL_PUBLIC_CPP_APPLICATION_TEST_BASE_H_ 5 #ifndef MOJO_SHELL_PUBLIC_CPP_APPLICATION_TEST_BASE_H_
6 #define MOJO_SHELL_PUBLIC_CPP_APPLICATION_TEST_BASE_H_ 6 #define MOJO_SHELL_PUBLIC_CPP_APPLICATION_TEST_BASE_H_
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "mojo/public/cpp/bindings/array.h" 9 #include "mojo/public/cpp/bindings/array.h"
10 #include "mojo/public/cpp/bindings/string.h" 10 #include "mojo/public/cpp/bindings/string.h"
11 #include "mojo/public/cpp/system/macros.h" 11 #include "mojo/public/cpp/system/macros.h"
12 #include "mojo/shell/public/cpp/application_delegate.h"
13 #include "mojo/shell/public/cpp/application_impl.h" 12 #include "mojo/shell/public/cpp/application_impl.h"
13 #include "mojo/shell/public/cpp/shell_client.h"
14 #include "mojo/shell/public/interfaces/application.mojom.h" 14 #include "mojo/shell/public/interfaces/application.mojom.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 16
17 namespace mojo { 17 namespace mojo {
18 18
19 class ApplicationImpl; 19 class ApplicationImpl;
20 20
21 namespace test { 21 namespace test {
22 22
23 // Run all application tests. This must be called after the environment is 23 // Run all application tests. This must be called after the environment is
24 // initialized, to support construction of a default run loop. 24 // initialized, to support construction of a default run loop.
25 MojoResult RunAllTests(MojoHandle application_request_handle); 25 MojoResult RunAllTests(MojoHandle application_request_handle);
26 26
27 // Used to configure the ApplicationImpl. This is used internally by 27 // Used to configure the ApplicationImpl. This is used internally by
28 // ApplicationTestBase, but useful if you do not want to subclass 28 // ApplicationTestBase, but useful if you do not want to subclass
29 // ApplicationTestBase. 29 // ApplicationTestBase.
30 class TestHelper { 30 class TestHelper {
31 public: 31 public:
32 explicit TestHelper(ApplicationDelegate* delegate); 32 explicit TestHelper(ShellClient* client);
33 ~TestHelper(); 33 ~TestHelper();
34 34
35 Shell* shell() { return application_impl_.get(); } 35 Shell* shell() { return application_impl_.get(); }
36 std::string shell_url() { return url_; } 36 std::string shell_url() { return url_; }
37 37
38 private: 38 private:
39 // The application delegate used if GetApplicationDelegate is not overridden. 39 // The application delegate used if GetShellClient is not overridden.
40 ApplicationDelegate default_application_delegate_; 40 ShellClient default_shell_client_;
41 41
42 // The application implementation instance, reconstructed for each test. 42 // The application implementation instance, reconstructed for each test.
43 scoped_ptr<ApplicationImpl> application_impl_; 43 scoped_ptr<ApplicationImpl> application_impl_;
44 44
45 std::string url_; 45 std::string url_;
46 46
47 MOJO_DISALLOW_COPY_AND_ASSIGN(TestHelper); 47 MOJO_DISALLOW_COPY_AND_ASSIGN(TestHelper);
48 }; 48 };
49 49
50 // A GTEST base class for application testing executed in mojo_shell. 50 // A GTEST base class for application testing executed in mojo_shell.
51 class ApplicationTestBase : public testing::Test { 51 class ApplicationTestBase : public testing::Test {
52 public: 52 public:
53 ApplicationTestBase(); 53 ApplicationTestBase();
54 ~ApplicationTestBase() override; 54 ~ApplicationTestBase() override;
55 55
56 protected: 56 protected:
57 Shell* shell() { 57 Shell* shell() {
58 return test_helper_ ? test_helper_->shell() : nullptr; 58 return test_helper_ ? test_helper_->shell() : nullptr;
59 } 59 }
60 std::string shell_url() const { 60 std::string shell_url() const {
61 return test_helper_ ? test_helper_->shell_url() : std::string(); 61 return test_helper_ ? test_helper_->shell_url() : std::string();
62 } 62 }
63 63
64 // Get the ApplicationDelegate for the application to be tested. 64 // Get the ShellClient for the application to be tested.
65 virtual ApplicationDelegate* GetApplicationDelegate(); 65 virtual ShellClient* GetShellClient();
66 66
67 // testing::Test: 67 // testing::Test:
68 void SetUp() override; 68 void SetUp() override;
69 void TearDown() override; 69 void TearDown() override;
70 70
71 // True by default, which indicates a MessageLoop will automatically be 71 // True by default, which indicates a MessageLoop will automatically be
72 // created for the application. Tests may override this function to prevent 72 // created for the application. Tests may override this function to prevent
73 // a default loop from being created. 73 // a default loop from being created.
74 virtual bool ShouldCreateDefaultRunLoop(); 74 virtual bool ShouldCreateDefaultRunLoop();
75 75
76 private: 76 private:
77 scoped_ptr<TestHelper> test_helper_; 77 scoped_ptr<TestHelper> test_helper_;
78 78
79 MOJO_DISALLOW_COPY_AND_ASSIGN(ApplicationTestBase); 79 MOJO_DISALLOW_COPY_AND_ASSIGN(ApplicationTestBase);
80 }; 80 };
81 81
82 } // namespace test 82 } // namespace test
83 83
84 } // namespace mojo 84 } // namespace mojo
85 85
86 #endif // MOJO_SHELL_PUBLIC_CPP_APPLICATION_TEST_BASE_H_ 86 #endif // MOJO_SHELL_PUBLIC_CPP_APPLICATION_TEST_BASE_H_
OLDNEW
« no previous file with comments | « mojo/shell/public/cpp/application_runner.h ('k') | mojo/shell/public/cpp/connection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698