cc: Added inline to Tile::IsReadyToDraw
[chromium-blink-merge.git] / gpu / command_buffer / client / client_test_helper.h
blobe9d6c365fae3375b6461cc8e6c4f538213fde308
1 // Copyright (c) 2012 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.
5 // Helper classes for implementing gpu client side unit tests.
7 #ifndef GPU_COMMAND_BUFFER_CLIENT_CLIENT_TEST_HELPER_H_
8 #define GPU_COMMAND_BUFFER_CLIENT_CLIENT_TEST_HELPER_H_
10 #include "base/memory/scoped_ptr.h"
11 #include "gpu/command_buffer/common/cmd_buffer_common.h"
12 #include "gpu/command_buffer/common/command_buffer.h"
13 #include "gpu/command_buffer/common/compiler_specific.h"
14 #include "gpu/command_buffer/common/gpu_control.h"
15 #include "testing/gmock/include/gmock/gmock.h"
16 #include "testing/gtest/include/gtest/gtest.h"
18 namespace gpu {
20 class CommandBufferHelper;
22 class MockCommandBufferBase : public CommandBuffer {
23 public:
24 static const int32 kTransferBufferBaseId = 0x123;
25 static const int32 kMaxTransferBuffers = 6;
27 MockCommandBufferBase() { }
28 virtual ~MockCommandBufferBase();
30 virtual bool Initialize() OVERRIDE;
31 virtual State GetState() OVERRIDE;
32 virtual State GetLastState() OVERRIDE;
33 virtual int32 GetLastToken() OVERRIDE;
34 virtual State FlushSync(int32 put_offset, int32 last_known_get) OVERRIDE;
35 virtual void SetGetBuffer(int transfer_buffer_id) OVERRIDE;
36 virtual void SetGetOffset(int32 get_offset) OVERRIDE;
37 virtual Buffer CreateTransferBuffer(size_t size, int32* id) OVERRIDE;
38 virtual Buffer GetTransferBuffer(int32 id) OVERRIDE;
39 virtual void SetToken(int32 token) OVERRIDE;
40 virtual void SetParseError(error::Error error) OVERRIDE;
41 virtual void SetContextLostReason(error::ContextLostReason reason) OVERRIDE;
42 virtual uint32 InsertSyncPoint() OVERRIDE;
44 // Get's the Id of the next transfer buffer that will be returned
45 // by CreateTransferBuffer. This is useful for testing expected ids.
46 int32 GetNextFreeTransferBufferId();
48 void FlushHelper(int32 put_offset);
49 void DestroyTransferBufferHelper(int32 id);
51 virtual void OnFlush() = 0;
53 private:
54 scoped_ptr<int8[]> transfer_buffers_[kMaxTransferBuffers];
55 Buffer transfer_buffer_buffers_[kMaxTransferBuffers];
56 CommandBufferEntry* ring_buffer_;
57 Buffer ring_buffer_buffer_;
58 State state_;
61 class MockClientCommandBuffer : public MockCommandBufferBase {
62 public:
63 MockClientCommandBuffer();
64 virtual ~MockClientCommandBuffer();
66 // This is so we can use all the gmock functions when Flush is called.
67 MOCK_METHOD0(OnFlush, void());
68 MOCK_METHOD1(DestroyTransferBuffer, void(int32 id));
70 virtual void Flush(int32 put_offset) OVERRIDE;
72 void DelegateToFake();
75 class MockClientCommandBufferMockFlush : public MockClientCommandBuffer {
76 public:
77 MockClientCommandBufferMockFlush();
78 virtual ~MockClientCommandBufferMockFlush();
80 MOCK_METHOD1(Flush, void(int32 put_offset));
82 void DelegateToFake();
85 class MockClientGpuControl : public GpuControl {
86 public:
87 MockClientGpuControl();
88 virtual ~MockClientGpuControl();
90 MOCK_METHOD4(CreateGpuMemoryBuffer,
91 gfx::GpuMemoryBuffer*(size_t width,
92 size_t height,
93 unsigned internalformat,
94 int32* id));
95 MOCK_METHOD1(DestroyGpuMemoryBuffer, void(int32 id));
97 private:
98 DISALLOW_COPY_AND_ASSIGN(MockClientGpuControl);
101 } // namespace gpu
103 #endif // GPU_COMMAND_BUFFER_CLIENT_CLIENT_TEST_HELPER_H_