Separate Simple Backend creation from initialization.
[chromium-blink-merge.git] / webkit / plugins / ppapi / ppapi_unittest.h
blob0c64db0eeb736d1de673cae15a33bf9df455909b
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.
5 #ifndef WEBKIT_PLUGINS_PPAPI_PPAPI_UNITTEST_H_
6 #define WEBKIT_PLUGINS_PPAPI_PPAPI_UNITTEST_H_
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"
14 namespace webkit {
15 namespace ppapi {
17 class MockPluginDelegate;
18 class PluginInstance;
19 class PluginModule;
21 class PpapiUnittest : public testing::Test,
22 public webkit::ppapi::PluginDelegate::ModuleLifetime {
23 public:
24 PpapiUnittest();
25 virtual ~PpapiUnittest();
27 virtual void SetUp();
28 virtual void TearDown();
30 MockPluginDelegate* delegate() { return delegate_.get(); }
31 PluginModule* module() const { return module_.get(); }
32 PluginInstance* instance() const { return instance_.get(); }
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;
38 // Deletes the instance and module to simulate module shutdown.
39 void ShutdownModule();
41 // Sets the view size of the plugin instance.
42 void SetViewSize(int width, int height) const;
44 protected:
45 virtual MockPluginDelegate* NewPluginDelegate();
47 private:
48 scoped_ptr<MockPluginDelegate> delegate_;
50 // Note: module must be declared first since we want it to get destroyed last.
51 scoped_refptr<PluginModule> module_;
52 scoped_refptr<PluginInstance> instance_;
54 // ModuleLifetime implementation.
55 virtual void PluginModuleDead(PluginModule* dead_module);
57 DISALLOW_COPY_AND_ASSIGN(PpapiUnittest);
60 } // namespace ppapi
61 } // namespace webkit
63 #endif // WEBKIT_PLUGINS_PPAPI_PPAPI_UNITTEST_H_