| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CONTENT_TEST_PPAPI_UNITTEST_H_ | 5 #ifndef CONTENT_TEST_PPAPI_UNITTEST_H_ |
| 6 #define CONTENT_TEST_PPAPI_UNITTEST_H_ | 6 #define CONTENT_TEST_PPAPI_UNITTEST_H_ |
| 7 | 7 |
| 8 #include <memory> | |
| 9 | |
| 10 #include "base/macros.h" | 8 #include "base/macros.h" |
| 11 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/test/scoped_task_environment.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 12 |
| 14 namespace base { | |
| 15 class MessageLoop; | |
| 16 } | |
| 17 | |
| 18 namespace content { | 13 namespace content { |
| 19 | 14 |
| 20 class PepperPluginInstanceImpl; | 15 class PepperPluginInstanceImpl; |
| 21 class PluginModule; | 16 class PluginModule; |
| 22 | 17 |
| 23 class PpapiUnittest : public testing::Test { | 18 class PpapiUnittest : public testing::Test { |
| 24 public: | 19 public: |
| 25 PpapiUnittest(); | 20 PpapiUnittest(); |
| 26 ~PpapiUnittest() override; | 21 ~PpapiUnittest() override; |
| 27 | 22 |
| 28 void SetUp() override; | 23 void SetUp() override; |
| 29 void TearDown() override; | 24 void TearDown() override; |
| 30 | 25 |
| 31 PluginModule* module() const { return module_.get(); } | 26 PluginModule* module() const { return module_.get(); } |
| 32 PepperPluginInstanceImpl* instance() const { return instance_.get(); } | 27 PepperPluginInstanceImpl* instance() const { return instance_.get(); } |
| 33 | 28 |
| 34 // Provides access to the interfaces implemented by the test. The default one | 29 // Provides access to the interfaces implemented by the test. The default one |
| 35 // implements PPP_INSTANCE. | 30 // implements PPP_INSTANCE. |
| 36 virtual const void* GetMockInterface(const char* interface_name) const; | 31 virtual const void* GetMockInterface(const char* interface_name) const; |
| 37 | 32 |
| 38 // Deletes the instance and module to simulate module shutdown. | 33 // Deletes the instance and module to simulate module shutdown. |
| 39 void ShutdownModule(); | 34 void ShutdownModule(); |
| 40 | 35 |
| 41 // Sets the view size of the plugin instance. | 36 // Sets the view size of the plugin instance. |
| 42 void SetViewSize(int width, int height) const; | 37 void SetViewSize(int width, int height) const; |
| 43 | 38 |
| 44 private: | 39 private: |
| 45 // Note: module must be declared first since we want it to get destroyed last. | 40 base::test::ScopedTaskEnvironment scoped_task_environment_; |
| 41 |
| 42 // Note: module must be declared right after |scoped_task_environment_| since |
| 43 // we want it to get destroyed just before |scoped_task_environment_|. |
| 46 scoped_refptr<PluginModule> module_; | 44 scoped_refptr<PluginModule> module_; |
| 47 scoped_refptr<PepperPluginInstanceImpl> instance_; | 45 scoped_refptr<PepperPluginInstanceImpl> instance_; |
| 48 | 46 |
| 49 std::unique_ptr<base::MessageLoop> message_loop_; | |
| 50 | |
| 51 DISALLOW_COPY_AND_ASSIGN(PpapiUnittest); | 47 DISALLOW_COPY_AND_ASSIGN(PpapiUnittest); |
| 52 }; | 48 }; |
| 53 | 49 |
| 54 } // namespace content | 50 } // namespace content |
| 55 | 51 |
| 56 #endif // CONTENT_TEST_PPAPI_UNITTEST_H_ | 52 #endif // CONTENT_TEST_PPAPI_UNITTEST_H_ |
| OLD | NEW |