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

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

Issue 744973002: Pass command line args to apptests (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: rebase and address comments Created 6 years, 1 month 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
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/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 // Access the command line arguments passed to the application test.
25 const Array<String>& Args();
26 void InitializeArgs(int argc, std::vector<const char*> argv);
27
24 // A GTEST base class for application testing executed in mojo_shell. 28 // A GTEST base class for application testing executed in mojo_shell.
25 class ApplicationTestBase : public testing::Test { 29 class ApplicationTestBase : public testing::Test {
26 public: 30 public:
27 explicit ApplicationTestBase(Array<String> args); 31 ApplicationTestBase();
28 ~ApplicationTestBase() override; 32 ~ApplicationTestBase() override;
29 33
30 protected: 34 protected:
31 ApplicationImpl* application_impl() { return application_impl_; } 35 ApplicationImpl* application_impl() { return application_impl_; }
32 36
33 // Get the ApplicationDelegate for the application to be tested. 37 // Get the ApplicationDelegate for the application to be tested.
34 virtual ApplicationDelegate* GetApplicationDelegate() = 0; 38 virtual ApplicationDelegate* GetApplicationDelegate() = 0;
35 39
40 // A testing::Test::SetUp helper to override the application command
41 // line arguments.
42 void SetUpWithArgs(const Array<String>& args);
43
36 // testing::Test: 44 // testing::Test:
37 void SetUp() override; 45 void SetUp() override;
38 void TearDown() override; 46 void TearDown() override;
39 47
40 private: 48 private:
41 // The command line arguments supplied to each test application instance.
42 Array<String> args_;
43
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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698