OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "webkit/glue/plugins/ppapi_unittest.h" | 5 #include "webkit/plugins/ppapi/ppapi_unittest.h" |
6 | 6 |
7 #include "ppapi/c/pp_var.h" | 7 #include "ppapi/c/pp_var.h" |
8 #include "ppapi/c/ppp_instance.h" | 8 #include "ppapi/c/ppp_instance.h" |
9 #include "webkit/glue/plugins/mock_plugin_delegate.h" | 9 #include "webkit/plugins/ppapi/mock_plugin_delegate.h" |
10 #include "webkit/glue/plugins/pepper_plugin_instance.h" | 10 #include "webkit/plugins/ppapi/plugin_instance.h" |
11 #include "webkit/glue/plugins/pepper_plugin_module.h" | 11 #include "webkit/plugins/ppapi/plugin_module.h" |
12 | 12 |
13 namespace pepper { | 13 namespace webkit { |
| 14 namespace plugins { |
| 15 namespace ppapi { |
14 | 16 |
15 namespace { | 17 namespace { |
16 | 18 |
17 PpapiUnittest* current_unittest = NULL; | 19 PpapiUnittest* current_unittest = NULL; |
18 | 20 |
19 const void* MockGetInterface(const char* interface_name) { | 21 const void* MockGetInterface(const char* interface_name) { |
20 return current_unittest->GetMockInterface(interface_name); | 22 return current_unittest->GetMockInterface(interface_name); |
21 } | 23 } |
22 | 24 |
23 int MockInitializeModule(PP_Module, PPB_GetInterface) { | 25 int MockInitializeModule(PP_Module, PPB_GetInterface) { |
24 return PP_OK; | 26 return PP_OK; |
25 } | 27 } |
26 | 28 |
27 // PepperPluginDelegate ------------------------------------- | |
28 | |
29 // PPP_Instance implementation ------------------------------------------------ | 29 // PPP_Instance implementation ------------------------------------------------ |
30 | 30 |
31 PP_Bool Instance_DidCreate(PP_Instance pp_instance, | 31 PP_Bool Instance_DidCreate(PP_Instance pp_instance, |
32 uint32_t argc, | 32 uint32_t argc, |
33 const char* argn[], | 33 const char* argn[], |
34 const char* argv[]) { | 34 const char* argv[]) { |
35 return PP_TRUE; | 35 return PP_TRUE; |
36 } | 36 } |
37 | 37 |
38 void Instance_DidDestroy(PP_Instance instance) { | 38 void Instance_DidDestroy(PP_Instance instance) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 current_unittest = this; | 79 current_unittest = this; |
80 } | 80 } |
81 | 81 |
82 PpapiUnittest::~PpapiUnittest() { | 82 PpapiUnittest::~PpapiUnittest() { |
83 DCHECK(current_unittest == this); | 83 DCHECK(current_unittest == this); |
84 current_unittest = NULL; | 84 current_unittest = NULL; |
85 } | 85 } |
86 | 86 |
87 void PpapiUnittest::SetUp() { | 87 void PpapiUnittest::SetUp() { |
88 delegate_.reset(new MockPluginDelegate); | 88 delegate_.reset(new MockPluginDelegate); |
89 | 89 |
90 // Initialize the mock module. | 90 // Initialize the mock module. |
91 module_ = new PluginModule; | 91 module_ = new PluginModule; |
92 PluginModule::EntryPoints entry_points; | 92 PluginModule::EntryPoints entry_points; |
93 entry_points.get_interface = &MockGetInterface; | 93 entry_points.get_interface = &MockGetInterface; |
94 entry_points.initialize_module = &MockInitializeModule; | 94 entry_points.initialize_module = &MockInitializeModule; |
95 ASSERT_TRUE(module_->InitAsInternalPlugin(entry_points)); | 95 ASSERT_TRUE(module_->InitAsInternalPlugin(entry_points)); |
96 | 96 |
97 // Initialize the mock instance. | 97 // Initialize the mock instance. |
98 instance_ = new PluginInstance(delegate_.get(), module(), | 98 instance_ = new PluginInstance(delegate_.get(), module(), |
99 static_cast<const PPP_Instance*>( | 99 static_cast<const PPP_Instance*>( |
100 GetMockInterface(PPP_INSTANCE_INTERFACE))); | 100 GetMockInterface(PPP_INSTANCE_INTERFACE))); |
101 } | 101 } |
102 | 102 |
103 void PpapiUnittest::TearDown() { | 103 void PpapiUnittest::TearDown() { |
104 } | 104 } |
105 | 105 |
106 const void* PpapiUnittest::GetMockInterface(const char* interface_name) const { | 106 const void* PpapiUnittest::GetMockInterface(const char* interface_name) const { |
107 if (strcmp(interface_name, PPP_INSTANCE_INTERFACE) == 0) | 107 if (strcmp(interface_name, PPP_INSTANCE_INTERFACE) == 0) |
108 return &mock_instance_interface; | 108 return &mock_instance_interface; |
109 return NULL; | 109 return NULL; |
110 } | 110 } |
111 | 111 |
112 } // namespace pepper | 112 } // namespace ppapi |
| 113 } // namespace plugins |
| 114 } // namespace webkit |
113 | 115 |
OLD | NEW |