| 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 WEBKIT_PLUGINS_PPAPI_PPAPI_UNITTEST_H_ | 5 #ifndef WEBKIT_PLUGINS_PPAPI_PPAPI_UNITTEST_H_ |
| 6 #define WEBKIT_PLUGINS_PPAPI_PPAPI_UNITTEST_H_ | 6 #define WEBKIT_PLUGINS_PPAPI_PPAPI_UNITTEST_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "webkit/plugins/ppapi/plugin_delegate.h" | 12 #include "webkit/plugins/ppapi/plugin_delegate.h" |
| 13 | 13 |
| 14 namespace base { | 14 namespace base { |
| 15 class MessageLoop; | 15 class MessageLoop; |
| 16 } | 16 } |
| 17 | 17 |
| 18 namespace webkit { | 18 namespace webkit { |
| 19 namespace ppapi { | 19 namespace ppapi { |
| 20 | 20 |
| 21 class MockPluginDelegate; | 21 class MockPluginDelegate; |
| 22 class PluginInstance; | 22 class PluginInstanceImpl; |
| 23 class PluginModule; | 23 class PluginModule; |
| 24 | 24 |
| 25 class PpapiUnittest : public testing::Test, | 25 class PpapiUnittest : public testing::Test, |
| 26 public webkit::ppapi::PluginDelegate::ModuleLifetime { | 26 public webkit::ppapi::PluginDelegate::ModuleLifetime { |
| 27 public: | 27 public: |
| 28 PpapiUnittest(); | 28 PpapiUnittest(); |
| 29 virtual ~PpapiUnittest(); | 29 virtual ~PpapiUnittest(); |
| 30 | 30 |
| 31 virtual void SetUp(); | 31 virtual void SetUp(); |
| 32 virtual void TearDown(); | 32 virtual void TearDown(); |
| 33 | 33 |
| 34 MockPluginDelegate* delegate() { return delegate_.get(); } | 34 MockPluginDelegate* delegate() { return delegate_.get(); } |
| 35 PluginModule* module() const { return module_.get(); } | 35 PluginModule* module() const { return module_.get(); } |
| 36 PluginInstance* instance() const { return instance_.get(); } | 36 PluginInstanceImpl* instance() const { return instance_.get(); } |
| 37 | 37 |
| 38 // Provides access to the interfaces implemented by the test. The default one | 38 // Provides access to the interfaces implemented by the test. The default one |
| 39 // implements PPP_INSTANCE. | 39 // implements PPP_INSTANCE. |
| 40 virtual const void* GetMockInterface(const char* interface_name) const; | 40 virtual const void* GetMockInterface(const char* interface_name) const; |
| 41 | 41 |
| 42 // Deletes the instance and module to simulate module shutdown. | 42 // Deletes the instance and module to simulate module shutdown. |
| 43 void ShutdownModule(); | 43 void ShutdownModule(); |
| 44 | 44 |
| 45 // Sets the view size of the plugin instance. | 45 // Sets the view size of the plugin instance. |
| 46 void SetViewSize(int width, int height) const; | 46 void SetViewSize(int width, int height) const; |
| 47 | 47 |
| 48 protected: | 48 protected: |
| 49 virtual MockPluginDelegate* NewPluginDelegate(); | 49 virtual MockPluginDelegate* NewPluginDelegate(); |
| 50 | 50 |
| 51 private: | 51 private: |
| 52 scoped_ptr<MockPluginDelegate> delegate_; | 52 scoped_ptr<MockPluginDelegate> delegate_; |
| 53 | 53 |
| 54 // Note: module must be declared first since we want it to get destroyed last. | 54 // Note: module must be declared first since we want it to get destroyed last. |
| 55 scoped_refptr<PluginModule> module_; | 55 scoped_refptr<PluginModule> module_; |
| 56 scoped_refptr<PluginInstance> instance_; | 56 scoped_refptr<PluginInstanceImpl> instance_; |
| 57 | 57 |
| 58 scoped_ptr<base::MessageLoop> message_loop_; | 58 scoped_ptr<base::MessageLoop> message_loop_; |
| 59 | 59 |
| 60 // ModuleLifetime implementation. | 60 // ModuleLifetime implementation. |
| 61 virtual void PluginModuleDead(PluginModule* dead_module); | 61 virtual void PluginModuleDead(PluginModule* dead_module); |
| 62 | 62 |
| 63 DISALLOW_COPY_AND_ASSIGN(PpapiUnittest); | 63 DISALLOW_COPY_AND_ASSIGN(PpapiUnittest); |
| 64 }; | 64 }; |
| 65 | 65 |
| 66 } // namespace ppapi | 66 } // namespace ppapi |
| 67 } // namespace webkit | 67 } // namespace webkit |
| 68 | 68 |
| 69 #endif // WEBKIT_PLUGINS_PPAPI_PPAPI_UNITTEST_H_ | 69 #endif // WEBKIT_PLUGINS_PPAPI_PPAPI_UNITTEST_H_ |
| OLD | NEW |