Chromium Code Reviews

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

Issue 1990603002: Make ApplicationTestBase not use ApplicationImpl. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: delete ApplicationImpl::WaitForInitialize() Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
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_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 <string>
9 #include <vector>
10
9 #include "mojo/public/cpp/bindings/array.h" 11 #include "mojo/public/cpp/bindings/array.h"
10 #include "mojo/public/cpp/bindings/string.h" 12 #include "mojo/public/cpp/bindings/string.h"
11 #include "mojo/public/cpp/system/macros.h" 13 #include "mojo/public/cpp/system/macros.h"
12 #include "mojo/public/interfaces/application/application.mojom.h" 14 #include "mojo/public/interfaces/application/application.mojom.h"
15 #include "mojo/public/interfaces/application/shell.mojom.h"
13 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
14 17
15 namespace mojo { 18 namespace mojo {
16
17 class ApplicationImpl;
18
19 namespace test { 19 namespace test {
20 20
21 // Access the command line arguments passed to the application test.
22 const Array<String>& Args();
23
24 // Run all application tests. This must be called after the environment is 21 // Run all application tests. This must be called after the environment is
25 // initialized, to support construction of a default run loop. 22 // initialized, to support construction of a default run loop.
26 MojoResult RunAllTests(MojoHandle application_request_handle); 23 MojoResult RunAllTests(MojoHandle application_request_handle);
27 24
28 // A GTEST base class for application testing executed in mojo_shell. 25 // A GTEST base class for application testing executed in mojo_shell.
29 class ApplicationTestBase : public testing::Test { 26 class ApplicationTestBase : public testing::Test {
30 public: 27 public:
31 ApplicationTestBase(); 28 ApplicationTestBase();
32 ~ApplicationTestBase() override; 29 ~ApplicationTestBase() override;
33 30
34 protected: 31 protected:
35 // TODO(vtl): Probably should get rid of this. There's really not much reason 32 Shell* shell() const { return shell_.get(); }
36 // to have an |ApplicationImpl|. 33 const std::vector<std::string>& args() const { return args_; }
37 ApplicationImpl* application_impl() { return application_impl_; }
38
39 // Get the ApplicationDelegate for the application to be tested.
40 virtual ApplicationDelegate* GetApplicationDelegate();
41 34
42 // testing::Test: 35 // testing::Test:
43 void SetUp() override; 36 void SetUp() override;
44 void TearDown() override; 37 void TearDown() override;
45 38
46 // True by default, which indicates a MessageLoop will automatically be 39 // True by default, which indicates a MessageLoop will automatically be
47 // created for the application. Tests may override this function to prevent 40 // created for the application. Tests may override this function to prevent
48 // a default loop from being created. 41 // a default loop from being created.
49 virtual bool ShouldCreateDefaultRunLoop(); 42 virtual bool ShouldCreateDefaultRunLoop();
50 43
51 private: 44 private:
52 // The application implementation instance, reconstructed for each test. 45 ShellPtr shell_;
53 ApplicationImpl* application_impl_; 46 std::vector<std::string> args_;
54 // The application delegate used if GetApplicationDelegate is not overridden.
55 ApplicationDelegate default_application_delegate_;
56 47
57 MOJO_DISALLOW_COPY_AND_ASSIGN(ApplicationTestBase); 48 MOJO_DISALLOW_COPY_AND_ASSIGN(ApplicationTestBase);
58 }; 49 };
59 50
60 } // namespace test 51 } // namespace test
61
62 } // namespace mojo 52 } // namespace mojo
63 53
64 #endif // MOJO_PUBLIC_CPP_APPLICATION_APPLICATION_TEST_BASE_H_ 54 #endif // MOJO_PUBLIC_CPP_APPLICATION_APPLICATION_TEST_BASE_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/application/application_impl.h ('k') | mojo/public/cpp/application/lib/application_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine