OLD | NEW |
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_PUBLIC_CPP_APPLICATION_APPLICATION_TEST_BASE_H_ | 5 #ifndef MOJO_PUBLIC_CPP_APPLICATION_APPLICATION_TEST_BASE_H_ |
6 #define MOJO_PUBLIC_CPP_APPLICATION_APPLICATION_TEST_BASE_H_ | 6 #define MOJO_PUBLIC_CPP_APPLICATION_APPLICATION_TEST_BASE_H_ |
7 | 7 |
8 #include "mojo/public/cpp/application/application_delegate.h" | 8 #include "mojo/public/cpp/application/application_delegate.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 14 matching lines...) Loading... |
25 // initialized, to support construction of a default run loop. | 25 // initialized, to support construction of a default run loop. |
26 MojoResult RunAllTests(MojoHandle application_request_handle); | 26 MojoResult RunAllTests(MojoHandle application_request_handle); |
27 | 27 |
28 // A GTEST base class for application testing executed in mojo_shell. | 28 // A GTEST base class for application testing executed in mojo_shell. |
29 class ApplicationTestBase : public testing::Test { | 29 class ApplicationTestBase : public testing::Test { |
30 public: | 30 public: |
31 ApplicationTestBase(); | 31 ApplicationTestBase(); |
32 ~ApplicationTestBase() override; | 32 ~ApplicationTestBase() override; |
33 | 33 |
34 protected: | 34 protected: |
| 35 // TODO(vtl): Probably should get rid of this. There's really not much reason |
| 36 // to have an |ApplicationImpl|. |
35 ApplicationImpl* application_impl() { return application_impl_; } | 37 ApplicationImpl* application_impl() { return application_impl_; } |
36 | 38 |
37 // Get the ApplicationDelegate for the application to be tested. | 39 // Get the ApplicationDelegate for the application to be tested. |
38 virtual ApplicationDelegate* GetApplicationDelegate(); | 40 virtual ApplicationDelegate* GetApplicationDelegate(); |
39 | 41 |
40 // testing::Test: | 42 // testing::Test: |
41 void SetUp() override; | 43 void SetUp() override; |
42 void TearDown() override; | 44 void TearDown() override; |
43 | 45 |
44 // True by default, which indicates a MessageLoop will automatically be | 46 // True by default, which indicates a MessageLoop will automatically be |
45 // created for the application. Tests may override this function to prevent | 47 // created for the application. Tests may override this function to prevent |
46 // a default loop from being created. | 48 // a default loop from being created. |
47 virtual bool ShouldCreateDefaultRunLoop(); | 49 virtual bool ShouldCreateDefaultRunLoop(); |
48 | 50 |
49 private: | 51 private: |
50 // The application implementation instance, reconstructed for each test. | 52 // The application implementation instance, reconstructed for each test. |
51 ApplicationImpl* application_impl_; | 53 ApplicationImpl* application_impl_; |
52 // The application delegate used if GetApplicationDelegate is not overridden. | 54 // The application delegate used if GetApplicationDelegate is not overridden. |
53 ApplicationDelegate default_application_delegate_; | 55 ApplicationDelegate default_application_delegate_; |
54 | 56 |
55 MOJO_DISALLOW_COPY_AND_ASSIGN(ApplicationTestBase); | 57 MOJO_DISALLOW_COPY_AND_ASSIGN(ApplicationTestBase); |
56 }; | 58 }; |
57 | 59 |
58 } // namespace test | 60 } // namespace test |
59 | 61 |
60 } // namespace mojo | 62 } // namespace mojo |
61 | 63 |
62 #endif // MOJO_PUBLIC_CPP_APPLICATION_APPLICATION_TEST_BASE_H_ | 64 #endif // MOJO_PUBLIC_CPP_APPLICATION_APPLICATION_TEST_BASE_H_ |
OLD | NEW |