OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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/plugins/ppapi/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/plugins/ppapi/mock_plugin_delegate.h" | 9 #include "webkit/plugins/ppapi/mock_plugin_delegate.h" |
10 #include "webkit/plugins/ppapi/plugin_module.h" | 10 #include "webkit/plugins/ppapi/plugin_module.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 PP_Bool Instance_HandleDocumentLoad(PP_Instance pp_instance, | 54 PP_Bool Instance_HandleDocumentLoad(PP_Instance pp_instance, |
55 PP_Resource pp_url_loader) { | 55 PP_Resource pp_url_loader) { |
56 return PP_FALSE; | 56 return PP_FALSE; |
57 } | 57 } |
58 | 58 |
59 static PPP_Instance mock_instance_interface = { | 59 static PPP_Instance mock_instance_interface = { |
60 &Instance_DidCreate, | 60 &Instance_DidCreate, |
61 &Instance_DidDestroy, | 61 &Instance_DidDestroy, |
62 &Instance_DidChangeView, | 62 &Instance_DidChangeView, |
63 &Instance_DidChangeFocus, | 63 &Instance_DidChangeFocus, |
| 64 &Instance_HandleInputEvent, |
64 &Instance_HandleDocumentLoad | 65 &Instance_HandleDocumentLoad |
65 }; | 66 }; |
66 | 67 |
67 } // namespace | 68 } // namespace |
68 | 69 |
69 // PpapiUnittest -------------------------------------------------------------- | 70 // PpapiUnittest -------------------------------------------------------------- |
70 | 71 |
71 PpapiUnittest::PpapiUnittest() { | 72 PpapiUnittest::PpapiUnittest() { |
72 DCHECK(!current_unittest); | 73 DCHECK(!current_unittest); |
73 current_unittest = this; | 74 current_unittest = this; |
74 } | 75 } |
75 | 76 |
76 PpapiUnittest::~PpapiUnittest() { | 77 PpapiUnittest::~PpapiUnittest() { |
77 DCHECK(current_unittest == this); | 78 DCHECK(current_unittest == this); |
78 current_unittest = NULL; | 79 current_unittest = NULL; |
79 } | 80 } |
80 | 81 |
81 void PpapiUnittest::SetUp() { | 82 void PpapiUnittest::SetUp() { |
82 delegate_.reset(new MockPluginDelegate); | 83 delegate_.reset(new MockPluginDelegate); |
83 | 84 |
84 // Initialize the mock module. | 85 // Initialize the mock module. |
85 module_ = new PluginModule("Mock plugin", FilePath(), this); | 86 module_ = new PluginModule("Mock plugin", FilePath(), this); |
86 PluginModule::EntryPoints entry_points; | 87 PluginModule::EntryPoints entry_points; |
87 entry_points.get_interface = &MockGetInterface; | 88 entry_points.get_interface = &MockGetInterface; |
88 entry_points.initialize_module = &MockInitializeModule; | 89 entry_points.initialize_module = &MockInitializeModule; |
89 ASSERT_TRUE(module_->InitAsInternalPlugin(entry_points)); | 90 ASSERT_TRUE(module_->InitAsInternalPlugin(entry_points)); |
90 | 91 |
91 // Initialize the mock instance. | 92 // Initialize the mock instance. |
92 instance_ = PluginInstance::Create1_0( | 93 instance_ = PluginInstance::Create0_5( |
93 delegate_.get(), | 94 delegate_.get(), |
94 module(), | 95 module(), |
95 GetMockInterface(PPP_INSTANCE_INTERFACE_1_0)); | 96 GetMockInterface(PPP_INSTANCE_INTERFACE_0_5)); |
96 | 97 |
97 } | 98 } |
98 | 99 |
99 void PpapiUnittest::TearDown() { | 100 void PpapiUnittest::TearDown() { |
100 instance_ = NULL; | 101 instance_ = NULL; |
101 module_ = NULL; | 102 module_ = NULL; |
102 } | 103 } |
103 | 104 |
104 const void* PpapiUnittest::GetMockInterface(const char* interface_name) const { | 105 const void* PpapiUnittest::GetMockInterface(const char* interface_name) const { |
105 if (strcmp(interface_name, PPP_INSTANCE_INTERFACE_1_0) == 0) | 106 if (strcmp(interface_name, PPP_INSTANCE_INTERFACE_0_5) == 0) |
106 return &mock_instance_interface; | 107 return &mock_instance_interface; |
107 return NULL; | 108 return NULL; |
108 } | 109 } |
109 | 110 |
110 void PpapiUnittest::ShutdownModule() { | 111 void PpapiUnittest::ShutdownModule() { |
111 DCHECK(instance_->HasOneRef()); | 112 DCHECK(instance_->HasOneRef()); |
112 instance_ = NULL; | 113 instance_ = NULL; |
113 DCHECK(module_->HasOneRef()); | 114 DCHECK(module_->HasOneRef()); |
114 module_ = NULL; | 115 module_ = NULL; |
115 } | 116 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 reset_result(); | 160 reset_result(); |
160 PpapiInterfaceFactoryManager::GetInstance()->UnregisterFactory( | 161 PpapiInterfaceFactoryManager::GetInstance()->UnregisterFactory( |
161 PpapiCustomInterfaceFactoryTest::InterfaceFactory); | 162 PpapiCustomInterfaceFactoryTest::InterfaceFactory); |
162 | 163 |
163 (*PluginModule::GetLocalGetInterfaceFunc())("DummyInterface"); | 164 (*PluginModule::GetLocalGetInterfaceFunc())("DummyInterface"); |
164 EXPECT_FALSE(result()); | 165 EXPECT_FALSE(result()); |
165 } | 166 } |
166 | 167 |
167 } // namespace ppapi | 168 } // namespace ppapi |
168 } // namespace webkit | 169 } // namespace webkit |
OLD | NEW |