| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "o3d/gpu_plugin/command_buffer_mock.h" | 5 #include "o3d/gpu_plugin/command_buffer_mock.h" |
| 6 #include "o3d/gpu_plugin/gpu_plugin_object.h" | 6 #include "o3d/gpu_plugin/gpu_plugin_object.h" |
| 7 #include "o3d/gpu_plugin/np_utils/base_np_object_mock.h" | |
| 8 #include "o3d/gpu_plugin/np_utils/np_browser_mock.h" | 7 #include "o3d/gpu_plugin/np_utils/np_browser_mock.h" |
| 8 #include "o3d/gpu_plugin/np_utils/np_object_mock.h" |
| 9 #include "o3d/gpu_plugin/np_utils/np_object_pointer.h" | 9 #include "o3d/gpu_plugin/np_utils/np_object_pointer.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "testing/gmock/include/gmock/gmock.h" | 11 #include "testing/gmock/include/gmock/gmock.h" |
| 12 #include "webkit/glue/plugins/nphostapi.h" | 12 #include "webkit/glue/plugins/nphostapi.h" |
| 13 | 13 |
| 14 using testing::_; | 14 using testing::_; |
| 15 using testing::DoAll; | 15 using testing::DoAll; |
| 16 using testing::Return; | 16 using testing::Return; |
| 17 using testing::SetArgumentPointee; | 17 using testing::SetArgumentPointee; |
| 18 using testing::StrictMock; | 18 using testing::StrictMock; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 | 100 |
| 101 TEST_F(GPUPluginObjectTest, CanGetScriptableNPObject) { | 101 TEST_F(GPUPluginObjectTest, CanGetScriptableNPObject) { |
| 102 EXPECT_EQ(plugin_object_.Get(), plugin_object_->GetScriptableNPObject()); | 102 EXPECT_EQ(plugin_object_.Get(), plugin_object_->GetScriptableNPObject()); |
| 103 } | 103 } |
| 104 | 104 |
| 105 TEST_F(GPUPluginObjectTest, OpenCommandBufferReturnsInitializedCommandBuffer) { | 105 TEST_F(GPUPluginObjectTest, OpenCommandBufferReturnsInitializedCommandBuffer) { |
| 106 // Intercept creation of command buffer object and return mock. | 106 // Intercept creation of command buffer object and return mock. |
| 107 NPObjectPointer<MockCommandBuffer> command_buffer_object = | 107 NPObjectPointer<MockCommandBuffer> command_buffer_object = |
| 108 NPCreateObject<StrictMock<MockCommandBuffer> >(NULL); | 108 NPCreateObject<StrictMock<MockCommandBuffer> >(NULL); |
| 109 EXPECT_CALL(mock_browser_, CreateObject(NULL, | 109 EXPECT_CALL(mock_browser_, CreateObject(NULL, |
| 110 BaseNPObject::GetNPClass<CommandBuffer>())) | 110 NPGetClass<CommandBuffer>())) |
| 111 .WillOnce(Return(command_buffer_object.ToReturned())); | 111 .WillOnce(Return(command_buffer_object.ToReturned())); |
| 112 | 112 |
| 113 EXPECT_CALL(*command_buffer_object.Get(), Initialize(1024)) | 113 EXPECT_CALL(*command_buffer_object.Get(), Initialize(1024)) |
| 114 .WillOnce(Return(true)); | 114 .WillOnce(Return(true)); |
| 115 | 115 |
| 116 EXPECT_EQ(NPERR_NO_ERROR, plugin_object_->New("application/foo", | 116 EXPECT_EQ(NPERR_NO_ERROR, plugin_object_->New("application/foo", |
| 117 0, | 117 0, |
| 118 NULL, | 118 NULL, |
| 119 NULL, | 119 NULL, |
| 120 NULL)); | 120 NULL)); |
| 121 | 121 |
| 122 EXPECT_EQ(command_buffer_object, plugin_object_->OpenCommandBuffer()); | 122 EXPECT_EQ(command_buffer_object, plugin_object_->OpenCommandBuffer()); |
| 123 | 123 |
| 124 // Calling OpenCommandBuffer again just returns the existing command buffer. | 124 // Calling OpenCommandBuffer again just returns the existing command buffer. |
| 125 EXPECT_EQ(command_buffer_object, plugin_object_->OpenCommandBuffer()); | 125 EXPECT_EQ(command_buffer_object, plugin_object_->OpenCommandBuffer()); |
| 126 | 126 |
| 127 EXPECT_EQ(NPERR_NO_ERROR, plugin_object_->Destroy(NULL)); | 127 EXPECT_EQ(NPERR_NO_ERROR, plugin_object_->Destroy(NULL)); |
| 128 } | 128 } |
| 129 | 129 |
| 130 TEST_F(GPUPluginObjectTest, OpenCommandBufferReturnsNullIfCannotInitialize) { | 130 TEST_F(GPUPluginObjectTest, OpenCommandBufferReturnsNullIfCannotInitialize) { |
| 131 // Intercept creation of command buffer object and return mock. | 131 // Intercept creation of command buffer object and return mock. |
| 132 NPObjectPointer<MockCommandBuffer> command_buffer_object = | 132 NPObjectPointer<MockCommandBuffer> command_buffer_object = |
| 133 NPCreateObject<StrictMock<MockCommandBuffer> >(NULL); | 133 NPCreateObject<StrictMock<MockCommandBuffer> >(NULL); |
| 134 EXPECT_CALL(mock_browser_, CreateObject(NULL, | 134 EXPECT_CALL(mock_browser_, CreateObject(NULL, |
| 135 BaseNPObject::GetNPClass<CommandBuffer>())) | 135 NPGetClass<CommandBuffer>())) |
| 136 .WillOnce(Return(command_buffer_object.ToReturned())); | 136 .WillOnce(Return(command_buffer_object.ToReturned())); |
| 137 | 137 |
| 138 EXPECT_CALL(*command_buffer_object.Get(), Initialize(1024)) | 138 EXPECT_CALL(*command_buffer_object.Get(), Initialize(1024)) |
| 139 .WillOnce(Return(false)); | 139 .WillOnce(Return(false)); |
| 140 | 140 |
| 141 EXPECT_EQ(NPERR_NO_ERROR, plugin_object_->New("application/foo", | 141 EXPECT_EQ(NPERR_NO_ERROR, plugin_object_->New("application/foo", |
| 142 0, | 142 0, |
| 143 NULL, | 143 NULL, |
| 144 NULL, | 144 NULL, |
| 145 NULL)); | 145 NULL)); |
| 146 | 146 |
| 147 EXPECT_EQ(NPObjectPointer<NPObject>(), plugin_object_->OpenCommandBuffer()); | 147 EXPECT_EQ(NPObjectPointer<NPObject>(), plugin_object_->OpenCommandBuffer()); |
| 148 | 148 |
| 149 EXPECT_EQ(NPERR_NO_ERROR, plugin_object_->Destroy(NULL)); | 149 EXPECT_EQ(NPERR_NO_ERROR, plugin_object_->Destroy(NULL)); |
| 150 } | 150 } |
| 151 } // namespace gpu_plugin | 151 } // namespace gpu_plugin |
| 152 } // namespace o3d | 152 } // namespace o3d |
| OLD | NEW |