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

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

Issue 1743473002: Change Mojo URLs to structured names (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@18collapse
Patch Set: . Created 4 years, 9 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/BUILD.gn ('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"
(...skipping 16 matching lines...) Expand all
27 27
28 // Used to configure the ShellConnection. This is used internally by 28 // Used to configure the ShellConnection. This is used internally by
29 // ApplicationTestBase, but useful if you do not want to subclass 29 // ApplicationTestBase, but useful if you do not want to subclass
30 // ApplicationTestBase. 30 // ApplicationTestBase.
31 class TestHelper { 31 class TestHelper {
32 public: 32 public:
33 explicit TestHelper(ShellClient* client); 33 explicit TestHelper(ShellClient* client);
34 ~TestHelper(); 34 ~TestHelper();
35 35
36 Connector* connector() { return shell_connection_->connector(); } 36 Connector* connector() { return shell_connection_->connector(); }
37 std::string test_url() { return url_; } 37 std::string test_name() { return name_; }
38 38
39 private: 39 private:
40 // The application delegate used if GetShellClient is not overridden. 40 // The application delegate used if GetShellClient is not overridden.
41 ShellClient default_shell_client_; 41 ShellClient default_shell_client_;
42 42
43 // The application implementation instance, reconstructed for each test. 43 // The application implementation instance, reconstructed for each test.
44 scoped_ptr<ShellConnection> shell_connection_; 44 scoped_ptr<ShellConnection> shell_connection_;
45 45
46 std::string url_; 46 std::string name_;
47 47
48 MOJO_DISALLOW_COPY_AND_ASSIGN(TestHelper); 48 MOJO_DISALLOW_COPY_AND_ASSIGN(TestHelper);
49 }; 49 };
50 50
51 // A GTEST base class for application testing executed in mojo_shell. 51 // A GTEST base class for application testing executed in mojo_shell.
52 class ApplicationTestBase : public testing::Test { 52 class ApplicationTestBase : public testing::Test {
53 public: 53 public:
54 ApplicationTestBase(); 54 ApplicationTestBase();
55 ~ApplicationTestBase() override; 55 ~ApplicationTestBase() override;
56 56
57 protected: 57 protected:
58 Connector* connector() { 58 Connector* connector() {
59 return test_helper_ ? test_helper_->connector() : nullptr; 59 return test_helper_ ? test_helper_->connector() : nullptr;
60 } 60 }
61 std::string test_url() const { 61 std::string test_name() const {
62 return test_helper_ ? test_helper_->test_url() : std::string(); 62 return test_helper_ ? test_helper_->test_name() : std::string();
63 } 63 }
64 64
65 // Get the ShellClient for the application to be tested. 65 // Get the ShellClient for the application to be tested.
66 virtual ShellClient* GetShellClient(); 66 virtual ShellClient* GetShellClient();
67 67
68 // testing::Test: 68 // testing::Test:
69 void SetUp() override; 69 void SetUp() override;
70 void TearDown() override; 70 void TearDown() override;
71 71
72 // True by default, which indicates a MessageLoop will automatically be 72 // True by default, which indicates a MessageLoop will automatically be
73 // created for the application. Tests may override this function to prevent 73 // created for the application. Tests may override this function to prevent
74 // a default loop from being created. 74 // a default loop from being created.
75 virtual bool ShouldCreateDefaultRunLoop(); 75 virtual bool ShouldCreateDefaultRunLoop();
76 76
77 private: 77 private:
78 scoped_ptr<TestHelper> test_helper_; 78 scoped_ptr<TestHelper> test_helper_;
79 79
80 MOJO_DISALLOW_COPY_AND_ASSIGN(ApplicationTestBase); 80 MOJO_DISALLOW_COPY_AND_ASSIGN(ApplicationTestBase);
81 }; 81 };
82 82
83 } // namespace test 83 } // namespace test
84 84
85 } // namespace mojo 85 } // namespace mojo
86 86
87 #endif // MOJO_SHELL_PUBLIC_CPP_APPLICATION_TEST_BASE_H_ 87 #endif // MOJO_SHELL_PUBLIC_CPP_APPLICATION_TEST_BASE_H_
OLDNEW
« no previous file with comments | « mojo/shell/public/cpp/BUILD.gn ('k') | mojo/shell/public/cpp/connection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698