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