[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame^] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
[email protected] | 5469a77 | 2010-12-09 22:59:53 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
[email protected] | 0bd75368 | 2010-12-16 18:15:52 | [diff] [blame] | 5 | #ifndef WEBKIT_PLUGINS_PPAPI_PPAPI_UNITTEST_H_ |
6 | #define WEBKIT_PLUGINS_PPAPI_PPAPI_UNITTEST_H_ | ||||
[email protected] | 5469a77 | 2010-12-09 22:59:53 | [diff] [blame] | 7 | |
8 | #include "base/basictypes.h" | ||||
[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame^] | 9 | #include "base/memory/ref_counted.h" |
10 | #include "base/memory/scoped_ptr.h" | ||||
[email protected] | 5469a77 | 2010-12-09 22:59:53 | [diff] [blame] | 11 | #include "testing/gtest/include/gtest/gtest.h" |
[email protected] | ece8f0b | 2011-01-04 22:31:21 | [diff] [blame] | 12 | #include "webkit/plugins/ppapi/plugin_delegate.h" |
[email protected] | 5469a77 | 2010-12-09 22:59:53 | [diff] [blame] | 13 | |
[email protected] | 0bd75368 | 2010-12-16 18:15:52 | [diff] [blame] | 14 | namespace webkit { |
15 | namespace ppapi { | ||||
[email protected] | 5469a77 | 2010-12-09 22:59:53 | [diff] [blame] | 16 | |
17 | class MockPluginDelegate; | ||||
18 | class PluginInstance; | ||||
19 | class PluginModule; | ||||
20 | |||||
[email protected] | ece8f0b | 2011-01-04 22:31:21 | [diff] [blame] | 21 | class PpapiUnittest : public testing::Test, |
22 | public webkit::ppapi::PluginDelegate::ModuleLifetime { | ||||
[email protected] | 5469a77 | 2010-12-09 22:59:53 | [diff] [blame] | 23 | public: |
24 | PpapiUnittest(); | ||||
25 | virtual ~PpapiUnittest(); | ||||
26 | |||||
27 | virtual void SetUp(); | ||||
28 | virtual void TearDown(); | ||||
29 | |||||
[email protected] | 859a7f3 | 2011-01-15 03:44:13 | [diff] [blame] | 30 | MockPluginDelegate* delegate() { return delegate_.get(); } |
[email protected] | 5469a77 | 2010-12-09 22:59:53 | [diff] [blame] | 31 | PluginModule* module() const { return module_.get(); } |
32 | PluginInstance* instance() const { return instance_.get(); } | ||||
33 | |||||
34 | // Provides access to the interfaces implemented by the test. The default one | ||||
35 | // implements PPP_INSTANCE. | ||||
36 | virtual const void* GetMockInterface(const char* interface_name) const; | ||||
37 | |||||
[email protected] | 64264ef | 2010-12-21 00:45:43 | [diff] [blame] | 38 | // Deletes the instance and module to simulate module shutdown. |
39 | void ShutdownModule(); | ||||
40 | |||||
[email protected] | 5469a77 | 2010-12-09 22:59:53 | [diff] [blame] | 41 | private: |
42 | scoped_ptr<MockPluginDelegate> delegate_; | ||||
43 | |||||
44 | // Note: module must be declared first since we want it to get destroyed last. | ||||
45 | scoped_refptr<PluginModule> module_; | ||||
46 | scoped_refptr<PluginInstance> instance_; | ||||
47 | |||||
[email protected] | ece8f0b | 2011-01-04 22:31:21 | [diff] [blame] | 48 | // ModuleLifetime implementation. |
[email protected] | 1647ac8f | 2011-02-27 20:33:02 | [diff] [blame] | 49 | virtual void PluginModuleDead(PluginModule* dead_module); |
[email protected] | ece8f0b | 2011-01-04 22:31:21 | [diff] [blame] | 50 | |
[email protected] | 5469a77 | 2010-12-09 22:59:53 | [diff] [blame] | 51 | DISALLOW_COPY_AND_ASSIGN(PpapiUnittest); |
52 | }; | ||||
53 | |||||
[email protected] | 0bd75368 | 2010-12-16 18:15:52 | [diff] [blame] | 54 | } // namespace ppapi |
55 | } // namespace webkit | ||||
[email protected] | 5469a77 | 2010-12-09 22:59:53 | [diff] [blame] | 56 | |
[email protected] | 0bd75368 | 2010-12-16 18:15:52 | [diff] [blame] | 57 | #endif // WEBKIT_GLUE_PPAPI_PLUGINS_PPAPI_UNITTEST_H_ |