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