| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef GPU_NP_UTILS_NP_BROWSER_MOCK_H_ | |
| 6 #define GPU_NP_UTILS_NP_BROWSER_MOCK_H_ | |
| 7 | |
| 8 #include "gpu/np_utils/np_browser_stub.h" | |
| 9 #include "testing/gmock/include/gmock/gmock.h" | |
| 10 | |
| 11 namespace np_utils { | |
| 12 | |
| 13 // This mocks certain member functions of the stub browser. Those relating | |
| 14 // to identifiers, memory management, reference counting and forwarding to | |
| 15 // NPObjects are deliberately not mocked so the mock browser can be used as | |
| 16 // normal for these calls. | |
| 17 class MockNPBrowser : public StubNPBrowser { | |
| 18 public: | |
| 19 NPObject* ConcreteCreateObject(NPP npp, const NPClass* cl) { | |
| 20 return StubNPBrowser::CreateObject(npp, cl); | |
| 21 } | |
| 22 | |
| 23 MockNPBrowser() { | |
| 24 // Do not mock CreateObject by default but allow it to be mocked so object | |
| 25 // creation can be intercepted. | |
| 26 ON_CALL(*this, CreateObject(testing::_, testing::_)) | |
| 27 .WillByDefault(testing::Invoke(this, | |
| 28 &MockNPBrowser::ConcreteCreateObject)); | |
| 29 } | |
| 30 | |
| 31 void ConcretePluginThreadAsyncCall(NPP npp, | |
| 32 PluginThreadAsyncCallProc callback, | |
| 33 void* data) { | |
| 34 return StubNPBrowser::PluginThreadAsyncCall(npp, callback, data); | |
| 35 } | |
| 36 | |
| 37 MOCK_METHOD2(CreateObject, NPObject*(NPP npp, const NPClass* cl)); | |
| 38 MOCK_METHOD1(GetWindowNPObject, NPObject*(NPP cpp)); | |
| 39 MOCK_METHOD3(PluginThreadAsyncCall, | |
| 40 void(NPP npp, PluginThreadAsyncCallProc callback, void* data)); | |
| 41 MOCK_METHOD4(ScheduleTimer, uint32(NPP npp, | |
| 42 uint32 interval, | |
| 43 bool repeat, | |
| 44 TimerProc callback)); | |
| 45 MOCK_METHOD2(UnscheduleTimer, void(NPP npp, uint32 timer_id)); | |
| 46 }; | |
| 47 | |
| 48 } // namespace np_utils | |
| 49 | |
| 50 #endif // GPU_NP_UTILS_NP_BROWSER_MOCK_H_ | |
| OLD | NEW |