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