Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef MOJO_SHELL_PUBLIC_CPP_SHELL_TEST_H_ | |
| 6 #define MOJO_SHELL_PUBLIC_CPP_SHELL_TEST_H_ | |
| 7 | |
| 8 #include "base/memory/scoped_ptr.h" | |
| 9 #include "mojo/public/cpp/bindings/array.h" | |
| 10 #include "mojo/public/cpp/bindings/string.h" | |
| 11 #include "mojo/public/cpp/system/macros.h" | |
| 12 #include "mojo/shell/public/cpp/connector.h" | |
| 13 #include "mojo/shell/public/cpp/shell_connection.h" | |
| 14 #include "mojo/shell/public/interfaces/shell_client.mojom.h" | |
| 15 #include "testing/gtest/include/gtest/gtest.h" | |
| 16 | |
| 17 namespace base { | |
| 18 class MessageLoop; | |
| 19 } | |
| 20 | |
| 21 namespace mojo { | |
| 22 namespace shell { | |
| 23 class BackgroundShell; | |
| 24 } | |
| 25 namespace test { | |
| 26 | |
| 27 class ShellTest : public testing::Test { | |
| 28 public: | |
| 29 ShellTest(); | |
| 30 // Initialize passing the name to use as the identity for the test itself. | |
| 31 // Once set via this constructor, it cannot be changed later by calling | |
| 32 // InitTestName(). The test executable must provide a manifest in the | |
| 33 // appropriate location that specifies this name also. | |
| 34 explicit ShellTest(const std::string& test_name); | |
| 35 ~ShellTest() override; | |
| 36 | |
| 37 protected: | |
| 38 // See constructor. Can only be called once. | |
| 39 void InitTestName(const std::string& test_name); | |
| 40 | |
| 41 Connector* connector() { return connector_; } | |
| 42 | |
| 43 // Instance information received from the Shell during Initialize(). | |
| 44 std::string test_name() const { return initialize_name_; } | |
|
sky
2016/03/02 16:10:31
nit: const &
| |
| 45 uint32_t test_instance_id() const { return initialize_instance_id_; } | |
| 46 uint32_t test_userid() const { return initialize_userid_; } | |
| 47 | |
| 48 // By default, creates a simple ShellClient that captures the metadata sent | |
| 49 // via Initialize(). Override to customize, but custom implementations must | |
| 50 // call InitializeCalled() to forward the metadata so test_name() etc all | |
| 51 // work. | |
| 52 virtual scoped_ptr<ShellClient> CreateShellClient(); | |
| 53 | |
| 54 // Call to set Initialize() metadata when GetShellClient() is overridden. | |
| 55 void InitializeCalled(const std::string& name, uint32_t id, uint32_t userid); | |
| 56 | |
| 57 // testing::Test: | |
| 58 void SetUp() override; | |
| 59 void TearDown() override; | |
| 60 | |
| 61 private: | |
| 62 class DefaultShellClient; | |
| 63 | |
| 64 scoped_ptr<ShellClient> shell_client_; | |
| 65 | |
| 66 scoped_ptr<base::MessageLoop> message_loop_; | |
| 67 scoped_ptr<shell::BackgroundShell> background_shell_; | |
| 68 scoped_ptr<ShellConnection> shell_connection_; | |
| 69 | |
| 70 // See constructor. | |
| 71 std::string test_name_; | |
| 72 | |
| 73 Connector* connector_ = nullptr; | |
| 74 std::string initialize_name_; | |
| 75 uint32_t initialize_instance_id_ = | |
| 76 shell::mojom::Connector::kInvalidApplicationID; | |
| 77 uint32_t initialize_userid_ = shell::mojom::Connector::kUserInherit; | |
| 78 | |
| 79 DISALLOW_COPY_AND_ASSIGN(ShellTest); | |
| 80 }; | |
| 81 | |
| 82 } // namespace test | |
| 83 } // namespace mojo | |
| 84 | |
| 85 #endif // MOJO_SHELL_PUBLIC_CPP_SHELL_TEST_H_ | |
| OLD | NEW |