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/bindings/array.h" | 8 #include "mojo/public/cpp/bindings/array.h" |
9 #include "mojo/public/cpp/bindings/string.h" | 9 #include "mojo/public/cpp/bindings/string.h" |
10 #include "mojo/public/cpp/system/macros.h" | 10 #include "mojo/public/cpp/system/macros.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 | 12 |
13 namespace mojo { | 13 namespace mojo { |
14 | 14 |
15 class ApplicationDelegate; | 15 class ApplicationDelegate; |
16 class ApplicationImpl; | 16 class ApplicationImpl; |
17 | 17 |
18 namespace test { | 18 namespace test { |
19 | 19 |
20 // Access the shell handle shared by multiple test application instances. | 20 // Access the shell handle shared by multiple test application instances. |
21 ScopedMessagePipeHandle PassShellHandle(); | 21 ScopedMessagePipeHandle PassShellHandle(); |
22 void SetShellHandle(ScopedMessagePipeHandle handle); | 22 void SetShellHandle(ScopedMessagePipeHandle handle); |
23 | 23 |
24 const Array<String>& Args(); | |
msw
2014/11/22 18:23:38
nit: Add a comment like "Access the command line a
Chris Masone
2014/11/22 20:14:44
Done.
| |
25 void InitializeArgs(int argc, std::vector<const char*> argv); | |
26 | |
24 // A GTEST base class for application testing executed in mojo_shell. | 27 // A GTEST base class for application testing executed in mojo_shell. |
25 class ApplicationTestBase : public testing::Test { | 28 class ApplicationTestBase : public testing::Test { |
26 public: | 29 public: |
27 explicit ApplicationTestBase(Array<String> args); | 30 ApplicationTestBase(); |
28 ~ApplicationTestBase() override; | 31 ~ApplicationTestBase() override; |
29 | 32 |
30 protected: | 33 protected: |
31 ApplicationImpl* application_impl() { return application_impl_; } | 34 ApplicationImpl* application_impl() { return application_impl_; } |
32 | 35 |
33 // Get the ApplicationDelegate for the application to be tested. | 36 // Get the ApplicationDelegate for the application to be tested. |
34 virtual ApplicationDelegate* GetApplicationDelegate() = 0; | 37 virtual ApplicationDelegate* GetApplicationDelegate() = 0; |
35 | 38 |
39 void SetUpWithArgs(Array<String> args); | |
msw
2014/11/22 18:23:38
nit: Add a comment, like "A testing::Test::SetUp h
Chris Masone
2014/11/22 20:14:44
Done.
| |
40 | |
36 // testing::Test: | 41 // testing::Test: |
37 void SetUp() override; | 42 void SetUp() override; |
38 void TearDown() override; | 43 void TearDown() override; |
39 | 44 |
40 private: | 45 private: |
41 // The command line arguments supplied to each test application instance. | 46 // The command line arguments supplied to each test application instance. |
42 Array<String> args_; | 47 Array<String> args_; |
43 | 48 |
44 // The application implementation instance, reconstructed for each test. | 49 // The application implementation instance, reconstructed for each test. |
45 ApplicationImpl* application_impl_; | 50 ApplicationImpl* application_impl_; |
46 | 51 |
47 MOJO_DISALLOW_COPY_AND_ASSIGN(ApplicationTestBase); | 52 MOJO_DISALLOW_COPY_AND_ASSIGN(ApplicationTestBase); |
48 }; | 53 }; |
49 | 54 |
50 } // namespace test | 55 } // namespace test |
51 | 56 |
52 } // namespace mojo | 57 } // namespace mojo |
53 | 58 |
54 #endif // MOJO_PUBLIC_CPP_APPLICATION_APPLICATION_TEST_BASE_H_ | 59 #endif // MOJO_PUBLIC_CPP_APPLICATION_APPLICATION_TEST_BASE_H_ |
OLD | NEW |