blob: c33f5f00673dd6fd295e775115cb765de628a71a [file] [log] [blame]
[email protected]3b63f8f42011-03-28 01:54:151// Copyright (c) 2011 The Chromium Authors. All rights reserved.
[email protected]5469a772010-12-09 22:59:532// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]0bd753682010-12-16 18:15:525#ifndef WEBKIT_PLUGINS_PPAPI_PPAPI_UNITTEST_H_
6#define WEBKIT_PLUGINS_PPAPI_PPAPI_UNITTEST_H_
[email protected]5469a772010-12-09 22:59:537
8#include "base/basictypes.h"
[email protected]3b63f8f42011-03-28 01:54:159#include "base/memory/ref_counted.h"
10#include "base/memory/scoped_ptr.h"
[email protected]5469a772010-12-09 22:59:5311#include "testing/gtest/include/gtest/gtest.h"
[email protected]ece8f0b2011-01-04 22:31:2112#include "webkit/plugins/ppapi/plugin_delegate.h"
[email protected]5469a772010-12-09 22:59:5313
[email protected]0bd753682010-12-16 18:15:5214namespace webkit {
15namespace ppapi {
[email protected]5469a772010-12-09 22:59:5316
17class MockPluginDelegate;
18class PluginInstance;
19class PluginModule;
20
[email protected]ece8f0b2011-01-04 22:31:2121class PpapiUnittest : public testing::Test,
22 public webkit::ppapi::PluginDelegate::ModuleLifetime {
[email protected]5469a772010-12-09 22:59:5323 public:
24 PpapiUnittest();
25 virtual ~PpapiUnittest();
26
27 virtual void SetUp();
28 virtual void TearDown();
29
[email protected]859a7f32011-01-15 03:44:1330 MockPluginDelegate* delegate() { return delegate_.get(); }
[email protected]5469a772010-12-09 22:59:5331 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]64264ef2010-12-21 00:45:4338 // Deletes the instance and module to simulate module shutdown.
39 void ShutdownModule();
40
[email protected]5469a772010-12-09 22:59:5341 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]ece8f0b2011-01-04 22:31:2148 // ModuleLifetime implementation.
[email protected]1647ac8f2011-02-27 20:33:0249 virtual void PluginModuleDead(PluginModule* dead_module);
[email protected]ece8f0b2011-01-04 22:31:2150
[email protected]5469a772010-12-09 22:59:5351 DISALLOW_COPY_AND_ASSIGN(PpapiUnittest);
52};
53
[email protected]0bd753682010-12-16 18:15:5254} // namespace ppapi
55} // namespace webkit
[email protected]5469a772010-12-09 22:59:5356
[email protected]0bd753682010-12-16 18:15:5257#endif // WEBKIT_GLUE_PPAPI_PLUGINS_PPAPI_UNITTEST_H_